Skip to content

Instantly share code, notes, and snippets.

@cupakromer
Created March 1, 2013 22:28
Show Gist options
  • Save cupakromer/5068434 to your computer and use it in GitHub Desktop.
Save cupakromer/5068434 to your computer and use it in GitHub Desktop.
Custom with matcher
class SubstringMatcher
def initialize(regexp)
@regexp = regexp
end
def ==(actual)
actual.to_s =~ @regexp
end
end
def substring(regexp)
SubstringMatcher.new regexp
end
# thing.should_receive(:foo).with(substring "test").and_call_original
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment