heirloom 0.12.1 → 0.12.2

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 (72) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +1 -0
  4. data/CHANGELOG.md +6 -0
  5. data/README.md +12 -6
  6. data/heirloom.gemspec +3 -5
  7. data/lib/heirloom/catalog/verify.rb +2 -2
  8. data/lib/heirloom/cli/authorize.rb +1 -2
  9. data/lib/heirloom/cli/catalog.rb +62 -19
  10. data/lib/heirloom/cli/cleanup.rb +1 -2
  11. data/lib/heirloom/cli/destroy.rb +1 -2
  12. data/lib/heirloom/cli/download.rb +2 -3
  13. data/lib/heirloom/cli/formatter/catalog.rb +25 -11
  14. data/lib/heirloom/cli/list.rb +1 -3
  15. data/lib/heirloom/cli/rotate.rb +1 -2
  16. data/lib/heirloom/cli/setup.rb +1 -2
  17. data/lib/heirloom/cli/shared.rb +3 -0
  18. data/lib/heirloom/cli/show.rb +1 -3
  19. data/lib/heirloom/cli/tag.rb +1 -2
  20. data/lib/heirloom/cli/teardown.rb +1 -2
  21. data/lib/heirloom/cli/upload.rb +1 -2
  22. data/lib/heirloom/version.rb +1 -1
  23. data/spec/acl/s3_spec.rb +11 -11
  24. data/spec/archive/authorizer_spec.rb +20 -20
  25. data/spec/archive/builder_spec.rb +13 -13
  26. data/spec/archive/checker_spec.rb +24 -24
  27. data/spec/archive/destroyer_spec.rb +20 -20
  28. data/spec/archive/downloader_spec.rb +30 -30
  29. data/spec/archive/lister_spec.rb +7 -7
  30. data/spec/archive/reader_spec.rb +65 -65
  31. data/spec/archive/setup_spec.rb +27 -27
  32. data/spec/archive/teardowner_spec.rb +19 -19
  33. data/spec/archive/updater_spec.rb +10 -10
  34. data/spec/archive/uploader_spec.rb +26 -26
  35. data/spec/archive/verifier_spec.rb +25 -25
  36. data/spec/archive/writer_spec.rb +11 -11
  37. data/spec/archive_spec.rb +91 -93
  38. data/spec/aws/s3_spec.rb +102 -102
  39. data/spec/aws/simpledb_spec.rb +33 -63
  40. data/spec/catalog/add_spec.rb +12 -12
  41. data/spec/catalog/delete_spec.rb +14 -14
  42. data/spec/catalog/list_spec.rb +8 -8
  43. data/spec/catalog/setup_spec.rb +11 -11
  44. data/spec/catalog/show_spec.rb +13 -13
  45. data/spec/catalog/verify_spec.rb +16 -16
  46. data/spec/catalog_spec.rb +36 -36
  47. data/spec/cipher/data_spec.rb +19 -19
  48. data/spec/cipher/file_spec.rb +11 -11
  49. data/spec/cli/authorize_spec.rb +16 -16
  50. data/spec/cli/catalog_spec.rb +18 -34
  51. data/spec/cli/destroy_spec.rb +13 -13
  52. data/spec/cli/download_spec.rb +31 -31
  53. data/spec/cli/formatter/catalog_spec.rb +19 -17
  54. data/spec/cli/list_spec.rb +14 -14
  55. data/spec/cli/rotate_spec.rb +9 -9
  56. data/spec/cli/setup_spec.rb +29 -29
  57. data/spec/cli/shared_spec.rb +119 -119
  58. data/spec/cli/show_spec.rb +20 -20
  59. data/spec/cli/tag_spec.rb +18 -18
  60. data/spec/cli/teardown_spec.rb +28 -28
  61. data/spec/cli/upload_spec.rb +38 -38
  62. data/spec/config_spec.rb +21 -21
  63. data/spec/destroyer/s3_spec.rb +6 -6
  64. data/spec/directory/directory_spec.rb +19 -19
  65. data/spec/downloader/s3_spec.rb +18 -18
  66. data/spec/logger_spec.rb +9 -9
  67. data/spec/spec_helper.rb +4 -80
  68. data/spec/uploader/s3_spec.rb +35 -35
  69. metadata +23 -56
  70. data/spec/integration/authorize_spec.rb +0 -79
  71. data/spec/integration/cleanup_spec.rb +0 -77
  72. data/watchr.rb +0 -101
@@ -9,26 +9,26 @@ describe Heirloom do
9
9
  :id => '1.0.0',
10
10
  :level => 'info',
11
11
  :metadata_region => 'us-west-1' }
12
- @logger_stub = stub :debug => true
13
- @config_mock = mock_config(:logger => @logger_stub)
14
- @archive_mock = mock 'archive'
12
+ @logger_double = double :debug => true
13
+ @config_double = double_config(:logger => @logger_double)
14
+ @archive_double = double 'archive'
15
15
  Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
16
- and_return @logger_stub
16
+ and_return @logger_double
17
17
  Heirloom::CLI::Show.any_instance.should_receive(:load_config).
18
- with(:logger => @logger_stub,
18
+ with(:logger => @logger_double,
19
19
  :opts => @options).
20
- and_return @config_mock
20
+ and_return @config_double
21
21
  Heirloom::Archive.should_receive(:new).
22
22
  with(:name => 'archive_name',
23
- :config => @config_mock).
24
- and_return @archive_mock
23
+ :config => @config_double).
24
+ and_return @archive_double
25
25
  Heirloom::Archive.should_receive(:new).
26
26
  with(:name => 'archive_name',
27
27
  :id => '1.0.0',
28
- :config => @config_mock).
29
- and_return @archive_mock
30
- @archive_mock.stub :exists? => true
31
- @archive_mock.stub :domain_exists? => true
28
+ :config => @config_double).
29
+ and_return @archive_double
30
+ @archive_double.stub :exists? => true
31
+ @archive_double.stub :domain_exists? => true
32
32
  end
33
33
 
34
34
  context "returning base attributes" do
@@ -44,7 +44,7 @@ describe Heirloom do
44
44
 
45
45
  it "should show a given id as json" do
46
46
  @cli_show = Heirloom::CLI::Show.new
47
- @archive_mock.stub :show => @attributes
47
+ @archive_double.stub :show => @attributes
48
48
  @cli_show.should_receive(:jj).with @attributes
49
49
  @cli_show.show
50
50
  end
@@ -59,13 +59,13 @@ describe Heirloom do
59
59
 
60
60
  it "should show a given id using the show formatter" do
61
61
  @cli_show = Heirloom::CLI::Show.new
62
- @archive_mock.stub :show => @attributes
63
- formatter_mock = mock 'format'
64
- Heirloom::CLI::Formatter::Show.stub :new => formatter_mock
65
- formatter_mock.should_receive(:format).
66
- with(:attributes => @attributes,
67
- :all => true).
68
- and_return 'the attribs'
62
+ @archive_double.stub :show => @attributes
63
+ formatter_double = double 'format'
64
+ Heirloom::CLI::Formatter::Show.stub :new => formatter_double
65
+ formatter_double.should_receive(:format).
66
+ with(:attributes => @attributes,
67
+ :all => true).
68
+ and_return 'the attribs'
69
69
  @cli_show.should_receive(:puts).with 'the attribs'
70
70
  @cli_show.show
71
71
  end
@@ -10,41 +10,41 @@ describe Heirloom do
10
10
  :attribute => 'att',
11
11
  :value => 'val',
12
12
  :metadata_region => 'us-west-1' }
13
- @logger_stub = stub :debug => true, :error => true
14
- @config_mock = mock_config(:logger => @logger_stub)
15
- @archive_mock = mock 'archive'
16
-
13
+ @logger_double = double :debug => true, :error => true
14
+ @config_double = double_config(:logger => @logger_double)
15
+ @archive_double = double 'archive'
16
+
17
17
  Trollop.stub(:options).and_return options
18
18
  Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
19
- and_return @logger_stub
19
+ and_return @logger_double
20
20
  Heirloom::CLI::Tag.any_instance.should_receive(:load_config).
21
- with(:logger => @logger_stub,
21
+ with(:logger => @logger_double,
22
22
  :opts => options).
23
- and_return @config_mock
23
+ and_return @config_double
24
24
  Heirloom::Archive.should_receive(:new).
25
25
  with(:name => 'archive_name',
26
- :config => @config_mock).
27
- and_return @archive_mock
26
+ :config => @config_double).
27
+ and_return @archive_double
28
28
  Heirloom::Archive.should_receive(:new).
29
29
  with(:name => 'archive_name',
30
30
  :id => '1.0.0',
31
- :config => @config_mock).
32
- and_return @archive_mock
33
- @archive_mock.stub :exists? => true
34
- @archive_mock.should_receive(:domain_exists?).and_return true
31
+ :config => @config_double).
32
+ and_return @archive_double
33
+ @archive_double.stub :exists? => true
34
+ @archive_double.should_receive(:domain_exists?).and_return true
35
35
  @cli_tag = Heirloom::CLI::Tag.new
36
36
  end
37
37
 
38
38
  it "should tag an archive attribute with a given id" do
39
- @archive_mock.stub :exists? => true
40
- @archive_mock.should_receive(:update).
41
- with(:attribute => 'att',
42
- :value => 'val')
39
+ @archive_double.stub :exists? => true
40
+ @archive_double.should_receive(:update).
41
+ with(:attribute => 'att',
42
+ :value => 'val')
43
43
  @cli_tag.tag
44
44
  end
45
45
 
46
46
  it "should exit if the archive does not exist" do
47
- @archive_mock.stub :exists? => false
47
+ @archive_double.stub :exists? => false
48
48
  lambda { @cli_tag.tag }.should raise_error SystemExit
49
49
  end
50
50
 
@@ -3,7 +3,7 @@ require 'heirloom/cli'
3
3
 
4
4
  describe Heirloom::CLI::Teardown do
5
5
 
6
- def stubbed_teardown
6
+ def doublebed_teardown
7
7
  teardown = Heirloom::CLI::Teardown.new
8
8
  teardown.stub(
9
9
  :ensure_domain_exists => true,
@@ -13,46 +13,46 @@ describe Heirloom::CLI::Teardown do
13
13
  end
14
14
 
15
15
  before do
16
- Heirloom.stub :log => mock_log
17
- @config_mock = mock_config
16
+ Heirloom.stub :log => double_log
17
+ @config_double = double_config
18
18
 
19
- @defaults = {
19
+ @defaults = {
20
20
  :level => 'info',
21
21
  :name => 'archive_name',
22
22
  :metadata_region => 'us-west-1'
23
23
  }
24
24
 
25
25
 
26
- @archive_mock = mock 'archive'
27
- @archive_mock.stub(
26
+ @archive_double = double 'archive'
27
+ @archive_double.stub(
28
28
  :delete_buckets => true,
29
29
  :delete_domain => true
30
30
  )
31
31
 
32
- @catalog_mock = mock 'catalog'
33
- @catalog_mock.stub(
32
+ @catalog_double = double 'catalog'
33
+ @catalog_double.stub(
34
34
  :regions => ['us-west-1', 'us-west-2'],
35
- :bucket_prefix => 'bp',
35
+ :bucket_prefix => 'bp',
36
36
  :catalog_domain_exists? => true,
37
37
  :delete_from_catalog => true,
38
38
  :entry_exists_in_catalog? => true
39
39
  )
40
-
40
+
41
41
  Trollop.stub :options => @defaults
42
- Heirloom::HeirloomLogger.stub :new => @logger_stub
42
+ Heirloom::HeirloomLogger.stub :new => @logger_double
43
43
  Heirloom::CLI::Teardown.any_instance.stub(:load_config)
44
- .and_return @config_mock
45
- Heirloom::Archive.stub :new => @archive_mock
46
- Heirloom::Catalog.stub :new => @catalog_mock
47
- @teardown = stubbed_teardown
44
+ .and_return @config_double
45
+ Heirloom::Archive.stub :new => @archive_double
46
+ Heirloom::Catalog.stub :new => @catalog_double
47
+ @teardown = doublebed_teardown
48
48
  end
49
49
 
50
50
  context "delete existing archives force option" do
51
-
51
+
52
52
  it "should ask archive to delete when passed the 'force' option" do
53
53
  Trollop.stub :options => @defaults.merge(:force => true)
54
- @teardown = stubbed_teardown
55
- @catalog_mock.should_receive(:cleanup).with(
54
+ @teardown = doublebed_teardown
55
+ @catalog_double.should_receive(:cleanup).with(
56
56
  :num_to_keep => 0,
57
57
  :remove_preserved => true
58
58
  )
@@ -61,24 +61,24 @@ describe Heirloom::CLI::Teardown do
61
61
 
62
62
  it "should not ask archive to delete when not passed the 'force' option" do
63
63
  Trollop.stub :options => @defaults.merge(:force => nil)
64
- @teardown = stubbed_teardown
65
- @catalog_mock.should_not_receive(:cleanup)
64
+ @teardown = doublebed_teardown
65
+ @catalog_double.should_not_receive(:cleanup)
66
66
  @teardown.teardown
67
67
  end
68
-
68
+
69
69
  end
70
70
 
71
71
  it "should delete s3 buckets, catalog and simpledb domain" do
72
72
  @teardown.should_receive(:ensure_domain_exists).
73
73
  with(:name => 'archive_name',
74
- :config => @config_mock)
74
+ :config => @config_double)
75
75
  @teardown.should_receive(:ensure_archive_domain_empty).
76
- with(:archive => @archive_mock,
77
- :config => @config_mock)
78
- @archive_mock.should_receive(:delete_buckets)
79
- @archive_mock.should_receive(:delete_domain)
80
- @catalog_mock.should_receive(:delete_from_catalog)
81
- @teardown.teardown
76
+ with(:archive => @archive_double,
77
+ :config => @config_double)
78
+ @archive_double.should_receive(:delete_buckets)
79
+ @archive_double.should_receive(:delete_domain)
80
+ @catalog_double.should_receive(:delete_from_catalog)
81
+ @teardown.teardown
82
82
  end
83
83
 
84
84
  end
@@ -11,71 +11,71 @@ describe Heirloom do
11
11
  :public => false,
12
12
  :secret => 'secret12',
13
13
  :name => 'archive_name',
14
- :id => '1.0.0',
14
+ :id => '1.0.0',
15
15
  :metadata_region => 'us-west-1' }
16
16
 
17
- @logger_stub = stub 'logger', :error => true, :info => true
18
- @config_mock = mock_config(:logger => @logger_stub)
19
- @archive_mock = mock 'archive'
20
- @catalog_mock = mock 'catalog'
21
- @catalog_mock.stub :regions => @regions,
17
+ @logger_double = double 'logger', :error => true, :info => true
18
+ @config_double = double_config(:logger => @logger_double)
19
+ @archive_double = double 'archive'
20
+ @catalog_double = double 'catalog'
21
+ @catalog_double.stub :regions => @regions,
22
22
  :bucket_prefix => 'bp',
23
23
  :catalog_domain_exists? => true
24
24
  Trollop.stub(:options).and_return options
25
- tempfile_stub = stub 'tempfile', :path => '/tmp/file.tar.gz',
26
- :close! => true
27
- Tempfile.stub :new => tempfile_stub
28
-
25
+ tempfile_double = double 'tempfile', :path => '/tmp/file.tar.gz',
26
+ :close! => true
27
+ Tempfile.stub :new => tempfile_double
28
+
29
29
  Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
30
- and_return @logger_stub
30
+ and_return @logger_double
31
31
  Heirloom::CLI::Upload.any_instance.should_receive(:load_config).
32
- with(:logger => @logger_stub,
32
+ with(:logger => @logger_double,
33
33
  :opts => options).
34
- and_return @config_mock
34
+ and_return @config_double
35
35
  Heirloom::Archive.should_receive(:new).
36
36
  with(:id => '1.0.0',
37
37
  :name => 'archive_name',
38
- :config => @config_mock).
39
- and_return @archive_mock
38
+ :config => @config_double).
39
+ and_return @archive_double
40
40
  Heirloom::Catalog.should_receive(:new).
41
41
  with(:name => 'archive_name',
42
- :config => @config_mock).
43
- and_return @catalog_mock
44
- @catalog_mock.should_receive(:entry_exists_in_catalog?).
45
- with('archive_name').
46
- and_return true
42
+ :config => @config_double).
43
+ and_return @catalog_double
44
+ @catalog_double.should_receive(:entry_exists_in_catalog?).
45
+ with('archive_name').
46
+ and_return true
47
47
  @upload = Heirloom::CLI::Upload.new
48
48
  end
49
49
 
50
50
  it "should upload an archive" do
51
51
  @upload.should_receive(:ensure_domain_exists).
52
52
  with(:name => 'archive_name',
53
- :config => @config_mock)
53
+ :config => @config_double)
54
54
  @upload.should_receive(:ensure_buckets_exist).
55
55
  with(:bucket_prefix => 'bp',
56
56
  :name => 'archive_name',
57
57
  :regions => @regions,
58
- :config => @config_mock)
58
+ :config => @config_double)
59
59
  @upload.should_receive(:ensure_path_is_directory).
60
60
  with(:path => '/buildme',
61
- :config => @config_mock)
61
+ :config => @config_double)
62
62
  @upload.should_receive(:ensure_valid_secret).
63
63
  with(:secret => 'secret12',
64
- :config => @config_mock)
65
- @archive_mock.stub :exists? => false
66
- @archive_mock.should_receive(:build).
67
- with(:bucket_prefix => 'bp',
68
- :directory => '/buildme',
69
- :exclude => ["exclude1", "exclude2"],
70
- :secret => 'secret12',
71
- :file => '/tmp/file.tar.gz').
72
- and_return true
73
- @archive_mock.should_receive(:upload).
74
- with(:bucket_prefix => 'bp',
75
- :regions => @regions,
76
- :public_readable => false,
77
- :secret => 'secret12',
78
- :file => '/tmp/file.tar.gz')
64
+ :config => @config_double)
65
+ @archive_double.stub :exists? => false
66
+ @archive_double.should_receive(:build).
67
+ with(:bucket_prefix => 'bp',
68
+ :directory => '/buildme',
69
+ :exclude => ["exclude1", "exclude2"],
70
+ :secret => 'secret12',
71
+ :file => '/tmp/file.tar.gz').
72
+ and_return true
73
+ @archive_double.should_receive(:upload).
74
+ with(:bucket_prefix => 'bp',
75
+ :regions => @regions,
76
+ :public_readable => false,
77
+ :secret => 'secret12',
78
+ :file => '/tmp/file.tar.gz')
79
79
  @upload.upload
80
80
  end
81
81
 
@@ -23,9 +23,9 @@ describe Heirloom do
23
23
  it "should open the HEIRLOOM_CONFIG_FILE if set" do
24
24
  File.stub :exists? => true
25
25
  File.should_receive(:open).with('~/.special_config.yml').and_return(@config_file.to_yaml)
26
- env_mock = mock 'env'
27
- env_mock.should_receive(:load).with('HEIRLOOM_CONFIG_FILE').and_return('~/.special_config.yml')
28
- Heirloom::Env.stub(:new).and_return(env_mock)
26
+ env_double = double 'env'
27
+ env_double.should_receive(:load).with('HEIRLOOM_CONFIG_FILE').and_return('~/.special_config.yml')
28
+ Heirloom::Env.stub(:new).and_return(env_double)
29
29
  config = Heirloom::Config.new :opts => @opts,
30
30
  :logger => 'da-logger'
31
31
  end
@@ -33,10 +33,10 @@ describe Heirloom do
33
33
  it "should open the default config file if HEIRLOOM_CONFIG_FILE is not set" do
34
34
  File.stub :exists? => true
35
35
  File.should_receive(:open).with('~/.heirloom.yml').and_return(@config_file.to_yaml)
36
- env_mock = mock 'env'
37
- env_mock.should_receive(:load).with('HEIRLOOM_CONFIG_FILE').and_return(nil)
38
- env_mock.should_receive(:load).with('HOME').and_return('~')
39
- Heirloom::Env.stub(:new).and_return(env_mock)
36
+ env_double = double 'env'
37
+ env_double.should_receive(:load).with('HEIRLOOM_CONFIG_FILE').and_return(nil)
38
+ env_double.should_receive(:load).with('HOME').and_return('~')
39
+ Heirloom::Env.stub(:new).and_return(env_double)
40
40
  config = Heirloom::Config.new :opts => @opts,
41
41
  :logger => 'da-logger'
42
42
  end
@@ -44,11 +44,11 @@ describe Heirloom do
44
44
 
45
45
  context "#reading env variables" do
46
46
  it "should return the proxy as set by https_proxy" do
47
- env_mock = mock 'env'
48
- env_mock.should_receive(:load).with('HEIRLOOM_CONFIG_FILE').and_return(nil)
49
- env_mock.should_receive(:load).with('HOME').and_return('~')
50
- env_mock.should_receive(:load).with('https_proxy').and_return('https://proxy.example.com:3128')
51
- Heirloom::Env.stub(:new).and_return(env_mock)
47
+ env_double = double 'env'
48
+ env_double.should_receive(:load).with('HEIRLOOM_CONFIG_FILE').and_return(nil)
49
+ env_double.should_receive(:load).with('HOME').and_return('~')
50
+ env_double.should_receive(:load).with('https_proxy').and_return('https://proxy.example.com:3128')
51
+ Heirloom::Env.stub(:new).and_return(env_double)
52
52
  config = Heirloom::Config.new :opts => @opts
53
53
  expect(config.proxy).to eq('https://proxy.example.com:3128')
54
54
  end
@@ -56,10 +56,10 @@ describe Heirloom do
56
56
 
57
57
  context "#with config file set" do
58
58
  before do
59
- env_mock = mock 'env'
60
- env_mock.should_receive(:load).with('HEIRLOOM_CONFIG_FILE').and_return(nil)
61
- env_mock.should_receive(:load).with('HOME').and_return('~')
62
- Heirloom::Env.stub(:new).and_return(env_mock)
59
+ env_double = double 'env'
60
+ env_double.should_receive(:load).with('HEIRLOOM_CONFIG_FILE').and_return(nil)
61
+ env_double.should_receive(:load).with('HOME').and_return('~')
62
+ Heirloom::Env.stub(:new).and_return(env_double)
63
63
  end
64
64
 
65
65
  it "should create a new config object from the hash passed as config" do
@@ -123,12 +123,12 @@ describe Heirloom do
123
123
  it "should log a warning if a non-existing environment is requested from existing config file" do
124
124
  File.stub :exists? => true
125
125
  File.should_receive(:open).with("~/.heirloom.yml").and_return(@config_file.to_yaml)
126
- logger_mock = mock 'logger'
127
- logger_mock.should_receive(:warn)
126
+ logger_double = double 'logger'
127
+ logger_double.should_receive(:warn)
128
128
 
129
- lambda {
130
- config = Heirloom::Config.new :environment => 'missing', :logger => logger_mock
131
- }.should_not raise_error SystemExit
129
+ expect {
130
+ config = Heirloom::Config.new :environment => 'missing', :logger => logger_double
131
+ }.not_to raise_error
132
132
  end
133
133
  end
134
134
  end
@@ -3,16 +3,16 @@ require 'spec_helper'
3
3
  describe Heirloom do
4
4
 
5
5
  before do
6
- @config_mock = double 'config'
7
- @s3 = Heirloom::Destroyer::S3.new :config => @config_mock,
6
+ @config_double = double 'config'
7
+ @s3 = Heirloom::Destroyer::S3.new :config => @config_double,
8
8
  :region => 'us-west-1'
9
9
  end
10
10
 
11
11
  it "should delete the specified file from s3" do
12
- s3_mock = mock 's3 mock'
13
- @s3.should_receive(:s3).and_return(s3_mock)
14
- s3_mock.should_receive(:delete_object).
15
- with('bucket', "key_folder/key_name")
12
+ s3_double = double 's3 mock'
13
+ @s3.should_receive(:s3).and_return(s3_double)
14
+ s3_double.should_receive(:delete_object).
15
+ with('bucket', "key_folder/key_name")
16
16
  @s3.destroy_file :key_name => 'key_name',
17
17
  :key_folder => 'key_folder',
18
18
  :bucket => 'bucket'
@@ -4,13 +4,13 @@ describe Heirloom::Directory do
4
4
 
5
5
  describe 'build_artifact_from_directory' do
6
6
  before do
7
- @config_mock = double 'config'
8
- @logger_stub = stub :debug => 'true',
9
- :info => 'true',
10
- :warn => 'true',
11
- :error => 'true'
12
- @config_mock.stub(:logger).and_return(@logger_stub)
13
- @directory = Heirloom::Directory.new :config => @config_mock,
7
+ @config_double = double 'config'
8
+ @logger_double = double :debug => 'true',
9
+ :info => 'true',
10
+ :warn => 'true',
11
+ :error => 'true'
12
+ @config_double.stub(:logger).and_return(@logger_double)
13
+ @directory = Heirloom::Directory.new :config => @config_double,
14
14
  :exclude => ['dont_pack_me', 'dont_pack_me1'],
15
15
  :path => '/dir',
16
16
  :file => '/tmp/file.tar.gz'
@@ -19,12 +19,12 @@ describe Heirloom::Directory do
19
19
  context 'when succesful' do
20
20
  before do
21
21
  @directory.should_receive(:which).with('tar').and_return true
22
- output_mock = double 'output mock'
22
+ output_double = double 'output double'
23
23
  command = "cd /dir && tar czf /tmp/file.tar.gz --exclude dont_pack_me --exclude dont_pack_me1 ."
24
24
  files = ['pack_me', '.hidden', 'with a space', 'dont_pack_me', 'dont_pack_me1']
25
25
  Heirloom::Directory.any_instance.should_receive(:`).
26
26
  with(command).
27
- and_return output_mock
27
+ and_return output_double
28
28
  $?.stub :success? => true
29
29
  end
30
30
 
@@ -37,17 +37,17 @@ describe Heirloom::Directory do
37
37
 
38
38
  context 'without secret provided' do
39
39
  before do
40
- @cipher_mock = mock 'cipher'
40
+ @cipher_double = double 'cipher'
41
41
  Heirloom::Cipher::File.should_receive(:new).
42
- with(:config => @config_mock).
43
- and_return @cipher_mock
42
+ with(:config => @config_double).
43
+ and_return @cipher_double
44
44
  end
45
45
 
46
46
  it "should build and encrypt an archive from the path" do
47
- @cipher_mock.should_receive(:encrypt_file).
48
- with(:file => '/tmp/file.tar.gz',
49
- :secret => 'supersecret').
50
- and_return true
47
+ @cipher_double.should_receive(:encrypt_file).
48
+ with(:file => '/tmp/file.tar.gz',
49
+ :secret => 'supersecret').
50
+ and_return true
51
51
  @directory.build_artifact_from_directory(:secret => 'supersecret').
52
52
  should be_true
53
53
  end
@@ -57,12 +57,12 @@ describe Heirloom::Directory do
57
57
  context 'when unable to create the tar' do
58
58
  before do
59
59
  @directory.should_receive(:which).with('tar').and_return true
60
- output_mock = double 'output mock'
60
+ output_double = double 'output double'
61
61
  command = "cd /dir && tar czf /tmp/file.tar.gz --exclude dont_pack_me --exclude dont_pack_me1 ."
62
62
  files = ['pack_me', '.hidden', 'with a space', 'dont_pack_me', 'dont_pack_me1']
63
63
  Heirloom::Directory.any_instance.should_receive(:`).
64
64
  with(command).
65
- and_return output_mock
65
+ and_return output_double
66
66
  $?.stub(:success?).and_return(false)
67
67
  end
68
68
 
@@ -89,7 +89,7 @@ describe Heirloom::Directory do
89
89
 
90
90
  context "parameter validation" do
91
91
  it "should not fail if exclude is nil" do
92
- @directory = Heirloom::Directory.new :config => @config_mock,
92
+ @directory = Heirloom::Directory.new :config => @config_double,
93
93
  :exclude => nil,
94
94
  :path => '/dir',
95
95
  :file => '/tmp/file.tar.gz'