Skip to content

Instantly share code, notes, and snippets.

@ajsharp
Created November 25, 2009 06:21
Show Gist options
  • Save ajsharp/242521 to your computer and use it in GitHub Desktop.
Save ajsharp/242521 to your computer and use it in GitHub Desktop.
module OptimisMatchers
def self.generate_matcher(matcher_name, url)
OptimisMatchers::module_eval do
Spec::Matchers.define matcher_name do
match do |actual|
actual.redirect_url == url
end
failure_message_for_should do |actual|
if actual.redirect?
"Expected redirect to #{url} but redirected to #{actual.redirect_url}"
else
"Expected redirect, didn't get one."
end
end
end
end
end
generate_matcher :require_practice, 'http://test.host/user/settings/current_practice'
generate_matcher :require_clinic, 'http://test.host/user/settings/current_clinic'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment