Skip to content

Behdad Analui's solution, 41 specs#74

Open
banalui wants to merge 2 commits into
vikingeducation:masterfrom
banalui:master
Open

Behdad Analui's solution, 41 specs#74
banalui wants to merge 2 commits into
vikingeducation:masterfrom
banalui:master

Conversation

@banalui

@banalui banalui commented Dec 16, 2016

Copy link
Copy Markdown

No description provided.

Comment thread spec/calculator_spec.rb

describe Calculator do


Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create a common instance for Calculator and use it throughout the specs.
let(:c) { Calculator.new }

Comment thread spec/calculator_spec.rb
it 'returns the sum of its arguments when they are float' do
first_arg = 3.53
second_arg = 8.64
expect(@test_calc.add(first_arg, second_arg)).to be_within(0.01).of(12.17)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using variables for arguments is not necessary, you can directly add them:
expect(@test_calc.add(3.53, 8.64)).to be_within(0.01).of(12.17)

Comment thread spec/calculator_spec.rb

describe '#subtract' do

it 'returns the subtract of its positive integer arguments' do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the correct term would be "difference" - it 'returns the difference of positive integer arguments' do

Comment thread spec/calculator_spec.rb

describe '#multiply' do

it 'returns the multiply of its positive integer arguments' do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the correct term is "product" - it 'returns the product of its positive integer arguments' do

Comment thread spec/calculator_spec.rb
second_arg = 2.21
expect(@test_calc.divide(first_arg, second_arg)).to be_within(0.01).of(-2.0)
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing spec:
it 'returns a float if there is a remainder with 2 integers'

Comment thread spec/calculator_spec.rb
first_arg = 6
second_arg = 1.7
expect(@test_calc.pow(first_arg, second_arg)).to eq(6**1.7)
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, test the case when the power is 0

Comment thread spec/calculator_spec.rb

it "can calculate sqr root of a positive integer in 2 decimal digits" do
first_arg = 224
expect(@test_calc.sqrt(first_arg)).to be_within(0.1).of(15)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should check if the result has 2 decimal places exactly.

Comment thread spec/calculator_spec.rb

it "getter, returns the memory object" do
@test_calc.memory = 13
memory_instance = @test_calc.memory

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line is redundant, you can directly use @test_calc.memory in the next line.

Comment thread spec/calculator_spec.rb
@test_calc = Calculator.new(false)
expect(@test_calc.output(50)).not_to be_a(String)
end
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, check if all the main methods(add, subtract, multiply etc) return string if stringify is true

Comment thread spec/calculator_spec.rb
memory_instance = @test_calc.memory
expect(memory_instance).to be_nil
end
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, write tests for memory= method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants