Scenario: List Tasks
Then I should have 3 forums
Then /^I should have ([0-9]+) forums$/ do |counts|
Forum.count.should == counts.to_i
end
====
When I go to the homepage #
features/step_definitions/webrat_steps.rb:10
Then I should have 3 forums #
features/step_definitions/forums_steps.rb:1
expected: 3,
got: 0 (using ==)
Diff:
@@ -1,2 +1,2 @@
-3
+0
(Spec::Expectations::ExpectationNotMetError)
features/forums.feature:8:in `Then I should have 3 forums’
1 scenario (1 failed)
2 steps (1 failed, 1 passed)
===
Forum.count == counts.to_i does fine! why Forum.count.should throw a
error?
how could I do?
On Tue, May 19, 2009 at 10:09 AM, Zhenning G. [email protected]
wrote:
features/step_definitions/webrat_steps.rb:10
1 scenario (1 failed)
2 steps (1 failed, 1 passed)
===
Forum.count == counts.to_i does fine
That’s not an expectation so it won’t pass or fail. I’d bet that’s
returning false, which is not going to make a step fail (only an error
will).
David C. wrote:
On Tue, May 19, 2009 at 10:09 AM, Zhenning G. [email protected]
wrote:
features/step_definitions/webrat_steps.rb:10
1 scenario (1 failed)
2 steps (1 failed, 1 passed)
===
Forum.count == counts.to_i does fine
That’s not an expectation so it won’t pass or fail. I’d bet that’s
returning false, which is not going to make a step fail (only an error
will).
I means…
Forum.count == counts.to_i
doesn’t work…
On Wed, May 20, 2009 at 4:18 AM, Zhenning G. [email protected]
wrote:
Forum.count == counts.to_i does fine
Forum.count.should == counts.to_i
doesn’t work.
You’re confusing me now
So, if I understand correctly, this fails:
Forum.count.should == counts.to_i
and this passes
Forurm.count == counts.to_i
The fact that the latter is passing is a false positive, because it is
not actually testing anything. It is a boolean statement that returns
true or false, and it doesn’t matter whether it returns true or false
because the step will pass in either case. The only thing that makes a
step fail is an error. When you say “Forum.count.should ==
counts.to_i” and those two values are not equal, an ExpectationNotMet
error is raised by RSpec. In that case you get a failure.
The reason “Forum.count.should == counts.to_i” is failing is because
… well, it is failing. Forum.count is returning 0 when you’re
expecting 3.
HTH,
David
Zhenning G. wrote:
David C. wrote:
On Tue, May 19, 2009 at 10:09 AM, Zhenning G. [email protected]
wrote:
features/step_definitions/webrat_steps.rb:10
1 scenario (1 failed)
2 steps (1 failed, 1 passed)
===
Forum.count == counts.to_i does fine
That’s not an expectation so it won’t pass or fail. I’d bet that’s
returning false, which is not going to make a step fail (only an error
will).
I means…
Forum.count == counts.to_i
doesn’t work…
correct it
Forum.count.should == counts.to_i
doesn’t work.