imap-backup 0.0.3 → 0.0.4
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.
- data/bin/imap-backup +18 -7
- data/imap-backup.gemspec +1 -0
- data/lib/imap/backup.rb +13 -1
- data/lib/imap/backup/configuration/account.rb +85 -0
- data/lib/imap/backup/configuration/asker.rb +42 -0
- data/lib/imap/backup/configuration/connection_tester.rb +19 -0
- data/lib/imap/backup/configuration/folder_chooser.rb +56 -0
- data/lib/imap/backup/configuration/list.rb +32 -0
- data/lib/imap/backup/configuration/setup.rb +68 -0
- data/lib/imap/backup/configuration/store.rb +64 -0
- data/lib/imap/backup/downloader.rb +2 -0
- data/lib/imap/backup/serializer/directory.rb +2 -4
- data/lib/imap/backup/utils.rb +11 -5
- data/lib/imap/backup/version.rb +1 -1
- data/spec/spec_helper.rb +26 -0
- data/spec/unit/configuration/account_spec.rb +224 -0
- data/spec/unit/configuration/asker_spec.rb +122 -0
- data/spec/unit/configuration/connection_tester_spec.rb +47 -0
- data/spec/unit/configuration/folder_chooser_spec.rb +131 -0
- data/spec/unit/configuration/list_spec.rb +73 -0
- data/spec/unit/configuration/setup_spec.rb +115 -0
- data/spec/unit/configuration/store_spec.rb +173 -0
- data/spec/unit/serializer/directory_spec.rb +2 -0
- data/spec/unit/utils_spec.rb +11 -9
- metadata +129 -113
- data/lib/imap/backup/settings.rb +0 -35
- data/spec/unit/settings_spec.rb +0 -109
@@ -7,6 +7,7 @@ describe Imap::Backup::Serializer::Directory do
|
|
7
7
|
context '#initialize' do
|
8
8
|
|
9
9
|
it 'should fail if download path file permissions are to lax' do
|
10
|
+
File.stub!(:exist?).with('/base/path').and_return(true)
|
10
11
|
stat = stub('File::Stat', :mode => 0345)
|
11
12
|
File.should_receive(:stat).with('/base/path').and_return(stat)
|
12
13
|
|
@@ -24,6 +25,7 @@ describe Imap::Backup::Serializer::Directory do
|
|
24
25
|
File.stub!(:stat).with('/base/path').and_return(stat)
|
25
26
|
FileUtils.stub!(:mkdir_p).with('/base/path/my_folder')
|
26
27
|
FileUtils.stub!(:chmod).with(0700, '/base/path/my_folder')
|
28
|
+
File.stub!(:exist?).with('/base/path').and_return(true)
|
27
29
|
end
|
28
30
|
|
29
31
|
subject { Imap::Backup::Serializer::Directory.new('/base/path', 'my_folder') }
|
data/spec/unit/utils_spec.rb
CHANGED
@@ -3,15 +3,17 @@ load File.expand_path( '../spec_helper.rb', File.dirname(__FILE__) )
|
|
3
3
|
|
4
4
|
describe Imap::Backup::Utils do
|
5
5
|
|
6
|
-
include Imap::Backup::Utils
|
7
|
-
|
8
6
|
context '#check_permissions' do
|
9
7
|
|
8
|
+
before :each do
|
9
|
+
File.stub!(:exist?).and_return(true)
|
10
|
+
end
|
11
|
+
|
10
12
|
it 'should stat the file' do
|
11
13
|
stat = stub('File::Stat', :mode => 0100)
|
12
14
|
File.should_receive(:stat).with('foobar').and_return(stat)
|
13
15
|
|
14
|
-
check_permissions('foobar', 0345)
|
16
|
+
Imap::Backup::Utils.check_permissions('foobar', 0345)
|
15
17
|
end
|
16
18
|
|
17
19
|
it 'should succeed if file permissions are less than limit' do
|
@@ -19,7 +21,7 @@ describe Imap::Backup::Utils do
|
|
19
21
|
File.stub!(:stat).and_return(stat)
|
20
22
|
|
21
23
|
expect do
|
22
|
-
check_permissions('foobar', 0345)
|
24
|
+
Imap::Backup::Utils.check_permissions('foobar', 0345)
|
23
25
|
end.to_not raise_error
|
24
26
|
end
|
25
27
|
|
@@ -28,7 +30,7 @@ describe Imap::Backup::Utils do
|
|
28
30
|
File.stub!(:stat).and_return(stat)
|
29
31
|
|
30
32
|
expect do
|
31
|
-
check_permissions('foobar', 0345)
|
33
|
+
Imap::Backup::Utils.check_permissions('foobar', 0345)
|
32
34
|
end.to_not raise_error
|
33
35
|
end
|
34
36
|
|
@@ -37,7 +39,7 @@ describe Imap::Backup::Utils do
|
|
37
39
|
File.stub!(:stat).and_return(stat)
|
38
40
|
|
39
41
|
expect do
|
40
|
-
check_permissions('foobar', 0345)
|
42
|
+
Imap::Backup::Utils.check_permissions('foobar', 0345)
|
41
43
|
end.to raise_error(RuntimeError, "Permissions on 'foobar' should be 0345, not 0777")
|
42
44
|
end
|
43
45
|
|
@@ -48,7 +50,7 @@ describe Imap::Backup::Utils do
|
|
48
50
|
it 'should do nothing if an empty path is supplied' do
|
49
51
|
FileUtils.should_not_receive(:mkdir_p)
|
50
52
|
|
51
|
-
make_folder('aaa', '', 0222)
|
53
|
+
Imap::Backup::Utils.make_folder('aaa', '', 0222)
|
52
54
|
end
|
53
55
|
|
54
56
|
it 'should create the path' do
|
@@ -56,7 +58,7 @@ describe Imap::Backup::Utils do
|
|
56
58
|
|
57
59
|
FileUtils.should_receive(:mkdir_p).with('/base/path/new/folder')
|
58
60
|
|
59
|
-
make_folder('/base/path', 'new/folder', 0222)
|
61
|
+
Imap::Backup::Utils.make_folder('/base/path', 'new/folder', 0222)
|
60
62
|
end
|
61
63
|
|
62
64
|
it 'should set permissions on the path' do
|
@@ -64,7 +66,7 @@ describe Imap::Backup::Utils do
|
|
64
66
|
|
65
67
|
FileUtils.should_receive(:chmod).with(0222, '/base/path/new')
|
66
68
|
|
67
|
-
make_folder('/base/path', 'new/folder', 0222)
|
69
|
+
Imap::Backup::Utils.make_folder('/base/path', 'new/folder', 0222)
|
68
70
|
end
|
69
71
|
|
70
72
|
end
|
metadata
CHANGED
@@ -1,119 +1,120 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: imap-backup
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 3
|
10
|
-
version: 0.0.3
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Joe Yates
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
22
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
-
none: false
|
24
|
-
requirements:
|
25
|
-
- - ">="
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
hash: 3
|
28
|
-
segments:
|
29
|
-
- 0
|
30
|
-
version: "0"
|
31
|
-
version_requirements: *id001
|
12
|
+
date: 2012-06-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
32
15
|
name: rake
|
33
|
-
|
34
|
-
type: :runtime
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
37
17
|
none: false
|
38
|
-
requirements:
|
39
|
-
- -
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
|
42
|
-
|
43
|
-
- 0
|
44
|
-
version: "0"
|
45
|
-
version_requirements: *id002
|
46
|
-
name: json
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
47
23
|
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: highline
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
48
38
|
type: :runtime
|
49
|
-
|
50
|
-
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
41
|
none: false
|
52
|
-
requirements:
|
53
|
-
- -
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
|
56
|
-
|
57
|
-
- 0
|
58
|
-
version: "0"
|
59
|
-
version_requirements: *id003
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
60
47
|
name: pry
|
61
|
-
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
62
54
|
type: :development
|
63
|
-
|
64
|
-
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
57
|
none: false
|
66
|
-
requirements:
|
67
|
-
- -
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
|
70
|
-
|
71
|
-
- 0
|
72
|
-
version: "0"
|
73
|
-
version_requirements: *id004
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
74
63
|
name: pry-doc
|
75
|
-
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
76
70
|
type: :development
|
77
|
-
|
78
|
-
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
73
|
none: false
|
80
|
-
requirements:
|
81
|
-
- -
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
|
84
|
-
|
85
|
-
- 2
|
86
|
-
- 3
|
87
|
-
- 0
|
88
|
-
version: 2.3.0
|
89
|
-
version_requirements: *id005
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
90
79
|
name: rspec
|
91
|
-
|
92
|
-
type: :development
|
93
|
-
- !ruby/object:Gem::Dependency
|
94
|
-
requirement: &id006 !ruby/object:Gem::Requirement
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
95
81
|
none: false
|
96
|
-
requirements:
|
97
|
-
- -
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
|
100
|
-
|
101
|
-
- 0
|
102
|
-
version: "0"
|
103
|
-
version_requirements: *id006
|
104
|
-
name: rcov
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 2.3.0
|
86
|
+
type: :development
|
105
87
|
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 2.3.0
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: simplecov
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
106
102
|
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
107
110
|
description: Backup GMail, or any other IMAP email service, to disk.
|
108
|
-
email:
|
111
|
+
email:
|
109
112
|
- joe.g.yates@gmail.com
|
110
|
-
executables:
|
113
|
+
executables:
|
111
114
|
- imap-backup
|
112
115
|
extensions: []
|
113
|
-
|
114
116
|
extra_rdoc_files: []
|
115
|
-
|
116
|
-
files:
|
117
|
+
files:
|
117
118
|
- .gitignore
|
118
119
|
- .travis.yml
|
119
120
|
- Gemfile
|
@@ -125,59 +126,74 @@ files:
|
|
125
126
|
- lib/imap/backup.rb
|
126
127
|
- lib/imap/backup/account/connection.rb
|
127
128
|
- lib/imap/backup/account/folder.rb
|
129
|
+
- lib/imap/backup/configuration/account.rb
|
130
|
+
- lib/imap/backup/configuration/asker.rb
|
131
|
+
- lib/imap/backup/configuration/connection_tester.rb
|
132
|
+
- lib/imap/backup/configuration/folder_chooser.rb
|
133
|
+
- lib/imap/backup/configuration/list.rb
|
134
|
+
- lib/imap/backup/configuration/setup.rb
|
135
|
+
- lib/imap/backup/configuration/store.rb
|
128
136
|
- lib/imap/backup/downloader.rb
|
129
137
|
- lib/imap/backup/serializer/directory.rb
|
130
|
-
- lib/imap/backup/settings.rb
|
131
138
|
- lib/imap/backup/utils.rb
|
132
139
|
- lib/imap/backup/version.rb
|
133
140
|
- spec/gather_rspec_coverage.rb
|
134
141
|
- spec/spec_helper.rb
|
135
142
|
- spec/unit/account/connection_spec.rb
|
136
143
|
- spec/unit/account/folder_spec.rb
|
144
|
+
- spec/unit/configuration/account_spec.rb
|
145
|
+
- spec/unit/configuration/asker_spec.rb
|
146
|
+
- spec/unit/configuration/connection_tester_spec.rb
|
147
|
+
- spec/unit/configuration/folder_chooser_spec.rb
|
148
|
+
- spec/unit/configuration/list_spec.rb
|
149
|
+
- spec/unit/configuration/setup_spec.rb
|
150
|
+
- spec/unit/configuration/store_spec.rb
|
137
151
|
- spec/unit/downloader_spec.rb
|
138
152
|
- spec/unit/serializer/directory_spec.rb
|
139
|
-
- spec/unit/settings_spec.rb
|
140
153
|
- spec/unit/utils_spec.rb
|
141
|
-
has_rdoc: true
|
142
154
|
homepage: https://github.com/joeyates/imap-backup
|
143
155
|
licenses: []
|
144
|
-
|
145
156
|
post_install_message:
|
146
157
|
rdoc_options: []
|
147
|
-
|
148
|
-
require_paths:
|
158
|
+
require_paths:
|
149
159
|
- lib
|
150
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
160
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
151
161
|
none: false
|
152
|
-
requirements:
|
153
|
-
- -
|
154
|
-
- !ruby/object:Gem::Version
|
155
|
-
|
156
|
-
segments:
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
segments:
|
157
167
|
- 0
|
158
|
-
|
159
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
|
+
hash: 1194066517873683688
|
169
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
170
|
none: false
|
161
|
-
requirements:
|
162
|
-
- -
|
163
|
-
- !ruby/object:Gem::Version
|
164
|
-
|
165
|
-
segments:
|
171
|
+
requirements:
|
172
|
+
- - ! '>='
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
segments:
|
166
176
|
- 0
|
167
|
-
|
177
|
+
hash: 1194066517873683688
|
168
178
|
requirements: []
|
169
|
-
|
170
179
|
rubyforge_project:
|
171
|
-
rubygems_version: 1.
|
180
|
+
rubygems_version: 1.8.23
|
172
181
|
signing_key:
|
173
182
|
specification_version: 3
|
174
183
|
summary: Backup GMail (or other IMAP) accounts to disk
|
175
|
-
test_files:
|
184
|
+
test_files:
|
176
185
|
- spec/gather_rspec_coverage.rb
|
177
186
|
- spec/spec_helper.rb
|
178
187
|
- spec/unit/account/connection_spec.rb
|
179
188
|
- spec/unit/account/folder_spec.rb
|
189
|
+
- spec/unit/configuration/account_spec.rb
|
190
|
+
- spec/unit/configuration/asker_spec.rb
|
191
|
+
- spec/unit/configuration/connection_tester_spec.rb
|
192
|
+
- spec/unit/configuration/folder_chooser_spec.rb
|
193
|
+
- spec/unit/configuration/list_spec.rb
|
194
|
+
- spec/unit/configuration/setup_spec.rb
|
195
|
+
- spec/unit/configuration/store_spec.rb
|
180
196
|
- spec/unit/downloader_spec.rb
|
181
197
|
- spec/unit/serializer/directory_spec.rb
|
182
|
-
- spec/unit/settings_spec.rb
|
183
198
|
- spec/unit/utils_spec.rb
|
199
|
+
has_rdoc:
|
data/lib/imap/backup/settings.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
module Imap
|
4
|
-
module Backup
|
5
|
-
|
6
|
-
class Settings
|
7
|
-
|
8
|
-
include Imap::Backup::Utils
|
9
|
-
|
10
|
-
attr_reader :accounts
|
11
|
-
|
12
|
-
def initialize(accounts = nil)
|
13
|
-
config_pathname = File.expand_path('~/.imap-backup/config.json')
|
14
|
-
raise "Configuration file '#{config_pathname}' not found" if ! File.exist?(config_pathname)
|
15
|
-
check_permissions(config_pathname, 0600)
|
16
|
-
@settings = JSON.parse(File.read(config_pathname), :symbolize_names => true)
|
17
|
-
if accounts.nil?
|
18
|
-
@accounts = @settings[:accounts]
|
19
|
-
else
|
20
|
-
@accounts = @settings[:accounts].select{ |account| accounts.include?(account[:username]) }
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def each_connection
|
25
|
-
@accounts.each do |account|
|
26
|
-
connection = Imap::Backup::Account::Connection.new(account)
|
27
|
-
yield connection
|
28
|
-
connection.disconnect
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
data/spec/unit/settings_spec.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
load File.expand_path( '../spec_helper.rb', File.dirname(__FILE__) )
|
3
|
-
|
4
|
-
describe Imap::Backup::Settings do
|
5
|
-
|
6
|
-
before :each do
|
7
|
-
@settings = {
|
8
|
-
:accounts => [
|
9
|
-
{
|
10
|
-
:username => 'a1@example.com'
|
11
|
-
},
|
12
|
-
{
|
13
|
-
:username => 'a2@example.com',
|
14
|
-
},
|
15
|
-
]
|
16
|
-
}
|
17
|
-
File.stub!(:exist?).and_return(true)
|
18
|
-
stat = stub('File::Stat', :mode => 0600)
|
19
|
-
File.stub!(:stat).and_return(stat)
|
20
|
-
File.stub!(:read)
|
21
|
-
JSON.stub!(:parse).and_return(@settings)
|
22
|
-
end
|
23
|
-
|
24
|
-
context '#initialize' do
|
25
|
-
|
26
|
-
it 'should fail if the config file is missing' do
|
27
|
-
File.should_receive(:exist?).and_return(false)
|
28
|
-
|
29
|
-
expect do
|
30
|
-
Imap::Backup::Settings.new
|
31
|
-
end.to raise_error(RuntimeError, /not found/)
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should fail if the config file permissions are too lax' do
|
35
|
-
File.stub!(:exist?).and_return(true)
|
36
|
-
|
37
|
-
stat = stub('File::Stat', :mode => 0644)
|
38
|
-
File.should_receive(:stat).and_return(stat)
|
39
|
-
|
40
|
-
expect do
|
41
|
-
Imap::Backup::Settings.new
|
42
|
-
end.to raise_error(RuntimeError, /Permissions.*?should be 0600/)
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'should load the config file' do
|
46
|
-
File.stub!(:exist?).and_return(true)
|
47
|
-
|
48
|
-
stat = stub('File::Stat', :mode => 0600)
|
49
|
-
File.stub!(:stat).and_return(stat)
|
50
|
-
|
51
|
-
configuration = 'JSON string'
|
52
|
-
File.should_receive(:read).with(%r{/.imap-backup/config.json}).and_return(configuration)
|
53
|
-
JSON.should_receive(:parse).with(configuration, :symbolize_names => true)
|
54
|
-
|
55
|
-
Imap::Backup::Settings.new
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'with account parameter' do
|
59
|
-
it 'should only create requested accounts' do
|
60
|
-
settings = Imap::Backup::Settings.new(['a2@example.com'])
|
61
|
-
|
62
|
-
settings.accounts.should == @settings[:accounts][1..1]
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
context 'instance methods' do
|
69
|
-
|
70
|
-
before :each do
|
71
|
-
@connection = stub('Imap::Backup::Account::Connection', :disconnect => nil)
|
72
|
-
end
|
73
|
-
|
74
|
-
subject { Imap::Backup::Settings.new }
|
75
|
-
|
76
|
-
context '#each_connection' do
|
77
|
-
|
78
|
-
it 'should instantiate connections' do
|
79
|
-
Imap::Backup::Account::Connection.should_receive(:new).with(@settings[:accounts][0]).and_return(@connection)
|
80
|
-
Imap::Backup::Account::Connection.should_receive(:new).with(@settings[:accounts][1]).and_return(@connection)
|
81
|
-
|
82
|
-
subject.each_connection{}
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'should call the block' do
|
86
|
-
Imap::Backup::Account::Connection.stub!(:new).and_return(@connection)
|
87
|
-
calls = 0
|
88
|
-
|
89
|
-
subject.each_connection do |a|
|
90
|
-
calls += 1
|
91
|
-
a.should == @connection
|
92
|
-
end
|
93
|
-
calls.should == 2
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'should disconnect connections' do
|
97
|
-
Imap::Backup::Account::Connection.stub!(:new).and_return(@connection)
|
98
|
-
|
99
|
-
@connection.should_receive(:disconnect)
|
100
|
-
|
101
|
-
subject.each_connection {}
|
102
|
-
end
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
107
|
-
|
108
|
-
end
|
109
|
-
|