Sha256: 69b6e2e6594e44446bb5d3dda149438292c791403b6506db61485f285c4a665e

Contents?: true

Size: 1.56 KB

Versions: 43

Compression:

Stored size: 1.56 KB

Contents

require 'spec_helper'
require 'page-object/elements'

describe PageObject::Elements::RadioButton do
  let(:radiobutton) { PageObject::Elements::RadioButton }

  describe "when mapping how to find an element" do
    it "should map watir types to same" do
      [:class, :id, :index, :name, :value, :xpath].each do |t|
        identifier = radiobutton.watir_identifier_for t => 'value'
        identifier.keys.first.should == t
      end
    end
    it "should map selenium types to same" do
      [:class, :id, :name, :xpath, :value, :index].each do |t|
        key, value = radiobutton.selenium_identifier_for t => 'value'
        key.should == t
      end
    end
  end

  describe "interface" do

    it "should register as type :radio" do
      ::PageObject::Elements.element_class_for(:input, :radio).should == ::PageObject::Elements::RadioButton
    end
    
    context "for selenium" do
      let(:selenium_rb) { double('radio_button') }
      let(:radio_button) { PageObject::Elements::RadioButton.new(selenium_rb, :platform => :selenium_webdriver) }

      it "should select" do
        selenium_rb.should_receive(:click)
        selenium_rb.should_receive(:selected?).and_return(false)
        radio_button.select
      end
      
      it "should clear" do
        selenium_rb.should_receive(:click)
        selenium_rb.should_receive(:selected?).and_return(true)
        radio_button.clear
      end
      
      it "should know if it is selected" do
        selenium_rb.should_receive(:selected?).and_return(true)
        radio_button.should be_selected
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
page-object-0.6.1 spec/page-object/elements/radio_button_spec.rb
page-object-0.6 spec/page-object/elements/radio_button_spec.rb
page-object-0.5.5 spec/page-object/elements/radio_button_spec.rb