Created
February 4, 2012 12:44
-
-
Save abyx/1737631 to your computer and use it in GitHub Desktop.
Gists from my blog post http://www.codelord.net/2012/02/04/extend-your-toolbox-custom-matchers/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| commentor.should_receive(:add).with(anonymous_comment) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This | |
| response['X-Runtime'].should =~ /[\d\.]+/ | |
| # .. or this? | |
| response['X-Runtime'].should be_a_number |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RSpec::Matchers.define :be_a_multiple_of do |expected| | |
| match do |actual| | |
| actual % expected == 0 | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| expected_comment = Comment.new(anonymous: true, user: "the dude", reply_to: nil) | |
| commentor.should_receive(:add).with(expected_comment) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment