Created
August 13, 2010 10:30
-
-
Save lukeredpath/522665 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
| # this is just a rough example, the actual nested matcher is irrelevant | |
| Spec::Matchers.define :string_containing do |substring| | |
| match do |actual| | |
| actual.include?(substring) | |
| end | |
| end | |
| results = some_array | |
| results.should include(string_containing("foo")) |
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
| # while I'm on the subject, it would be able to reuse the above string_containing matcher for a string directly, but it would need to be named differently to read correctly, i.e.: | |
| "foobar".should contain_string("foo") | |
| # so it would be nice to do: | |
| Spec::Matchers.define :string_containing, :aliases => [:contain_string] do |substring| | |
| match do |actual| | |
| actual.include?(substring) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment