Sha256: f4157cb57423f1d6f90212debac9a023c5a97535730ceb9233d219b7817d1346

Contents?: true

Size: 1.53 KB

Versions: 14

Compression:

Stored size: 1.53 KB

Contents

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

context "The Web.de importer" do

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

    @importer = Blackbook::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 Blackbook::BadCredentialsError do
      login
    end
  end

  specify "should raise BadCredentialsError on login with correct username and wrong password" do
    should.raise Blackbook::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

14 entries across 14 versions & 3 rubygems

Version Path
bcardarella-blackbook-1.0.10 test/web.de_importer_test.rb
bcardarella-blackbook-1.0.11 test/web.de_importer_test.rb
bcardarella-blackbook-1.0.7 test/web.de_importer_test.rb
bcardarella-blackbook-1.0.8 test/web.de_importer_test.rb
bcardarella-blackbook-1.0.9 test/web.de_importer_test.rb
briancollins-blackbook-1.0.15 test/web.de_importer_test.rb
rakutenusa-blackbook-1.0.12 test/web.de_importer_test.rb
rakutenusa-blackbook-1.0.13 test/web.de_importer_test.rb
rakutenusa-blackbook-1.0.14 test/web.de_importer_test.rb
rakutenusa-blackbook-1.0.15 test/web.de_importer_test.rb
rakutenusa-blackbook-1.0.16 test/web.de_importer_test.rb
rakutenusa-blackbook-1.0.17 test/web.de_importer_test.rb
rakutenusa-blackbook-1.0.18 test/web.de_importer_test.rb
rakutenusa-blackbook-1.0.19 test/web.de_importer_test.rb