graybook 1.0.24 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. data/{CHANGES.md → CHANGELOG} +13 -2
  2. data/README +94 -0
  3. data/Rakefile +3 -22
  4. data/VERSION +1 -1
  5. data/VERSION.yml +2 -2
  6. data/VERSION_NAME +1 -1
  7. data/lib/graybook/importer/aol.rb +11 -11
  8. data/lib/graybook/importer/gmail.rb +20 -20
  9. data/lib/graybook/importer/hotmail.rb +2 -4
  10. data/lib/graybook/importer/page_scraper.rb +4 -2
  11. data/lib/graybook/importer/yahoo.rb +12 -12
  12. data/lib/graybook.rb +20 -21
  13. metadata +9 -102
  14. data/README.md +0 -66
  15. data/debug_graybook.rb +0 -10
  16. data/lib/graybook/exporter/vcf.rb +0 -45
  17. data/lib/graybook/exporter/xml.rb +0 -28
  18. data/lib/graybook/importer/csv.rb +0 -74
  19. data/lib/graybook/importer/freenet.rb +0 -62
  20. data/lib/graybook/importer/gmx.rb +0 -68
  21. data/lib/graybook/importer/web.de.rb +0 -67
  22. data/test/config/credentials.yml.example +0 -9
  23. data/test/fixtures/aol_application_page.html +0 -566
  24. data/test/fixtures/aol_bad_login_response_stage_3.html +0 -565
  25. data/test/fixtures/aol_contacts.html +0 -102
  26. data/test/fixtures/aol_login_response_stage_1.html +0 -158
  27. data/test/fixtures/aol_login_response_stage_2.html +0 -559
  28. data/test/fixtures/aol_login_response_stage_3.html +0 -48
  29. data/test/fixtures/aol_login_response_stage_4.html +0 -404
  30. data/test/fixtures/aol_login_response_stage_5.html +0 -404
  31. data/test/fixtures/aol_new_contacts.html +0 -431
  32. data/test/fixtures/gmail.csv +0 -3
  33. data/test/fixtures/gmail_bad_login_response_stage_2.html +0 -560
  34. data/test/fixtures/gmail_contacts.html +0 -228
  35. data/test/fixtures/gmail_login_response_stage_1.html +0 -556
  36. data/test/fixtures/gmail_login_response_stage_2.html +0 -1
  37. data/test/fixtures/gmail_login_response_stage_2a.html +0 -1
  38. data/test/fixtures/gmail_login_response_stage_3.html +0 -249
  39. data/test/fixtures/gmail_redirect_body.html +0 -10
  40. data/test/fixtures/hotmail_bad_login_response_stage_2.html +0 -31
  41. data/test/fixtures/hotmail_contacts.html +0 -262
  42. data/test/fixtures/hotmail_login_response_stage_1.html +0 -31
  43. data/test/fixtures/hotmail_login_response_stage_2.html +0 -1
  44. data/test/fixtures/hotmail_login_response_stage_3.html +0 -519
  45. data/test/fixtures/hotmail_scrape_first_page.html +0 -77
  46. data/test/fixtures/hotmail_scrape_response_stage_1.html +0 -90
  47. data/test/fixtures/hotmail_scrape_response_stage_2.html +0 -77
  48. data/test/fixtures/hotmail_scrape_response_stage_3.html +0 -0
  49. data/test/fixtures/yahoo_bad_login_response_stage_2.html +0 -443
  50. data/test/fixtures/yahoo_contacts.csv +0 -3
  51. data/test/fixtures/yahoo_contacts_not_logged_in.html +0 -432
  52. data/test/fixtures/yahoo_contacts_stage_1.html +0 -399
  53. data/test/fixtures/yahoo_login_response_stage_1.html +0 -433
  54. data/test/fixtures/yahoo_login_response_stage_2.html +0 -16
  55. data/test/fixtures/yahoo_no_user_response_stage_2.html +0 -574
  56. data/test/freenet_importer_test.rb +0 -53
  57. data/test/gmx_importer_test.rb +0 -53
  58. data/test/scripts/live_test.rb +0 -25
  59. data/test/test_graybook.rb +0 -60
  60. data/test/test_graybook_exporter_base.rb +0 -16
  61. data/test/test_graybook_exporter_vcf.rb +0 -52
  62. data/test/test_graybook_exporter_xml.rb +0 -16
  63. data/test/test_graybook_importer_aol.rb +0 -108
  64. data/test/test_graybook_importer_base.rb +0 -24
  65. data/test/test_graybook_importer_csv.rb +0 -60
  66. data/test/test_graybook_importer_gmail.rb +0 -116
  67. data/test/test_graybook_importer_hotmail.rb +0 -165
  68. data/test/test_graybook_importer_page_scraper.rb +0 -51
  69. data/test/test_graybook_importer_yahoo.rb +0 -137
  70. data/test/test_helper.rb +0 -71
  71. data/test/web.de_importer_test.rb +0 -53
  72. data/vendor/plugins/graybook/lib/autotest/discover.rb +0 -3
  73. data/vendor/plugins/graybook/lib/autotest/graybook.rb +0 -27
@@ -1,165 +0,0 @@
1
- require File.join( File.dirname(__FILE__), '../lib/graybook.rb' )
2
- require File.join( File.dirname(__FILE__), 'test_helper.rb' )
3
- require 'test/unit'
4
- require 'mocha'
5
- require 'mechanize'
6
-
7
- class TestGraybookImporterHotmail < Test::Unit::TestCase
8
-
9
- include TestHelper
10
-
11
-
12
- def setup
13
- @importer = Graybook::Importer::Hotmail.new
14
- @importer.options = {:username => 'user@hotmail.com', :password => 'password'}
15
- @importer.create_agent
16
- end
17
-
18
- def test_bad_login
19
- response = {'content-type' => 'text/html'}
20
-
21
- body = load_fixture('hotmail_login_response_stage_1.html').join
22
- page = WWW::Mechanize::Page.new(uri=nil, response, body, code=nil, mech=nil)
23
- @importer.agent.expects(:get).with('http://login.live.com/login.srf?id=2'
24
- ).once.returns(page)
25
-
26
- body = load_fixture('hotmail_bad_login_response_stage_2.html').join
27
- page = WWW::Mechanize::Page.new(uri=nil, response, body, code=nil, mech=nil)
28
- @importer.agent.expects(:submit).once.returns(page)
29
-
30
- assert_raises(Graybook::BadCredentialsError) do
31
- @importer.login
32
- end
33
-
34
- end
35
-
36
- def test_login
37
- response = {'content-type' => 'text/html'}
38
-
39
- body = load_fixture('hotmail_login_response_stage_1.html').join
40
- page = WWW::Mechanize::Page.new(uri=nil, response, body, code=nil, mech=nil)
41
- @importer.agent.expects(:get).with('http://login.live.com/login.srf?id=2'
42
- ).once.returns(page)
43
-
44
- body = load_fixture('hotmail_login_response_stage_2.html').join
45
- page = WWW::Mechanize::Page.new(uri=nil, response, body, code=nil, mech=nil)
46
- @importer.agent.expects(:submit).once.returns(page)
47
-
48
- body = load_fixture('hotmail_login_response_stage_3.html').join
49
- page = WWW::Mechanize::Page.new(uri=nil, response, body, code=nil, mech=nil)
50
- @importer.agent.expects(:get).with(
51
- 'http://www.hotmail.msn.com/cgi-bin/sbox?t=9m9!oYK!qAKigHv8qDw1X1CMCqcbK10gIMWFQjyEK5dofUz!Aneq2zVs58p30sL*Vn8LAwVDD7952o!s1iny8uLHnZxso8YLLoQo4Z3CxhDx11tpPojydwUvwNF9zLFas7&p=9ZiSOOa!3CzsA5AbkqScGrB6w0zuXf!S*UaqQfk0fTM54toklVx51mUYcS3O8JAxjQmsQiwdEBIueipsTADcMs!2RRit547E5MtOMhA6NdiUNkoRvaGsSXK*j1iKAm7Z5jpdKpvW8oSv5yNpN5mWoULuD6lUEqC7i0KHR22e3NJ95C8uGbIGfgxkCjluo7Ye0eJcGraNIAbG0$&lc=1033&id=2'
52
- ).once.returns(page)
53
-
54
- assert_nothing_raised do
55
- @importer.login
56
- end
57
- end
58
-
59
- def test_scrape_contacts_not_logged_in
60
- @importer.agent.expects(:cookies).once.returns([])
61
- assert_raises(Graybook::BadCredentialsError) do
62
- @importer.scrape_contacts
63
- end
64
- end
65
-
66
- def test_scrape_contacts
67
- cookie = WWW::Mechanize::Cookie.new('MSPPre', 'user@hotmail.com')
68
- cookie.domain = 'localhost'
69
- @importer.agent.expects(:cookies).once.returns([cookie])
70
-
71
- response = {'content-type' => 'text/html'}
72
- uri = URI.parse('http://by135w.bay135.mail.live.com/mail/')
73
-
74
- body = load_fixture('hotmail_scrape_first_page.html').join
75
- page = WWW::Mechanize::Page.new(uri, response, body, code=nil, mech=nil)
76
- @importer.instance_variable_set("@first_page", page)
77
-
78
- body = load_fixture('hotmail_scrape_response_stage_1.html').join
79
- page = WWW::Mechanize::Page.new(uri, response, body, code=nil, mech=nil)
80
- @importer.agent.expects(:get).with('http://by118w.bay118.mail.live.com/mail/TodayLight.aspx?&ip=10.1.106.216&d=d952&mf=0&n=1587813607').once.returns(page)
81
-
82
- body = load_fixture('hotmail_scrape_response_stage_2.html').join
83
- page = WWW::Mechanize::Page.new(uri, response, body, code=nil, mech=nil)
84
- @importer.agent.expects(:click).once.returns(page)
85
-
86
- body = load_fixture('hotmail_scrape_response_stage_3.html').join
87
- page = WWW::Mechanize::Page.new(uri, response, body, code=nil, mech=nil)
88
- @importer.agent.expects(:get).with('http://by118w.bay118.mail.live.com/mail/TodayLight.aspx?rru=inbox&n=650062209').once.returns(page)
89
-
90
- body = load_fixture('hotmail_contacts.html').join
91
- page = WWW::Mechanize::Page.new(uri, response, body, code=nil, mech=nil)
92
- @importer.agent.expects(:get).with('/mail/PrintShell.aspx?type=contact').once.returns(page)
93
-
94
- assert_nothing_raised do
95
- contacts = @importer.scrape_contacts
96
- assert_equal 3, contacts.size
97
-
98
- # Joe doesn't have a name
99
- assert contacts.detect{|c| c[:email] == 'joe.user@example.com' && c[:name].nil? }
100
-
101
- # Jane has both a name and an email
102
- assert contacts.detect{|c| c[:email] == 'jane.user@example.com' && c[:name] == 'Jane User'}
103
-
104
- # John doesn't have a name, just a Windows Live ID treated as a name
105
- assert contacts.detect{|c| c[:email] == 'john.user@example.com' && c[:name].nil? }
106
- end
107
- end
108
-
109
- def test_prepare
110
- @importer.expects(:login).once
111
- @importer.prepare
112
- end
113
-
114
- def test_importer_match
115
- assert_equal false, @importer =~ nil
116
- assert_equal false, @importer =~ {}
117
- assert_equal false, @importer =~ {'username' => 'joe@example.com'}
118
- assert_equal false, @importer =~ {:username => 'joe@example.com'}
119
- assert_equal false, @importer =~ {:username => 'joe'}
120
-
121
- domains = ["compaq.net",
122
- "hotmail.co.jp",
123
- "hotmail.co.uk",
124
- "hotmail.com",
125
- "hotmail.de",
126
- "hotmail.fr",
127
- "hotmail.it",
128
- "messengeruser.com",
129
- "msn.com",
130
- "passport.com",
131
- "webtv.net"]
132
- domains.each do |domain|
133
- assert_equal true, @importer =~ {:username => "joe@#{domain}"}
134
- assert_equal true, @importer =~ {:username => "joe@#{domain}".upcase}
135
- end
136
- end
137
-
138
-
139
- def test_login_url
140
- assert_equal "https://login.live.com/ppsecure/post.srf", @importer.login_url
141
- @importer.options = {:username => 'user@msn.com', :password => 'password'}
142
- assert_equal "https://msnia.login.live.com/ppsecure/post.srf", @importer.login_url
143
- end
144
-
145
- def test_current_host
146
- response = {'content-type' => 'text/html'}
147
- page = WWW::Mechanize::Page.new(URI.parse('http://localhost/'), response, '<html></html>', code=nil, mech=nil)
148
-
149
- importer = Graybook::Importer::Hotmail.new
150
- assert_nil importer.current_host
151
- importer.create_agent
152
- assert_nil importer.current_host
153
- importer.agent.expects(:current_page).times(2).returns(page)
154
- assert_equal 'http://localhost', importer.current_host
155
- end
156
-
157
- def test_username_domain(username = nil)
158
- importer = Graybook::Importer::Hotmail.new
159
- assert_nil importer.username_domain
160
- assert_equal 'example.com', importer.username_domain('user@example.com')
161
- assert_equal 'example.com', @importer.username_domain('user@example.com')
162
- assert_equal 'hotmail.com', @importer.username_domain
163
- end
164
-
165
- end
@@ -1,51 +0,0 @@
1
- require File.join( File.dirname(__FILE__), '..', 'lib', 'graybook.rb' )
2
- require File.join( File.dirname(__FILE__), 'test_helper.rb' )
3
- require 'test/unit'
4
- require 'mocha'
5
-
6
- class TestGraybookImporterPageScraper < Test::Unit::TestCase
7
-
8
- include TestHelper
9
-
10
- def setup
11
- @scraper = Graybook::Importer::PageScraper.new
12
- end
13
-
14
- def test_mechanize_patch_to_absolute_uri
15
- @scraper.create_agent
16
- response = {'content-type' => 'text/html'}
17
- page = WWW::Mechanize::Page.new(uri=nil, response, '<html></html>', code=nil, mech=nil)
18
- url = "http://localhost/?arg=val&jank=AAA%3D"
19
- assert_equal URI.parse(url), @scraper.agent.send(:to_absolute_uri, url)
20
- # pattern of odd URL created by javascript validator in AOL webmail login
21
- url = "http://localhost/?arg=val&jank=AAA%3D%3D"
22
- assert_equal URI.parse(url), @scraper.agent.send(:to_absolute_uri, url)
23
- end
24
-
25
- def test_create_agent
26
- agent = nil
27
- assert_nothing_raised do
28
- agent = @scraper.create_agent
29
- end
30
- assert_equal agent, @scraper.agent
31
- assert_equal true, agent.is_a?(WWW::Mechanize)
32
- assert_equal "Mozilla/4.0 (compatible; Graybook #{Graybook::VERSION})", agent.user_agent
33
- assert_equal false, agent.keep_alive
34
- end
35
-
36
- def test_strip_html
37
- assert_equal '', @scraper.strip_html('<foo></foo>')
38
- assert_equal 'bar', @scraper.strip_html('<foo>bar</foo>')
39
- assert_equal 'bar', @scraper.strip_html('bar</foo>')
40
- assert_equal 'bar', @scraper.strip_html('<foo>bar')
41
- end
42
-
43
- def test_fetch_contacts!
44
- @scraper.expects(:create_agent).once
45
- @scraper.expects(:prepare).once
46
- @scraper.expects(:scrape_contacts).once
47
- assert_nothing_raised do
48
- agent = @scraper.fetch_contacts!
49
- end
50
- end
51
- end
@@ -1,137 +0,0 @@
1
- require File.join( File.dirname(__FILE__), '../lib/graybook.rb' )
2
- require File.join( File.dirname(__FILE__), 'test_helper.rb' )
3
- require 'test/unit'
4
- require 'mocha'
5
-
6
- class TestGraybookImporterYahoo < Test::Unit::TestCase
7
-
8
- include TestHelper
9
-
10
- def setup
11
- @importer = Graybook::Importer::Yahoo.new
12
- @importer.options = {:username => 'user@yahoo.com', :password => 'password'}
13
- @importer.create_agent
14
- end
15
-
16
- def test_prepare
17
- @importer.expects(:login).once
18
- @importer.prepare
19
- end
20
-
21
- def test_importer_match
22
- assert_equal false, @importer =~ nil
23
- assert_equal false, @importer =~ {}
24
- assert_equal false, @importer =~ {'username' => 'joe@example.com'}
25
- assert_equal false, @importer =~ {:username => 'joe@example.com'}
26
- assert_equal false, @importer =~ {:username => 'joe'}
27
- assert_equal true, @importer =~ {:username => 'joe@yahoo.com'}
28
- assert_equal true, @importer =~ {:username => 'joe@yahoo.co.uk'}
29
- assert_equal true, @importer =~ {:username => 'JOE@YAHOO.COM'}
30
- end
31
-
32
- def test_login
33
- response = {'content-type' => 'text/html'}
34
-
35
- body = load_fixture('yahoo_login_response_stage_1.html').join
36
- page = WWW::Mechanize::Page.new(uri=nil, response, body, code=nil, mech=nil)
37
- @importer.agent.expects(:get).with('https://login.yahoo.com/config/login_verify2?').once.returns(page)
38
-
39
- body = load_fixture('yahoo_login_response_stage_2.html').join
40
- page = WWW::Mechanize::Page.new(uri=nil, response, body, code=nil, mech=nil)
41
- @importer.agent.expects(:submit).once.returns(page)
42
-
43
- assert_nothing_raised do
44
- assert @importer.login
45
- end
46
- end
47
-
48
- def test_bad_login
49
- response = {'content-type' => 'text/html'}
50
-
51
- body = load_fixture('yahoo_login_response_stage_1.html').join
52
- page = WWW::Mechanize::Page.new(uri=nil, response, body, code=nil, mech=nil)
53
- @importer.agent.expects(:get).with('https://login.yahoo.com/config/login_verify2?').once.returns(page)
54
-
55
- body = load_fixture('yahoo_bad_login_response_stage_2.html').join
56
- page = WWW::Mechanize::Page.new(uri=nil, response, body, code=nil, mech=nil)
57
- @importer.agent.expects(:submit).once.returns(page)
58
-
59
- assert_raises(Graybook::BadCredentialsError) do
60
- @importer.login
61
- end
62
- end
63
-
64
- def test_no_such_user
65
- response = {'content-type' => 'text/html'}
66
-
67
- body = load_fixture('yahoo_login_response_stage_1.html').join
68
- page = WWW::Mechanize::Page.new(uri=nil, response, body, code=nil, mech=nil)
69
- @importer.agent.expects(:get).with('https://login.yahoo.com/config/login_verify2?').once.returns(page)
70
-
71
- body = load_fixture('yahoo_no_user_response_stage_2.html').join
72
- page = WWW::Mechanize::Page.new(uri=nil, response, body, code=nil, mech=nil)
73
- @importer.agent.expects(:submit).once.returns(page)
74
-
75
- assert_raises(Graybook::BadCredentialsError) do
76
- @importer.login
77
- end
78
- end
79
-
80
- def test_scrape_contacts_raises_badcredentialerror_when_not_logged_in
81
- response = {'content-type' => 'text/html'}
82
- body = load_fixture('yahoo_contacts_not_logged_in.html').join
83
- page = WWW::Mechanize::Page.new(uri=nil, response, body, code=nil, mech=nil)
84
- @importer.agent.expects(:get).with('http://address.yahoo.com/?1=&VPC=import_export'
85
- ).once.returns(page)
86
-
87
- assert_raises(Graybook::BadCredentialsError) do
88
- @importer.scrape_contacts
89
- end
90
- end
91
-
92
- def test_scrape_contacts
93
- response = {'content-type' => 'text/html'}
94
- body = load_fixture('yahoo_contacts_stage_1.html').join
95
- page = WWW::Mechanize::Page.new(uri=nil, response, body, code=nil, mech=nil)
96
- @importer.agent.expects(:get).with('http://address.yahoo.com/?1=&VPC=import_export'
97
- ).once.returns(page)
98
-
99
- response = {'content-type' => 'text/csv; charset=UTF-8'}
100
- body = load_fixture('yahoo_contacts.csv').join
101
- page = WWW::Mechanize::File.new(uri=nil, response, body, code=nil)
102
- @importer.agent.expects(:submit).once.returns(page)
103
-
104
- assert_nothing_raised do
105
- contacts = @importer.scrape_contacts
106
- assert_equal 2, contacts.size
107
- assert contacts.detect{|c| c[:email] == 'joe.user@example.com'}
108
- assert contacts.detect{|c| c[:name] == 'Joe User'}
109
- assert contacts.detect{|c| c[:email] == 'jane.user@example.com'}
110
- assert contacts.detect{|c| c[:name] == 'Jane User'}
111
- end
112
- end
113
-
114
-
115
- def test_scrape_contacts_with_invalid_regex_character_in_email
116
- response = {'content-type' => 'text/html'}
117
- body = load_fixture('yahoo_contacts_stage_1.html').join
118
- page = WWW::Mechanize::Page.new(uri=nil, response, body, code=nil, mech=nil)
119
- @importer.agent.expects(:get).with('http://address.yahoo.com/?1=&VPC=import_export'
120
- ).once.returns(page)
121
-
122
- response = {'content-type' => 'text/csv; charset=UTF-8'}
123
- body = load_fixture('yahoo_contacts.csv').join
124
- body.gsub!(/joe\.user\@example\.com/, "joe+user@example.com")
125
- page = WWW::Mechanize::File.new(uri=nil, response, body, code=nil)
126
- @importer.agent.expects(:submit).once.returns(page)
127
-
128
- assert_nothing_raised do
129
- contacts = @importer.scrape_contacts
130
- assert_equal 2, contacts.size
131
- assert contacts.detect{|c| c[:email] == 'joe+user@example.com'}
132
- assert contacts.detect{|c| c[:name] == 'Joe User'}
133
- assert contacts.detect{|c| c[:email] == 'jane.user@example.com'}
134
- assert contacts.detect{|c| c[:name] == 'Jane User'}
135
- end
136
- end
137
- end
data/test/test_helper.rb DELETED
@@ -1,71 +0,0 @@
1
- require 'ruby-debug'
2
-
3
- module TestHelper
4
-
5
- def fixture_path(name)
6
- "#{File.dirname(__FILE__)}/fixtures/#{name}"
7
- end
8
-
9
- def load_fixture(file)
10
- IO.readlines(fixture_path(file))
11
- end
12
-
13
- def fixture_file(name)
14
- File.new fixture_path(name)
15
- end
16
-
17
- end
18
-
19
- module Net #:nodoc:
20
- class HTTP #:nodoc:
21
-
22
- extend TestHelper
23
-
24
- RESPONSES = {}
25
-
26
- def self.responses=(r)
27
- RESPONSES.clear
28
- r.each{|k,v| RESPONSES[k] = v}
29
- end
30
-
31
-
32
- alias :old_net_http_request :request
33
-
34
- def request(req, body = nil, &block)
35
- prot = use_ssl ? "https" : "http"
36
- uri_cls = use_ssl ? URI::HTTPS : URI::HTTP
37
- query = req.path.split('?',2)
38
- opts = {:host => self.address,
39
- :port => self.port, :path => query[0]}
40
- opts[:query] = query[1] if query[1]
41
- uri = uri_cls.build(opts)
42
- raise ArgumentError.new("#{req.method} method to #{uri} not being handled in testing")
43
- end
44
-
45
- def connect
46
- raise ArgumentError.new("connect not being handled in testing")
47
- end
48
- end
49
- end
50
-
51
- plugin_root = "#{ File.dirname(__FILE__) }/.."
52
-
53
- require 'rubygems'
54
- require 'mocha'
55
-
56
- module GraybookExtensions
57
- module TestHelper
58
- class Credentials
59
- attr_accessor :network, :config
60
-
61
- def initialize(network)
62
- self.network = network.to_s
63
- self.config = YAML.load_file( File.join(File.dirname(__FILE__), "config/credentials.yml") )
64
- end
65
-
66
- def get
67
- [ self.config[self.network]["username"], self.config[self.network]["password"] ]
68
- end
69
- end
70
- end
71
- end
@@ -1,53 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper.rb'
2
-
3
- context "The Web.de importer" do
4
-
5
- setup do
6
- @username, @password = GraybookExtensions::TestHelper::Credentials.new(:webde).get
7
-
8
- @importer = Graybook::Importer::WebDE.new
9
- @importer.create_agent
10
- end
11
-
12
- specify "should match emails" do
13
- @importer.=~(nil).should.not.be
14
- @importer.=~({}).should.not.be
15
- @importer.=~({ 'username' => "john@foo.com" }).should.not.be
16
- @importer.=~({ :username => "john@foo.com" }).should.not.be
17
- @importer.=~({ :username => "john" }).should.not.be
18
- @importer.=~({ :username => "john@web.de" }).should.be
19
- @importer.=~({ :username => "JOHN@WEB.DE" }).should.be
20
- end
21
-
22
- specify "should be able to login with correct credentials" do
23
- should.not.raise Exception do
24
- login(@username, @password)
25
- end
26
- end
27
-
28
- specify "should raise BadCredentialsError on login with wrong credentials" do
29
- should.raise Graybook::BadCredentialsError do
30
- login
31
- end
32
- end
33
-
34
- specify "should raise BadCredentialsError on login with correct username and wrong password" do
35
- should.raise Graybook::BadCredentialsError do
36
- login(@username)
37
- end
38
- end
39
-
40
- specify "should able to get contacts" do
41
- login(@username, @password)
42
-
43
- contacts = @importer.scrape_contacts
44
- contacts.should.not.be.empty
45
- contacts.should.be.all { |contact| contact.is_a? Hash }
46
- end
47
-
48
- private
49
- def login(username = "foo", password = "bar")
50
- @importer.options = { :username => username, :password => password }
51
- @importer.login
52
- end
53
- end
@@ -1,3 +0,0 @@
1
- Autotest.add_discovery do
2
- "blackbook"
3
- end
@@ -1,27 +0,0 @@
1
- require 'autotest'
2
-
3
- class Autotest::Blackbook < Autotest
4
-
5
- def initialize # :nodoc:
6
- super
7
- @exceptions = /\.svn|\.html/
8
- @test_mappings = {
9
- %r%^lib/blackbook/([^\/]+)/([^\/]+)\.rb$% => proc { |_, m|
10
- ["test/test_blackbook_#{m[1]}_#{m[2]}.rb"]
11
- },
12
- %r%^lib/blackbook.rb$% => proc { |_, m|
13
- ["test/test_blackbook.rb"]
14
- },
15
- %r%^test/test_blackbook_.*\.rb$% => proc { |filename, _|
16
- filename
17
- }
18
- }
19
- end
20
-
21
- def path_to_classname(s)
22
- f = s.sub(/test\/(.+).rb$/, '\1')
23
- f = f.map { |path| path.split(/_/).map { |seg| seg.capitalize }.join }
24
- f.join('::')
25
- end
26
-
27
- end