imap-backup 4.0.7 → 4.1.1
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.
- checksums.yaml +4 -4
- data/bin/imap-backup +5 -2
- data/lib/imap/backup/account/connection.rb +53 -33
- data/lib/imap/backup/account/folder.rb +22 -2
- data/lib/imap/backup/account.rb +4 -0
- data/lib/imap/backup/cli/accounts.rb +43 -0
- data/lib/imap/backup/cli/folders.rb +3 -1
- data/lib/imap/backup/cli/helpers.rb +8 -9
- data/lib/imap/backup/cli/local.rb +4 -2
- data/lib/imap/backup/cli/setup.rb +1 -1
- data/lib/imap/backup/cli/utils.rb +3 -2
- data/lib/imap/backup/{configuration/store.rb → configuration.rb} +16 -3
- data/lib/imap/backup/downloader.rb +26 -12
- data/lib/imap/backup/logger.rb +42 -0
- data/lib/imap/backup/sanitizer.rb +42 -0
- data/lib/imap/backup/serializer/mbox_store.rb +2 -2
- data/lib/imap/backup/{configuration → setup}/account.rb +29 -19
- data/lib/imap/backup/{configuration → setup}/asker.rb +5 -5
- data/lib/imap/backup/setup/connection_tester.rb +26 -0
- data/lib/imap/backup/{configuration → setup}/folder_chooser.rb +18 -8
- data/lib/imap/backup/setup/helpers.rb +15 -0
- data/lib/imap/backup/{configuration/setup.rb → setup.rb} +23 -17
- data/lib/imap/backup/uploader.rb +2 -2
- data/lib/imap/backup/version.rb +2 -2
- data/lib/imap/backup.rb +7 -33
- data/lib/retry_on_error.rb +1 -1
- data/spec/features/backup_spec.rb +1 -0
- data/spec/features/support/email_server.rb +5 -2
- data/spec/support/higline_test_helpers.rb +1 -1
- data/spec/support/silence_logging.rb +1 -1
- data/spec/unit/imap/backup/account/connection_spec.rb +14 -9
- data/spec/unit/imap/backup/cli/accounts_spec.rb +47 -0
- data/spec/unit/imap/backup/cli/local_spec.rb +7 -3
- data/spec/unit/imap/backup/cli/utils_spec.rb +15 -5
- data/spec/unit/imap/backup/{configuration/store_spec.rb → configuration_spec.rb} +2 -2
- data/spec/unit/imap/backup/downloader_spec.rb +1 -1
- data/spec/unit/imap/backup/logger_spec.rb +48 -0
- data/spec/unit/imap/backup/{configuration → setup}/account_spec.rb +31 -24
- data/spec/unit/imap/backup/{configuration → setup}/asker_spec.rb +2 -2
- data/spec/unit/imap/backup/{configuration → setup}/connection_tester_spec.rb +10 -10
- data/spec/unit/imap/backup/{configuration → setup}/folder_chooser_spec.rb +8 -8
- data/spec/unit/imap/backup/{configuration/setup_spec.rb → setup_spec.rb} +48 -40
- metadata +49 -46
- data/lib/imap/backup/configuration/connection_tester.rb +0 -14
- data/lib/imap/backup/configuration/list.rb +0 -53
- data/spec/unit/imap/backup/configuration/list_spec.rb +0 -96
- data/spec/unit/imap/backup_spec.rb +0 -28
@@ -3,7 +3,7 @@ require "os"
|
|
3
3
|
|
4
4
|
# rubocop:disable RSpec/PredicateMatcher
|
5
5
|
|
6
|
-
describe Imap::Backup::Configuration
|
6
|
+
describe Imap::Backup::Configuration do
|
7
7
|
let(:directory) { "/base/path" }
|
8
8
|
let(:file_path) { File.join(directory, "/config.json") }
|
9
9
|
let(:file_exists) { true }
|
@@ -17,7 +17,7 @@ describe Imap::Backup::Configuration::Store do
|
|
17
17
|
|
18
18
|
before do
|
19
19
|
stub_const(
|
20
|
-
"Imap::Backup::Configuration::
|
20
|
+
"Imap::Backup::Configuration::CONFIGURATION_DIRECTORY", directory
|
21
21
|
)
|
22
22
|
allow(File).to receive(:directory?).with(directory) { directory_exists }
|
23
23
|
allow(File).to receive(:exist?).and_call_original
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "net/imap"
|
2
|
+
|
3
|
+
module Imap::Backup
|
4
|
+
describe Logger do
|
5
|
+
describe ".setup_logging" do
|
6
|
+
let(:config) { instance_double(Configuration, debug?: debug) }
|
7
|
+
|
8
|
+
around do |example|
|
9
|
+
logger_previous = described_class.logger.level
|
10
|
+
net_imap_previous = Net::IMAP.debug
|
11
|
+
described_class.logger.level = 42
|
12
|
+
Net::IMAP.debug = 42
|
13
|
+
example.run
|
14
|
+
Net::IMAP.debug = net_imap_previous
|
15
|
+
described_class.logger.level = logger_previous
|
16
|
+
end
|
17
|
+
|
18
|
+
before do
|
19
|
+
allow(Configuration).to receive(:new) { config }
|
20
|
+
described_class.setup_logging
|
21
|
+
end
|
22
|
+
|
23
|
+
context "when config.debug?" do
|
24
|
+
let(:debug) { true }
|
25
|
+
|
26
|
+
it "sets logger level to debug" do
|
27
|
+
expect(described_class.logger.level).to eq(::Logger::Severity::DEBUG)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "sets the Net::IMAP debug flag" do
|
31
|
+
expect(Net::IMAP.debug).to be_a(TrueClass)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "when not config.debug?" do
|
36
|
+
let(:debug) { false }
|
37
|
+
|
38
|
+
it "sets logger level to error" do
|
39
|
+
expect(described_class.logger.level).to eq(::Logger::Severity::ERROR)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "sets the Net::IMAP debug flag" do
|
43
|
+
expect(Net::IMAP.debug).to be_a(FalseClass)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
describe Imap::Backup::
|
1
|
+
describe Imap::Backup::Setup::Account do
|
2
2
|
ACCOUNT = "account".freeze
|
3
3
|
GMAIL_IMAP_SERVER = "imap.gmail.com".freeze
|
4
4
|
HIGHLINE = "highline".freeze
|
5
|
-
|
5
|
+
CONFIG = "config".freeze
|
6
6
|
|
7
|
-
subject { described_class.new(
|
7
|
+
subject { described_class.new(config, account, highline) }
|
8
8
|
|
9
9
|
let(:account) do
|
10
10
|
instance_double(
|
@@ -14,7 +14,8 @@ describe Imap::Backup::Configuration::Account do
|
|
14
14
|
server: current_server,
|
15
15
|
connection_options: nil,
|
16
16
|
local_path: "/backup/path",
|
17
|
-
folders: [{name: "my_folder"}]
|
17
|
+
folders: [{name: "my_folder"}],
|
18
|
+
modified?: false
|
18
19
|
)
|
19
20
|
end
|
20
21
|
let(:account1) do
|
@@ -33,10 +34,10 @@ describe Imap::Backup::Configuration::Account do
|
|
33
34
|
let(:other_existing_path) { "/other/existing/path" }
|
34
35
|
|
35
36
|
let(:highline) { HIGHLINE }
|
36
|
-
let(:
|
37
|
+
let(:config) { CONFIG }
|
37
38
|
|
38
39
|
describe "#initialize" do
|
39
|
-
[:
|
40
|
+
[:config, :account, :highline].each do |param|
|
40
41
|
it "expects #{param}" do
|
41
42
|
expect(subject.send(param)).to eq(send(param))
|
42
43
|
end
|
@@ -65,8 +66,8 @@ describe Imap::Backup::Configuration::Account do
|
|
65
66
|
|
66
67
|
let(:highline) { instance_double(HighLine) }
|
67
68
|
let(:menu) { highline_menu_class.new }
|
68
|
-
let(:
|
69
|
-
instance_double(Imap::Backup::Configuration
|
69
|
+
let(:config) do
|
70
|
+
instance_double(Imap::Backup::Configuration, accounts: accounts)
|
70
71
|
end
|
71
72
|
|
72
73
|
before do
|
@@ -103,7 +104,7 @@ describe Imap::Backup::Configuration::Account do
|
|
103
104
|
"choose backup folders",
|
104
105
|
"test connection",
|
105
106
|
"delete",
|
106
|
-
"return to main menu",
|
107
|
+
"(q) return to main menu",
|
107
108
|
"quit" # TODO: quit is hidden
|
108
109
|
].each do |item|
|
109
110
|
before { subject.run }
|
@@ -116,11 +117,11 @@ describe Imap::Backup::Configuration::Account do
|
|
116
117
|
|
117
118
|
describe "account details" do
|
118
119
|
[
|
119
|
-
["email", /email
|
120
|
-
["
|
121
|
-
["
|
122
|
-
["
|
123
|
-
["
|
120
|
+
["email", /email\s+user@example.com/],
|
121
|
+
["password", /password\s+x+/],
|
122
|
+
["path", %r(path\s+/backup/path)],
|
123
|
+
["folders", /folders\s+my_folder/],
|
124
|
+
["server", /server\s+imap.example.com/]
|
124
125
|
].each do |attribute, value|
|
125
126
|
before { subject.run }
|
126
127
|
|
@@ -135,7 +136,7 @@ describe Imap::Backup::Configuration::Account do
|
|
135
136
|
before { subject.run }
|
136
137
|
|
137
138
|
it "indicates that a password is not set" do
|
138
|
-
expect(menu.header).to include("password
|
139
|
+
expect(menu.header).to include("password (unset)")
|
139
140
|
end
|
140
141
|
end
|
141
142
|
end
|
@@ -144,7 +145,7 @@ describe Imap::Backup::Configuration::Account do
|
|
144
145
|
before do
|
145
146
|
allow(account).to receive(:"username=")
|
146
147
|
allow(account).to receive(:"server=")
|
147
|
-
allow(Imap::Backup::
|
148
|
+
allow(Imap::Backup::Setup::Asker).
|
148
149
|
to receive(:email) { new_email }
|
149
150
|
subject.run
|
150
151
|
menu.choices["modify email"].call
|
@@ -218,7 +219,7 @@ describe Imap::Backup::Configuration::Account do
|
|
218
219
|
|
219
220
|
before do
|
220
221
|
allow(account).to receive(:"password=")
|
221
|
-
allow(Imap::Backup::
|
222
|
+
allow(Imap::Backup::Setup::Asker).
|
222
223
|
to receive(:password) { new_password }
|
223
224
|
subject.run
|
224
225
|
menu.choices["modify password"].call
|
@@ -263,7 +264,7 @@ describe Imap::Backup::Configuration::Account do
|
|
263
264
|
allow(account).to receive(:"local_path=")
|
264
265
|
@validator = nil
|
265
266
|
allow(
|
266
|
-
Imap::Backup::
|
267
|
+
Imap::Backup::Setup::Asker
|
267
268
|
).to receive(:backup_path) do |_path, validator|
|
268
269
|
@validator = validator
|
269
270
|
new_backup_path
|
@@ -295,11 +296,11 @@ describe Imap::Backup::Configuration::Account do
|
|
295
296
|
|
296
297
|
describe "choosing 'choose backup folders'" do
|
297
298
|
let(:chooser) do
|
298
|
-
instance_double(Imap::Backup::
|
299
|
+
instance_double(Imap::Backup::Setup::FolderChooser, run: nil)
|
299
300
|
end
|
300
301
|
|
301
302
|
before do
|
302
|
-
allow(Imap::Backup::
|
303
|
+
allow(Imap::Backup::Setup::FolderChooser).
|
303
304
|
to receive(:new) { chooser }
|
304
305
|
subject.run
|
305
306
|
menu.choices["choose backup folders"].call
|
@@ -311,17 +312,23 @@ describe Imap::Backup::Configuration::Account do
|
|
311
312
|
end
|
312
313
|
|
313
314
|
describe "choosing 'test connection'" do
|
315
|
+
let(:connection_tester) do
|
316
|
+
instance_double(
|
317
|
+
Imap::Backup::Setup::ConnectionTester,
|
318
|
+
test: "All fine"
|
319
|
+
)
|
320
|
+
end
|
321
|
+
|
314
322
|
before do
|
315
|
-
allow(Imap::Backup::
|
316
|
-
to receive(:
|
323
|
+
allow(Imap::Backup::Setup::ConnectionTester).
|
324
|
+
to receive(:new) { connection_tester }
|
317
325
|
allow(highline).to receive(:ask)
|
318
326
|
subject.run
|
319
327
|
menu.choices["test connection"].call
|
320
328
|
end
|
321
329
|
|
322
330
|
it "tests the connection" do
|
323
|
-
expect(
|
324
|
-
to have_received(:test).with(account)
|
331
|
+
expect(connection_tester).to have_received(:test)
|
325
332
|
end
|
326
333
|
end
|
327
334
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Imap::Backup
|
2
|
-
describe
|
2
|
+
describe Setup::Asker do
|
3
3
|
subject { described_class.new(highline) }
|
4
4
|
|
5
5
|
let(:highline) { double }
|
@@ -16,7 +16,7 @@ module Imap::Backup
|
|
16
16
|
let(:answer) { "foo" }
|
17
17
|
|
18
18
|
before do
|
19
|
-
allow(
|
19
|
+
allow(Setup).to receive(:highline) { highline }
|
20
20
|
allow(highline).to receive(:ask) do |&b|
|
21
21
|
b.call query
|
22
22
|
answer
|
@@ -1,5 +1,7 @@
|
|
1
|
-
describe Imap::Backup::
|
2
|
-
describe "
|
1
|
+
describe Imap::Backup::Setup::ConnectionTester do
|
2
|
+
describe "#test" do
|
3
|
+
subject { described_class.new("foo") }
|
4
|
+
|
3
5
|
let(:connection) do
|
4
6
|
instance_double(Imap::Backup::Account::Connection, client: nil)
|
5
7
|
end
|
@@ -8,17 +10,15 @@ describe Imap::Backup::Configuration::ConnectionTester do
|
|
8
10
|
allow(Imap::Backup::Account::Connection).to receive(:new) { connection }
|
9
11
|
end
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
expect(connection).to receive(:client)
|
13
|
+
it "tries to connect" do
|
14
|
+
expect(connection).to receive(:client)
|
14
15
|
|
15
|
-
|
16
|
-
end
|
16
|
+
subject.test
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "success" do
|
20
20
|
it "returns success" do
|
21
|
-
expect(subject.test
|
21
|
+
expect(subject.test).to match(/successful/)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -35,7 +35,7 @@ describe Imap::Backup::Configuration::ConnectionTester do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it "returns error" do
|
38
|
-
expect(subject.test
|
38
|
+
expect(subject.test).to match(/no response/i)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -43,7 +43,7 @@ describe Imap::Backup::Configuration::ConnectionTester do
|
|
43
43
|
let(:error) { "Error" }
|
44
44
|
|
45
45
|
it "returns error" do
|
46
|
-
expect(subject.test
|
46
|
+
expect(subject.test).to match(/unexpected error/i)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
describe Imap::Backup::
|
1
|
+
describe Imap::Backup::Setup::FolderChooser do
|
2
2
|
include HighLineTestHelpers
|
3
3
|
|
4
4
|
describe "#run" do
|
@@ -6,7 +6,7 @@ describe Imap::Backup::Configuration::FolderChooser do
|
|
6
6
|
|
7
7
|
let(:connection) do
|
8
8
|
instance_double(
|
9
|
-
Imap::Backup::Account::Connection,
|
9
|
+
Imap::Backup::Account::Connection, folder_names: connection_folders
|
10
10
|
)
|
11
11
|
end
|
12
12
|
let(:account) do
|
@@ -25,7 +25,7 @@ describe Imap::Backup::Configuration::FolderChooser do
|
|
25
25
|
before do
|
26
26
|
allow(Imap::Backup::Account::Connection).to receive(:new) { connection }
|
27
27
|
allow(Kernel).to receive(:system)
|
28
|
-
allow(Imap::Backup.logger).to receive(:warn)
|
28
|
+
allow(Imap::Backup::Logger.logger).to receive(:warn)
|
29
29
|
end
|
30
30
|
|
31
31
|
describe "display" do
|
@@ -108,12 +108,12 @@ describe Imap::Backup::Configuration::FolderChooser do
|
|
108
108
|
let(:connection_folders) { nil }
|
109
109
|
|
110
110
|
before do
|
111
|
-
allow(Imap::Backup::
|
111
|
+
allow(Imap::Backup::Setup.highline).
|
112
112
|
to receive(:ask) { "q" }
|
113
113
|
end
|
114
114
|
|
115
115
|
it "asks to press a key" do
|
116
|
-
expect(Imap::Backup::
|
116
|
+
expect(Imap::Backup::Setup.highline).
|
117
117
|
to receive(:ask).with("Press a key ")
|
118
118
|
|
119
119
|
subject.run
|
@@ -124,19 +124,19 @@ describe Imap::Backup::Configuration::FolderChooser do
|
|
124
124
|
before do
|
125
125
|
allow(Imap::Backup::Account::Connection).
|
126
126
|
to receive(:new).with(account).and_raise("error")
|
127
|
-
allow(Imap::Backup::
|
127
|
+
allow(Imap::Backup::Setup.highline).
|
128
128
|
to receive(:ask) { "q" }
|
129
129
|
end
|
130
130
|
|
131
131
|
it "prints an error message" do
|
132
|
-
expect(Imap::Backup.logger).
|
132
|
+
expect(Imap::Backup::Logger.logger).
|
133
133
|
to receive(:warn).with("Connection failed")
|
134
134
|
|
135
135
|
subject.run
|
136
136
|
end
|
137
137
|
|
138
138
|
it "asks to continue" do
|
139
|
-
expect(Imap::Backup::
|
139
|
+
expect(Imap::Backup::Setup.highline).
|
140
140
|
to receive(:ask).with("Press a key ")
|
141
141
|
|
142
142
|
subject.run
|
@@ -1,4 +1,4 @@
|
|
1
|
-
describe Imap::Backup::
|
1
|
+
describe Imap::Backup::Setup do
|
2
2
|
include HighLineTestHelpers
|
3
3
|
|
4
4
|
subject { described_class.new }
|
@@ -30,17 +30,17 @@ describe Imap::Backup::Configuration::Setup do
|
|
30
30
|
let(:accounts) { [normal_account] }
|
31
31
|
let(:store) do
|
32
32
|
instance_double(
|
33
|
-
Imap::Backup::Configuration
|
33
|
+
Imap::Backup::Configuration,
|
34
34
|
"accounts": accounts,
|
35
35
|
"path": "/base/path",
|
36
36
|
"save": nil,
|
37
37
|
"debug?": debug,
|
38
38
|
"debug=": nil,
|
39
|
-
"modified?":
|
39
|
+
"modified?": config_modified
|
40
40
|
)
|
41
41
|
end
|
42
42
|
let(:debug) { false }
|
43
|
-
let(:
|
43
|
+
let(:config_modified) { false }
|
44
44
|
let!(:highline_streams) { prepare_highline }
|
45
45
|
let(:input) { highline_streams[0] }
|
46
46
|
let(:output) { highline_streams[1] }
|
@@ -56,31 +56,42 @@ describe Imap::Backup::Configuration::Setup do
|
|
56
56
|
|
57
57
|
describe "#run" do
|
58
58
|
before do
|
59
|
-
allow(Imap::Backup::Configuration
|
60
|
-
allow(Imap::Backup).to receive(:setup_logging)
|
59
|
+
allow(Imap::Backup::Configuration).to receive(:new) { store }
|
60
|
+
allow(Imap::Backup::Logger).to receive(:setup_logging)
|
61
61
|
allow(input).to receive(:eof?) { false }
|
62
|
-
allow(input).to receive(:gets) { "
|
62
|
+
allow(input).to receive(:gets) { "q\n" }
|
63
63
|
allow(Kernel).to receive(:system)
|
64
64
|
end
|
65
65
|
|
66
66
|
describe "main menu" do
|
67
|
-
|
67
|
+
context "when changes have not been made" do
|
68
|
+
before { subject.run }
|
68
69
|
|
69
|
-
|
70
|
-
|
71
|
-
|
70
|
+
["add account", "quit"].each do |choice|
|
71
|
+
it "includes #{choice}" do
|
72
|
+
expect(output.string).to include(choice)
|
73
|
+
end
|
72
74
|
end
|
73
75
|
end
|
74
|
-
end
|
75
76
|
|
76
|
-
|
77
|
-
|
77
|
+
context "when changes have been made" do
|
78
|
+
let(:config_modified) { true }
|
78
79
|
|
79
|
-
|
80
|
+
before do
|
81
|
+
allow(input).to receive(:gets) { "exit\n" }
|
82
|
+
subject.run
|
83
|
+
end
|
84
|
+
|
85
|
+
["save and exit", "exit without saving"].each do |choice|
|
86
|
+
it "includes '#{choice}'" do
|
87
|
+
expect(output.string).to include(choice)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
80
91
|
end
|
81
92
|
|
82
|
-
it "
|
83
|
-
expect(
|
93
|
+
it "clears the screen" do
|
94
|
+
expect(Kernel).to receive(:system).with("clear")
|
84
95
|
|
85
96
|
subject.run
|
86
97
|
end
|
@@ -111,14 +122,15 @@ describe Imap::Backup::Configuration::Setup do
|
|
111
122
|
|
112
123
|
context "when editing accounts" do
|
113
124
|
let(:account) do
|
114
|
-
instance_double(Imap::Backup::
|
125
|
+
instance_double(Imap::Backup::Setup::Account, run: nil)
|
115
126
|
end
|
127
|
+
let(:config_modified) { true }
|
116
128
|
|
117
129
|
before do
|
118
130
|
allow(input).to receive(:gets).and_return("1\n", "exit\n")
|
119
|
-
allow(Imap::Backup::
|
131
|
+
allow(Imap::Backup::Setup::Asker).to receive(:email).
|
120
132
|
with(no_args) { "new@example.com" }
|
121
|
-
allow(Imap::Backup::
|
133
|
+
allow(Imap::Backup::Setup::Account).to receive(:new).
|
122
134
|
with(store, normal_account, anything) { account }
|
123
135
|
end
|
124
136
|
|
@@ -139,16 +151,17 @@ describe Imap::Backup::Configuration::Setup do
|
|
139
151
|
}
|
140
152
|
end
|
141
153
|
let(:account) do
|
142
|
-
instance_double(Imap::Backup::
|
154
|
+
instance_double(Imap::Backup::Setup::Account, run: nil)
|
143
155
|
end
|
156
|
+
let(:config_modified) { true }
|
144
157
|
let(:added_email) { "new@example.com" }
|
145
158
|
let(:local_path) { "/base/path/new_example.com" }
|
146
159
|
|
147
160
|
before do
|
148
161
|
allow(input).to receive(:gets).and_return("add\n", "exit\n")
|
149
|
-
allow(Imap::Backup::
|
162
|
+
allow(Imap::Backup::Setup::Asker).to receive(:email).
|
150
163
|
with(no_args) { added_email }
|
151
|
-
allow(Imap::Backup::
|
164
|
+
allow(Imap::Backup::Setup::Account).to receive(:new).
|
152
165
|
with(store, anything, anything) { account }
|
153
166
|
|
154
167
|
subject.run
|
@@ -186,6 +199,8 @@ describe Imap::Backup::Configuration::Setup do
|
|
186
199
|
|
187
200
|
describe "logging" do
|
188
201
|
context "when debug logging is disabled" do
|
202
|
+
let(:config_modified) { true }
|
203
|
+
|
189
204
|
before do
|
190
205
|
allow(input).to receive(:gets).and_return("start\n", "exit\n")
|
191
206
|
end
|
@@ -204,7 +219,7 @@ describe Imap::Backup::Configuration::Setup do
|
|
204
219
|
end
|
205
220
|
|
206
221
|
it "updates logging status" do
|
207
|
-
expect(Imap::Backup).to receive(:setup_logging)
|
222
|
+
expect(Imap::Backup::Logger).to receive(:setup_logging)
|
208
223
|
|
209
224
|
subject.run
|
210
225
|
end
|
@@ -213,6 +228,7 @@ describe Imap::Backup::Configuration::Setup do
|
|
213
228
|
|
214
229
|
context "when debug logging is enabled" do
|
215
230
|
let(:debug) { true }
|
231
|
+
let(:config_modified) { true }
|
216
232
|
|
217
233
|
before do
|
218
234
|
allow(input).to receive(:gets).and_return("stop\n", "exit\n")
|
@@ -236,7 +252,7 @@ describe Imap::Backup::Configuration::Setup do
|
|
236
252
|
end
|
237
253
|
|
238
254
|
it "updates logging status" do
|
239
|
-
expect(Imap::Backup).to receive(:setup_logging)
|
255
|
+
expect(Imap::Backup::Logger).to receive(:setup_logging)
|
240
256
|
|
241
257
|
subject.run
|
242
258
|
end
|
@@ -245,6 +261,8 @@ describe Imap::Backup::Configuration::Setup do
|
|
245
261
|
end
|
246
262
|
|
247
263
|
context "when 'save' is selected" do
|
264
|
+
let(:config_modified) { true }
|
265
|
+
|
248
266
|
before do
|
249
267
|
allow(input).to receive(:gets) { "save\n" }
|
250
268
|
end
|
@@ -262,6 +280,8 @@ describe Imap::Backup::Configuration::Setup do
|
|
262
280
|
end
|
263
281
|
|
264
282
|
context "when 'exit without saving' is selected" do
|
283
|
+
let(:config_modified) { true }
|
284
|
+
|
265
285
|
before do
|
266
286
|
allow(input).to receive(:gets) { "exit\n" }
|
267
287
|
end
|
@@ -271,22 +291,10 @@ describe Imap::Backup::Configuration::Setup do
|
|
271
291
|
subject.run
|
272
292
|
end
|
273
293
|
|
274
|
-
|
275
|
-
|
294
|
+
it "doesn't save the configuration" do
|
295
|
+
expect(store).to_not receive(:save)
|
276
296
|
|
277
|
-
|
278
|
-
expect(store).to_not receive(:save)
|
279
|
-
|
280
|
-
subject.run
|
281
|
-
end
|
282
|
-
end
|
283
|
-
|
284
|
-
context "when the configuration isn't modified" do
|
285
|
-
it "doesn't save the configuration" do
|
286
|
-
expect(store).to_not receive(:save)
|
287
|
-
|
288
|
-
subject.run
|
289
|
-
end
|
297
|
+
subject.run
|
290
298
|
end
|
291
299
|
end
|
292
300
|
end
|