Class: RainforestRubyRuntime::Drivers::Selenium

Inherits:
Object
  • Object
show all
Defined in:
lib/rainforest_ruby_runtime/drivers/selenium.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Selenium

Returns a new instance of Selenium.



6
7
8
# File 'lib/rainforest_ruby_runtime/drivers/selenium.rb', line 6

def initialize(options)
  @browsers = options[:browsers]
end

Instance Attribute Details

#browsersObject (readonly)

Returns the value of attribute browsers.



4
5
6
# File 'lib/rainforest_ruby_runtime/drivers/selenium.rb', line 4

def browsers
  @browsers
end

Instance Method Details

#to_rspec(tests) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rainforest_ruby_runtime/drivers/selenium.rb', line 10

def to_rspec(tests)
  RSpec.describe 'Rainforest', tests: tests, browsers: browsers do
    [:tests].each do |test|
      describe "[#{test.id}] #{test.title}" do
        [:browsers].each do |browser|
          let(:current_driver) { Capybara.current_session.driver }

          after do
            if current_driver.respond_to?(:finish!)
              current_driver.finish!
            elsif current_driver.respond_to?(:quit)
              current_driver.quit
            end
          end

          specify browser do
            # for whatever reason, this line no longer works if put in a `before` block
            current_driver.options[:browser] = browser

            test.run
          end
        end
      end
    end
  end
end