|
| 1 | +# Add better debuggability to be_forbidden failures |
| 2 | +RSpec::Matchers.define :be_forbidden do |
| 3 | + match(&:forbidden?) |
| 4 | + |
| 5 | + failure_message do |actual| |
| 6 | + "expected response to be forbidden but HTTP code was #{actual.status}." \ |
| 7 | + " Response body was:\n" + actual.body |
| 8 | + end |
| 9 | +end |
| 10 | + |
| 11 | +# Add better debuggability to be_not_found failures |
| 12 | +RSpec::Matchers.define :be_not_found do |
| 13 | + match(&:not_found?) |
| 14 | + |
| 15 | + failure_message do |actual| |
| 16 | + "expected response to be not_found but HTTP code was #{actual.status}." \ |
| 17 | + " Response body was:\n" + actual.body |
| 18 | + end |
| 19 | +end |
| 20 | + |
| 21 | +# Add better debuggability to be_unprocessable failures |
| 22 | +RSpec::Matchers.define :be_unprocessable do |
| 23 | + match(&:unprocessable?) |
| 24 | + |
| 25 | + failure_message do |actual| |
| 26 | + "expected response to be unprocessable but HTTP code was #{actual.status}." \ |
| 27 | + " Response body was:\n" + actual.body |
| 28 | + end |
| 29 | +end |
| 30 | + |
| 31 | +# Add better debuggability to be_successful failures |
| 32 | +RSpec::Matchers.define :be_successful do |
| 33 | + match(&:successful?) |
| 34 | + |
| 35 | + failure_message do |actual| |
| 36 | + "expected response to be successful but HTTP code was #{actual.status}." \ |
| 37 | + " Response body was:\n" + actual.body |
| 38 | + end |
| 39 | +end |
| 40 | + |
| 41 | +# Add better debuggability to be_ok failures |
| 42 | +RSpec::Matchers.define :be_ok do |
| 43 | + match(&:ok?) |
| 44 | + |
| 45 | + failure_message do |actual| |
| 46 | + "expected response to be ok but HTTP code was #{actual.status}." \ |
| 47 | + " Response body was:\n" + actual.body |
| 48 | + end |
| 49 | +end |
0 commit comments