ryanprayogo
ryanprayogo

Reputation: 11817

Rails unit testing

In one of my Rails test case:

test "something" do
  assert_raise RuntimeError do
    @foo.bar
  end
end

I set up the @foo object such that @foo.bar does not raise RuntimeError (ie, the test case will fail)

But the following code passed the test:

test "something" do
  blah(@foo)
end

private
  def blah(foo)
    assert RuntimeError do
      foo.bar 
    end
  end

Why is this so?

Upvotes: 1

Views: 397

Answers (1)

Pablo B.
Pablo B.

Reputation: 1833

- assert RuntimeError do

+ assert_raise RuntimeError do

Upvotes: 6

Related Questions