Skip to content

RSpec Calculator Submission#77

Open
yxlau wants to merge 3 commits into
vikingeducation:masterfrom
yxlau:master
Open

RSpec Calculator Submission#77
yxlau wants to merge 3 commits into
vikingeducation:masterfrom
yxlau:master

Conversation

@yxlau

@yxlau yxlau commented Jan 3, 2017

Copy link
Copy Markdown

No description provided.

Comment thread spec/calculator_spec.rb
it "properly divides numbers" do
expect(c.divide(8,2)).to eq(4)
expect(c.divide(-8,2)).to eq(-4)
expect(c.divide(-8.0,-2)).to eq(4.0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It raises an ArgumentError when the second argument is < 0

Comment thread spec/calculator_spec.rb
it "handles decimal powers" do
expect(c.pow(27,1/3.0)).to eq(3.0)
expect(c.pow(27,-1/3.0)).to be_within(0.05).of(0.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, check if it handles the case when power is 0

Comment thread spec/calculator_spec.rb
expect{ c.sqrt(-4) }.to raise_error(ArgumentError)
end
it "returns 2-digit decimals for non-round roots" do
expect(c.sqrt(27)).to eq(5.20)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

check if the output has 2 decimal places exactly.

Comment thread spec/calculator_spec.rb

describe "#stringify" do
it "returns output in form of string when stringify is true" do
expect(c_s.output(c.add(1,2))).to be_kind_of(String)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

check if it returns a string for all the main methods - add, subtract, multiply etc.

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