gmail-afurmanov 0.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.
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Any object" do
4
+ it "should be able to convert itself to IMAP date format" do
5
+ "20-12-1988".to_imap_date.should == "20-December-1988"
6
+ end
7
+
8
+ %w[new new!].each do |method|
9
+ it "##{method} should properly connect with GMail service and return valid connection object" do
10
+ gmail = Gmail.send(method, *TEST_ACCOUNT)
11
+ gmail.should be_kind_of(Gmail::Client::Plain)
12
+ gmail.connection.should_not be_nil
13
+ gmail.should be_logged_in
14
+ end
15
+
16
+ it "##{method} should connect with client and give it context when block given" do
17
+ Gmail.send(method, *TEST_ACCOUNT) do |gmail|
18
+ gmail.should be_kind_of(Gmail::Client::Plain)
19
+ gmail.connection.should_not be_nil
20
+ gmail.should be_logged_in
21
+ end
22
+ end
23
+ end
24
+
25
+ it "#new should not raise error when couldn't connect with given account" do
26
+ lambda {
27
+ gmail = Gmail.new("foo", "bar")
28
+ gmail.should_not be_logged_in
29
+ }.should_not raise_error(Gmail::Client::AuthorizationError)
30
+ end
31
+
32
+ it "#new! should raise error when couldn't connect with given account" do
33
+ lambda {
34
+ gmail = Gmail.new!("foo", "bar")
35
+ gmail.should_not be_logged_in
36
+ }.should raise_error(Gmail::Client::AuthorizationError)
37
+ end
38
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe "A Gmail mailbox" do
4
+ subject { Gmail::Mailbox }
5
+
6
+ context "on initialize" do
7
+ it "should set client and name" do
8
+ within_gmail do |gmail|
9
+ mailbox = subject.new(gmail, "TEST")
10
+ mailbox.instance_variable_get("@gmail").should == gmail
11
+ mailbox.name.should == "TEST"
12
+ end
13
+ end
14
+
15
+ it "should work in INBOX by default" do
16
+ within_gmail do |gmail|
17
+ mailbox = subject.new(@gmail)
18
+ mailbox.name.should == "INBOX"
19
+ end
20
+ end
21
+ end
22
+
23
+ context "instance" do
24
+ it "should be able to count all emails" do
25
+ mock_mailbox do |mailbox|
26
+ mailbox.count.should > 0
27
+ end
28
+ end
29
+
30
+ it "should be able to find messages" do
31
+ mock_mailbox do |mailbox|
32
+ message = mailbox.emails.first
33
+ mailbox.emails(:all, :from => message.from.first.name) == message.from.first.name
34
+ end
35
+ end
36
+
37
+ it "should be able to do a full text search of message bodies" do
38
+ pending "This can wait..."
39
+ #mock_mailbox do |mailbox|
40
+ # message = mailbox.emails.first
41
+ # body = message.parts.blank? ? message.body.decoded : message.parts[0].body.decoded
42
+ # emails = mailbox.emails(:search => body.split(' ').first)
43
+ # emails.size.should > 0
44
+ #end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe "A Gmail message" do
4
+ context "on initialize" do
5
+ it "should set uid and mailbox" do
6
+ pending
7
+ end
8
+ end
9
+
10
+ context "instance" do
11
+ it "should be able to mark itself as read" do
12
+ pending
13
+ end
14
+
15
+ it "should be able to mark itself as unread" do
16
+ pending
17
+ end
18
+
19
+ it "should be able to set star itself" do
20
+ pending
21
+ end
22
+
23
+ it "should be able to unset start" do
24
+ pending
25
+ end
26
+
27
+ it "should be able to archive itself" do
28
+ pending
29
+ end
30
+
31
+ it "should be able to delete itself" do
32
+ pending
33
+ end
34
+
35
+ it "should be able to move itself to spam" do
36
+ pending
37
+ end
38
+
39
+ it "should be able to set given label" do
40
+ pending
41
+ end
42
+
43
+ it "should be able to mark itself with given flag" do
44
+ pending
45
+ end
46
+
47
+ it "should be able to move itself to given box" do
48
+ pending
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,29 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
4
+ require 'rubygems'
5
+ require 'rspec'
6
+ require 'mocha'
7
+ require 'yaml'
8
+ require 'gmail'
9
+
10
+ RSpec.configure do |config|
11
+ config.mock_with :mocha
12
+ end
13
+
14
+ def within_gmail(&block)
15
+ gmail = Gmail.connect!(*TEST_ACCOUNT)
16
+ yield(gmail)
17
+ gmail.logout if gmail
18
+ end
19
+
20
+ def mock_mailbox(box="INBOX", &block)
21
+ within_gmail do |gmail|
22
+ mailbox = subject.new(gmail, box)
23
+ yield(mailbox) if block_given?
24
+ mailbox
25
+ end
26
+ end
27
+
28
+ # Run test by creating your own test account with credentials in account.yml
29
+ TEST_ACCOUNT = YAML.load_file(File.join(File.dirname(__FILE__), 'account.yml'))
metadata ADDED
@@ -0,0 +1,185 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gmail-afurmanov
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Chris Kowalik
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-17 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: gmail_xoauth
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 19
30
+ segments:
31
+ - 0
32
+ - 3
33
+ - 0
34
+ version: 0.3.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: mail
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 5
46
+ segments:
47
+ - 2
48
+ - 2
49
+ - 1
50
+ version: 2.2.1
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: mime
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 9
62
+ segments:
63
+ - 0
64
+ - 1
65
+ version: "0.1"
66
+ type: :runtime
67
+ version_requirements: *id003
68
+ - !ruby/object:Gem::Dependency
69
+ name: ore-tasks
70
+ prerelease: false
71
+ requirement: &id004 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ - 4
80
+ version: "0.4"
81
+ type: :development
82
+ version_requirements: *id004
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ prerelease: false
86
+ requirement: &id005 !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ~>
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 2
94
+ - 0
95
+ version: "2.0"
96
+ type: :development
97
+ version_requirements: *id005
98
+ - !ruby/object:Gem::Dependency
99
+ name: mocha
100
+ prerelease: false
101
+ requirement: &id006 !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ hash: 25
107
+ segments:
108
+ - 0
109
+ - 9
110
+ version: "0.9"
111
+ type: :development
112
+ version_requirements: *id006
113
+ description: A Rubyesque interface to Gmail, with all the tools you will need. Search, read and send multipart emails; archive, mark as read/unread, delete emails; and manage labels.
114
+ email:
115
+ - chris@nu7hat.ch
116
+ executables: []
117
+
118
+ extensions: []
119
+
120
+ extra_rdoc_files:
121
+ - README.md
122
+ files:
123
+ - spec/spec_helper.rb
124
+ - spec/account.yml.example
125
+ - gemspec.yml
126
+ - TODO.md
127
+ - .rspec
128
+ - spec/message_spec.rb
129
+ - lib/gmail/version.rb
130
+ - LICENSE
131
+ - spec/mailbox_spec.rb
132
+ - lib/gmail/labels.rb
133
+ - lib/gmail/client/xoauth.rb
134
+ - lib/gmail/client.rb
135
+ - spec/gmail_spec.rb
136
+ - spec/client_spec.rb
137
+ - Rakefile
138
+ - README.md
139
+ - VERSION
140
+ - CHANGELOG.md
141
+ - lib/gmail/mailbox.rb
142
+ - lib/gmail/client/base.rb
143
+ - gmail.gemspec
144
+ - lib/gmail/message.rb
145
+ - lib/gmail/client/plain.rb
146
+ - lib/gmail.rb
147
+ has_rdoc: true
148
+ homepage: http://github.com/nu7hatch/gmail
149
+ licenses:
150
+ - MIT
151
+ post_install_message:
152
+ rdoc_options: []
153
+
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ none: false
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ hash: 3
162
+ segments:
163
+ - 0
164
+ version: "0"
165
+ required_rubygems_version: !ruby/object:Gem::Requirement
166
+ none: false
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ hash: 3
171
+ segments:
172
+ - 0
173
+ version: "0"
174
+ requirements: []
175
+
176
+ rubyforge_project: gmail-afurmanov
177
+ rubygems_version: 1.5.0
178
+ signing_key:
179
+ specification_version: 3
180
+ summary: A Rubyesque interface to Gmail, with all the tools you will need.
181
+ test_files:
182
+ - spec/client_spec.rb
183
+ - spec/gmail_spec.rb
184
+ - spec/mailbox_spec.rb
185
+ - spec/message_spec.rb