Skip to content

Instantly share code, notes, and snippets.

@dchelimsky
Forked from wycats/matcher-dsl.rb
Created September 18, 2008 01:56
Show Gist options
  • Save dchelimsky/11355 to your computer and use it in GitHub Desktop.
Save dchelimsky/11355 to your computer and use it in GitHub Desktop.
Spec::Matchers.create(:be_successful) do
matches do |rack|
rack.status == 200
end
message do |not_string, rack|
"Expected #{describe_request(rack)}#{not_string} " \
"to be successful, but it returned a #{rack.status}"
end
end
def be_successful
simple_matcher("response to be successful") do |response|
response.status == 200
end
end
or
def be_successful
simple_matcher("response to be successful") do |response, matcher|
matcher.failure_message = "expected successful response, got #{response.status}"
matcher.negative_failure_message = "expected error response, got #{response.status}"
response.status == 200
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment