Sha256: 241241e825e4597fbefea1478a060a0df227ff07eeaf9fd74780433980e19563

Contents?: true

Size: 1.63 KB

Versions: 3

Compression:

Stored size: 1.63 KB

Contents

require File.expand_path("../spec_helper", __FILE__)

describe Selenium::Client::SeleniumHelper do
  class SeleniumHelperClass
    include Selenium::Client::SeleniumHelper
    attr_accessor :selenium
  end

  let :object do
    @object ||= (
      o = SeleniumHelperClass.new
      o.selenium = double("selenium")

      o
    )
  end

  it "delegates open to @selenium" do
    object.selenium.should_receive(:open).with(:the_url).and_return(:the_result)

    object.open(:the_url).should == :the_result
  end

  it "delegates type to @selenium" do
    object.selenium.should_receive(:type).with(:the_locator, :the_value) \
                   .and_return(:the_result)

    object.type(:the_locator, :the_value).should == :the_result
  end

  it "delegates select to @selenium" do
    object.selenium.should_receive(:type).with(:the_input_locator,
                                        :the_option_locator) \
                                  .and_return(:the_result)

    object.type(:the_input_locator, :the_option_locator).should == :the_result
  end

  it "delegates to any no-arg method defined on @selenium" do
    object.selenium.should_receive(:a_noarg_method).with().and_return(:the_result)

    object.a_noarg_method.should == :the_result
  end

  it "delegates to any arg method defined on @selenium" do
    object.selenium.should_receive(:a_method).with(:alpha, :beta)\
                   .and_return(:the_result)

    object.a_method(:alpha, :beta).should == :the_result
  end

  it "calls default method_missing when a method is not defined on @selenium" do
    lambda { object.a_method(:alpha, :beta) }.should raise_error(NoMethodError)
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
browserstack-webdriver-2.40.1 spec/unit/selenium/client/selenium_helper_spec.rb
browserstack-webdriver-0.0.22 spec/unit/selenium/client/selenium_helper_spec.rb
browserstack-webdriver-0.0.1 spec/unit/selenium/client/selenium_helper_spec.rb