imap-backup 1.2.2 → 1.2.3
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/.rubocop.yml +7 -0
- data/Gemfile +1 -1
- data/Rakefile +4 -4
- data/bin/imap-backup +23 -25
- data/imap-backup.gemspec +14 -14
- data/lib/email/mboxrd/message.rb +23 -5
- data/lib/email/provider.rb +4 -4
- data/lib/imap/backup.rb +18 -18
- data/lib/imap/backup/account/connection.rb +6 -6
- data/lib/imap/backup/account/folder.rb +4 -5
- data/lib/imap/backup/configuration/account.rb +20 -22
- data/lib/imap/backup/configuration/asker.rb +8 -10
- data/lib/imap/backup/configuration/connection_tester.rb +3 -5
- data/lib/imap/backup/configuration/folder_chooser.rb +10 -12
- data/lib/imap/backup/configuration/list.rb +1 -3
- data/lib/imap/backup/configuration/setup.rb +13 -14
- data/lib/imap/backup/configuration/store.rb +7 -8
- data/lib/imap/backup/downloader.rb +0 -2
- data/lib/imap/backup/serializer/base.rb +0 -2
- data/lib/imap/backup/serializer/directory.rb +3 -4
- data/lib/imap/backup/serializer/mbox.rb +11 -12
- data/lib/imap/backup/utils.rb +2 -3
- data/lib/imap/backup/version.rb +2 -2
- data/spec/spec_helper.rb +6 -6
- data/spec/support/higline_test_helpers.rb +1 -1
- data/spec/support/shared_examples/account_flagging.rb +6 -6
- data/spec/unit/account/connection_spec.rb +50 -51
- data/spec/unit/account/folder_spec.rb +18 -19
- data/spec/unit/configuration/account_spec.rb +96 -97
- data/spec/unit/configuration/asker_spec.rb +33 -34
- data/spec/unit/configuration/connection_tester_spec.rb +18 -19
- data/spec/unit/configuration/folder_chooser_spec.rb +34 -35
- data/spec/unit/configuration/list_spec.rb +13 -14
- data/spec/unit/configuration/setup_spec.rb +46 -47
- data/spec/unit/configuration/store_spec.rb +56 -57
- data/spec/unit/downloader_spec.rb +18 -19
- data/spec/unit/email/mboxrd/message_spec.rb +55 -11
- data/spec/unit/email/provider_spec.rb +12 -12
- data/spec/unit/serializer/base_spec.rb +7 -9
- data/spec/unit/serializer/directory_spec.rb +18 -19
- data/spec/unit/serializer/mbox_spec.rb +35 -37
- data/spec/unit/utils_spec.rb +26 -27
- metadata +17 -2
@@ -1,12 +1,11 @@
|
|
1
|
-
|
2
|
-
require 'spec_helper'
|
1
|
+
require "spec_helper"
|
3
2
|
|
4
3
|
module Imap::Backup
|
5
4
|
describe Configuration::Asker do
|
6
5
|
let(:highline) { double }
|
7
6
|
let(:query) do
|
8
7
|
double(
|
9
|
-
|
8
|
+
"Query",
|
10
9
|
:default= => nil,
|
11
10
|
:readline= => nil,
|
12
11
|
:validate= => nil,
|
@@ -14,7 +13,7 @@ module Imap::Backup
|
|
14
13
|
:echo= => nil
|
15
14
|
)
|
16
15
|
end
|
17
|
-
let(:answer) {
|
16
|
+
let(:answer) { "foo" }
|
18
17
|
|
19
18
|
before do
|
20
19
|
allow(Configuration::Setup).to receive(:highline).and_return(highline)
|
@@ -27,63 +26,63 @@ module Imap::Backup
|
|
27
26
|
subject { described_class.new(highline) }
|
28
27
|
|
29
28
|
[
|
30
|
-
[:email, [],
|
31
|
-
[:password, [],
|
32
|
-
[:backup_path, [
|
29
|
+
[:email, [], "email address"],
|
30
|
+
[:password, [], "password"],
|
31
|
+
[:backup_path, ["x", "y"], "backup directory"]
|
33
32
|
].each do |method, params, prompt|
|
34
33
|
context ".#{method}" do
|
35
|
-
it
|
34
|
+
it "asks for input" do
|
36
35
|
described_class.send(method, *params)
|
37
36
|
|
38
37
|
expect(highline).to have_received(:ask).with("#{prompt}: ")
|
39
38
|
end
|
40
39
|
|
41
|
-
it
|
40
|
+
it "returns the answer" do
|
42
41
|
expect(described_class.send(method, *params)).to eq(answer)
|
43
42
|
end
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
47
|
-
context
|
48
|
-
it
|
46
|
+
context "#initialize" do
|
47
|
+
it "requires 1 parameter" do
|
49
48
|
expect do
|
50
49
|
described_class.new
|
51
50
|
end.to raise_error(ArgumentError, /wrong number/)
|
52
51
|
end
|
53
52
|
|
54
|
-
it
|
53
|
+
it "expects a higline" do
|
55
54
|
expect(subject.highline).to eq(highline)
|
56
55
|
end
|
57
56
|
end
|
58
57
|
|
59
|
-
context
|
60
|
-
let(:email) {
|
58
|
+
context "#email" do
|
59
|
+
let(:email) { "email@example.com" }
|
61
60
|
let(:answer) { email }
|
62
61
|
|
63
62
|
before do
|
64
63
|
@result = subject.email
|
65
64
|
end
|
66
65
|
|
67
|
-
it
|
66
|
+
it "asks for an email" do
|
68
67
|
expect(highline).to have_received(:ask).with(/email/)
|
69
68
|
end
|
70
69
|
|
71
|
-
it
|
70
|
+
it "returns the address" do
|
72
71
|
expect(@result).to eq(email)
|
73
72
|
end
|
74
73
|
end
|
75
74
|
|
76
|
-
context
|
77
|
-
let(:password1) {
|
78
|
-
let(:password2) {
|
75
|
+
context "#password" do
|
76
|
+
let(:password1) { "password" }
|
77
|
+
let(:password2) { "password" }
|
79
78
|
let(:answers) { [answer1, answer2] }
|
80
79
|
let(:answer1) { true }
|
81
80
|
let(:answer2) { false }
|
82
81
|
|
83
82
|
before do
|
84
83
|
@i = 0
|
85
|
-
allow(highline).to receive(:ask).with(
|
86
|
-
allow(highline).to receive(:ask).with(
|
84
|
+
allow(highline).to receive(:ask).with("password: ").and_return(password1)
|
85
|
+
allow(highline).to receive(:ask).with("repeat password: ").and_return(password2)
|
87
86
|
allow(highline).to receive(:agree) do
|
88
87
|
answer = answers[@i]
|
89
88
|
@i += 1
|
@@ -92,29 +91,29 @@ module Imap::Backup
|
|
92
91
|
@result = subject.password
|
93
92
|
end
|
94
93
|
|
95
|
-
it
|
96
|
-
expect(highline).to have_received(:ask).with(
|
94
|
+
it "asks for a password" do
|
95
|
+
expect(highline).to have_received(:ask).with("password: ")
|
97
96
|
end
|
98
97
|
|
99
|
-
it
|
100
|
-
expect(highline).to have_received(:ask).with(
|
98
|
+
it "asks for confirmation" do
|
99
|
+
expect(highline).to have_received(:ask).with("repeat password: ")
|
101
100
|
end
|
102
101
|
|
103
|
-
it
|
102
|
+
it "returns the password" do
|
104
103
|
expect(@result).to eq(password1)
|
105
104
|
end
|
106
105
|
|
107
|
-
context
|
108
|
-
let(:password2) {
|
106
|
+
context "different answers" do
|
107
|
+
let(:password2) { "secret" }
|
109
108
|
|
110
|
-
it
|
109
|
+
it "asks to continue" do
|
111
110
|
expect(highline).to have_received(:agree).at_least(1).times.with(/Continue\?/)
|
112
111
|
end
|
113
112
|
end
|
114
113
|
end
|
115
114
|
|
116
|
-
context
|
117
|
-
let(:path) {
|
115
|
+
context "#backup_path" do
|
116
|
+
let(:path) { "/path" }
|
118
117
|
let(:answer) { path }
|
119
118
|
|
120
119
|
before do
|
@@ -122,14 +121,14 @@ module Imap::Backup
|
|
122
121
|
b.call query
|
123
122
|
path
|
124
123
|
end
|
125
|
-
@result = subject.backup_path(
|
124
|
+
@result = subject.backup_path("", //)
|
126
125
|
end
|
127
126
|
|
128
|
-
it
|
127
|
+
it "asks for a directory" do
|
129
128
|
expect(highline).to have_received(:ask).with(/directory/)
|
130
129
|
end
|
131
130
|
|
132
|
-
it
|
131
|
+
it "returns the path" do
|
133
132
|
expect(@result).to eq(path)
|
134
133
|
end
|
135
134
|
end
|
@@ -1,50 +1,49 @@
|
|
1
|
-
|
2
|
-
require 'spec_helper'
|
1
|
+
require "spec_helper"
|
3
2
|
|
4
3
|
describe Imap::Backup::Configuration::ConnectionTester do
|
5
|
-
context
|
6
|
-
let(:connection) { double(
|
4
|
+
context ".test" do
|
5
|
+
let(:connection) { double("Imap::Backup::Account::Connection", imap: nil) }
|
7
6
|
|
8
7
|
before do
|
9
8
|
allow(Imap::Backup::Account::Connection).to receive(:new).and_return(connection)
|
10
9
|
end
|
11
10
|
|
12
|
-
context
|
13
|
-
before { @result = subject.test(
|
11
|
+
context "call" do
|
12
|
+
before { @result = subject.test("foo") }
|
14
13
|
|
15
|
-
it
|
14
|
+
it "tries to connect" do
|
16
15
|
expect(connection).to have_received(:imap)
|
17
16
|
end
|
18
17
|
end
|
19
18
|
|
20
|
-
context
|
21
|
-
before { @result = subject.test(
|
19
|
+
context "success" do
|
20
|
+
before { @result = subject.test("foo") }
|
22
21
|
|
23
|
-
it
|
22
|
+
it "returns success" do
|
24
23
|
expect(@result).to match(/successful/)
|
25
24
|
end
|
26
25
|
end
|
27
26
|
|
28
|
-
context
|
27
|
+
context "failure" do
|
29
28
|
before do
|
30
29
|
allow(connection).to receive(:imap).and_raise(error)
|
31
|
-
@result = subject.test(
|
30
|
+
@result = subject.test("foo")
|
32
31
|
end
|
33
32
|
|
34
|
-
context
|
33
|
+
context "no connection" do
|
35
34
|
let(:error) do
|
36
|
-
data = double(
|
37
|
-
Net::IMAP::NoResponseError.new(double(
|
35
|
+
data = double("foo", text: "bar")
|
36
|
+
Net::IMAP::NoResponseError.new(double("o", data: data))
|
38
37
|
end
|
39
38
|
|
40
|
-
it
|
39
|
+
it "returns success" do
|
41
40
|
expect(@result).to match(/no response/i)
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
45
|
-
context
|
46
|
-
let(:error) {
|
47
|
-
it
|
44
|
+
context "other" do
|
45
|
+
let(:error) { "Error" }
|
46
|
+
it "returns success" do
|
48
47
|
expect(@result).to match(/unexpected error/i)
|
49
48
|
end
|
50
49
|
end
|
@@ -1,12 +1,11 @@
|
|
1
|
-
|
2
|
-
require 'spec_helper'
|
1
|
+
require "spec_helper"
|
3
2
|
|
4
3
|
describe Imap::Backup::Configuration::FolderChooser do
|
5
4
|
include HighLineTestHelpers
|
6
5
|
|
7
|
-
context
|
8
|
-
let(:connection) { double(
|
9
|
-
let(:account) { {:
|
6
|
+
context "#run" do
|
7
|
+
let(:connection) { double("Imap::Backup::Account::Connection", folders: remote_folders) }
|
8
|
+
let(:account) { {folders: []} }
|
10
9
|
let(:remote_folders) { [] }
|
11
10
|
|
12
11
|
subject { described_class.new(account) }
|
@@ -18,68 +17,68 @@ describe Imap::Backup::Configuration::FolderChooser do
|
|
18
17
|
allow(Imap::Backup.logger).to receive(:warn)
|
19
18
|
end
|
20
19
|
|
21
|
-
context
|
20
|
+
context "display" do
|
22
21
|
before { subject.run }
|
23
22
|
|
24
|
-
it
|
25
|
-
expect(subject).to have_received(:system).with(
|
23
|
+
it "clears the screen" do
|
24
|
+
expect(subject).to have_received(:system).with("clear")
|
26
25
|
end
|
27
26
|
|
28
|
-
it
|
27
|
+
it "should show the menu" do
|
29
28
|
expect(@output.string).to match %r{Add/remove folders}
|
30
29
|
end
|
31
30
|
end
|
32
31
|
|
33
|
-
context
|
34
|
-
let(:account) { {:
|
32
|
+
context "folder listing" do
|
33
|
+
let(:account) { {folders: [{name: "my_folder"}]} }
|
35
34
|
let(:remote_folders) do
|
36
|
-
folder1 = double(
|
37
|
-
folder2 = double(
|
35
|
+
folder1 = double("folder", name: "my_folder") # this one is already backed up
|
36
|
+
folder2 = double("folder", name: "another_folder")
|
38
37
|
[folder1, folder2]
|
39
38
|
end
|
40
39
|
|
41
|
-
context
|
40
|
+
context "display" do
|
42
41
|
before { subject.run }
|
43
42
|
|
44
|
-
it
|
45
|
-
expect(@output.string).to include(
|
43
|
+
it "shows folders which are being backed up" do
|
44
|
+
expect(@output.string).to include("+ my_folder")
|
46
45
|
end
|
47
46
|
|
48
|
-
it
|
49
|
-
expect(@output.string).to include(
|
47
|
+
it "shows folders which are not being backed up" do
|
48
|
+
expect(@output.string).to include("- another_folder")
|
50
49
|
end
|
51
50
|
end
|
52
51
|
|
53
|
-
context
|
52
|
+
context "adding folders" do
|
54
53
|
before do
|
55
54
|
allow(@input).to receive(:gets).and_return("2\n", "q\n")
|
56
55
|
|
57
56
|
subject.run
|
58
57
|
end
|
59
58
|
|
60
|
-
specify
|
61
|
-
expect(account[:folders]).to include({:
|
59
|
+
specify "are added to the account" do
|
60
|
+
expect(account[:folders]).to include({name: "another_folder"})
|
62
61
|
end
|
63
62
|
|
64
|
-
include_examples
|
63
|
+
include_examples "it flags the account as modified"
|
65
64
|
end
|
66
65
|
|
67
|
-
context
|
66
|
+
context "removing folders" do
|
68
67
|
before do
|
69
68
|
allow(@input).to receive(:gets).and_return("1\n", "q\n")
|
70
69
|
|
71
70
|
subject.run
|
72
71
|
end
|
73
72
|
|
74
|
-
specify
|
75
|
-
expect(account[:folders]).to_not include({:
|
73
|
+
specify "are removed from the account" do
|
74
|
+
expect(account[:folders]).to_not include({name: "my_folder"})
|
76
75
|
end
|
77
76
|
|
78
|
-
include_examples
|
77
|
+
include_examples "it flags the account as modified"
|
79
78
|
end
|
80
79
|
end
|
81
80
|
|
82
|
-
context
|
81
|
+
context "when folders are not available" do
|
83
82
|
let(:remote_folders) { nil }
|
84
83
|
|
85
84
|
before do
|
@@ -87,24 +86,24 @@ describe Imap::Backup::Configuration::FolderChooser do
|
|
87
86
|
subject.run
|
88
87
|
end
|
89
88
|
|
90
|
-
it
|
91
|
-
expect(Imap::Backup::Configuration::Setup.highline).to have_received(:ask).with(
|
89
|
+
it "asks to press a key" do
|
90
|
+
expect(Imap::Backup::Configuration::Setup.highline).to have_received(:ask).with("Press a key ")
|
92
91
|
end
|
93
92
|
end
|
94
93
|
|
95
|
-
context
|
94
|
+
context "with connection errors" do
|
96
95
|
before do
|
97
|
-
allow(Imap::Backup::Account::Connection).to receive(:new).with(account).and_raise(
|
96
|
+
allow(Imap::Backup::Account::Connection).to receive(:new).with(account).and_raise("error")
|
98
97
|
allow(Imap::Backup::Configuration::Setup.highline).to receive(:ask).and_return("q")
|
99
98
|
subject.run
|
100
99
|
end
|
101
100
|
|
102
|
-
it
|
103
|
-
expect(Imap::Backup.logger).to have_received(:warn).with(
|
101
|
+
it "prints an error message" do
|
102
|
+
expect(Imap::Backup.logger).to have_received(:warn).with("Connection failed")
|
104
103
|
end
|
105
104
|
|
106
|
-
it
|
107
|
-
expect(Imap::Backup::Configuration::Setup.highline).to have_received(:ask).with(
|
105
|
+
it "asks to continue" do
|
106
|
+
expect(Imap::Backup::Configuration::Setup.highline).to have_received(:ask).with("Press a key ")
|
108
107
|
end
|
109
108
|
end
|
110
109
|
end
|
@@ -1,19 +1,18 @@
|
|
1
|
-
|
2
|
-
require 'spec_helper'
|
1
|
+
require "spec_helper"
|
3
2
|
|
4
3
|
describe Imap::Backup::Configuration::List do
|
5
4
|
let(:accounts) do
|
6
5
|
[
|
7
|
-
{:
|
8
|
-
{:
|
6
|
+
{username: "a1@example.com"},
|
7
|
+
{username: "a2@example.com"}
|
9
8
|
]
|
10
9
|
end
|
11
10
|
let(:store) do
|
12
|
-
double(
|
11
|
+
double("Imap::Backup::Configuration::Store", accounts: accounts)
|
13
12
|
end
|
14
13
|
let(:exists) { true }
|
15
|
-
let(:connection1) { double(
|
16
|
-
let(:connection2) { double(
|
14
|
+
let(:connection1) { double("Imap::Backup::Account::Connection", disconnect: nil) }
|
15
|
+
let(:connection2) { double("Imap::Backup::Account::Connection", disconnect: nil) }
|
17
16
|
|
18
17
|
before do
|
19
18
|
allow(Imap::Backup::Configuration::Store).to receive(:new).and_return(store)
|
@@ -24,10 +23,10 @@ describe Imap::Backup::Configuration::List do
|
|
24
23
|
|
25
24
|
subject { described_class.new }
|
26
25
|
|
27
|
-
context
|
26
|
+
context "#initialize" do
|
28
27
|
end
|
29
28
|
|
30
|
-
context
|
29
|
+
context "#each_connection" do
|
31
30
|
specify "calls the block with each account's connection" do
|
32
31
|
connections = []
|
33
32
|
|
@@ -36,10 +35,10 @@ describe Imap::Backup::Configuration::List do
|
|
36
35
|
expect(connections).to eq([connection1, connection2])
|
37
36
|
end
|
38
37
|
|
39
|
-
context
|
40
|
-
subject { described_class.new([
|
38
|
+
context "with account parameter" do
|
39
|
+
subject { described_class.new(["a2@example.com"]) }
|
41
40
|
|
42
|
-
it
|
41
|
+
it "should only create requested accounts" do
|
43
42
|
connections = []
|
44
43
|
|
45
44
|
subject.each_connection { |a| connections << a }
|
@@ -48,10 +47,10 @@ describe Imap::Backup::Configuration::List do
|
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
51
|
-
context
|
50
|
+
context "when the configuration file is missing" do
|
52
51
|
let(:exists) { false }
|
53
52
|
|
54
|
-
it
|
53
|
+
it "fails" do
|
55
54
|
expect {
|
56
55
|
subject.each_connection {}
|
57
56
|
}.to raise_error(Imap::Backup::ConfigurationNotFound, /not found/)
|
@@ -1,25 +1,24 @@
|
|
1
|
-
|
2
|
-
require 'spec_helper'
|
1
|
+
require "spec_helper"
|
3
2
|
|
4
3
|
describe Imap::Backup::Configuration::Setup do
|
5
4
|
include HighLineTestHelpers
|
6
5
|
|
7
|
-
context
|
8
|
-
context
|
9
|
-
it
|
6
|
+
context "#initialize" do
|
7
|
+
context "without a config file" do
|
8
|
+
it "works" do
|
10
9
|
described_class.new
|
11
10
|
end
|
12
11
|
end
|
13
12
|
end
|
14
13
|
|
15
|
-
context
|
16
|
-
let(:normal) { {:
|
14
|
+
context "#run" do
|
15
|
+
let(:normal) { {username: "account@example.com"} }
|
17
16
|
let(:accounts) { [normal] }
|
18
17
|
let(:store) do
|
19
18
|
double(
|
20
|
-
|
19
|
+
"Imap::Backup::Configuration::Store",
|
21
20
|
:accounts => accounts,
|
22
|
-
:path =>
|
21
|
+
:path => "/base/path",
|
23
22
|
:save => nil,
|
24
23
|
:debug? => debug,
|
25
24
|
:debug= => nil,
|
@@ -40,7 +39,7 @@ describe Imap::Backup::Configuration::Setup do
|
|
40
39
|
|
41
40
|
subject { described_class.new }
|
42
41
|
|
43
|
-
context
|
42
|
+
context "main menu" do
|
44
43
|
before { subject.run }
|
45
44
|
|
46
45
|
%w(add\ account save\ and\ exit exit\ without\ saving).each do |choice|
|
@@ -50,64 +49,64 @@ describe Imap::Backup::Configuration::Setup do
|
|
50
49
|
end
|
51
50
|
end
|
52
51
|
|
53
|
-
it
|
52
|
+
it "clears the screen" do
|
54
53
|
subject.run
|
55
54
|
|
56
|
-
expect(subject).to have_received(:system).with(
|
55
|
+
expect(subject).to have_received(:system).with("clear")
|
57
56
|
end
|
58
57
|
|
59
|
-
it
|
58
|
+
it "updates logging status" do
|
60
59
|
subject.run
|
61
60
|
|
62
61
|
expect(Imap::Backup).to have_received(:setup_logging)
|
63
62
|
end
|
64
63
|
|
65
|
-
context
|
64
|
+
context "listing" do
|
66
65
|
let(:accounts) { [normal, modified, deleted] }
|
67
|
-
let(:modified) { {:
|
68
|
-
let(:deleted) { {:
|
66
|
+
let(:modified) { {username: "modified@example.com", modified: true} }
|
67
|
+
let(:deleted) { {username: "deleted@example.com", delete: true} }
|
69
68
|
|
70
69
|
before { subject.run }
|
71
70
|
|
72
|
-
context
|
73
|
-
it
|
71
|
+
context "normal accounts" do
|
72
|
+
it "are listed" do
|
74
73
|
expect(@output.string).to match /account@example.com/
|
75
74
|
end
|
76
75
|
end
|
77
76
|
|
78
|
-
context
|
79
|
-
it
|
77
|
+
context "modified accounts" do
|
78
|
+
it "are flagged" do
|
80
79
|
expect(@output.string).to match /modified@example.com \*/
|
81
80
|
end
|
82
81
|
end
|
83
82
|
|
84
|
-
context
|
85
|
-
it
|
83
|
+
context "deleted accounts" do
|
84
|
+
it "are hidden" do
|
86
85
|
expect(@output.string).to_not match /delete@example.com/
|
87
86
|
end
|
88
87
|
end
|
89
88
|
end
|
90
89
|
|
91
|
-
context
|
90
|
+
context "adding accounts" do
|
92
91
|
let(:blank_account) do
|
93
92
|
{
|
94
|
-
:
|
95
|
-
:
|
96
|
-
:
|
97
|
-
:
|
93
|
+
username: "new@example.com",
|
94
|
+
password: "",
|
95
|
+
local_path: "/base/path/new_example.com",
|
96
|
+
folders: []
|
98
97
|
}
|
99
98
|
end
|
100
|
-
let(:account) { double(
|
99
|
+
let(:account) { double("Imap::Backup::Configuration::Account", run: nil) }
|
101
100
|
|
102
101
|
before do
|
103
102
|
allow(@input).to receive(:gets).and_return("add\n", "exit\n")
|
104
|
-
allow(Imap::Backup::Configuration::Asker).to receive(:email).with(no_args).and_return(
|
103
|
+
allow(Imap::Backup::Configuration::Asker).to receive(:email).with(no_args).and_return("new@example.com")
|
105
104
|
allow(Imap::Backup::Configuration::Account).to receive(:new).with(store, blank_account, anything).and_return(account)
|
106
105
|
|
107
106
|
subject.run
|
108
107
|
end
|
109
108
|
|
110
|
-
it
|
109
|
+
it "adds account data" do
|
111
110
|
expect(accounts[1]).to eq(blank_account)
|
112
111
|
end
|
113
112
|
|
@@ -116,29 +115,29 @@ describe Imap::Backup::Configuration::Setup do
|
|
116
115
|
end
|
117
116
|
end
|
118
117
|
|
119
|
-
context
|
120
|
-
context
|
118
|
+
context "logging" do
|
119
|
+
context "when debug logging is disabled" do
|
121
120
|
before do
|
122
121
|
allow(@input).to receive(:gets).and_return("start\n", "exit\n")
|
123
122
|
subject.run
|
124
123
|
end
|
125
124
|
|
126
|
-
it
|
127
|
-
expect(@output.string).to include(
|
125
|
+
it "shows a menu item" do
|
126
|
+
expect(@output.string).to include("start logging")
|
128
127
|
end
|
129
128
|
|
130
|
-
context
|
131
|
-
it
|
129
|
+
context "when selected" do
|
130
|
+
it "sets the debug flag" do
|
132
131
|
expect(store).to have_received(:debug=).with(true)
|
133
132
|
end
|
134
133
|
|
135
|
-
it
|
134
|
+
it "updates logging status" do
|
136
135
|
expect(Imap::Backup).to have_received(:setup_logging).twice
|
137
136
|
end
|
138
137
|
end
|
139
138
|
end
|
140
139
|
|
141
|
-
context
|
140
|
+
context "when debug logging is enabled" do
|
142
141
|
let(:debug) { true }
|
143
142
|
|
144
143
|
before do
|
@@ -146,20 +145,20 @@ describe Imap::Backup::Configuration::Setup do
|
|
146
145
|
subject.run
|
147
146
|
end
|
148
147
|
|
149
|
-
it
|
150
|
-
expect(@output.string).to include(
|
148
|
+
it "shows a menu item" do
|
149
|
+
expect(@output.string).to include("stop logging")
|
151
150
|
end
|
152
151
|
|
153
|
-
context
|
152
|
+
context "when selected" do
|
154
153
|
before do
|
155
154
|
allow(@input).to receive(:gets).and_return("stop\n", "exit\n")
|
156
155
|
end
|
157
156
|
|
158
|
-
it
|
157
|
+
it "unsets the debug flag" do
|
159
158
|
expect(store).to have_received(:debug=).with(false)
|
160
159
|
end
|
161
160
|
|
162
|
-
it
|
161
|
+
it "updates logging status" do
|
163
162
|
expect(Imap::Backup).to have_received(:setup_logging).twice
|
164
163
|
end
|
165
164
|
end
|
@@ -172,11 +171,11 @@ describe Imap::Backup::Configuration::Setup do
|
|
172
171
|
subject.run
|
173
172
|
end
|
174
173
|
|
175
|
-
it
|
174
|
+
it "exits" do
|
176
175
|
# N.B. this will hang forever if save does not cause an exit
|
177
176
|
end
|
178
177
|
|
179
|
-
it
|
178
|
+
it "saves the configuration" do
|
180
179
|
expect(store).to have_received(:save)
|
181
180
|
end
|
182
181
|
end
|
@@ -188,11 +187,11 @@ describe Imap::Backup::Configuration::Setup do
|
|
188
187
|
subject.run
|
189
188
|
end
|
190
189
|
|
191
|
-
it
|
190
|
+
it "exits" do
|
192
191
|
# N.B. this will hang forever if quit does not cause an exit
|
193
192
|
end
|
194
193
|
|
195
|
-
context
|
194
|
+
context "when the configuration is modified" do
|
196
195
|
let(:modified) { true }
|
197
196
|
|
198
197
|
it "doesn't save the configuration" do
|