asset_cloud 2.7.1 → 2.7.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 (55) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +6 -0
  3. data/.github/workflows/ci.yml +21 -7
  4. data/.github/workflows/cla.yml +22 -0
  5. data/.gitignore +0 -1
  6. data/.rubocop.yml +0 -1
  7. data/.ruby-version +1 -0
  8. data/Gemfile +5 -3
  9. data/Gemfile.lock +180 -0
  10. data/History.md +9 -0
  11. data/README.rdoc +1 -3
  12. data/Rakefile +18 -16
  13. data/asset_cloud.gemspec +19 -18
  14. data/dev.yml +1 -2
  15. data/lib/asset_cloud/asset.rb +17 -13
  16. data/lib/asset_cloud/asset_extension.rb +27 -15
  17. data/lib/asset_cloud/base.rb +77 -72
  18. data/lib/asset_cloud/bucket.rb +5 -2
  19. data/lib/asset_cloud/buckets/active_record_bucket.rb +16 -14
  20. data/lib/asset_cloud/buckets/blackhole_bucket.rb +2 -0
  21. data/lib/asset_cloud/buckets/bucket_chain.rb +38 -31
  22. data/lib/asset_cloud/buckets/file_system_bucket.rb +14 -15
  23. data/lib/asset_cloud/buckets/gcs_bucket.rb +6 -8
  24. data/lib/asset_cloud/buckets/invalid_bucket.rb +9 -6
  25. data/lib/asset_cloud/buckets/memory_bucket.rb +7 -4
  26. data/lib/asset_cloud/buckets/s3_bucket.rb +11 -8
  27. data/lib/asset_cloud/buckets/versioned_memory_bucket.rb +4 -2
  28. data/lib/asset_cloud/callbacks.rb +24 -16
  29. data/lib/asset_cloud/free_key_locator.rb +6 -6
  30. data/lib/asset_cloud/metadata.rb +11 -7
  31. data/lib/asset_cloud/validations.rb +9 -5
  32. data/lib/asset_cloud.rb +24 -22
  33. data/spec/active_record_bucket_spec.rb +27 -26
  34. data/spec/asset_cloud/metadata_spec.rb +4 -2
  35. data/spec/asset_extension_spec.rb +17 -16
  36. data/spec/asset_spec.rb +27 -21
  37. data/spec/base_spec.rb +93 -92
  38. data/spec/blackhole_bucket_spec.rb +12 -11
  39. data/spec/bucket_chain_spec.rb +61 -56
  40. data/spec/bucket_spec.rb +6 -5
  41. data/spec/callbacks_spec.rb +65 -39
  42. data/spec/file_system_spec.rb +25 -24
  43. data/spec/find_free_key_spec.rb +16 -17
  44. data/spec/gcs_bucket_remote_spec.rb +23 -22
  45. data/spec/gcs_bucket_spec.rb +48 -60
  46. data/spec/memory_bucket_spec.rb +12 -11
  47. data/spec/mock_s3_interface.rb +17 -6
  48. data/spec/remote_s3_bucket_spec.rb +31 -28
  49. data/spec/s3_bucket_spec.rb +19 -17
  50. data/spec/spec_helper.rb +8 -7
  51. data/spec/validations_spec.rb +13 -12
  52. data/spec/versioned_memory_bucket_spec.rb +11 -10
  53. metadata +13 -36
  54. data/.github/probots.yml +0 -2
  55. data/.rubocop_todo.yml +0 -326
data/spec/asset_spec.rb CHANGED
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+
3
+ require "spec_helper"
3
4
 
4
5
  describe "Asset" do
5
6
  include AssetCloud
6
7
 
7
8
  before do
8
- @cloud = double('Cloud', asset_extension_classes_for_bucket: [])
9
+ @cloud = double("Cloud", asset_extension_classes_for_bucket: [])
9
10
  end
10
11
 
11
12
  describe "when first created (without a value)" do
@@ -18,7 +19,7 @@ describe "Asset" do
18
19
  end
19
20
 
20
21
  it "should have a key" do
21
- expect(@asset.key).to(eq('products/key.txt'))
22
+ expect(@asset.key).to(eq("products/key.txt"))
22
23
  end
23
24
 
24
25
  it "should have a value of nil" do
@@ -26,23 +27,23 @@ describe "Asset" do
26
27
  end
27
28
 
28
29
  it "should have a basename" do
29
- expect(@asset.basename).to(eq('key.txt'))
30
+ expect(@asset.basename).to(eq("key.txt"))
30
31
  end
31
32
 
32
33
  it "should have a basename without ext (if required)" do
33
- expect(@asset.basename_without_ext).to(eq('key'))
34
+ expect(@asset.basename_without_ext).to(eq("key"))
34
35
  end
35
36
 
36
37
  it "should have an ext" do
37
- expect(@asset.extname).to(eq('.txt'))
38
+ expect(@asset.extname).to(eq(".txt"))
38
39
  end
39
40
 
40
41
  it "should have a relative_key_without_ext" do
41
- expect(@asset.relative_key_without_ext).to(eq('key'))
42
+ expect(@asset.relative_key_without_ext).to(eq("key"))
42
43
  end
43
44
 
44
45
  it "should have a bucket_name" do
45
- expect(@asset.bucket_name).to(eq('products'))
46
+ expect(@asset.bucket_name).to(eq("products"))
46
47
  end
47
48
 
48
49
  it "should have a bucket" do
@@ -51,9 +52,9 @@ describe "Asset" do
51
52
  end
52
53
 
53
54
  it "should store data to the bucket" do
54
- expect(@cloud).to(receive(:write).with("products/key.txt", 'value'))
55
+ expect(@cloud).to(receive(:write).with("products/key.txt", "value"))
55
56
 
56
- @asset.value = 'value'
57
+ @asset.value = "value"
57
58
  @asset.store
58
59
  end
59
60
 
@@ -82,17 +83,17 @@ describe "Asset" do
82
83
  end
83
84
 
84
85
  it "should have a relative_key_without_ext" do
85
- expect(@asset.relative_key_without_ext).to(eq('retail/key'))
86
+ expect(@asset.relative_key_without_ext).to(eq("retail/key"))
86
87
  end
87
88
 
88
89
  it "should have a relative_key" do
89
- expect(@asset.relative_key).to(eq('retail/key.txt'))
90
+ expect(@asset.relative_key).to(eq("retail/key.txt"))
90
91
  end
91
92
  end
92
93
 
93
94
  describe "when first created with value" do
94
95
  before do
95
- @asset = AssetCloud::Asset.new(@cloud, "products/key.txt", 'value')
96
+ @asset = AssetCloud::Asset.new(@cloud, "products/key.txt", "value")
96
97
  end
97
98
 
98
99
  it "should be return new_asset? => true" do
@@ -100,7 +101,7 @@ describe "Asset" do
100
101
  end
101
102
 
102
103
  it "should have a value of 'value'" do
103
- expect(@asset.value).to(eq('value'))
104
+ expect(@asset.value).to(eq("value"))
104
105
  end
105
106
 
106
107
  it "should return false when asked if it exists because its still a new_asset" do
@@ -110,18 +111,23 @@ describe "Asset" do
110
111
  it "should not try to read data from bucket if its a new_asset" do
111
112
  expect(@cloud).to(receive(:read).never)
112
113
 
113
- expect(@asset.value).to(eq('value'))
114
+ expect(@asset.value).to(eq("value"))
114
115
  end
115
116
 
116
117
  it "should write data to the bucket" do
117
- expect(@cloud).to(receive(:write).with("products/key.txt", 'value'))
118
+ expect(@cloud).to(receive(:write).with("products/key.txt", "value"))
118
119
  @asset.store
119
120
  end
120
121
  end
121
122
 
122
123
  describe "when fetched from the bucket" do
123
124
  before do
124
- @asset = AssetCloud::Asset.at(@cloud, "products/key.txt", 'value', AssetCloud::Metadata.new(true, 'value'.size, Time.now, Time.now))
125
+ @asset = AssetCloud::Asset.at(
126
+ @cloud,
127
+ "products/key.txt",
128
+ "value",
129
+ AssetCloud::Metadata.new(true, "value".size, Time.now, Time.now),
130
+ )
125
131
  end
126
132
 
127
133
  it "should be return new_asset? => false" do
@@ -133,7 +139,7 @@ describe "Asset" do
133
139
  end
134
140
 
135
141
  it "should read the value from the bucket" do
136
- expect(@asset.value).to(eq('value'))
142
+ expect(@asset.value).to(eq("value"))
137
143
  end
138
144
 
139
145
  it "should simply ignore calls to delete" do
@@ -143,13 +149,13 @@ describe "Asset" do
143
149
  end
144
150
 
145
151
  it "should ask the bucket to create a full url" do
146
- expect(@cloud).to(receive(:url_for).with('products/key.txt', {}).and_return('http://assets/products/key.txt'))
152
+ expect(@cloud).to(receive(:url_for).with("products/key.txt", {}).and_return("http://assets/products/key.txt"))
147
153
 
148
- expect(@asset.url).to(eq('http://assets/products/key.txt'))
154
+ expect(@asset.url).to(eq("http://assets/products/key.txt"))
149
155
  end
150
156
 
151
157
  it "should ask the bucket whether or not it is versioned" do
152
- bucket = double('Bucket')
158
+ bucket = double("Bucket")
153
159
  expect(@cloud).to(receive(:buckets).and_return(products: bucket))
154
160
  expect(bucket).to(receive(:versioned?).and_return(true))
155
161
 
data/spec/base_spec.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+
3
+ require "spec_helper"
3
4
 
4
5
  class SpecialAsset < AssetCloud::Asset
5
6
  end
@@ -16,182 +17,182 @@ end
16
17
  class BasicCloud < AssetCloud::Base
17
18
  bucket :special, AssetCloud::MemoryBucket, asset_class: SpecialAsset
18
19
  bucket :conditional, AssetCloud::MemoryBucket, asset_class: proc { |key|
19
- LiquidAsset if key.ends_with?('.liquid')
20
+ LiquidAsset if key.ends_with?(".liquid")
20
21
  }
21
22
  bucket :broken, BrokenBucket, asset_class: AssetCloud::Asset
22
23
  end
23
24
 
24
25
  describe BasicCloud do
25
- directory = File.dirname(__FILE__) + '/files'
26
+ directory = File.dirname(__FILE__) + "/files"
26
27
 
27
28
  before do
28
- @fs = BasicCloud.new(directory, 'http://assets/files')
29
+ @fs = BasicCloud.new(directory, "http://assets/files")
29
30
  end
30
31
 
31
32
  it "should raise invalid bucket if none is given" do
32
- expect(@fs['image.jpg'].exist?).to(eq(false))
33
+ expect(@fs["image.jpg"].exist?).to(eq(false))
33
34
  end
34
35
 
35
36
  it "should be backed by a file system bucket" do
36
- expect(@fs['products/key.txt'].exist?).to(eq(true))
37
+ expect(@fs["products/key.txt"].exist?).to(eq(true))
37
38
  end
38
39
 
39
40
  it "should raise when listing non existing buckets" do
40
- expect(@fs.ls('products')).to(eq([AssetCloud::Asset.new(@fs, 'products/key.txt')]))
41
+ expect(@fs.ls("products")).to(eq([AssetCloud::Asset.new(@fs, "products/key.txt")]))
41
42
  end
42
43
 
43
44
  it "should allow you to create new assets" do
44
- obj = @fs.build('new_file.test')
45
+ obj = @fs.build("new_file.test")
45
46
  expect(obj).to(be_an_instance_of(AssetCloud::Asset))
46
47
  expect(obj.cloud).to(be_an_instance_of(BasicCloud))
47
48
  end
48
49
 
49
50
  it "should raise error when using with minus relative or absolute paths" do
50
- expect { @fs['../test'] }.to(raise_error(AssetCloud::IllegalPath))
51
- expect { @fs['/test'] }.to(raise_error(AssetCloud::IllegalPath))
52
- expect { @fs['.../test'] }.to(raise_error(AssetCloud::IllegalPath))
53
- expect { @fs['./test'] }.to(raise_error(AssetCloud::IllegalPath))
51
+ expect { @fs["../test"] }.to(raise_error(AssetCloud::IllegalPath))
52
+ expect { @fs["/test"] }.to(raise_error(AssetCloud::IllegalPath))
53
+ expect { @fs[".../test"] }.to(raise_error(AssetCloud::IllegalPath))
54
+ expect { @fs["./test"] }.to(raise_error(AssetCloud::IllegalPath))
54
55
  end
55
56
 
56
57
  it "should raise error when filename has trailing period" do
57
- expect { @fs['test.'] }.to(raise_error(AssetCloud::IllegalPath))
58
- expect { @fs['/test/testfile.'] }.to(raise_error(AssetCloud::IllegalPath))
59
- expect { @fs['test/directory/.'] }.to(raise_error(AssetCloud::IllegalPath))
60
- expect { @fs['/test/testfile .'] }.to(raise_error(AssetCloud::IllegalPath))
61
- expect { @fs['test/directory /.'] }.to(raise_error(AssetCloud::IllegalPath))
58
+ expect { @fs["test."] }.to(raise_error(AssetCloud::IllegalPath))
59
+ expect { @fs["/test/testfile."] }.to(raise_error(AssetCloud::IllegalPath))
60
+ expect { @fs["test/directory/."] }.to(raise_error(AssetCloud::IllegalPath))
61
+ expect { @fs["/test/testfile ."] }.to(raise_error(AssetCloud::IllegalPath))
62
+ expect { @fs["test/directory /."] }.to(raise_error(AssetCloud::IllegalPath))
62
63
  end
63
64
 
64
65
  it "should raise error when filename ends with space" do
65
- expect { @fs['test '] }.to(raise_error(AssetCloud::IllegalPath))
66
- expect { @fs['/test/testfile '] }.to(raise_error(AssetCloud::IllegalPath))
67
- expect { @fs['test/directory/ '] }.to(raise_error(AssetCloud::IllegalPath))
68
- expect { @fs['test. '] }.to(raise_error(AssetCloud::IllegalPath))
69
- expect { @fs['/test/testfile. '] }.to(raise_error(AssetCloud::IllegalPath))
70
- expect { @fs['test/directory/. '] }.to(raise_error(AssetCloud::IllegalPath))
66
+ expect { @fs["test "] }.to(raise_error(AssetCloud::IllegalPath))
67
+ expect { @fs["/test/testfile "] }.to(raise_error(AssetCloud::IllegalPath))
68
+ expect { @fs["test/directory/ "] }.to(raise_error(AssetCloud::IllegalPath))
69
+ expect { @fs["test. "] }.to(raise_error(AssetCloud::IllegalPath))
70
+ expect { @fs["/test/testfile. "] }.to(raise_error(AssetCloud::IllegalPath))
71
+ expect { @fs["test/directory/. "] }.to(raise_error(AssetCloud::IllegalPath))
71
72
  end
72
73
 
73
74
  it "should raise error when filename ends with slash" do
74
- expect { @fs['test/'] }.to(raise_error(AssetCloud::IllegalPath))
75
- expect { @fs['test/directory/'] }.to(raise_error(AssetCloud::IllegalPath))
76
- expect { @fs['test /'] }.to(raise_error(AssetCloud::IllegalPath))
77
- expect { @fs['/test/testfile /'] }.to(raise_error(AssetCloud::IllegalPath))
78
- expect { @fs['test/directory//'] }.to(raise_error(AssetCloud::IllegalPath))
75
+ expect { @fs["test/"] }.to(raise_error(AssetCloud::IllegalPath))
76
+ expect { @fs["test/directory/"] }.to(raise_error(AssetCloud::IllegalPath))
77
+ expect { @fs["test /"] }.to(raise_error(AssetCloud::IllegalPath))
78
+ expect { @fs["/test/testfile /"] }.to(raise_error(AssetCloud::IllegalPath))
79
+ expect { @fs["test/directory//"] }.to(raise_error(AssetCloud::IllegalPath))
79
80
  end
80
81
 
81
82
  it "should raise error when using with minus relative even after another directory" do
82
- expect { @fs['test/../test'] }.to(raise_error(AssetCloud::IllegalPath))
83
- expect { @fs['test/../../test'] }.to(raise_error(AssetCloud::IllegalPath))
84
- expect { @fs['test/../../../test'] }.to(raise_error(AssetCloud::IllegalPath))
83
+ expect { @fs["test/../test"] }.to(raise_error(AssetCloud::IllegalPath))
84
+ expect { @fs["test/../../test"] }.to(raise_error(AssetCloud::IllegalPath))
85
+ expect { @fs["test/../../../test"] }.to(raise_error(AssetCloud::IllegalPath))
85
86
  end
86
87
 
87
88
  it "should raise an error when using names with combinations of '.' and ' '" do
88
- expect { @fs['test. . . .. ... .. . '] }.to(raise_error(AssetCloud::IllegalPath))
89
- expect { @fs['test. .'] }.to(raise_error(AssetCloud::IllegalPath))
90
- expect { @fs['test. .test2'] }.to(raise_error(AssetCloud::IllegalPath))
89
+ expect { @fs["test. . . .. ... .. . "] }.to(raise_error(AssetCloud::IllegalPath))
90
+ expect { @fs["test. ."] }.to(raise_error(AssetCloud::IllegalPath))
91
+ expect { @fs["test. .test2"] }.to(raise_error(AssetCloud::IllegalPath))
91
92
  end
92
93
 
93
94
  it "should allow filenames with repeating dots" do
94
- @fs['test..jpg']
95
- @fs['assets/T.T..jpg']
96
- @fs['test/assets/1234123412341234_obj_description..14...58......v8...._2134123412341234.jpg']
95
+ @fs["test..jpg"]
96
+ @fs["assets/T.T..jpg"]
97
+ @fs["test/assets/1234123412341234_obj_description..14...58......v8...._2134123412341234.jpg"]
97
98
  end
98
99
 
99
100
  it "should allow filenames with repeating underscores" do
100
- @fs['test__jpg']
101
- @fs['assets/T__T..jpg']
102
- @fs['test/assets/1234123412341234_obj_description..14...58......v8...__2134123412341234.jpg']
101
+ @fs["test__jpg"]
102
+ @fs["assets/T__T..jpg"]
103
+ @fs["test/assets/1234123412341234_obj_description..14...58......v8...__2134123412341234.jpg"]
103
104
  end
104
105
 
105
106
  it "should allow filenames with various bracket arragements" do
106
- @fs['test[1].jpg']
107
- @fs['test[1]']
108
- @fs['[test].jpg']
107
+ @fs["test[1].jpg"]
108
+ @fs["test[1]"]
109
+ @fs["[test].jpg"]
109
110
  end
110
111
 
111
112
  it "should not raise an error when using directory names with spaces" do
112
- @fs['files/ass ets/.DS_Store']
113
+ @fs["files/ass ets/.DS_Store"]
113
114
  end
114
115
 
115
116
  it "should not raise_error when using unusual but valid filenames" do
116
- @fs['.DS_Store']
117
- @fs['photograph.g']
118
- @fs['_testfilename']
119
- @fs['assets/.DS_Store']
120
- @fs['assets/photograph.g']
121
- @fs['a/_testfilename']
122
- @fs['a']
117
+ @fs[".DS_Store"]
118
+ @fs["photograph.g"]
119
+ @fs["_testfilename"]
120
+ @fs["assets/.DS_Store"]
121
+ @fs["assets/photograph.g"]
122
+ @fs["a/_testfilename"]
123
+ @fs["a"]
123
124
  end
124
125
 
125
126
  it "should allow sensible relative filenames" do
126
- @fs['assets/rails_logo.gif']
127
- @fs['assets/rails_logo']
128
- @fs['assets/rails-2.gif']
129
- @fs['assets/223434.gif']
130
- @fs['files/1.JPG']
127
+ @fs["assets/rails_logo.gif"]
128
+ @fs["assets/rails_logo"]
129
+ @fs["assets/rails-2.gif"]
130
+ @fs["assets/223434.gif"]
131
+ @fs["files/1.JPG"]
131
132
  end
132
133
 
133
134
  it "should compute complete urls to assets" do
134
- expect(@fs.url_for('products/[key] with spaces.txt?foo=1&bar=2')).to(eq('http://assets/files/products/[key]%20with%20spaces.txt?foo=1&bar=2'))
135
+ expect(@fs.url_for("products/[key] with spaces.txt?foo=1&bar=2")).to(eq("http://assets/files/products/[key]%20with%20spaces.txt?foo=1&bar=2"))
135
136
  end
136
137
 
137
138
  describe "#find" do
138
139
  it "should return the appropriate asset when one exists" do
139
- asset = @fs.find('products/key.txt')
140
- expect(asset.key).to(eq('products/key.txt'))
141
- expect(asset.value).to(eq('value'))
140
+ asset = @fs.find("products/key.txt")
141
+ expect(asset.key).to(eq("products/key.txt"))
142
+ expect(asset.value).to(eq("value"))
142
143
  end
143
144
  it "should raise AssetNotFoundError when the asset doesn't exist" do
144
- expect { @fs.find('products/not-there.txt') }.to(raise_error(AssetCloud::AssetNotFoundError))
145
+ expect { @fs.find("products/not-there.txt") }.to(raise_error(AssetCloud::AssetNotFoundError))
145
146
  end
146
147
  end
147
148
 
148
149
  describe "#[]" do
149
150
  it "should return the appropriate asset when one exists" do
150
- asset = @fs['products/key.txt']
151
- expect(asset.key).to(eq('products/key.txt'))
152
- expect(asset.value).to(eq('value'))
151
+ asset = @fs["products/key.txt"]
152
+ expect(asset.key).to(eq("products/key.txt"))
153
+ expect(asset.value).to(eq("value"))
153
154
  end
154
155
  it "should not raise any errors when the asset doesn't exist" do
155
- expect { @fs['products/not-there.txt'] }.not_to(raise_error)
156
+ expect { @fs["products/not-there.txt"] }.not_to(raise_error)
156
157
  end
157
158
  end
158
159
 
159
160
  describe "#move" do
160
161
  it "should return move a resource" do
161
- asset = @fs['products/key.txt']
162
- expect(asset.key).to(eq('products/key.txt'))
163
- expect(asset.value).to(eq('value'))
164
- @fs.move('products/key.txt', 'products/key2.txt')
165
- new_asset = @fs['products/key2.txt']
166
- expect(new_asset.key).to(eq('products/key2.txt'))
167
- expect(new_asset.value).to(eq('value'))
168
- expect { @fs['products/key.txt'].value }.to(raise_error(AssetCloud::AssetNotFoundError))
169
- @fs.move('products/key2.txt', 'products/key.txt')
162
+ asset = @fs["products/key.txt"]
163
+ expect(asset.key).to(eq("products/key.txt"))
164
+ expect(asset.value).to(eq("value"))
165
+ @fs.move("products/key.txt", "products/key2.txt")
166
+ new_asset = @fs["products/key2.txt"]
167
+ expect(new_asset.key).to(eq("products/key2.txt"))
168
+ expect(new_asset.value).to(eq("value"))
169
+ expect { @fs["products/key.txt"].value }.to(raise_error(AssetCloud::AssetNotFoundError))
170
+ @fs.move("products/key2.txt", "products/key.txt")
170
171
  end
171
172
  end
172
173
 
173
174
  describe "#[]=" do
174
175
  it "should write through the Asset object (and thus run any callbacks on the asset)" do
175
176
  special_asset = double(:special_asset)
176
- expect(special_asset).to(receive(:value=).with('fancy fancy!'))
177
+ expect(special_asset).to(receive(:value=).with("fancy fancy!"))
177
178
  expect(special_asset).to(receive(:store))
178
179
  expect(SpecialAsset).to(receive(:at).and_return(special_asset))
179
- @fs['special/fancy.txt'] = 'fancy fancy!'
180
+ @fs["special/fancy.txt"] = "fancy fancy!"
180
181
  end
181
182
  end
182
183
 
183
184
  describe "#bucket" do
184
185
  it "should allow specifying a class to use for assets in this bucket" do
185
- expect(@fs['assets/rails_logo.gif']).to(be_instance_of(AssetCloud::Asset))
186
- expect(@fs['special/fancy.txt']).to(be_instance_of(SpecialAsset))
186
+ expect(@fs["assets/rails_logo.gif"]).to(be_instance_of(AssetCloud::Asset))
187
+ expect(@fs["special/fancy.txt"]).to(be_instance_of(SpecialAsset))
187
188
 
188
- expect(@fs.build('assets/foo')).to(be_instance_of(AssetCloud::Asset))
189
- expect(@fs.build('special/foo')).to(be_instance_of(SpecialAsset))
189
+ expect(@fs.build("assets/foo")).to(be_instance_of(AssetCloud::Asset))
190
+ expect(@fs.build("special/foo")).to(be_instance_of(SpecialAsset))
190
191
  end
191
192
 
192
193
  it "should allow specifying a proc that determines the class to use, using the default bucket when returning nil" do
193
- expect(@fs.build('conditional/default.js')).to(be_instance_of(AssetCloud::Asset))
194
- expect(@fs.build('conditional/better.liquid')).to(be_instance_of(LiquidAsset))
194
+ expect(@fs.build("conditional/default.js")).to(be_instance_of(AssetCloud::Asset))
195
+ expect(@fs.build("conditional/better.liquid")).to(be_instance_of(LiquidAsset))
195
196
  end
196
197
 
197
198
  it "should raise " do
@@ -202,30 +203,30 @@ describe BasicCloud do
202
203
  describe "write!" do
203
204
  it "should write through the Asset object (and thus run any callbacks on the asset)" do
204
205
  special_asset = double(:special_asset)
205
- expect(special_asset).to(receive(:value=).with('fancy fancy!'))
206
+ expect(special_asset).to(receive(:value=).with("fancy fancy!"))
206
207
  expect(special_asset).to(receive(:store!))
207
208
  expect(SpecialAsset).to(receive(:at).and_return(special_asset))
208
- @fs.write!('special/fancy.txt', 'fancy fancy!')
209
+ @fs.write!("special/fancy.txt", "fancy fancy!")
209
210
  end
210
211
 
211
212
  it "should raise AssetNotSaved when write fails" do
212
- expect { @fs.write!('broken/file.txt', 'n/a') }.to(raise_error(AssetCloud::AssetNotSaved))
213
+ expect { @fs.write!("broken/file.txt", "n/a") }.to(raise_error(AssetCloud::AssetNotSaved))
213
214
  end
214
215
  end
215
216
 
216
217
  describe "MATCH_BUCKET" do
217
218
  it "should match following stuff " do
218
- 'products/key.txt' =~ AssetCloud::Base::MATCH_BUCKET
219
- expect(Regexp.last_match(1)).to(eq('products'))
219
+ "products/key.txt" =~ AssetCloud::Base::MATCH_BUCKET
220
+ expect(Regexp.last_match(1)).to(eq("products"))
220
221
 
221
- 'products/subpath/key.txt' =~ AssetCloud::Base::MATCH_BUCKET
222
- expect(Regexp.last_match(1)).to(eq('products'))
222
+ "products/subpath/key.txt" =~ AssetCloud::Base::MATCH_BUCKET
223
+ expect(Regexp.last_match(1)).to(eq("products"))
223
224
 
224
- 'key.txt' =~ AssetCloud::Base::MATCH_BUCKET
225
+ "key.txt" =~ AssetCloud::Base::MATCH_BUCKET
225
226
  expect(Regexp.last_match(1)).to(eq(nil))
226
227
 
227
- 'products' =~ AssetCloud::Base::MATCH_BUCKET
228
- expect(Regexp.last_match(1)).to(eq('products'))
228
+ "products" =~ AssetCloud::Base::MATCH_BUCKET
229
+ expect(Regexp.last_match(1)).to(eq("products"))
229
230
  end
230
231
  end
231
232
  end
@@ -1,42 +1,43 @@
1
1
  # frozen_string_literal: true
2
- require 'spec_helper'
2
+
3
+ require "spec_helper"
3
4
 
4
5
  class BlackholeCloud < AssetCloud::Base
5
6
  bucket AssetCloud::BlackholeBucket
6
7
  end
7
8
 
8
9
  describe BlackholeCloud do
9
- directory = File.dirname(__FILE__) + '/files'
10
+ directory = File.dirname(__FILE__) + "/files"
10
11
 
11
12
  before do
12
- @fs = BlackholeCloud.new(directory, 'http://assets/files')
13
+ @fs = BlackholeCloud.new(directory, "http://assets/files")
13
14
  end
14
15
 
15
16
  it "should allow access to files using the [] operator" do
16
- @fs['tmp/image.jpg']
17
+ @fs["tmp/image.jpg"]
17
18
  end
18
19
 
19
20
  it "should return nil for non existent files" do
20
- expect(@fs['tmp/image.jpg'].exist?).to(eq(false))
21
+ expect(@fs["tmp/image.jpg"].exist?).to(eq(false))
21
22
  end
22
23
 
23
24
  it "should still return nil, even if you wrote something there" do
24
- @fs['tmp/image.jpg'] = 'test'
25
- expect(@fs['tmp/image.jpg'].exist?).to(eq(false))
25
+ @fs["tmp/image.jpg"] = "test"
26
+ expect(@fs["tmp/image.jpg"].exist?).to(eq(false))
26
27
  end
27
28
 
28
29
  describe "when using a sub path" do
29
30
  it "should allow access to files using the [] operator" do
30
- @fs['tmp/image.jpg']
31
+ @fs["tmp/image.jpg"]
31
32
  end
32
33
 
33
34
  it "should return nil for non existent files" do
34
- expect(@fs['tmp/image.jpg'].exist?).to(eq(false))
35
+ expect(@fs["tmp/image.jpg"].exist?).to(eq(false))
35
36
  end
36
37
 
37
38
  it "should still return nil, even if you wrote something there" do
38
- @fs['tmp/image.jpg'] = 'test'
39
- expect(@fs['tmp/image.jpg'].exist?).to(eq(false))
39
+ @fs["tmp/image.jpg"] = "test"
40
+ expect(@fs["tmp/image.jpg"].exist?).to(eq(false))
40
41
  end
41
42
  end
42
43
  end