Created
April 2, 2009 15:34
-
-
Save pd/89256 to your computer and use it in GitHub Desktop.
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
| -- % spec -fs matcher_spec.rb | |
| a string | |
| - should should be pretty lengthy | |
| - can be short | |
| - can be long | |
| - can be too short (FAILED - 1) | |
| - can be too long (FAILED - 2) | |
| 1) | |
| 'a string can be too short' FAILED | |
| was not that long really | |
| ./matcher_spec.rb:26: | |
| 2) | |
| 'a string can be too long' FAILED | |
| was unexpectedly large | |
| ./matcher_spec.rb:30: | |
| Finished in 0.007922 seconds | |
| 5 examples, 2 failures |
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
| require 'rubygems' | |
| require 'spec' | |
| def be_long | |
| simple_matcher do |given, matcher| | |
| matcher.description = "should be pretty lengthy" | |
| matcher.failure_message = "was not that long really" | |
| matcher.negative_failure_message = "was unexpectedly large" | |
| given.length > 1 | |
| end | |
| end | |
| describe "a string" do | |
| it { "abc".should be_long } | |
| it 'can be short' do | |
| "a".should_not be_long | |
| end | |
| it 'can be long' do | |
| "ab".should be_long | |
| end | |
| it 'can be too short' do | |
| "a".should be_long | |
| end | |
| it 'can be too long' do | |
| "ab".should_not be_long | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment