akamai-rspec
akamai-rspec copied to clipboard
Matchers fail with exceptions
It appears that, when akamai-rspec matchers "fail", they do so by raising an exception, e.g.
- https://github.com/realestate-com-au/akamai-rspec/blob/master/lib/akamai_rspec/matchers/caching.rb#L52
which in action looks like this:
1) www.casa.it /vendita should not be cacheable
Failure/Error: expect("http://#{domain}/vendita").to_not be_cacheable
RuntimeError:
X-Check-Cacheable header is: NO expected YES
# /usr/local/bundle/gems/akamai_rspec-0.2.4/lib/akamai_rspec/matchers/caching.rb:52:in `x_check_cacheable'
# /usr/local/bundle/gems/akamai_rspec-0.2.4/lib/akamai_rspec/matchers/caching.rb:7:in `block (2 levels) in <top (required)>'
# ./spec/sample_spec.rb:18:in `block (3 levels) in <top (required)>'
I came across this while attempting to write some akamai-rspec
tests for Casa (see https://git.realestate.com.au/mwilliams/casa-akamai-tests).
RSpec matchers are supposed to fail by returning false
, rather than by raising exceptions.
Thanks Mike, I didn't realise how they were meant to behave - I'll try to get to it within a week.
Thanks @biancaG. Sing out if you need any help. The RSpec documentation around defining matchers is pretty good, though; see: https://www.relishapp.com/rspec/rspec-expectations/v/2-4/docs/custom-matchers/define-matcher
Note that by design you should be able to use matchers in either a positive or negative sense, e.g.
expect(one_url).to be_cachable
expect(another_url).to_not be_cachable