module Watir::RSpec::Helper

Public Instance Methods

browser() click to toggle source

@return [Watir::Browser] a current browser instance if it is initialized with

@browser or $browser variable name.
# File lib/watir/rspec/helper.rb, line 10
def browser
  @browser || $browser
end
method_missing(name, *args) click to toggle source

Will dispatch all missing methods to the {#browser} instance. @example Makes it possible to use Watir::Browser methods without specifying the browser instance in the specs like this:

it "text field is present" do
  # notice that we're calling Watir::Browser#text_field here directly
  expect(text_field(id: "foo")).to be_present
end
Calls superclass method
# File lib/watir/rspec/helper.rb, line 20
def method_missing(name, *args)
  if browser.respond_to?(name)
    Helper.module_eval %Q[
      def #{name}(*args)
        if block_given?
          browser.send(:#{name}, *args, &Proc.new)
        else
          browser.send(:#{name}, *args)
        end
      end
    ]

    if block_given?
      self.send(name, *args, &Proc.new)
    else
      self.send(name, *args)
    end
  else
    super
  end
end