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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +7 -0
  3. data/Gemfile +1 -1
  4. data/Rakefile +4 -4
  5. data/bin/imap-backup +23 -25
  6. data/imap-backup.gemspec +14 -14
  7. data/lib/email/mboxrd/message.rb +23 -5
  8. data/lib/email/provider.rb +4 -4
  9. data/lib/imap/backup.rb +18 -18
  10. data/lib/imap/backup/account/connection.rb +6 -6
  11. data/lib/imap/backup/account/folder.rb +4 -5
  12. data/lib/imap/backup/configuration/account.rb +20 -22
  13. data/lib/imap/backup/configuration/asker.rb +8 -10
  14. data/lib/imap/backup/configuration/connection_tester.rb +3 -5
  15. data/lib/imap/backup/configuration/folder_chooser.rb +10 -12
  16. data/lib/imap/backup/configuration/list.rb +1 -3
  17. data/lib/imap/backup/configuration/setup.rb +13 -14
  18. data/lib/imap/backup/configuration/store.rb +7 -8
  19. data/lib/imap/backup/downloader.rb +0 -2
  20. data/lib/imap/backup/serializer/base.rb +0 -2
  21. data/lib/imap/backup/serializer/directory.rb +3 -4
  22. data/lib/imap/backup/serializer/mbox.rb +11 -12
  23. data/lib/imap/backup/utils.rb +2 -3
  24. data/lib/imap/backup/version.rb +2 -2
  25. data/spec/spec_helper.rb +6 -6
  26. data/spec/support/higline_test_helpers.rb +1 -1
  27. data/spec/support/shared_examples/account_flagging.rb +6 -6
  28. data/spec/unit/account/connection_spec.rb +50 -51
  29. data/spec/unit/account/folder_spec.rb +18 -19
  30. data/spec/unit/configuration/account_spec.rb +96 -97
  31. data/spec/unit/configuration/asker_spec.rb +33 -34
  32. data/spec/unit/configuration/connection_tester_spec.rb +18 -19
  33. data/spec/unit/configuration/folder_chooser_spec.rb +34 -35
  34. data/spec/unit/configuration/list_spec.rb +13 -14
  35. data/spec/unit/configuration/setup_spec.rb +46 -47
  36. data/spec/unit/configuration/store_spec.rb +56 -57
  37. data/spec/unit/downloader_spec.rb +18 -19
  38. data/spec/unit/email/mboxrd/message_spec.rb +55 -11
  39. data/spec/unit/email/provider_spec.rb +12 -12
  40. data/spec/unit/serializer/base_spec.rb +7 -9
  41. data/spec/unit/serializer/directory_spec.rb +18 -19
  42. data/spec/unit/serializer/mbox_spec.rb +35 -37
  43. data/spec/unit/utils_spec.rb +26 -27
  44. metadata +17 -2
@@ -1,28 +1,27 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
1
+ require "spec_helper"
3
2
 
4
3
  describe Imap::Backup::Account::Connection do
5
4
  def self.backup_folder
6
- 'backup_folder'
5
+ "backup_folder"
7
6
  end
8
7
 
9
8
  def self.folder_config
10
- {:name => backup_folder}
9
+ {name: backup_folder}
11
10
  end
12
11
 
13
- let(:imap) { double('Net::IMAP', :login => nil, :list => imap_folders, :disconnect => nil) }
12
+ let(:imap) { double("Net::IMAP", login: nil, list: imap_folders, disconnect: nil) }
14
13
  let(:imap_folders) { [] }
15
14
  let(:options) do
16
15
  {
17
- :username => username,
18
- :password => 'password',
19
- :local_path => local_path,
20
- :folders => backup_folders,
16
+ username: username,
17
+ password: "password",
18
+ local_path: local_path,
19
+ folders: backup_folders,
21
20
  }
22
21
  end
23
- let(:local_path) { 'local_path' }
22
+ let(:local_path) { "local_path" }
24
23
  let(:backup_folders) { [self.class.folder_config] }
25
- let(:username) { 'username@gmail.com' }
24
+ let(:username) { "username@gmail.com" }
26
25
 
27
26
  before do
28
27
  allow(Net::IMAP).to receive(:new).and_return(imap)
@@ -31,88 +30,88 @@ describe Imap::Backup::Account::Connection do
31
30
 
32
31
  subject { described_class.new(options) }
33
32
 
34
- shared_examples 'connects to IMAP' do
35
- it 'sets up the IMAP connection' do
33
+ shared_examples "connects to IMAP" do
34
+ it "sets up the IMAP connection" do
36
35
  expect(Net::IMAP).to have_received(:new)
37
36
  end
38
37
 
39
- it 'logs in to the imap server' do
38
+ it "logs in to the imap server" do
40
39
  expect(imap).to have_received(:login)
41
40
  end
42
41
  end
43
42
 
44
- context '#initialize' do
43
+ context "#initialize" do
45
44
  [
46
- [:username, 'username@gmail.com'],
47
- [:local_path, 'local_path'],
48
- [:backup_folders, [folder_config]],
45
+ [:username, "username@gmail.com"],
46
+ [:local_path, "local_path"],
47
+ [:backup_folders, [folder_config]]
49
48
  ].each do |attr, expected|
50
49
  it "expects #{attr}" do
51
50
  expect(subject.send(attr)).to eq(expected)
52
51
  end
53
52
  end
54
53
 
55
- it 'creates the path' do
54
+ it "creates the path" do
56
55
  subject.username
57
56
  expect(Imap::Backup::Utils).to have_received(:make_folder)
58
57
  end
59
58
  end
60
59
 
61
- describe '#imap' do
60
+ describe "#imap" do
62
61
  before { @result = subject.imap }
63
62
 
64
- it 'returns the IMAP connection' do
63
+ it "returns the IMAP connection" do
65
64
  expect(@result).to eq(imap)
66
65
  end
67
66
 
68
- include_examples 'connects to IMAP'
67
+ include_examples "connects to IMAP"
69
68
  end
70
69
 
71
- context '#folders' do
72
- let(:imap_folders) { ['imap_folder'] }
70
+ context "#folders" do
71
+ let(:imap_folders) { ["imap_folder"] }
73
72
 
74
73
  before { allow(imap).to receive(:list).and_return(imap_folders) }
75
74
 
76
- it 'returns the list of folders' do
75
+ it "returns the list of folders" do
77
76
  expect(subject.folders).to eq(imap_folders)
78
77
  end
79
78
  end
80
79
 
81
- context '#status' do
82
- let(:folder) { double('folder', :uids => [remote_uid]) }
83
- let(:local_uid) { 'local_uid' }
84
- let(:serializer) { double('serializer', :uids => [local_uid]) }
85
- let(:remote_uid) { 'remote_uid' }
80
+ context "#status" do
81
+ let(:folder) { double("folder", uids: [remote_uid]) }
82
+ let(:local_uid) { "local_uid" }
83
+ let(:serializer) { double("serializer", uids: [local_uid]) }
84
+ let(:remote_uid) { "remote_uid" }
86
85
 
87
86
  before do
88
87
  allow(Imap::Backup::Account::Folder).to receive(:new).and_return(folder)
89
88
  allow(Imap::Backup::Serializer::Directory).to receive(:new).and_return(serializer)
90
89
  end
91
90
 
92
- it 'should return the names of folders' do
91
+ it "should return the names of folders" do
93
92
  expect(subject.status[0][:name]).to eq(self.class.backup_folder)
94
93
  end
95
94
 
96
- it 'returns local message uids' do
95
+ it "returns local message uids" do
97
96
  expect(subject.status[0][:local]).to eq([local_uid])
98
97
  end
99
98
 
100
- it 'should retrieve the available uids' do
99
+ it "should retrieve the available uids" do
101
100
  expect(subject.status[0][:remote]).to eq([remote_uid])
102
101
  end
103
102
  end
104
103
 
105
- context '#run_backup' do
106
- let(:folder) { double('folder', name: 'folder') }
107
- let(:serializer) { double('serializer') }
108
- let(:downloader) { double(Imap::Backup::Downloader, :run => nil) }
104
+ context "#run_backup" do
105
+ let(:folder) { double("folder", name: "folder") }
106
+ let(:serializer) { double("serializer") }
107
+ let(:downloader) { double(Imap::Backup::Downloader, run: nil) }
109
108
 
110
109
  before do
111
110
  allow(Imap::Backup::Downloader).
112
111
  to receive(:new).with(folder, serializer) { downloader }
113
112
  end
114
113
 
115
- context 'with supplied backup_folders' do
114
+ context "with supplied backup_folders" do
116
115
  before do
117
116
  allow(Imap::Backup::Account::Folder).to receive(:new).
118
117
  with(subject, self.class.backup_folder).and_return(folder)
@@ -122,37 +121,37 @@ describe Imap::Backup::Account::Connection do
122
121
 
123
122
  before { subject.run_backup }
124
123
 
125
- it 'runs the downloader' do
124
+ it "runs the downloader" do
126
125
  expect(downloader).to have_received(:run)
127
126
  end
128
127
  end
129
128
 
130
- context 'without supplied backup_folders' do
131
- let(:imap_folders) { [double(:name => 'foo')] }
129
+ context "without supplied backup_folders" do
130
+ let(:imap_folders) { [double(name: "foo")] }
132
131
 
133
132
  before do
134
133
  allow(Imap::Backup::Account::Folder).to receive(:new).
135
- with(subject, 'foo').and_return(folder)
134
+ with(subject, "foo").and_return(folder)
136
135
  allow(Imap::Backup::Serializer::Mbox).to receive(:new).
137
- with(local_path, 'foo').and_return(serializer)
136
+ with(local_path, "foo").and_return(serializer)
138
137
  end
139
138
 
140
- context 'when supplied backup_folders is nil' do
139
+ context "when supplied backup_folders is nil" do
141
140
  let(:backup_folders) { nil }
142
141
 
143
142
  before { subject.run_backup }
144
143
 
145
- it 'runs the downloader for each folder' do
144
+ it "runs the downloader for each folder" do
146
145
  expect(downloader).to have_received(:run).exactly(:once)
147
146
  end
148
147
  end
149
148
 
150
- context 'when supplied backup_folders is an empty list' do
149
+ context "when supplied backup_folders is an empty list" do
151
150
  let(:backup_folders) { [] }
152
151
 
153
152
  before { subject.run_backup }
154
153
 
155
- it 'runs the downloader for each folder' do
154
+ it "runs the downloader for each folder" do
156
155
  expect(downloader).to have_received(:run).exactly(:once)
157
156
  end
158
157
  end
@@ -161,20 +160,20 @@ describe Imap::Backup::Account::Connection do
161
160
  let(:backup_folders) { nil }
162
161
  let(:imap_folders) { nil }
163
162
 
164
- it 'does not fail' do
163
+ it "does not fail" do
165
164
  expect { subject.run_backup }.to_not raise_error
166
165
  end
167
166
  end
168
167
  end
169
168
  end
170
169
 
171
- context '#disconnect' do
170
+ context "#disconnect" do
172
171
  before { subject.disconnect }
173
172
 
174
- it 'disconnects from the server' do
173
+ it "disconnects from the server" do
175
174
  expect(imap).to have_received(:disconnect)
176
175
  end
177
176
 
178
- include_examples 'connects to IMAP'
177
+ include_examples "connects to IMAP"
179
178
  end
180
179
  end
@@ -1,50 +1,49 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
1
+ require "spec_helper"
3
2
 
4
3
  describe Imap::Backup::Account::Folder do
5
- let(:imap) { double('Net::IMAP', :examine => nil) }
6
- let(:connection) { double('Imap::Backup::Account::Connection', :imap => imap) }
7
- let(:missing_mailbox_data) { double('Data', :text => 'Unknown Mailbox: my_folder') }
8
- let(:missing_mailbox_response) { double('Response', :data => missing_mailbox_data) }
4
+ let(:imap) { double("Net::IMAP", examine: nil) }
5
+ let(:connection) { double("Imap::Backup::Account::Connection", imap: imap) }
6
+ let(:missing_mailbox_data) { double("Data", text: "Unknown Mailbox: my_folder") }
7
+ let(:missing_mailbox_response) { double("Response", data: missing_mailbox_data) }
9
8
  let(:missing_mailbox_error) { Net::IMAP::NoResponseError.new(missing_mailbox_response) }
10
9
 
11
- subject { described_class.new(connection, 'my_folder') }
10
+ subject { described_class.new(connection, "my_folder") }
12
11
 
13
- context '#uids' do
12
+ context "#uids" do
14
13
  let(:uids) { [5678, 123] }
15
14
 
16
15
  before { allow(imap).to receive(:uid_search).and_return(uids) }
17
16
 
18
- it 'lists available messages' do
17
+ it "lists available messages" do
19
18
  expect(subject.uids).to eq(uids.reverse)
20
19
  end
21
20
 
22
- context 'with missing mailboxes' do
21
+ context "with missing mailboxes" do
23
22
  before { allow(imap).to receive(:examine).and_raise(missing_mailbox_error) }
24
23
 
25
- it 'returns an empty array' do
24
+ it "returns an empty array" do
26
25
  expect(subject.uids).to eq([])
27
26
  end
28
27
  end
29
28
  end
30
29
 
31
- context '#fetch' do
32
- let(:message_body) { double('the body', :force_encoding => nil) }
33
- let(:attributes) { {'RFC822' => message_body, 'other' => 'xxx'} }
30
+ context "#fetch" do
31
+ let(:message_body) { double("the body", force_encoding: nil) }
32
+ let(:attributes) { {"RFC822" => message_body, "other" => "xxx"} }
34
33
  let(:fetch_data_item) do
35
34
  instance_double(Net::IMAP::FetchData, attr: attributes)
36
35
  end
37
36
 
38
37
  before { allow(imap).to receive(:uid_fetch) { [fetch_data_item] } }
39
38
 
40
- it 'returns the message' do
39
+ it "returns the message" do
41
40
  expect(subject.fetch(123)).to eq(attributes)
42
41
  end
43
42
 
44
43
  context "if the server responds with nothing" do
45
44
  before { allow(imap).to receive(:uid_fetch) { nil } }
46
45
 
47
- it 'is nil' do
46
+ it "is nil" do
48
47
  expect(subject.fetch(123)).to be_nil
49
48
  end
50
49
  end
@@ -52,15 +51,15 @@ describe Imap::Backup::Account::Folder do
52
51
  context "if the mailbox doesn't exist" do
53
52
  before { allow(imap).to receive(:examine).and_raise(missing_mailbox_error) }
54
53
 
55
- it 'is nil' do
54
+ it "is nil" do
56
55
  expect(subject.fetch(123)).to be_nil
57
56
  end
58
57
  end
59
58
 
60
- it 'sets the encoding on the message' do
59
+ it "sets the encoding on the message" do
61
60
  subject.fetch(123)
62
61
 
63
- expect(message_body).to have_received(:force_encoding).with('utf-8')
62
+ expect(message_body).to have_received(:force_encoding).with("utf-8")
64
63
  end
65
64
  end
66
65
  end
@@ -1,5 +1,4 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
1
+ require "spec_helper"
3
2
 
4
3
  describe Imap::Backup::Configuration::Account do
5
4
  class MockHighlineMenu
@@ -19,10 +18,10 @@ describe Imap::Backup::Configuration::Account do
19
18
  end
20
19
  end
21
20
 
22
- context '#initialize' do
23
- let(:store) { 'store' }
24
- let(:account) { 'account' }
25
- let(:highline) { 'highline' }
21
+ context "#initialize" do
22
+ let(:store) { "store" }
23
+ let(:account) { "account" }
24
+ let(:highline) { "highline" }
26
25
 
27
26
  subject { described_class.new(store, account, highline) }
28
27
 
@@ -33,32 +32,32 @@ describe Imap::Backup::Configuration::Account do
33
32
  end
34
33
  end
35
34
 
36
- context '#run' do
37
- let(:highline) { double('Highline') }
35
+ context "#run" do
36
+ let(:highline) { double("Highline") }
38
37
  let(:menu) { MockHighlineMenu.new }
39
- let(:store) { double('Imap::Backup::Configuration::Store', :accounts => accounts) }
38
+ let(:store) { double("Imap::Backup::Configuration::Store", accounts: accounts) }
40
39
  let(:accounts) { [account, account1] }
41
40
  let(:account) do
42
41
  {
43
- :username => existing_email,
44
- :server => existing_server,
45
- :local_path => '/backup/path',
46
- :folders => [{:name => 'my_folder'}],
47
- :password => existing_password,
42
+ username: existing_email,
43
+ server: existing_server,
44
+ local_path: "/backup/path",
45
+ folders: [{name: "my_folder"}],
46
+ password: existing_password,
48
47
  }
49
48
  end
50
49
  let(:account1) do
51
50
  {
52
- :username => other_email,
53
- :local_path => other_existing_path,
51
+ username: other_email,
52
+ local_path: other_existing_path,
54
53
  }
55
54
  end
56
- let(:existing_email) { 'user@example.com' }
57
- let(:new_email) { 'foo@example.com' }
58
- let(:existing_server) { 'imap.example.com' }
59
- let(:existing_password) { 'password' }
60
- let(:other_email) { 'other@example.com' }
61
- let(:other_existing_path) { '/other/existing/path' }
55
+ let(:existing_email) { "user@example.com" }
56
+ let(:new_email) { "foo@example.com" }
57
+ let(:existing_server) { "imap.example.com" }
58
+ let(:existing_password) { "password" }
59
+ let(:other_email) { "other@example.com" }
60
+ let(:other_existing_path) { "/other/existing/path" }
62
61
 
63
62
  before do
64
63
  allow(subject).to receive(:system).and_return(nil)
@@ -71,31 +70,31 @@ describe Imap::Backup::Configuration::Account do
71
70
 
72
71
  subject { described_class.new(store, account, highline) }
73
72
 
74
- context 'preparation' do
73
+ context "preparation" do
75
74
  before { subject.run }
76
75
 
77
- it 'clears the screen' do
78
- expect(subject).to have_received(:system).with('clear')
76
+ it "clears the screen" do
77
+ expect(subject).to have_received(:system).with("clear")
79
78
  end
80
79
 
81
- context 'menu' do
82
- it 'shows the menu' do
80
+ context "menu" do
81
+ it "shows the menu" do
83
82
  expect(highline).to have_received(:choose)
84
83
  end
85
84
  end
86
85
  end
87
86
 
88
- context 'menu' do
87
+ context "menu" do
89
88
  [
90
- 'modify email',
91
- 'modify password',
92
- 'modify server',
93
- 'modify backup path',
94
- 'choose backup folders',
95
- 'test connection',
96
- 'delete',
97
- 'return to main menu',
98
- 'quit', # TODO: quit is hidden
89
+ "modify email",
90
+ "modify password",
91
+ "modify server",
92
+ "modify backup path",
93
+ "choose backup folders",
94
+ "test connection",
95
+ "delete",
96
+ "return to main menu",
97
+ "quit", # TODO: quit is hidden
99
98
  ].each do |item|
100
99
  before { subject.run }
101
100
 
@@ -105,13 +104,13 @@ describe Imap::Backup::Configuration::Account do
105
104
  end
106
105
  end
107
106
 
108
- context 'account details' do
107
+ context "account details" do
109
108
  [
110
- ['email', /email:\s+user@example.com/],
111
- ['server', /server:\s+imap.example.com/],
112
- ['password', /password:\s+x+/],
113
- ['path', %r(path:\s+/backup/path)],
114
- ['folders', /folders:\s+my_folder/],
109
+ ["email", /email:\s+user@example.com/],
110
+ ["server", /server:\s+imap.example.com/],
111
+ ["password", /password:\s+x+/],
112
+ ["path", %r(path:\s+/backup/path)],
113
+ ["folders", /folders:\s+my_folder/]
115
114
  ].each do |attribute, value|
116
115
  before { subject.run }
117
116
 
@@ -120,44 +119,44 @@ describe Imap::Backup::Configuration::Account do
120
119
  end
121
120
  end
122
121
 
123
- context 'with no password' do
124
- let(:existing_password) { '' }
122
+ context "with no password" do
123
+ let(:existing_password) { "" }
125
124
 
126
125
  before { subject.run }
127
126
 
128
- it 'indicates that a password is not set' do
129
- expect(menu.header).to include('password: (unset)')
127
+ it "indicates that a password is not set" do
128
+ expect(menu.header).to include("password: (unset)")
130
129
  end
131
130
  end
132
131
  end
133
132
 
134
- context 'email' do
133
+ context "email" do
135
134
  before do
136
135
  allow(Imap::Backup::Configuration::Asker).to receive(:email).and_return(new_email)
137
136
  subject.run
138
- menu.choices['modify email'].call
137
+ menu.choices["modify email"].call
139
138
  end
140
139
 
141
- context 'if the server is blank' do
140
+ context "if the server is blank" do
142
141
  [
143
- ['GMail', 'foo@gmail.com', 'imap.gmail.com'],
144
- ['Fastmail', 'bar@fastmail.fm', 'mail.messagingengine.com'],
142
+ ["GMail", "foo@gmail.com", "imap.gmail.com"],
143
+ ["Fastmail", "bar@fastmail.fm", "mail.messagingengine.com"]
145
144
  ].each do |service, email, expected|
146
145
  context service do
147
146
  let(:new_email) { email }
148
147
 
149
- context 'with nil' do
148
+ context "with nil" do
150
149
  let(:existing_server) { nil }
151
150
 
152
- it 'sets a default server' do
151
+ it "sets a default server" do
153
152
  expect(account[:server]).to eq(expected)
154
153
  end
155
154
  end
156
155
 
157
- context 'with an empty string' do
158
- let(:existing_server) { '' }
156
+ context "with an empty string" do
157
+ let(:existing_server) { "" }
159
158
 
160
- it 'sets a default server' do
159
+ it "sets a default server" do
161
160
  expect(account[:server]).to eq(expected)
162
161
  end
163
162
  end
@@ -165,19 +164,19 @@ describe Imap::Backup::Configuration::Account do
165
164
  end
166
165
  end
167
166
 
168
- context 'the email is new' do
169
- it 'modifies the email address' do
167
+ context "the email is new" do
168
+ it "modifies the email address" do
170
169
  expect(account[:username]).to eq(new_email)
171
170
  end
172
171
 
173
- include_examples 'it flags the account as modified'
172
+ include_examples "it flags the account as modified"
174
173
  end
175
174
 
176
- context 'the email already exists' do
175
+ context "the email already exists" do
177
176
  let(:new_email) { other_email }
178
177
 
179
- it 'indicates the error' do
180
- expect(subject).to have_received(:puts).with('There is already an account set up with that email address')
178
+ it "indicates the error" do
179
+ expect(subject).to have_received(:puts).with("There is already an account set up with that email address")
181
180
  end
182
181
 
183
182
  it "doesn't set the email" do
@@ -188,27 +187,27 @@ describe Imap::Backup::Configuration::Account do
188
187
  end
189
188
  end
190
189
 
191
- context 'password' do
192
- let(:new_password) { 'new_password' }
190
+ context "password" do
191
+ let(:new_password) { "new_password" }
193
192
 
194
193
  before do
195
194
  allow(Imap::Backup::Configuration::Asker).to receive(:password).and_return(new_password)
196
195
  subject.run
197
- menu.choices['modify password'].call
196
+ menu.choices["modify password"].call
198
197
  end
199
198
 
200
- context 'if the user enters a password' do
201
- it 'updates the password' do
199
+ context "if the user enters a password" do
200
+ it "updates the password" do
202
201
  expect(account[:password]).to eq(new_password)
203
202
  end
204
203
 
205
- include_examples 'it flags the account as modified'
204
+ include_examples "it flags the account as modified"
206
205
  end
207
206
 
208
- context 'if the user cancels' do
207
+ context "if the user cancels" do
209
208
  let(:new_password) { nil }
210
209
 
211
- it 'does nothing' do
210
+ it "does nothing" do
212
211
  expect(account[:password]).to eq(existing_password)
213
212
  end
214
213
 
@@ -216,27 +215,27 @@ describe Imap::Backup::Configuration::Account do
216
215
  end
217
216
  end
218
217
 
219
- context 'server' do
220
- let(:server) { 'server' }
218
+ context "server" do
219
+ let(:server) { "server" }
221
220
 
222
221
  before do
223
- allow(highline).to receive(:ask).with('server: ').and_return(server)
222
+ allow(highline).to receive(:ask).with("server: ").and_return(server)
224
223
  end
225
224
 
226
225
  before do
227
226
  subject.run
228
- menu.choices['modify server'].call
227
+ menu.choices["modify server"].call
229
228
  end
230
229
 
231
- it 'updates the server' do
230
+ it "updates the server" do
232
231
  expect(account[:server]).to eq(server)
233
232
  end
234
233
 
235
- include_examples 'it flags the account as modified'
234
+ include_examples "it flags the account as modified"
236
235
  end
237
236
 
238
- context 'backup_path' do
239
- let(:new_backup_path) { '/new/path' }
237
+ context "backup_path" do
238
+ let(:new_backup_path) { "/new/path" }
240
239
 
241
240
  before do
242
241
  @validator = nil
@@ -245,67 +244,67 @@ describe Imap::Backup::Configuration::Account do
245
244
  new_backup_path
246
245
  end
247
246
  subject.run
248
- menu.choices['modify backup path'].call
247
+ menu.choices["modify backup path"].call
249
248
  end
250
249
 
251
- it 'updates the path' do
250
+ it "updates the path" do
252
251
  expect(account[:local_path]).to eq(new_backup_path)
253
252
  end
254
253
 
255
- it 'validates that the path is not used by other backups' do
254
+ it "validates that the path is not used by other backups" do
256
255
  expect(@validator.call(other_existing_path)).to be_falsey
257
256
  end
258
257
 
259
- include_examples 'it flags the account as modified'
258
+ include_examples "it flags the account as modified"
260
259
  end
261
260
 
262
- context 'folders' do
263
- let(:chooser) { double(:run => nil) }
261
+ context "folders" do
262
+ let(:chooser) { double(run: nil) }
264
263
 
265
264
  before do
266
265
  allow(Imap::Backup::Configuration::FolderChooser).to receive(:new).and_return(chooser)
267
266
  subject.run
268
- menu.choices['choose backup folders'].call
267
+ menu.choices["choose backup folders"].call
269
268
  end
270
269
 
271
- it 'edits folders' do
270
+ it "edits folders" do
272
271
  expect(chooser).to have_received(:run)
273
272
  end
274
273
  end
275
274
 
276
- context 'connection test' do
275
+ context "connection test" do
277
276
  before do
278
- allow(Imap::Backup::Configuration::ConnectionTester).to receive(:test).and_return('All fine')
277
+ allow(Imap::Backup::Configuration::ConnectionTester).to receive(:test).and_return("All fine")
279
278
  allow(highline).to receive(:ask)
280
279
  subject.run
281
- menu.choices['test connection'].call
280
+ menu.choices["test connection"].call
282
281
  end
283
282
 
284
- it 'tests the connection' do
283
+ it "tests the connection" do
285
284
  expect(Imap::Backup::Configuration::ConnectionTester).to have_received(:test).with(account)
286
285
  end
287
286
  end
288
287
 
289
- context 'deletion' do
288
+ context "deletion" do
290
289
  let(:confirmed) { true }
291
290
 
292
291
  before do
293
292
  allow(highline).to receive(:agree).and_return(confirmed)
294
293
  subject.run
295
294
  catch :done do
296
- menu.choices['delete'].call
295
+ menu.choices["delete"].call
297
296
  end
298
297
  end
299
298
 
300
- it 'asks for confirmation' do
299
+ it "asks for confirmation" do
301
300
  expect(highline).to have_received(:agree)
302
301
  end
303
302
 
304
- context 'when the user confirms deletion' do
305
- include_examples 'it flags the account to be deleted'
303
+ context "when the user confirms deletion" do
304
+ include_examples "it flags the account to be deleted"
306
305
  end
307
306
 
308
- context 'without confirmation' do
307
+ context "without confirmation" do
309
308
  let(:confirmed) { false }
310
309
 
311
310
  include_examples "it doesn't flag the account to be deleted"