Filtering Shokkenki Provider Examples
Shokkenki specs are just RSpec specs. All of the tools available for selectively running RSpec examples can be used.
Provider examples can be filtered using standard RSpec tag or example filtering. You can run just shokkenki provider examples or even run only examples to do with parts of the request like the status.
You can use the example option to filter by Consumer, interaction label or status - see the documentation for details. Shokkenki provider examples are generated on the fly so you can't run individual examples using line number.
Scenario: Run only Shokkenki provider examples using the --tag option
- Given a ticket named "
tickets/consumer-provider.json" including the following interaction:json{ "label": "greeting", "request": { "type": "hash", "value": { "path": { "type": "string", "value": "/greeting" }, "method": { "type": "string", "value": "get" } } }, "response": { "type": "hash", "value": { "status": { "type": "number", "value": 200 } } } } - And a file named "
spec/provider.spec" with:rubyprovider = lambda do |env| [200, {}, ['']] end Shokkenki.provider.configure do provider :provider { run provider } end Shokkenki.provider.redeem_tickets describe 'Some other thing' do it 'does unrelated stuff' {} end - When I run `rspec --format documentation --tag shokkenki_provider`
- Then all examples should pass
- And the output should contain:
text
Consumer greeting status is 200 - But the output should not contain:
text
does unrelated stuff
Scenario: Run only Shokkenki provider examples related to status
- Given a ticket named "
tickets/consumer-provider.json" including the following interaction:json{ "label": "greeting", "request": { "type": "hash", "value": { "path": { "type": "string", "value": "/greeting" }, "method": { "type": "string", "value": "get" } } }, "response": { "type": "hash", "value": { "status": { "type": "number", "value": 200 }, "body": { "type": "json_paths", "value": { "$.message" : { "type": "regexp", "value": "hi" } } } } } } - And a file named "
spec/provider.spec" with:rubyprovider = lambda do |env| [200, {}, ['{"message":"hi there"}']] end Shokkenki.provider.configure do provider :provider { run provider } end Shokkenki.provider.redeem_tickets describe 'Some other thing' do it 'does unrelated stuff' {} end - When I run `rspec --format documentation --tag shokkenki_provider --example status`
- Then all examples should pass
- And the output should contain:
text
Consumer greeting status is 200 - But the output should not contain:
text
body json
Source: features/running/filtering.feature at commit e6e14680, Shokkenki Provider (GPL license).