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.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rack-rest-rspec/lib/rest_service.rb', line 12 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.
10 11 12 |
# File 'lib/rack-rest-rspec/lib/rest_service.rb', line 10 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.
9 10 11 |
# File 'lib/rack-rest-rspec/lib/rest_service.rb', line 9 def service @service end |
Instance Method Details
#returned_data ⇒ Object
25 26 27 |
# File 'lib/rack-rest-rspec/lib/rest_service.rb', line 25 def returned_data return JSON::parse(@browser.last_response.body, symbolize_names: true) end |