Reputation: 45943
foo.should_receive( :save ).with( html )
Where html
is an HTML string, but I don't want to check against specific HTML because that would make the test brittle.
Is there a way to check the length of the param that foo should receive? Is it possible to use a matcher or something like html.should include '<html'
?
Working in RSpec.
Upvotes: 1
Views: 60
Reputation: 2045
As stated in the comment above you can use a regex for the argument matcher.
foo.should_receive(:save).with(/<html/)
If you want to do more complicated assertions you can provide a block:
foo.should_receive(:save).with do |arg|
arg.should include '<html'
end
Upvotes: 1
Reputation: 175
I don't see why that would not work using the code you provided. Maybe use include?
instead. You also could use a regex to determine if it was HTML. While for this specific example it might be a little much, you may be able to determine more specific things about the html then just if it has that tag.
Upvotes: 1