Stefan
Stefan

Reputation: 9329

rspec check 'with' argument is true

I have the following rspec example:

describe "with spike" do
  it "succeeds" do
    a = double('whatever')

    a.should_receive(:b).with(true)

    a.b('not false')
  end
end

How can I make with accept any non-false argument?

Upvotes: 0

Views: 32

Answers (1)

theldoria
theldoria

Reputation: 378

Just write an arbitrary message handler:

describe "with spike" do
  it "succeeds" do
    a = double('whatever')

    a.should_receive(:b) { |x|
      x.should_not be_false
    }

    a.b('not false')
  end
end

Upvotes: 1

Related Questions