Class: Capybara::RackTestJson::Driver
- Inherits:
-
Json::Driver::Base
- Object
- Json::Driver::Base
- Capybara::RackTestJson::Driver
- Defined in:
- lib/capybara/rack_test_json/driver.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #body ⇒ Object
- #client ⇒ Object
- #current_url ⇒ Object
-
#initialize(app, options = {}) ⇒ Driver
constructor
A new instance of Driver.
- #json ⇒ Object
- #last_request ⇒ Object
- #last_response ⇒ Object (also: #response)
- #raw_json ⇒ Object (also: #source, #html)
- #reset! ⇒ Object
- #response_headers ⇒ Object
- #status_code ⇒ Object
Methods inherited from Json::Driver::Base
Constructor Details
#initialize(app, options = {}) ⇒ Driver
Returns a new instance of Driver.
4 5 6 |
# File 'lib/capybara/rack_test_json/driver.rb', line 4 def initialize(app, = {}) @app, @options = app, { :follow_redirect => true }.merge() end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
2 3 4 |
# File 'lib/capybara/rack_test_json/driver.rb', line 2 def app @app end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
2 3 4 |
# File 'lib/capybara/rack_test_json/driver.rb', line 2 def @options end |
Instance Method Details
#body ⇒ Object
64 65 66 |
# File 'lib/capybara/rack_test_json/driver.rb', line 64 def body MultiJson.load(source) || {} end |
#client ⇒ Object
8 9 10 |
# File 'lib/capybara/rack_test_json/driver.rb', line 8 def client @client ||= Capybara::RackTestJson::Client.new(app, ) end |
#current_url ⇒ Object
54 55 56 |
# File 'lib/capybara/rack_test_json/driver.rb', line 54 def current_url last_request.url end |
#json ⇒ Object
68 69 70 |
# File 'lib/capybara/rack_test_json/driver.rb', line 68 def json MultiJson.load(source) || {} end |
#last_request ⇒ Object
12 13 14 |
# File 'lib/capybara/rack_test_json/driver.rb', line 12 def last_request client.last_request end |
#last_response ⇒ Object Also known as: response
16 17 18 |
# File 'lib/capybara/rack_test_json/driver.rb', line 16 def last_response client.last_response end |
#raw_json ⇒ Object Also known as: source, html
58 59 60 |
# File 'lib/capybara/rack_test_json/driver.rb', line 58 def raw_json last_response.body end |
#reset! ⇒ Object
80 81 82 |
# File 'lib/capybara/rack_test_json/driver.rb', line 80 def reset! @client = nil end |
#response_headers ⇒ Object
72 73 74 |
# File 'lib/capybara/rack_test_json/driver.rb', line 72 def response_headers last_response.headers end |
#status_code ⇒ Object
76 77 78 |
# File 'lib/capybara/rack_test_json/driver.rb', line 76 def status_code last_response.status end |