Class: CheckAuth::Request
- Inherits:
-
Object
- Object
- CheckAuth::Request
- Defined in:
- lib/rspec_check_auth/check_auth/request.rb
Overview
Represents a single request spec
Format and Method should be a single symbol
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
-
#default_method ⇒ Object
Works out the default method for certain controller actions.
-
#default_params ⇒ Object
Adds an id for actions that require it.
-
#initialize(action, format, opts) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(action, format, opts) ⇒ Request
Returns a new instance of Request.
8 9 10 11 12 13 |
# File 'lib/rspec_check_auth/check_auth/request.rb', line 8 def initialize action, format, opts @action = action @format = format @method = opts[:method] || default_method self.params = opts.except(:method) end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
6 7 8 |
# File 'lib/rspec_check_auth/check_auth/request.rb', line 6 def action @action end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
6 7 8 |
# File 'lib/rspec_check_auth/check_auth/request.rb', line 6 def format @format end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
6 7 8 |
# File 'lib/rspec_check_auth/check_auth/request.rb', line 6 def method @method end |
#params ⇒ Object
Returns the value of attribute params.
6 7 8 |
# File 'lib/rspec_check_auth/check_auth/request.rb', line 6 def params @params end |
Instance Method Details
#default_method ⇒ Object
Works out the default method for certain controller actions
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rspec_check_auth/check_auth/request.rb', line 32 def default_method case @action.to_s when /create/ :post when /update/ :put when /destroy/ :delete else# and when /(index|show|new|edit)/ :get end end |
#default_params ⇒ Object
Adds an id for actions that require it
46 47 48 49 50 51 52 53 |
# File 'lib/rspec_check_auth/check_auth/request.rb', line 46 def default_params case @action.to_s when /(show|edit|update|destroy)/ {:id => "some_id"} else {} end end |