-
-
Save dchelimsky/11355 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::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