Sha256: 48fbffc11e98c2c0be08fefc381c50c0292e4c1ae469c965797630a0cd0060f7

Contents?: true

Size: 1.57 KB

Versions: 17

Compression:

Stored size: 1.57 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe "Mechanizer" do
  it "retains access to the last page loaded" do
    mech = AmazonSellerCentral.mechanizer
    mech.login_to_seller_central
    mech.last_page.body.should =~ /Welcome! You are signed in as/
  end

  it "logs in and returns the home page" do
    mech = AmazonSellerCentral.mechanizer
    mech.login_to_seller_central.should be_true
  end

  it "raises a LinkNotFoundError if the requested link doesn't exist" do
    mech = AmazonSellerCentral.mechanizer
    mech.login_to_seller_central
    lambda {
      mech.follow_link_with(:text => "Foo")
    }.should raise_exception(AmazonSellerCentral::Mechanizer::LinkNotFoundError)
  end

  it "resets to a nil agent" do
    mech = AmazonSellerCentral.mechanizer
    mech.login_to_seller_central
    lambda {
      mech.follow_link_with(:text => "Feedback")
    }.should_not raise_exception
    AmazonSellerCentral.mechanizer.reset!

    mech = AmazonSellerCentral.mechanizer
    mech.login_to_seller_central
    mech.reset!
    lambda {
      mech.follow_link_with(:text => "Feedback")
    }.should raise_exception(AmazonSellerCentral::Mechanizer::AgentResetError)
    AmazonSellerCentral.mechanizer.last_page.should be_nil
  end

  it "logs in twice successfully" do
    mech = AmazonSellerCentral.mechanizer
    mech.login_to_seller_central
    mech.last_page.body.should =~ /Welcome! You are signed in as/
    mech.follow_link_with :text => "Feedback"

    mech.login_to_seller_central
    mech.last_page.body.should =~ /Welcome! You are signed in as/
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
amazon_seller_central-0.3.0 spec/lib/mechanizer_spec.rb
amazon_seller_central-0.2.16 spec/lib/mechanizer_spec.rb
amazon_seller_central-0.2.15 spec/lib/mechanizer_spec.rb
amazon_seller_central-0.2.14 spec/lib/mechanizer_spec.rb
amazon_seller_central-0.2.13 spec/lib/mechanizer_spec.rb
amazon_seller_central-0.2.12 spec/lib/mechanizer_spec.rb
amazon_seller_central-0.2.11 spec/lib/mechanizer_spec.rb
amazon_seller_central-0.2.10 spec/lib/mechanizer_spec.rb
amazon_seller_central-0.2.9 spec/lib/mechanizer_spec.rb
amazon_seller_central-0.2.8 spec/lib/mechanizer_spec.rb
amazon_seller_central-0.2.7 spec/lib/mechanizer_spec.rb
amazon_seller_central-0.2.6 spec/lib/mechanizer_spec.rb
amazon_seller_central-0.2.5 spec/lib/mechanizer_spec.rb
amazon_seller_central-0.2.4 spec/lib/mechanizer_spec.rb
amazon_seller_central-0.2.3 spec/lib/mechanizer_spec.rb
amazon_seller_central-0.2.2 spec/lib/mechanizer_spec.rb
amazon_seller_central-0.2.1 spec/lib/mechanizer_spec.rb