Sha256: 5c8bdffda22641a5f1ed3af2ef4840e4f9ae6e982a8460031e2e2cca2a3fd08f

Contents?: true

Size: 1.97 KB

Versions: 3

Compression:

Stored size: 1.97 KB

Contents

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

describe PageObject::Elements::Image do
  let(:image) { PageObject::Elements::Image }
  
  describe "when mapping how to find an element" do
    it "should map watir types to same" do
      [:class, :id, :index, :name, :xpath].each do |t|
        identifier = image.watir_identifier_for t => 'value'
        identifier.keys.first.should == t
      end
    end

    it "should map selenium types to same" do
      [:class, :id, :index, :name, :xpath].each do |t|
        key, value = image.selenium_identifier_for t => 'value'
        key.should == t
      end
    end
  end
  
  describe "interface" do
    let(:image_element) { double('image_element') }
    
    before(:each) do
      image_element.stub(:size).and_return(image_element)
    end
    
    context "for watir" do
      it "should know the images width" do
        image = PageObject::Elements::Image.new(image_element, :platform => :watir)
        image_element.should_receive(:width).and_return(100)
        image.width.should == 100
      end
      
      it "should know the images height" do
        image = PageObject::Elements::Image.new(image_element, :platform => :watir)
        image_element.should_receive(:height).and_return(120)
        image.height.should == 120
      end
    end
    
    context "for selenium" do
      it "should know the images width" do
        dim = double('dimension')
        image = PageObject::Elements::Image.new(image_element, :platform => :selenium)
        image_element.should_receive(:size).and_return(dim)
        dim.should_receive(:width).and_return(100)
        image.width.should == 100
      end
      
      it "should know the images height" do
        dim = double('dimension')
        image = PageObject::Elements::Image.new(image_element, :platform => :selenium)
        image_element.should_receive(:size).and_return(dim)
        dim.should_receive(:height).and_return(120)
        image.height.should == 120
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
page-object-0.2 spec/page-object/elements/image_spec.rb
page-object-0.1.1 spec/page-object/elements/image_spec.rb
page-object-0.1 spec/page-object/elements/image_spec.rb