Sha256: 608e97154258322ed94212bc9519e7a9077e4763eb71db2c3e07ccf279fab0a5

Contents?: true

Size: 992 Bytes

Versions: 8

Compression:

Stored size: 992 Bytes

Contents

require 'spec_helper'
require 'druid/page_factory'

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

class TestWorldOne
  include Druid::PageFactory

  attr_accessor :driver
end

describe Druid::PageFactory do
  before(:each) do
    @world = TestWorldOne.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

8 entries across 8 versions & 2 rubygems

Version Path
druid-s-1.0.0 spec/druid/elements/page_factory_spec.rb
druid-ts-1.2.6 spec/druid/elements/page_factory_spec.rb
druid-ts-1.2.5 spec/druid/elements/page_factory_spec.rb
druid-ts-1.2.4 spec/druid/elements/page_factory_spec.rb
druid-ts-1.2.3 spec/druid/elements/page_factory_spec.rb
druid-ts-1.2.2 spec/druid/elements/page_factory_spec.rb
druid-ts-1.2.1 spec/druid/elements/page_factory_spec.rb
druid-ts-1.2.0 spec/druid/elements/page_factory_spec.rb