Sha256: 8a6189557d2f52f370effd2fef56ab4aabf3f377ce3f88a5b66486baae5f5830

Contents?: true

Size: 1.52 KB

Versions: 3

Compression:

Stored size: 1.52 KB

Contents

require File.dirname(__FILE__) + '/../test_helper.rb'

context "The Web.de importer" do

  setup do
    @username, @password = GraybookExtensions::TestHelper::Credentials.new(:webde).get

    @importer = Graybook::Importer::WebDE.new
    @importer.create_agent
  end

  specify "should match emails" do
    @importer.=~(nil).should.not.be
    @importer.=~({}).should.not.be
    @importer.=~({ 'username' => "john@foo.com" }).should.not.be
    @importer.=~({ :username => "john@foo.com" }).should.not.be
    @importer.=~({ :username => "john" }).should.not.be
    @importer.=~({ :username => "john@web.de" }).should.be
    @importer.=~({ :username => "JOHN@WEB.DE" }).should.be
  end

  specify "should be able to login with correct credentials" do
    should.not.raise Exception do
      login(@username, @password)
    end
  end

  specify "should raise BadCredentialsError on login with wrong credentials" do
    should.raise Graybook::BadCredentialsError do
      login
    end
  end

  specify "should raise BadCredentialsError on login with correct username and wrong password" do
    should.raise Graybook::BadCredentialsError do
      login(@username)
    end
  end

  specify "should able to get contacts" do
    login(@username, @password)

    contacts = @importer.scrape_contacts
    contacts.should.not.be.empty
    contacts.should.be.all { |contact| contact.is_a? Hash }
  end

  private
    def login(username = "foo", password = "bar")
      @importer.options = { :username => username, :password => password }
      @importer.login
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
graybook-1.0.24 test/web.de_importer_test.rb
graybook-1.0.23 test/web.de_importer_test.rb
graybook-1.0.22 test/web.de_importer_test.rb