Class: Capybara::RackTestJson::Driver

Inherits:
Json::Driver::Base show all
Defined in:
lib/capybara/rack_test_json/driver.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Json::Driver::Base

#needs_server?

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, options = {})
  @app, @options = app, { :follow_redirect => true }.merge(options)
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



2
3
4
# File 'lib/capybara/rack_test_json/driver.rb', line 2

def app
  @app
end

#optionsObject (readonly)

Returns the value of attribute options.



2
3
4
# File 'lib/capybara/rack_test_json/driver.rb', line 2

def options
  @options
end

Instance Method Details

#bodyObject



64
65
66
# File 'lib/capybara/rack_test_json/driver.rb', line 64

def body
  MultiJson.load(source) || {}
end

#clientObject



8
9
10
# File 'lib/capybara/rack_test_json/driver.rb', line 8

def client
  @client ||= Capybara::RackTestJson::Client.new(app, options)
end

#current_urlObject



54
55
56
# File 'lib/capybara/rack_test_json/driver.rb', line 54

def current_url
  last_request.url
end

#jsonObject



68
69
70
# File 'lib/capybara/rack_test_json/driver.rb', line 68

def json
  MultiJson.load(source) || {}
end

#last_requestObject



12
13
14
# File 'lib/capybara/rack_test_json/driver.rb', line 12

def last_request
  client.last_request
end

#last_responseObject 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_jsonObject 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_headersObject



72
73
74
# File 'lib/capybara/rack_test_json/driver.rb', line 72

def response_headers
  last_response.headers
end

#status_codeObject



76
77
78
# File 'lib/capybara/rack_test_json/driver.rb', line 76

def status_code
  last_response.status
end