lundi 9 novembre 2020

Rspec will turn a blind eye what the matchers in a block

I have several methods that accepts a block and I want to test code inside a block. I'm doing this:

describe "MyClass" do
  it "should call .my_method" do
    MyClass.my_method(@var1) do |result|

      expect(res.good?).to eq true
      # expect(res.good?).to eq false # also will pass
      # raise 'aaaaaaaa'              # also will pass

    end
  end
end

Rspec will ignore code inside the block and will return "passed" no matter what.

Why? How to fix it?

Aucun commentaire:

Enregistrer un commentaire