Sha256: cfd238d0d6cc2db9cb87af0b90d26ec5efd7326ba7f24ae7b012ab83ca39b483

Contents?: true

Size: 986 Bytes

Versions: 9

Compression:

Stored size: 986 Bytes

Contents

require 'spec_helper'
require 'druid/page_factory'

class FactoryTestDruid
  include Druid
  page_url "http://www.baidu.com"
end

class TestWorld
  include Druid::PageFactory

  attr_accessor :driver
end

describe Druid::PageFactory do
  before(:each) do
    @world = TestWorld.new
    @world.driver = mock_driver
  end

  it "should create and visit a new page" do
    expect(@world.driver).to receive(:goto)
    @world.visit_page FactoryTestDruid do |page|
      expect(page).to be_instance_of FactoryTestDruid
    end
  end

  it "should create a new page object and execute a block" do
    expect(@world.driver).not_to receive(:goto)
    @world.on_page FactoryTestDruid do |page|
      expect(page).to be_instance_of FactoryTestDruid
    end
  end

  it "should set an instance variable that can be used outside of the block" do
    page = @world.on_page FactoryTestDruid
    current_page = @world.instance_variable_get "@current_page"
    expect(current_page).to eq page
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
druid-ts-1.1.8 spec/druid/elements/page_factory_spec.rb
druid-ts-1.1.7 spec/druid/elements/page_factory_spec.rb
druid-ts-1.1.6 spec/druid/elements/page_factory_spec.rb
druid-ts-1.1.5 spec/druid/elements/page_factory_spec.rb
druid-ts-1.1.4 spec/druid/elements/page_factory_spec.rb
druid-ts-1.1.3 spec/druid/elements/page_factory_spec.rb
druid-ts-1.1.2 spec/druid/elements/page_factory_spec.rb
druid-ts-1.1.1 spec/druid/elements/page_factory_spec.rb
druid-ts-1.1.0 spec/druid/elements/page_factory_spec.rb