asset_sync 1.0.0 → 1.1.0

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.
@@ -16,36 +16,36 @@ describe AssetSync do
16
16
  end
17
17
 
18
18
  it "should configure provider as Google" do
19
- AssetSync.config.fog_provider.should == 'Google'
20
- AssetSync.config.should be_google
19
+ expect(AssetSync.config.fog_provider).to eq('Google')
20
+ expect(AssetSync.config).to be_google
21
21
  end
22
22
 
23
23
  it "should should keep existing remote files" do
24
- AssetSync.config.existing_remote_files?.should == true
24
+ expect(AssetSync.config.existing_remote_files?).to eq(true)
25
25
  end
26
26
 
27
27
  it "should configure google_storage_access_key_id" do
28
- AssetSync.config.google_storage_access_key_id.should == "aaaa"
28
+ expect(AssetSync.config.google_storage_access_key_id).to eq("aaaa")
29
29
  end
30
30
 
31
31
  it "should configure google_storage_secret_access_key" do
32
- AssetSync.config.google_storage_secret_access_key.should == "bbbb"
32
+ expect(AssetSync.config.google_storage_secret_access_key).to eq("bbbb")
33
33
  end
34
34
 
35
35
  it "should configure fog_directory" do
36
- AssetSync.config.fog_directory.should == "mybucket"
36
+ expect(AssetSync.config.fog_directory).to eq("mybucket")
37
37
  end
38
38
 
39
39
  it "should configure existing_remote_files" do
40
- AssetSync.config.existing_remote_files.should == "keep"
40
+ expect(AssetSync.config.existing_remote_files).to eq("keep")
41
41
  end
42
42
 
43
43
  it "should default gzip_compression to false" do
44
- AssetSync.config.gzip_compression.should be_false
44
+ expect(AssetSync.config.gzip_compression).to be_falsey
45
45
  end
46
46
 
47
47
  it "should default manifest to false" do
48
- AssetSync.config.manifest.should be_false
48
+ expect(AssetSync.config.manifest).to be_falsey
49
49
  end
50
50
  end
51
51
 
@@ -56,27 +56,27 @@ describe AssetSync do
56
56
  end
57
57
 
58
58
  it "should configure google_storage_access_key_id" do
59
- AssetSync.config.google_storage_access_key_id.should == "xxxx"
59
+ expect(AssetSync.config.google_storage_access_key_id).to eq("xxxx")
60
60
  end
61
61
 
62
62
  it "should configure google_storage_secret_access_key" do
63
- AssetSync.config.google_storage_secret_access_key.should == "zzzz"
63
+ expect(AssetSync.config.google_storage_secret_access_key).to eq("zzzz")
64
64
  end
65
65
 
66
66
  it "should configure google_storage_access_key" do
67
- AssetSync.config.fog_directory.should == "rails_app_test"
67
+ expect(AssetSync.config.fog_directory).to eq("rails_app_test")
68
68
  end
69
69
 
70
70
  it "should configure google_storage_access_key" do
71
- AssetSync.config.existing_remote_files.should == "keep"
71
+ expect(AssetSync.config.existing_remote_files).to eq("keep")
72
72
  end
73
73
 
74
74
  it "should default gzip_compression to false" do
75
- AssetSync.config.gzip_compression.should be_false
75
+ expect(AssetSync.config.gzip_compression).to be_falsey
76
76
  end
77
77
 
78
78
  it "should default manifest to false" do
79
- AssetSync.config.manifest.should be_false
79
+ expect(AssetSync.config.manifest).to be_falsey
80
80
  end
81
81
  end
82
82
 
@@ -92,7 +92,7 @@ describe AssetSync do
92
92
 
93
93
  describe 'with fail_silent configuration' do
94
94
  before(:each) do
95
- AssetSync.stub(:stderr).and_return(StringIO.new)
95
+ allow(AssetSync).to receive(:stderr).and_return(StringIO.new)
96
96
  AssetSync.config = AssetSync::Config.new
97
97
  AssetSync.configure do |config|
98
98
  config.fail_silently = true
@@ -111,7 +111,7 @@ describe AssetSync do
111
111
  end
112
112
 
113
113
  it "config.gzip? should be true" do
114
- AssetSync.config.gzip?.should be_true
114
+ expect(AssetSync.config.gzip?).to be_truthy
115
115
  end
116
116
  end
117
117
 
@@ -122,21 +122,21 @@ describe AssetSync do
122
122
  end
123
123
 
124
124
  it "config.manifest should be true" do
125
- AssetSync.config.manifest.should be_true
125
+ expect(AssetSync.config.manifest).to be_truthy
126
126
  end
127
127
 
128
128
  it "config.manifest_path should default to public/assets.." do
129
- AssetSync.config.manifest_path.should =~ /public\/assets\/manifest.yml/
129
+ expect(AssetSync.config.manifest_path).to match(/public\/assets\/manifest.yml/)
130
130
  end
131
131
 
132
132
  it "config.manifest_path should default to public/assets.." do
133
133
  Rails.application.config.assets.manifest = "/var/assets"
134
- AssetSync.config.manifest_path.should == "/var/assets/manifest.yml"
134
+ expect(AssetSync.config.manifest_path).to eq("/var/assets/manifest.yml")
135
135
  end
136
136
 
137
137
  it "config.manifest_path should default to public/custom_assets.." do
138
138
  Rails.application.config.assets.prefix = 'custom_assets'
139
- AssetSync.config.manifest_path.should =~ /public\/custom_assets\/manifest.yml/
139
+ expect(AssetSync.config.manifest_path).to match(/public\/custom_assets\/manifest.yml/)
140
140
  end
141
141
  end
142
142
  end
@@ -21,9 +21,8 @@ describe AssetSync::MultiMime do
21
21
  describe 'Mime::Type' do
22
22
 
23
23
  it 'should detect mime type' do
24
- pending "Fails on Travis CI only as of https://travis-ci.org/rumblelabs/asset_sync/builds/4188196"
25
24
  require 'rails'
26
- AssetSync::MultiMime.lookup('css').should == "text/css"
25
+ expect(AssetSync::MultiMime.lookup('css')).to eq("text/css")
27
26
  end
28
27
 
29
28
  end
@@ -32,7 +31,7 @@ describe AssetSync::MultiMime do
32
31
 
33
32
  it 'should detect mime type' do
34
33
  require 'rack/mime'
35
- AssetSync::MultiMime.lookup('css').should == "text/css"
34
+ expect(AssetSync::MultiMime.lookup('css')).to eq("text/css")
36
35
  end
37
36
 
38
37
  end
@@ -41,9 +40,9 @@ describe AssetSync::MultiMime do
41
40
 
42
41
  it 'should detect mime type' do
43
42
  require 'mime/types'
44
- AssetSync::MultiMime.lookup('css').should == "text/css"
43
+ expect(AssetSync::MultiMime.lookup('css')).to eq("text/css")
45
44
  end
46
45
 
47
46
  end
48
47
 
49
- end
48
+ end
@@ -18,40 +18,40 @@ describe AssetSync do
18
18
  end
19
19
 
20
20
  it "should configure provider as Rackspace" do
21
- AssetSync.config.fog_provider.should == 'Rackspace'
22
- AssetSync.config.should be_rackspace
21
+ expect(AssetSync.config.fog_provider).to eq('Rackspace')
22
+ expect(AssetSync.config).to be_rackspace
23
23
  end
24
24
 
25
25
  it "should keep existing remote files" do
26
- AssetSync.config.existing_remote_files?.should == true
26
+ expect(AssetSync.config.existing_remote_files?).to eq(true)
27
27
  end
28
28
 
29
29
  it "should configure rackspace_username" do
30
- AssetSync.config.rackspace_username.should == "aaaa"
30
+ expect(AssetSync.config.rackspace_username).to eq("aaaa")
31
31
  end
32
32
 
33
33
  it "should configure rackspace_api_key" do
34
- AssetSync.config.rackspace_api_key.should == "bbbb"
34
+ expect(AssetSync.config.rackspace_api_key).to eq("bbbb")
35
35
  end
36
36
 
37
37
  it "should configure fog_directory" do
38
- AssetSync.config.fog_directory.should == "mybucket"
38
+ expect(AssetSync.config.fog_directory).to eq("mybucket")
39
39
  end
40
40
 
41
41
  it "should configure fog_region" do
42
- AssetSync.config.fog_region.should == "dunno"
42
+ expect(AssetSync.config.fog_region).to eq("dunno")
43
43
  end
44
44
 
45
45
  it "should configure existing_remote_files" do
46
- AssetSync.config.existing_remote_files.should == "keep"
46
+ expect(AssetSync.config.existing_remote_files).to eq("keep")
47
47
  end
48
48
 
49
49
  it "should configure existing_remote_files" do
50
- AssetSync.config.existing_remote_files.should == "keep"
50
+ expect(AssetSync.config.existing_remote_files).to eq("keep")
51
51
  end
52
52
 
53
53
  it "should default rackspace_auth_url to false" do
54
- AssetSync.config.rackspace_auth_url.should be_false
54
+ expect(AssetSync.config.rackspace_auth_url).to be_falsey
55
55
  end
56
56
 
57
57
  end
@@ -64,27 +64,27 @@ describe AssetSync do
64
64
  end
65
65
 
66
66
  it "should keep existing remote files" do
67
- AssetSync.config.existing_remote_files?.should == true
67
+ expect(AssetSync.config.existing_remote_files?).to eq(true)
68
68
  end
69
69
 
70
70
  it "should configure rackspace_username" do
71
- AssetSync.config.rackspace_username.should == "xxxx"
71
+ expect(AssetSync.config.rackspace_username).to eq("xxxx")
72
72
  end
73
73
 
74
74
  it "should configure rackspace_api_key" do
75
- AssetSync.config.rackspace_api_key.should == "zzzz"
75
+ expect(AssetSync.config.rackspace_api_key).to eq("zzzz")
76
76
  end
77
77
 
78
78
  it "should configure fog_directory" do
79
- AssetSync.config.fog_directory.should == "rails_app_test"
79
+ expect(AssetSync.config.fog_directory).to eq("rails_app_test")
80
80
  end
81
81
 
82
82
  it "should configure fog_region" do
83
- AssetSync.config.fog_region.should == "eu-west-1"
83
+ expect(AssetSync.config.fog_region).to eq("eu-west-1")
84
84
  end
85
85
 
86
86
  it "should configure existing_remote_files" do
87
- AssetSync.config.existing_remote_files.should == "keep"
87
+ expect(AssetSync.config.existing_remote_files).to eq("keep")
88
88
  end
89
89
  end
90
90
  end
@@ -19,53 +19,53 @@ describe AssetSync do
19
19
  end
20
20
 
21
21
  it "should have prefix of assets" do
22
- AssetSync.config.prefix.should == "assets"
22
+ expect(AssetSync.config.prefix).to eq("assets")
23
23
  end
24
24
 
25
25
  it "should have prefix of assets" do
26
- AssetSync.config.public_path.to_s.should == "./public"
26
+ expect(AssetSync.config.public_path.to_s).to eq("./public")
27
27
  end
28
28
 
29
29
  it "should default AssetSync to enabled" do
30
- AssetSync.config.enabled?.should be_true
31
- AssetSync.enabled?.should be_true
30
+ expect(AssetSync.config.enabled?).to be_truthy
31
+ expect(AssetSync.enabled?).to be_truthy
32
32
  end
33
33
 
34
34
  it "should configure provider as AWS" do
35
- AssetSync.config.fog_provider.should == 'AWS'
36
- AssetSync.config.should be_aws
35
+ expect(AssetSync.config.fog_provider).to eq('AWS')
36
+ expect(AssetSync.config).to be_aws
37
37
  end
38
38
 
39
39
  it "should should keep existing remote files" do
40
- AssetSync.config.existing_remote_files?.should == true
40
+ expect(AssetSync.config.existing_remote_files?).to eq(true)
41
41
  end
42
42
 
43
43
  it "should configure aws_access_key" do
44
- AssetSync.config.aws_access_key_id.should == "aaaa"
44
+ expect(AssetSync.config.aws_access_key_id).to eq("aaaa")
45
45
  end
46
46
 
47
47
  it "should configure aws_secret_access_key" do
48
- AssetSync.config.aws_secret_access_key.should == "bbbb"
48
+ expect(AssetSync.config.aws_secret_access_key).to eq("bbbb")
49
49
  end
50
50
 
51
51
  it "should configure aws_access_key" do
52
- AssetSync.config.fog_directory.should == "mybucket"
52
+ expect(AssetSync.config.fog_directory).to eq("mybucket")
53
53
  end
54
54
 
55
55
  it "should configure fog_region" do
56
- AssetSync.config.fog_region.should == "eu-west-1"
56
+ expect(AssetSync.config.fog_region).to eq("eu-west-1")
57
57
  end
58
58
 
59
59
  it "should configure existing_remote_files" do
60
- AssetSync.config.existing_remote_files.should == "keep"
60
+ expect(AssetSync.config.existing_remote_files).to eq("keep")
61
61
  end
62
62
 
63
63
  it "should default gzip_compression to false" do
64
- AssetSync.config.gzip_compression.should be_false
64
+ expect(AssetSync.config.gzip_compression).to be_falsey
65
65
  end
66
66
 
67
67
  it "should default manifest to false" do
68
- AssetSync.config.manifest.should be_false
68
+ expect(AssetSync.config.manifest).to be_falsey
69
69
  end
70
70
 
71
71
  end
@@ -13,11 +13,11 @@ describe AssetSync::Storage do
13
13
  it 'should overwrite all remote files if set to ignore' do
14
14
  @config.existing_remote_files = 'ignore'
15
15
  storage = AssetSync::Storage.new(@config)
16
- storage.stub(:local_files).and_return(@local_files)
17
- File.stub(:file?).and_return(true) # Pretend they all exist
16
+ allow(storage).to receive(:local_files).and_return(@local_files)
17
+ allow(File).to receive(:file?).and_return(true) # Pretend they all exist
18
18
 
19
19
  @local_files.each do |file|
20
- storage.should_receive(:upload_file).with(file)
20
+ expect(storage).to receive(:upload_file).with(file)
21
21
  end
22
22
  storage.upload_files
23
23
  end
@@ -26,12 +26,12 @@ describe AssetSync::Storage do
26
26
  @config.always_upload = ['local_image.jpg']
27
27
 
28
28
  storage = AssetSync::Storage.new(@config)
29
- storage.stub(:local_files).and_return(@local_files)
30
- storage.stub(:get_remote_files).and_return(@remote_files)
31
- File.stub(:file?).and_return(true) # Pretend they all exist
29
+ allow(storage).to receive(:local_files).and_return(@local_files)
30
+ allow(storage).to receive(:get_remote_files).and_return(@remote_files)
31
+ allow(File).to receive(:file?).and_return(true) # Pretend they all exist
32
32
 
33
33
  (@local_files - @remote_files + storage.always_upload_files).each do |file|
34
- storage.should_receive(:upload_file).with(file)
34
+ expect(storage).to receive(:upload_file).with(file)
35
35
  end
36
36
  storage.upload_files
37
37
  end
@@ -40,12 +40,12 @@ describe AssetSync::Storage do
40
40
  @config.ignored_files = ['local_image1.jpg', /local_stylesheet\d\.css/]
41
41
 
42
42
  storage = AssetSync::Storage.new(@config)
43
- storage.stub(:local_files).and_return(@local_files)
44
- storage.stub(:get_remote_files).and_return(@remote_files)
45
- File.stub(:file?).and_return(true) # Pretend they all exist
43
+ allow(storage).to receive(:local_files).and_return(@local_files)
44
+ allow(storage).to receive(:get_remote_files).and_return(@remote_files)
45
+ allow(File).to receive(:file?).and_return(true) # Pretend they all exist
46
46
 
47
47
  (@local_files - @remote_files - storage.ignored_files + storage.always_upload_files).each do |file|
48
- storage.should_receive(:upload_file).with(file)
48
+ expect(storage).to receive(:upload_file).with(file)
49
49
  end
50
50
  storage.upload_files
51
51
  end
@@ -68,16 +68,16 @@ describe AssetSync::Storage do
68
68
  ]
69
69
 
70
70
  storage = AssetSync::Storage.new(@config)
71
- storage.stub(:local_files).and_return(@local_files)
72
- storage.stub(:get_remote_files).and_return(@remote_files)
73
- File.stub(:file?).and_return(true) # Pretend they all exist
71
+ allow(storage).to receive(:local_files).and_return(@local_files)
72
+ allow(storage).to receive(:get_remote_files).and_return(@remote_files)
73
+ allow(File).to receive(:file?).and_return(true) # Pretend they all exist
74
74
 
75
75
  updated_nonfingerprinted_files = [
76
76
  'public/image.png',
77
77
  'public/application.js',
78
78
  ]
79
79
  (@local_files - @remote_files + updated_nonfingerprinted_files).each do |file|
80
- storage.should_receive(:upload_file).with(file)
80
+ expect(storage).to receive(:upload_file).with(file)
81
81
  end
82
82
  storage.upload_files
83
83
  end
@@ -88,19 +88,19 @@ describe AssetSync::Storage do
88
88
  local_files += ['dir1/dir2/file2.jpg', 'dir1/dir2/file2-1234567890abcdef1234567890abcdef.jpg']
89
89
  remote_files = []
90
90
  storage = AssetSync::Storage.new(@config)
91
- storage.stub(:local_files).and_return(local_files)
92
- storage.stub(:get_remote_files).and_return(remote_files)
93
- File.stub(:file?).and_return(true)
94
- File.stub(:open).and_return(nil)
91
+ allow(storage).to receive(:local_files).and_return(local_files)
92
+ allow(storage).to receive(:get_remote_files).and_return(remote_files)
93
+ allow(File).to receive(:file?).and_return(true)
94
+ allow(File).to receive(:open).and_return(nil)
95
95
 
96
96
  def check_file(file)
97
97
  case file[:key]
98
98
  when 'file1.jpg'
99
99
  when 'dir1/dir2/file2.jpg'
100
- !file.should_not include(:cache_control, :expires)
100
+ !expect(file).not_to include(:cache_control, :expires)
101
101
  when 'file1-1234567890abcdef1234567890abcdef.jpg'
102
102
  when 'dir1/dir2/file2-1234567890abcdef1234567890abcdef.jpg'
103
- file.should include(:cache_control, :expires)
103
+ expect(file).to include(:cache_control, :expires)
104
104
  else
105
105
  fail
106
106
  end
@@ -108,9 +108,9 @@ describe AssetSync::Storage do
108
108
 
109
109
  files = double()
110
110
  local_files.count.times do
111
- files.should_receive(:create) { |file| check_file(file) }
111
+ expect(files).to receive(:create) { |file| check_file(file) }
112
112
  end
113
- storage.stub_chain(:bucket, :files).and_return(files)
113
+ allow(storage).to receive_message_chain(:bucket, :files).and_return(files)
114
114
  storage.upload_files
115
115
  end
116
116
 
@@ -120,13 +120,13 @@ describe AssetSync::Storage do
120
120
  @config.fog_provider = 'AWS'
121
121
 
122
122
  storage = AssetSync::Storage.new(@config)
123
- storage.stub(:local_files).and_return(@local_files)
124
- storage.stub(:get_remote_files).and_return(@remote_files)
125
- storage.stub(:upload_file).and_return(true)
123
+ allow(storage).to receive(:local_files).and_return(@local_files)
124
+ allow(storage).to receive(:get_remote_files).and_return(@remote_files)
125
+ allow(storage).to receive(:upload_file).and_return(true)
126
126
 
127
- mock_cdn = mock
128
- Fog::CDN.should_receive(:new).and_return(mock_cdn)
129
- mock_cdn.should_receive(:post_invalidation).with("1234", ["/assets/local_image1.jpg"]).and_return(stub({:body => {:id => '1234'}}))
127
+ mock_cdn = double
128
+ expect(Fog::CDN).to receive(:new).and_return(mock_cdn)
129
+ expect(mock_cdn).to receive(:post_invalidation).with("1234", ["/assets/local_image1.jpg"]).and_return(double({:body => {:id => '1234'}}))
130
130
 
131
131
  storage.upload_files
132
132
  end
@@ -136,7 +136,7 @@ describe AssetSync::Storage do
136
136
  before(:each) do
137
137
  # Object#remove_const does not remove the loaded
138
138
  # file from the $" variable
139
- Object.send(:remove_const, :MIME) if defined?(MIME)
139
+ #Object.send(:remove_const, :MIME) if defined?(MIME)
140
140
  mime_types = $".grep(/mime\/types/).first
141
141
  $".delete(mime_types)
142
142
  require 'mime/types'
@@ -150,18 +150,18 @@ describe AssetSync::Storage do
150
150
  }
151
151
  }
152
152
  storage = AssetSync::Storage.new(@config)
153
- storage.stub(:local_files).and_return(@local_files)
154
- storage.stub(:get_remote_files).and_return(@remote_files)
155
- File.stub(:open).and_return('file') # Pretend they all exist
153
+ allow(storage).to receive(:local_files).and_return(@local_files)
154
+ allow(storage).to receive(:get_remote_files).and_return(@remote_files)
155
+ allow(File).to receive(:open).and_return('file') # Pretend they all exist
156
156
 
157
157
  bucket = double
158
158
  files = double
159
159
 
160
- storage.stub(:bucket).and_return(bucket)
161
- bucket.stub(:files).and_return(files)
160
+ allow(storage).to receive(:bucket).and_return(bucket)
161
+ allow(bucket).to receive(:files).and_return(files)
162
162
 
163
- files.should_receive(:create) do |argument|
164
- argument[:cache_control].should == 'max-age=0'
163
+ expect(files).to receive(:create) do |argument|
164
+ expect(argument[:cache_control]).to eq('max-age=0')
165
165
  end
166
166
  storage.upload_file('assets/local_image2.jpg')
167
167
  end
@@ -173,22 +173,22 @@ describe AssetSync::Storage do
173
173
  }
174
174
  }
175
175
  storage = AssetSync::Storage.new(@config)
176
- storage.stub(:local_files).and_return(@local_files)
177
- storage.stub(:get_remote_files).and_return(@remote_files)
178
- File.stub(:open).and_return('file') # Pretend they all exist
179
- bucket = mock
180
- files = mock
181
- storage.stub(:bucket).and_return(bucket)
182
- bucket.stub(:files).and_return(files)
183
-
184
- files.should_receive(:create) do |argument|
185
- argument[:cache_control].should == 'max-age=0'
176
+ allow(storage).to receive(:local_files).and_return(@local_files)
177
+ allow(storage).to receive(:get_remote_files).and_return(@remote_files)
178
+ allow(File).to receive(:open).and_return('file') # Pretend they all exist
179
+ bucket = double
180
+ files = double
181
+ allow(storage).to receive(:bucket).and_return(bucket)
182
+ allow(bucket).to receive(:files).and_return(files)
183
+
184
+ expect(files).to receive(:create) do |argument|
185
+ expect(argument[:cache_control]).to eq('max-age=0')
186
186
  end
187
187
  storage.upload_file('assets/some_longer_path/local_image2.jpg')
188
188
  end
189
189
 
190
190
  after(:each) do
191
- Object.send(:remove_const, :MIME) if defined?(MIME)
191
+ #Object.send(:remove_const, :MIME) if defined?(MIME)
192
192
  end
193
193
  end
194
194
  end