Class: Infrataster::Contexts::CapybaraContext
- Inherits:
-
BaseContext
- Object
- BaseContext
- Infrataster::Contexts::CapybaraContext
- Defined in:
- lib/infrataster/contexts/capybara_context.rb
Constant Summary collapse
- CAPYBARA_DRIVER_NAME =
:infrataster_driver
Instance Attribute Summary
Attributes inherited from BaseContext
Class Method Summary collapse
Instance Method Summary collapse
- #before_each(example) ⇒ Object
-
#initialize(*args) ⇒ CapybaraContext
constructor
A new instance of CapybaraContext.
- #page ⇒ Object
- #session ⇒ Object
Methods inherited from BaseContext
Constructor Details
#initialize(*args) ⇒ CapybaraContext
Returns a new instance of CapybaraContext.
23 24 25 |
# File 'lib/infrataster/contexts/capybara_context.rb', line 23 def initialize(*args) super(*args) end |
Class Method Details
.prepare_session ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/infrataster/contexts/capybara_context.rb', line 14 def self.prepare_session Capybara.register_driver CAPYBARA_DRIVER_NAME do |app| Capybara::Poltergeist::Driver.new( app, ) end Capybara::Session.new(CAPYBARA_DRIVER_NAME) end |
.session ⇒ Object
10 11 12 |
# File 'lib/infrataster/contexts/capybara_context.rb', line 10 def self.session @session ||= prepare_session end |
Instance Method Details
#before_each(example) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/infrataster/contexts/capybara_context.rb', line 35 def before_each(example) example.example_group_instance.extend(Capybara::RSpecMatchers) session.driver.headers = {"Host" => resource.uri.host} address, port = server.forward_port(resource.uri.port) Capybara.app_host = "http://#{address}:#{port}" end |
#page ⇒ Object
31 32 33 |
# File 'lib/infrataster/contexts/capybara_context.rb', line 31 def page session end |
#session ⇒ Object
27 28 29 |
# File 'lib/infrataster/contexts/capybara_context.rb', line 27 def session self.class.session end |