Class: RSpec::Resources::DSL::Actions::IncludeIfNeeded
- Inherits:
-
Object
- Object
- RSpec::Resources::DSL::Actions::IncludeIfNeeded
- Defined in:
- lib/rspec/resources/dsl/actions/include_if_needed.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
Instance Method Summary collapse
- #auth_examples ⇒ Object
-
#initialize(context, action) ⇒ IncludeIfNeeded
constructor
A new instance of IncludeIfNeeded.
- #restricted_examples ⇒ Object
Constructor Details
#initialize(context, action) ⇒ IncludeIfNeeded
Returns a new instance of IncludeIfNeeded.
8 9 10 11 |
# File 'lib/rspec/resources/dsl/actions/include_if_needed.rb', line 8 def initialize(context, action) @ctx = context @action = action end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
13 14 15 |
# File 'lib/rspec/resources/dsl/actions/include_if_needed.rb', line 13 def action @action end |
Instance Method Details
#auth_examples ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rspec/resources/dsl/actions/include_if_needed.rb', line 15 def auth_examples :it_needs_authentication do || context 'when authentication is missing' do let([:headers]) { {} } it "denies access with status code #{[:error_status]}" do expect(response).to have_http_status([:error_status]) end end end end |
#restricted_examples ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rspec/resources/dsl/actions/include_if_needed.rb', line 27 def restricted_examples :it_has_restricted_access do || case action when :index then restricted_index_examples when :create then restricted_create_examples else context 'when trying to access a restricted resource' do subject { send [:for_resource] } it "denies access with status code #{[:error_status]}" do expect(response).to have_http_status([:error_status]) end end end end end |