Module: Capybara::RackTest::Driver::Ios

Defined in:
lib/capybara-ios-emulation-driver.rb

Class Method Summary collapse

Class Method Details

.rack_test_driver(params = {}) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/capybara-ios-emulation-driver.rb', line 31

def self.rack_test_driver params = {}
  options = {
    :ios_version => ::Capybara::IosEmulationDriver::LATEST_IOS_VERSION,
    :ios_device  => :iphone,
    :app         => nil,
    :rack_test_options => {}
  }.update(params)

  ua = ::Capybara::IosEmulationDriver::UserAgent.of(:ios => options[:ios_version], :device => options[:ios_device])
  driver = Class.new(::Capybara::RackTest::Driver)
  driver.module_eval %|
    def env
      super.merge('HTTP_USER_AGENT' => "#{ua}")
    end
  |
  driver.new(options[:app], options[:rack_test_options])
end