Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matchers fail with exceptions #5

Open
mdub opened this issue Nov 11, 2015 · 2 comments
Open

Matchers fail with exceptions #5

mdub opened this issue Nov 11, 2015 · 2 comments

Comments

@mdub
Copy link
Collaborator

mdub commented Nov 11, 2015

It appears that, when akamai-rspec matchers "fail", they do so by raising an exception, e.g.

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.

@beegibson
Copy link
Collaborator

Thanks Mike, I didn't realise how they were meant to behave - I'll try to get to it within a week.

@mdub
Copy link
Collaborator Author

mdub commented Nov 12, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants