Sha256: a2fa26addb17b3adfdc793faa46516d9353144de083600eef3e1cf5a7859b3ff

Contents?: true

Size: 1.51 KB

Versions: 2

Compression:

Stored size: 1.51 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 =~ /BLINQ/
  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 =~ /BLINQ/
    mech.follow_link_with :text => "Feedback"

    mech.reset!
    mech.login_to_seller_central
    mech.last_page.body.should =~ /BLINQ/
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
amazon_seller_central-0.3.2 spec/lib/mechanizer_spec.rb
amazon_seller_central-0.3.1 spec/lib/mechanizer_spec.rb