Noah Clark
Noah Clark

Reputation: 8131

Why can't I get a be_nil test to fail in Rspec

In Rspec I have the following:

describe "triangle.parameter" do
  it "should return nil when it has 0 sides" do
    @triangle = Triangle.new({})
    @triangle.paramater.should be_nil
  end
end

And I have my parameter method like so:

def parameter
  return 4
end

I've tried true, false, 4, "apple" for parameter to return and nothing will fail. I also can't get it to fail with nothing in the method. What am I doing wrong?

Upvotes: 0

Views: 67

Answers (1)

Dylan Markow
Dylan Markow

Reputation: 124419

You have @triangle.paramater instead of @triangle.parameter; since it doesn't know what paramater is, it will always be nil.

Upvotes: 3

Related Questions