Created
September 29, 2015 11:43
-
-
Save ArturT/701aa4ed2d49071abbe2 to your computer and use it in GitHub Desktop.
Exercise. Create class Square to pass tests or implement tests for the class.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rspec' | |
class Square | |
def initialize(x, y) | |
@x = x | |
@y = y | |
end | |
def area | |
@x * @y | |
end | |
end | |
describe Square do | |
describe '#area' do | |
subject { described_class.new(x, y).area } | |
context 'when x=2 and y=3' do | |
let(:x) { 2 } | |
let(:y) { 3 } | |
it { should eq 6 } | |
end | |
context 'when x=2 and y=2' do | |
let(:x) { 2 } | |
let(:y) { 2 } | |
it { should eq 4 } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment