mardi 30 décembre 2014

Rspec how to expect to receive a message "with", when object receives message twice?


Vote count:

0




I have the following example:



it 'receives message' do
expect(Foo).to receive(:bar).with(baz)
OtherClass.send(baz)
end

class OtherClass
def self.send(baz)
Foo.bar(1) # this first one is the problem
Foo.bar(baz)
end
end

class Foo
def self.bar(whatever)
puts whatever + " was received"
end
end


This is the error:



Failure/Error: Foo received :bar with unexpected arguments


asked 1 min ago

mehulkar

1,542






Rspec how to expect to receive a message "with", when object receives message twice?

Aucun commentaire:

Enregistrer un commentaire