Class: RestService
- Inherits:
-
Object
- Object
- RestService
- Extended by:
- Forwardable
- Defined in:
- lib/rack-rest-rspec/lib/rest_service.rb
Instance Attribute Summary collapse
-
#browser ⇒ Object
readonly
Returns the value of attribute browser.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ RestService
constructor
A new instance of RestService.
- #returned_data ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ RestService
Returns a new instance of RestService.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rack-rest-rspec/lib/rest_service.rb', line 10 def initialize(params = {}) defaults = { service: Sinatra::Base, path: '/' } defaults.merge! params @service = defaults[:service] @path = defaults[:path] @browser = Rack::Test::Session.new(Rack::MockSession.new(@service)) end |
Instance Attribute Details
#browser ⇒ Object (readonly)
Returns the value of attribute browser.
8 9 10 |
# File 'lib/rack-rest-rspec/lib/rest_service.rb', line 8 def browser @browser end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/rack-rest-rspec/lib/rest_service.rb', line 8 def path @path end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
8 9 10 |
# File 'lib/rack-rest-rspec/lib/rest_service.rb', line 8 def service @service end |
Instance Method Details
#returned_data ⇒ Object
23 24 25 |
# File 'lib/rack-rest-rspec/lib/rest_service.rb', line 23 def returned_data JSON.parse(@browser.last_response.body, symbolize_names: true) end |