imap-backup 4.0.6 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/bin/imap-backup +5 -2
  3. data/lib/email/mboxrd/message.rb +6 -2
  4. data/lib/imap/backup/account/connection.rb +53 -33
  5. data/lib/imap/backup/account/folder.rb +22 -2
  6. data/lib/imap/backup/account.rb +4 -0
  7. data/lib/imap/backup/cli/accounts.rb +43 -0
  8. data/lib/imap/backup/cli/folders.rb +3 -1
  9. data/lib/imap/backup/cli/helpers.rb +8 -9
  10. data/lib/imap/backup/cli/local.rb +4 -2
  11. data/lib/imap/backup/cli/setup.rb +1 -1
  12. data/lib/imap/backup/cli/status.rb +1 -1
  13. data/lib/imap/backup/cli/utils.rb +3 -2
  14. data/lib/imap/backup/{configuration/store.rb → configuration.rb} +16 -3
  15. data/lib/imap/backup/downloader.rb +26 -12
  16. data/lib/imap/backup/logger.rb +42 -0
  17. data/lib/imap/backup/sanitizer.rb +42 -0
  18. data/lib/imap/backup/serializer/mbox_store.rb +2 -2
  19. data/lib/imap/backup/{configuration → setup}/account.rb +29 -19
  20. data/lib/imap/backup/{configuration → setup}/asker.rb +5 -5
  21. data/lib/imap/backup/setup/connection_tester.rb +26 -0
  22. data/lib/imap/backup/{configuration → setup}/folder_chooser.rb +18 -8
  23. data/lib/imap/backup/setup/helpers.rb +15 -0
  24. data/lib/imap/backup/{configuration/setup.rb → setup.rb} +23 -17
  25. data/lib/imap/backup/thunderbird/mailbox_exporter.rb +10 -1
  26. data/lib/imap/backup/uploader.rb +2 -2
  27. data/lib/imap/backup/version.rb +2 -2
  28. data/lib/imap/backup.rb +7 -33
  29. data/lib/retry_on_error.rb +1 -1
  30. data/lib/thunderbird/subdirectory.rb +3 -6
  31. data/spec/features/backup_spec.rb +1 -0
  32. data/spec/features/status_spec.rb +43 -0
  33. data/spec/features/support/email_server.rb +5 -2
  34. data/spec/support/higline_test_helpers.rb +1 -1
  35. data/spec/support/silence_logging.rb +1 -1
  36. data/spec/unit/imap/backup/account/connection_spec.rb +14 -9
  37. data/spec/unit/imap/backup/cli/accounts_spec.rb +47 -0
  38. data/spec/unit/imap/backup/cli/local_spec.rb +7 -3
  39. data/spec/unit/imap/backup/cli/utils_spec.rb +15 -5
  40. data/spec/unit/imap/backup/{configuration/store_spec.rb → configuration_spec.rb} +2 -2
  41. data/spec/unit/imap/backup/downloader_spec.rb +1 -1
  42. data/spec/unit/imap/backup/logger_spec.rb +48 -0
  43. data/spec/unit/imap/backup/{configuration → setup}/account_spec.rb +31 -24
  44. data/spec/unit/imap/backup/{configuration → setup}/asker_spec.rb +2 -2
  45. data/spec/unit/imap/backup/{configuration → setup}/connection_tester_spec.rb +10 -10
  46. data/spec/unit/imap/backup/{configuration → setup}/folder_chooser_spec.rb +8 -8
  47. data/spec/unit/imap/backup/{configuration/setup_spec.rb → setup_spec.rb} +48 -40
  48. metadata +54 -49
  49. data/lib/imap/backup/configuration/connection_tester.rb +0 -14
  50. data/lib/imap/backup/configuration/list.rb +0 -53
  51. data/spec/unit/imap/backup/configuration/list_spec.rb +0 -89
  52. data/spec/unit/imap/backup_spec.rb +0 -28
@@ -1,8 +1,10 @@
1
+ require "imap/backup/setup/helpers"
2
+
1
3
  module Imap::Backup
2
- module Configuration; end
4
+ class Setup; end
3
5
 
4
- Configuration::Account = Struct.new(:store, :account, :highline) do
5
- def initialize(store, account, highline)
6
+ Setup::Account = Struct.new(:config, :account, :highline) do
7
+ def initialize(config, account, highline)
6
8
  super
7
9
  end
8
10
 
@@ -28,34 +30,38 @@ module Imap::Backup
28
30
  modify_connection_options menu
29
31
  test_connection menu
30
32
  delete_account menu
31
- menu.choice("return to main menu") { throw :done }
33
+ menu.choice("(q) return to main menu") { throw :done }
32
34
  menu.hidden("quit") { throw :done }
33
35
  end
34
36
  end
35
37
 
36
38
  def header(menu)
39
+ modified = account.modified? ? "*" : ""
37
40
  connection_options =
38
41
  if account.connection_options
39
42
  escaped =
40
43
  JSON.generate(account.connection_options).
41
44
  gsub('"', '\"')
42
- "\n connection options: #{escaped}"
45
+ "\n connection options #{escaped}"
43
46
  end
44
- menu.header = <<~HEADER
45
- Account:
46
- email: #{account.username}
47
- password: #{masked_password}
48
- path: #{account.local_path}
49
- folders: #{folders.map { |f| f[:name] }.join(', ')}
50
- server: #{account.server}#{connection_options}
47
+ menu.header = <<~HEADER.chomp
48
+ #{helpers.title_prefix} Account#{modified}
49
+
50
+ email #{account.username}
51
+ password #{masked_password}
52
+ path #{account.local_path}
53
+ folders #{folders.map { |f| f[:name] }.join(', ')}
54
+ server #{account.server}#{connection_options}
55
+
56
+ Choose an action
51
57
  HEADER
52
58
  end
53
59
 
54
60
  def modify_email(menu)
55
61
  menu.choice("modify email") do
56
- username = Configuration::Asker.email(username)
62
+ username = Setup::Asker.email(username)
57
63
  Kernel.puts "username: #{username}"
58
- other_accounts = store.accounts.reject { |a| a == account }
64
+ other_accounts = config.accounts.reject { |a| a == account }
59
65
  others = other_accounts.map { |a| a.username }
60
66
  Kernel.puts "others: #{others.inspect}"
61
67
  if others.include?(username)
@@ -76,7 +82,7 @@ module Imap::Backup
76
82
 
77
83
  def modify_password(menu)
78
84
  menu.choice("modify password") do
79
- password = Configuration::Asker.password
85
+ password = Setup::Asker.password
80
86
 
81
87
  account.password = password if !password.nil?
82
88
  end
@@ -97,7 +103,7 @@ module Imap::Backup
97
103
  end
98
104
 
99
105
  def path_modification_validator(path)
100
- same = store.accounts.find do |a|
106
+ same = config.accounts.find do |a|
101
107
  a.username != account.username && a.local_path == path
102
108
  end
103
109
  if same
@@ -112,7 +118,7 @@ module Imap::Backup
112
118
  def modify_backup_path(menu)
113
119
  menu.choice("modify backup path") do
114
120
  existing = account.local_path.clone
115
- account.local_path = Configuration::Asker.backup_path(
121
+ account.local_path = Setup::Asker.backup_path(
116
122
  account.local_path, ->(path) { path_modification_validator(path) }
117
123
  )
118
124
  end
@@ -120,13 +126,13 @@ module Imap::Backup
120
126
 
121
127
  def choose_folders(menu)
122
128
  menu.choice("choose backup folders") do
123
- Configuration::FolderChooser.new(account).run
129
+ Setup::FolderChooser.new(account).run
124
130
  end
125
131
  end
126
132
 
127
133
  def test_connection(menu)
128
134
  menu.choice("test connection") do
129
- result = Configuration::ConnectionTester.test(account)
135
+ result = Setup::ConnectionTester.new(account).test
130
136
  Kernel.puts result
131
137
  highline.ask "Press a key "
132
138
  end
@@ -163,5 +169,9 @@ module Imap::Backup
163
169
 
164
170
  provider.host
165
171
  end
172
+
173
+ def helpers
174
+ Setup::Helpers.new
175
+ end
166
176
  end
167
177
  end
@@ -1,7 +1,7 @@
1
1
  module Imap::Backup
2
- module Configuration; end
2
+ class Setup; end
3
3
 
4
- Configuration::Asker = Struct.new(:highline) do
4
+ Setup::Asker = Struct.new(:highline) do
5
5
  EMAIL_MATCHER = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]+$/i.freeze
6
6
 
7
7
  def initialize(highline)
@@ -40,15 +40,15 @@ module Imap::Backup
40
40
  end
41
41
 
42
42
  def self.email(default = "")
43
- new(Configuration::Setup.highline).email(default)
43
+ new(Setup.highline).email(default)
44
44
  end
45
45
 
46
46
  def self.password
47
- new(Configuration::Setup.highline).password
47
+ new(Setup.highline).password
48
48
  end
49
49
 
50
50
  def self.backup_path(default, validator)
51
- new(Configuration::Setup.highline).backup_path(default, validator)
51
+ new(Setup.highline).backup_path(default, validator)
52
52
  end
53
53
  end
54
54
  end
@@ -0,0 +1,26 @@
1
+ module Imap::Backup
2
+ class Setup; end
3
+
4
+ class Setup::ConnectionTester
5
+ attr_reader :account
6
+
7
+ def initialize(account)
8
+ @account = account
9
+ end
10
+
11
+ def test
12
+ connection.client
13
+ "Connection successful"
14
+ rescue Net::IMAP::NoResponseError
15
+ "No response"
16
+ rescue StandardError => e
17
+ "Unexpected error: #{e}"
18
+ end
19
+
20
+ private
21
+
22
+ def connection
23
+ Account::Connection.new(account)
24
+ end
25
+ end
26
+ end
@@ -1,7 +1,9 @@
1
+ require "imap/backup/setup/helpers"
2
+
1
3
  module Imap::Backup
2
- module Configuration; end
4
+ class Setup; end
3
5
 
4
- class Configuration::FolderChooser
6
+ class Setup::FolderChooser
5
7
  attr_reader :account
6
8
 
7
9
  def initialize(account)
@@ -10,13 +12,13 @@ module Imap::Backup
10
12
 
11
13
  def run
12
14
  if connection.nil?
13
- Imap::Backup.logger.warn "Connection failed"
15
+ Imap::Backup::Logger.logger.warn "Connection failed"
14
16
  highline.ask "Press a key "
15
17
  return
16
18
  end
17
19
 
18
20
  if imap_folders.nil?
19
- Imap::Backup.logger.warn "Unable to get folder list"
21
+ Imap::Backup::Logger.logger.warn "Unable to get folder list"
20
22
  highline.ask "Press a key "
21
23
  return
22
24
  end
@@ -35,10 +37,14 @@ module Imap::Backup
35
37
 
36
38
  def show_menu
37
39
  highline.choose do |menu|
38
- menu.header = "Add/remove folders"
40
+ menu.header = <<~MENU.chomp
41
+ #{helpers.title_prefix} Add/remove folders
42
+
43
+ Select a folder (toggles)
44
+ MENU
39
45
  menu.index = :number
40
46
  add_folders menu
41
- menu.choice("return to the account menu") { throw :done }
47
+ menu.choice("(q) return to the account menu") { throw :done }
42
48
  menu.hidden("quit") { throw :done }
43
49
  end
44
50
  end
@@ -99,11 +105,15 @@ module Imap::Backup
99
105
  end
100
106
 
101
107
  def imap_folders
102
- @imap_folders ||= connection.folders
108
+ @imap_folders ||= connection.folder_names
103
109
  end
104
110
 
105
111
  def highline
106
- Configuration::Setup.highline
112
+ Setup.highline
113
+ end
114
+
115
+ def helpers
116
+ Setup::Helpers.new
107
117
  end
108
118
  end
109
119
  end
@@ -0,0 +1,15 @@
1
+ require "imap/backup/version"
2
+
3
+ module Imap::Backup
4
+ class Setup; end
5
+
6
+ class Setup::Helpers
7
+ def title_prefix
8
+ "imap-backup –"
9
+ end
10
+
11
+ def version
12
+ Version::VERSION
13
+ end
14
+ end
15
+ end
@@ -1,18 +1,16 @@
1
1
  require "highline"
2
2
 
3
3
  require "imap/backup/account"
4
+ require "imap/backup/setup/helpers"
4
5
 
5
6
  module Imap::Backup
6
- module Configuration; end
7
-
8
- class Configuration::Setup
7
+ class Setup
9
8
  class << self
10
9
  attr_accessor :highline
11
10
  end
12
11
  self.highline = HighLine.new
13
12
 
14
13
  def run
15
- Imap::Backup.setup_logging config
16
14
  catch :done do
17
15
  loop do
18
16
  Kernel.system("clear")
@@ -25,16 +23,22 @@ module Imap::Backup
25
23
 
26
24
  def show_menu
27
25
  self.class.highline.choose do |menu|
28
- menu.header = "Choose an action"
26
+ menu.header = <<~MENU.chomp
27
+ #{helpers.title_prefix} Main Menu
28
+
29
+ Choose an action
30
+ MENU
29
31
  account_items menu
30
32
  add_account_item menu
31
33
  toggle_logging_item menu
32
- menu.choice("save and exit") do
33
- config.save
34
- throw :done
35
- end
36
- menu.choice("exit without saving changes") do
37
- throw :done
34
+ if config.modified?
35
+ menu.choice("save and exit") do
36
+ config.save
37
+ throw :done
38
+ end
39
+ menu.choice("exit without saving changes") { throw :done }
40
+ else
41
+ menu.choice("quit") { throw :done }
38
42
  end
39
43
  end
40
44
  end
@@ -53,7 +57,7 @@ module Imap::Backup
53
57
 
54
58
  def add_account_item(menu)
55
59
  menu.choice("add account") do
56
- username = Configuration::Asker.email
60
+ username = Asker.email
57
61
  edit_account username
58
62
  end
59
63
  end
@@ -63,12 +67,12 @@ module Imap::Backup
63
67
  new_setting = !config.debug?
64
68
  menu.choice(menu_item) do
65
69
  config.debug = new_setting
66
- Imap::Backup.setup_logging config
70
+ Imap::Backup::Logger.setup_logging(config)
67
71
  end
68
72
  end
69
73
 
70
74
  def config
71
- @config ||= Configuration::Store.new
75
+ @config ||= Configuration.new
72
76
  end
73
77
 
74
78
  def default_account_config(username)
@@ -89,9 +93,11 @@ module Imap::Backup
89
93
  account = default_account_config(username)
90
94
  config.accounts << account
91
95
  end
92
- Configuration::Account.new(
93
- config, account, Configuration::Setup.highline
94
- ).run
96
+ Account.new(config, account, Setup.highline).run
97
+ end
98
+
99
+ def helpers
100
+ Helpers.new
95
101
  end
96
102
  end
97
103
  end
@@ -40,7 +40,16 @@ module Imap::Backup
40
40
  end
41
41
  end
42
42
 
43
- FileUtils.cp serializer.mbox_pathname, local_folder.full_path
43
+ File.open(local_folder.full_path, "w") do |f|
44
+ enumerator = Serializer::MboxEnumerator.new(serializer.mbox_pathname)
45
+ enumerator.each.with_index do |raw, i|
46
+ clean = Email::Mboxrd::Message.clean_serialized(raw)
47
+ timestamp = Time.now.strftime("%a %b %d %H:%M:%S %Y")
48
+ thunderbird_fom_line = "From - #{timestamp}"
49
+ output = "#{thunderbird_fom_line}\n#{clean}\n"
50
+ f.write output
51
+ end
52
+ end
44
53
 
45
54
  true
46
55
  end
@@ -12,12 +12,12 @@ module Imap::Backup
12
12
  count = missing_uids.count
13
13
  return if count.zero?
14
14
 
15
- Imap::Backup.logger.debug "[#{folder.name}] #{count} to restore"
15
+ Imap::Backup::Logger.logger.debug "[#{folder.name}] #{count} to restore"
16
16
  serializer.each_message(missing_uids).with_index do |(uid, message), i|
17
17
  next if message.nil?
18
18
 
19
19
  log_prefix = "[#{folder.name}] uid: #{uid} (#{i + 1}/#{count}) -"
20
- Imap::Backup.logger.debug(
20
+ Imap::Backup::Logger.logger.debug(
21
21
  "#{log_prefix} #{message.supplied_body.size} bytes"
22
22
  )
23
23
 
@@ -2,8 +2,8 @@ module Imap; end
2
2
 
3
3
  module Imap::Backup
4
4
  MAJOR = 4
5
- MINOR = 0
6
- REVISION = 6
5
+ MINOR = 2
6
+ REVISION = 0
7
7
  PRE = nil
8
8
  VERSION = [MAJOR, MINOR, REVISION, PRE].compact.map(&:to_s).join(".")
9
9
  end
data/lib/imap/backup.rb CHANGED
@@ -3,46 +3,20 @@ module Imap; end
3
3
  require "imap/backup/utils"
4
4
  require "imap/backup/account/connection"
5
5
  require "imap/backup/account/folder"
6
- require "imap/backup/configuration/account"
7
- require "imap/backup/configuration/asker"
8
- require "imap/backup/configuration/connection_tester"
9
- require "imap/backup/configuration/folder_chooser"
10
- require "imap/backup/configuration/list"
11
- require "imap/backup/configuration/setup"
12
- require "imap/backup/configuration/store"
6
+ require "imap/backup/configuration"
13
7
  require "imap/backup/downloader"
8
+ require "imap/backup/logger"
14
9
  require "imap/backup/uploader"
15
10
  require "imap/backup/serializer"
16
11
  require "imap/backup/serializer/mbox"
12
+ require "imap/backup/setup"
13
+ require "imap/backup/setup/account"
14
+ require "imap/backup/setup/asker"
15
+ require "imap/backup/setup/connection_tester"
16
+ require "imap/backup/setup/folder_chooser"
17
17
  require "imap/backup/version"
18
18
  require "email/provider"
19
19
 
20
- require "logger"
21
-
22
20
  module Imap::Backup
23
21
  class ConfigurationNotFound < StandardError; end
24
-
25
- class Logger
26
- include Singleton
27
-
28
- attr_reader :logger
29
-
30
- def initialize
31
- @logger = ::Logger.new($stdout)
32
- $stdout.sync = true
33
- end
34
- end
35
-
36
- def self.logger
37
- Logger.instance.logger
38
- end
39
-
40
- def self.setup_logging(config)
41
- logger.level =
42
- if config.debug?
43
- ::Logger::Severity::DEBUG
44
- else
45
- ::Logger::Severity::ERROR
46
- end
47
- end
48
22
  end
@@ -5,7 +5,7 @@ module RetryOnError
5
5
  rescue *errors => e
6
6
  if tries < limit
7
7
  message = "#{e}, attempt #{tries} of #{limit}"
8
- Imap::Backup.logger.debug message
8
+ Imap::Backup::Logger.logger.debug message
9
9
  tries += 1
10
10
  retry
11
11
  end
@@ -77,17 +77,14 @@ class Thunderbird::Subdirectory
77
77
 
78
78
  def check
79
79
  case
80
- when placeholder.exists? && !exists?
81
- Kernel.puts "Can't set up folder '#{folder_path}': '#{placeholder.path}' exists, but '#{full_path}' is missing"
82
- false
83
80
  when exists? && !placeholder.exists?
84
- Kernel.puts "Can't set up folder '#{folder_path}': '#{full_path}' exists, but '#{placeholder.path}' is missing"
81
+ Kernel.puts "Can't set up folder '#{full_path}': '#{full_path}' exists, but '#{placeholder.path}' is missing"
85
82
  false
86
83
  when placeholder.exists? && !placeholder.regular?
87
- Kernel.puts "Can't set up folder '#{folder_path}': '#{placeholder.path}' exists, but it is not a regular file"
84
+ Kernel.puts "Can't set up folder '#{full_path}': '#{placeholder.path}' exists, but it is not a regular file"
88
85
  false
89
86
  when exists? && !directory?
90
- Kernel.puts "Can't set up folder '#{folder_path}': '#{full_path}' exists, but it is not a directory"
87
+ Kernel.puts "Can't set up folder '#{full_path}': '#{full_path}' exists, but it is not a directory"
91
88
  false
92
89
  else
93
90
  true
@@ -58,6 +58,7 @@ RSpec.describe "backup", type: :feature, docker: true do
58
58
  email3
59
59
  original_folder_uid_validity
60
60
  connection.run_backup
61
+ connection.disconnect
61
62
  server_rename_folder folder, new_name
62
63
  end
63
64
  let(:renamed_folder) { "#{folder}.#{original_folder_uid_validity}" }
@@ -0,0 +1,43 @@
1
+ require "features/helper"
2
+ require "imap/backup/cli/status"
3
+
4
+ RSpec.describe "status", type: :feature, docker: true do
5
+ include_context "imap-backup connection"
6
+ include_context "message-fixtures"
7
+
8
+ context "when there are non-backed-up messages" do
9
+ let(:options) do
10
+ {accounts: "address@example.org"}
11
+ end
12
+ let(:folder) { "my-stuff" }
13
+ let(:backup_folders) { [{name: folder}] }
14
+ let(:email1) { send_email folder, msg1 }
15
+ let(:output) { StringIO.new }
16
+
17
+ before do
18
+ allow(Imap::Backup::CLI::Accounts).to receive(:new) { [account] }
19
+ server_create_folder folder
20
+ email1
21
+ end
22
+
23
+ around do |example|
24
+ stdout = $stdout
25
+ $stdout = output
26
+ example.run
27
+ $stdout = stdout
28
+ end
29
+
30
+ after do
31
+ FileUtils.rm_rf local_backup_path
32
+ delete_emails folder
33
+ server_delete_folder folder
34
+ connection.disconnect
35
+ end
36
+
37
+ it "prints the number" do
38
+ Imap::Backup::CLI::Status.new(options).run
39
+
40
+ expect(output.string).to eq("address@example.org\nmy-stuff: 1\n")
41
+ end
42
+ end
43
+ end
@@ -63,11 +63,14 @@ module EmailServerHelpers
63
63
  end
64
64
 
65
65
  def server_folders
66
- root_info = imap.list("", "")[0]
67
- root = root_info.name
68
66
  imap.list(root, "*")
69
67
  end
70
68
 
69
+ def root
70
+ root_info = imap.list("", "")[0]
71
+ root_info.name
72
+ end
73
+
71
74
  def server_create_folder(folder)
72
75
  imap.create(folder)
73
76
  imap.disconnect
@@ -2,7 +2,7 @@ module HighLineTestHelpers
2
2
  def prepare_highline
3
3
  @input = instance_double(IO, eof?: false, gets: "q\n")
4
4
  @output = StringIO.new
5
- Imap::Backup::Configuration::Setup.highline = HighLine.new(@input, @output)
5
+ Imap::Backup::Setup.highline = HighLine.new(@input, @output)
6
6
  [@input, @output]
7
7
  end
8
8
  end
@@ -1,7 +1,7 @@
1
1
  def silence_logging
2
2
  RSpec.configure do |config|
3
3
  config.before(:suite) do
4
- Imap::Backup.logger.level = Logger::UNKNOWN
4
+ Imap::Backup::Logger.logger.level = Logger::UNKNOWN
5
5
  end
6
6
  end
7
7
  end
@@ -5,6 +5,7 @@ describe Imap::Backup::Account::Connection do
5
5
  FOLDER_CONFIG = {name: BACKUP_FOLDER}.freeze
6
6
  FOLDER_NAME = "my_folder".freeze
7
7
  GMAIL_IMAP_SERVER = "imap.gmail.com".freeze
8
+ IMAP_FOLDER = "imap_folder".freeze
8
9
  LOCAL_PATH = "local_path".freeze
9
10
  LOCAL_UID = "local_uid".freeze
10
11
  PASSWORD = "secret".freeze
@@ -101,19 +102,23 @@ describe Imap::Backup::Account::Connection do
101
102
  end
102
103
  end
103
104
 
104
- describe "#folders" do
105
+ describe "#folder_names" do
105
106
  let(:imap_folders) do
106
- [BACKUP_FOLDER]
107
+ [IMAP_FOLDER]
107
108
  end
108
109
 
109
110
  it "returns the list of folders" do
110
- expect(subject.folders).to eq([BACKUP_FOLDER])
111
+ expect(subject.folder_names).to eq([IMAP_FOLDER])
111
112
  end
112
113
  end
113
114
 
114
115
  describe "#status" do
115
116
  let(:folder) do
116
- instance_double(Imap::Backup::Account::Folder, uids: [remote_uid])
117
+ instance_double(
118
+ Imap::Backup::Account::Folder,
119
+ uids: [remote_uid],
120
+ name: IMAP_FOLDER
121
+ )
117
122
  end
118
123
  let(:remote_uid) { "remote_uid" }
119
124
 
@@ -123,7 +128,7 @@ describe Imap::Backup::Account::Connection do
123
128
  end
124
129
 
125
130
  it "returns the names of folders" do
126
- expect(subject.status[0][:name]).to eq(BACKUP_FOLDER)
131
+ expect(subject.status[0][:name]).to eq(IMAP_FOLDER)
127
132
  end
128
133
 
129
134
  it "returns local message uids" do
@@ -139,7 +144,7 @@ describe Imap::Backup::Account::Connection do
139
144
  let(:folder) do
140
145
  instance_double(
141
146
  Imap::Backup::Account::Folder,
142
- name: "folder",
147
+ name: IMAP_FOLDER,
143
148
  exist?: exists,
144
149
  uid_validity: uid_validity
145
150
  )
@@ -150,11 +155,11 @@ describe Imap::Backup::Account::Connection do
150
155
 
151
156
  before do
152
157
  allow(Imap::Backup::Downloader).
153
- to receive(:new).with(folder, serializer) { downloader }
158
+ to receive(:new).with(folder, serializer, anything) { downloader }
154
159
  allow(Imap::Backup::Account::Folder).to receive(:new).
155
160
  with(subject, BACKUP_FOLDER) { folder }
156
161
  allow(Imap::Backup::Serializer::Mbox).to receive(:new).
157
- with(LOCAL_PATH, BACKUP_FOLDER) { serializer }
162
+ with(LOCAL_PATH, IMAP_FOLDER) { serializer }
158
163
  end
159
164
 
160
165
  context "with supplied config_folders" do
@@ -248,7 +253,7 @@ describe Imap::Backup::Account::Connection do
248
253
  Imap::Backup::Account::Folder,
249
254
  create: nil,
250
255
  uids: uids,
251
- name: FOLDER_NAME,
256
+ name: IMAP_FOLDER,
252
257
  uid_validity: uid_validity
253
258
  )
254
259
  end