Skip to content

assignment_rspec_calculator#84

Open
chadl76 wants to merge 4 commits into
vikingeducation:masterfrom
chadl76:master
Open

assignment_rspec_calculator#84
chadl76 wants to merge 4 commits into
vikingeducation:masterfrom
chadl76:master

Conversation

@chadl76

@chadl76 chadl76 commented Apr 2, 2017

Copy link
Copy Markdown

No description provided.

@remis1889 remis1889 left a comment

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 tests for memory and memory= methods

Comment thread spec/calculator_spec.rb
require 'calculator.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 'properly adds two negative numbers' do
expect(Calculator.new.add(-1,-2)).to eq(-3)
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.

test for floating point numbers too.

Comment thread spec/calculator_spec.rb
it 'should divide two integers without remainder' do
expect(Calculator.new.divide(8,2)).to eq(4)
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.

You should also test if the result of a division with remainder is a Float

Comment thread spec/calculator_spec.rb
end
it 'should raise number to its negative power' do
expect(Calculator.new.pow(2,-3)).to eq(2 ** -3)
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 for cases when the exponent is zero and a decimal

Comment thread spec/calculator_spec.rb

describe '#sqrt' do
it 'should return the square root of integer' do
expect(Calculator.new.sqrt(16)).to eq(Math.sqrt(16))

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 negative argument, round roots and non-round roots.

Comment thread spec/calculator_spec.rb

describe '#stringify' do
it 'should return answer as a string' do
expect(Calculator.new(true).add(1,1)).to eq(2.to_s)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

write tests for other main operations too when stringify is true

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