asset_cloud 2.5.3 → 2.6.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.
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+ require 'asset_cloud/metadata'
3
+
4
+ module AssetCloud
5
+ describe Metadata do
6
+ it "exposes the checksum" do
7
+ exist = true
8
+ size = 1
9
+ created_at = Time.utc(2020, 5, 19, 13, 14, 15)
10
+ updated_at = Time.utc(2020, 5, 19, 16, 17, 18)
11
+ value_hash = "abc123"
12
+ checksum = "def456"
13
+
14
+ metadata = Metadata.new(exist, size, created_at, updated_at, value_hash, checksum)
15
+
16
+ expect(metadata.checksum).to(eq("def456"))
17
+ end
18
+
19
+ it "defaults the checksum to nil if not provided" do
20
+ exist = true
21
+ size = 1
22
+ created_at = Time.utc(2020, 5, 19, 13, 14, 15)
23
+ updated_at = Time.utc(2020, 5, 19, 16, 17, 18)
24
+ value_hash = "abc123"
25
+
26
+ metadata = Metadata.new(exist, size, created_at, updated_at, value_hash)
27
+
28
+ expect(metadata.checksum).to(be(nil))
29
+ end
30
+ end
31
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  class NoCatsAsset < AssetCloud::Asset
@@ -5,6 +6,7 @@ class NoCatsAsset < AssetCloud::Asset
5
6
  before_store :asset_callback
6
7
 
7
8
  private
9
+
8
10
  def no_cats
9
11
  add_error('no cats allowed!') if value =~ /cat/i
10
12
  end
@@ -16,8 +18,9 @@ class CssAssetExtension < AssetCloud::AssetExtension
16
18
  validate :valid_css
17
19
 
18
20
  private
21
+
19
22
  def valid_css
20
- add_error "not enough curly brackets!" unless asset.value =~ /\{.*\}/
23
+ add_error("not enough curly brackets!") unless asset.value =~ /\{.*\}/
21
24
  end
22
25
  end
23
26
 
@@ -32,17 +35,18 @@ class XmlAssetExtension < AssetCloud::AssetExtension
32
35
  end
33
36
 
34
37
  private
38
+
35
39
  def valid_xml
36
- add_error "not enough angle brackets!" unless asset.value =~ /\<.*\>/
40
+ add_error("not enough angle brackets!") unless asset.value =~ /\<.*\>/
37
41
  end
38
42
  end
39
43
 
40
44
  class CatsAndDogsCloud < AssetCloud::Base
41
- bucket :dog_pound, AssetCloud::MemoryBucket, :asset_class => NoCatsAsset
45
+ bucket :dog_pound, AssetCloud::MemoryBucket, asset_class: NoCatsAsset
42
46
  bucket :cat_pen, AssetCloud::MemoryBucket
43
47
 
44
- asset_extensions CssAssetExtension, :only => :cat_pen
45
- asset_extensions XmlAssetExtension, :except => :cat_pen
48
+ asset_extensions CssAssetExtension, only: :cat_pen
49
+ asset_extensions XmlAssetExtension, except: :cat_pen
46
50
  end
47
51
 
48
52
  describe "AssetExtension" do
@@ -55,7 +59,7 @@ describe "AssetExtension" do
55
59
  describe "applicability" do
56
60
  it "should work" do
57
61
  asset = @cloud['cat_pen/cats.xml']
58
- XmlAssetExtension.applies_to_asset?(asset).should == true
62
+ expect(XmlAssetExtension.applies_to_asset?(asset)).to(eq(true))
59
63
  end
60
64
  end
61
65
 
@@ -63,31 +67,31 @@ describe "AssetExtension" do
63
67
  it "should be added to assets in the right bucket with the right extension" do
64
68
  asset = @cloud['cat_pen/cats.css']
65
69
  asset.value = 'foo'
66
- asset.store.should == false
67
- asset.errors.should == ["not enough curly brackets!"]
70
+ expect(asset.store).to(eq(false))
71
+ expect(asset.errors).to(eq(["not enough curly brackets!"]))
68
72
  end
69
73
 
70
74
  it "should not squash existing validations on the asset" do
71
75
  asset = @cloud['dog_pound/cats.xml']
72
76
  asset.value = 'cats!'
73
- asset.store.should == false
74
- asset.errors.should == ['no cats allowed!', "not enough angle brackets!"]
77
+ expect(asset.store).to(eq(false))
78
+ expect(asset.errors).to(eq(['no cats allowed!', "not enough angle brackets!"]))
75
79
  end
76
80
 
77
81
  it "should not apply to non-matching assets or those in exempted buckets" do
78
82
  asset = @cloud['cat_pen/cats.xml']
79
83
  asset.value = "xml"
80
- asset.store.should == true
84
+ expect(asset.store).to(eq(true))
81
85
  end
82
86
  end
83
87
 
84
88
  describe "callbacks" do
85
89
  it "should run alongside the asset's callbacks" do
86
90
  asset = @cloud['dog_pound/dogs.xml']
87
- asset.should_receive(:asset_callback)
88
- asset.extensions.first.should_receive(:xml_callback)
91
+ expect(asset).to(receive(:asset_callback))
92
+ expect(asset.extensions.first).to(receive(:xml_callback))
89
93
  asset.value = '<dogs/>'
90
- asset.store.should == true
94
+ expect(asset.store).to(eq(true))
91
95
  end
92
96
  end
93
97
 
@@ -96,7 +100,7 @@ describe "AssetExtension" do
96
100
  asset = @cloud['dog_pound/dogs.xml']
97
101
  asset.value = 'dogs'
98
102
  asset.turn_into_xml
99
- asset.value.should == '<xml>dogs</xml>'
103
+ expect(asset.value).to(eq('<xml>dogs</xml>'))
100
104
  end
101
105
 
102
106
  it "does not swallow NotImplementedError" do
@@ -106,9 +110,8 @@ describe "AssetExtension" do
106
110
 
107
111
  asset = @cloud['dog_pound/dogs.xml']
108
112
 
109
- expect(asset).to respond_to(:my_unimplemented_extension)
110
- expect { asset.my_unimplemented_extension }.to raise_error(NotImplementedError)
113
+ expect(asset).to(respond_to(:my_unimplemented_extension))
114
+ expect { asset.my_unimplemented_extension }.to(raise_error(NotImplementedError))
111
115
  end
112
116
  end
113
-
114
117
  end
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "Asset" do
4
5
  include AssetCloud
5
6
 
6
7
  before do
7
- @cloud = double('Cloud', :asset_extension_classes_for_bucket => [])
8
+ @cloud = double('Cloud', asset_extension_classes_for_bucket: [])
8
9
  end
9
10
 
10
11
  describe "when first created (without a value)" do
@@ -13,116 +14,109 @@ describe "Asset" do
13
14
  end
14
15
 
15
16
  it "should be return new_asset? => true" do
16
- @asset.new_asset?.should == true
17
+ expect(@asset.new_asset?).to(eq(true))
17
18
  end
18
19
 
19
20
  it "should have a key" do
20
- @asset.key.should == 'products/key.txt'
21
+ expect(@asset.key).to(eq('products/key.txt'))
21
22
  end
22
23
 
23
24
  it "should have a value of nil" do
24
-
25
- @asset.value.should == nil
25
+ expect(@asset.value).to(eq(nil))
26
26
  end
27
27
 
28
28
  it "should have a basename" do
29
- @asset.basename.should == 'key.txt'
29
+ expect(@asset.basename).to(eq('key.txt'))
30
30
  end
31
31
 
32
32
  it "should have a basename without ext (if required)" do
33
- @asset.basename_without_ext.should == 'key'
33
+ expect(@asset.basename_without_ext).to(eq('key'))
34
34
  end
35
35
 
36
36
  it "should have an ext" do
37
- @asset.extname.should == '.txt'
37
+ expect(@asset.extname).to(eq('.txt'))
38
38
  end
39
39
 
40
40
  it "should have a relative_key_without_ext" do
41
- @asset.relative_key_without_ext.should == 'key'
41
+ expect(@asset.relative_key_without_ext).to(eq('key'))
42
42
  end
43
43
 
44
44
  it "should have a bucket_name" do
45
- @asset.bucket_name.should == 'products'
45
+ expect(@asset.bucket_name).to(eq('products'))
46
46
  end
47
47
 
48
48
  it "should have a bucket" do
49
- @cloud.should_receive(:buckets).and_return(:products => :products_bucket)
50
- @asset.bucket.should == :products_bucket
49
+ expect(@cloud).to(receive(:buckets).and_return(products: :products_bucket))
50
+ expect(@asset.bucket).to(eq(:products_bucket))
51
51
  end
52
52
 
53
53
  it "should store data to the bucket" do
54
- @cloud.should_receive(:write).with("products/key.txt", 'value')
54
+ expect(@cloud).to(receive(:write).with("products/key.txt", 'value'))
55
55
 
56
56
  @asset.value = 'value'
57
57
  @asset.store
58
58
  end
59
59
 
60
60
  it "should not try to store data when it's value is nil" do
61
- @cloud.should_receive(:write).never
61
+ expect(@cloud).to(receive(:write).never)
62
62
 
63
63
  @asset.store
64
64
  end
65
65
 
66
66
  it "should not try to read data from bucket if its a new_asset" do
67
- @cloud.should_receive(:read).never
67
+ expect(@cloud).to(receive(:read).never)
68
68
 
69
- @asset.value.should == nil
69
+ expect(@asset.value).to(eq(nil))
70
70
  end
71
71
 
72
72
  it "should simply ignore calls to delete" do
73
- @cloud.should_receive(:delete).never
73
+ expect(@cloud).to(receive(:delete).never)
74
74
 
75
75
  @asset.delete
76
76
  end
77
-
78
77
  end
79
78
 
80
-
81
79
  describe "when first created (without a value) with subdirectory" do
82
80
  before do
83
81
  @asset = AssetCloud::Asset.new(@cloud, "products/retail/key.txt")
84
82
  end
85
83
 
86
84
  it "should have a relative_key_without_ext" do
87
- @asset.relative_key_without_ext.should == 'retail/key'
85
+ expect(@asset.relative_key_without_ext).to(eq('retail/key'))
88
86
  end
89
87
 
90
88
  it "should have a relative_key" do
91
- @asset.relative_key.should == 'retail/key.txt'
89
+ expect(@asset.relative_key).to(eq('retail/key.txt'))
92
90
  end
93
91
  end
94
92
 
95
-
96
93
  describe "when first created with value" do
97
94
  before do
98
95
  @asset = AssetCloud::Asset.new(@cloud, "products/key.txt", 'value')
99
96
  end
100
97
 
101
98
  it "should be return new_asset? => true" do
102
- @asset.new_asset?.should == true
99
+ expect(@asset.new_asset?).to(eq(true))
103
100
  end
104
101
 
105
-
106
102
  it "should have a value of 'value'" do
107
- @asset.value.should == 'value'
103
+ expect(@asset.value).to(eq('value'))
108
104
  end
109
105
 
110
106
  it "should return false when asked if it exists because its still a new_asset" do
111
- @asset.exist?.should == false
107
+ expect(@asset.exist?).to(eq(false))
112
108
  end
113
109
 
114
-
115
110
  it "should not try to read data from bucket if its a new_asset" do
116
- @cloud.should_receive(:read).never
111
+ expect(@cloud).to(receive(:read).never)
117
112
 
118
- @asset.value.should == 'value'
113
+ expect(@asset.value).to(eq('value'))
119
114
  end
120
115
 
121
116
  it "should write data to the bucket" do
122
- @cloud.should_receive(:write).with("products/key.txt", 'value')
117
+ expect(@cloud).to(receive(:write).with("products/key.txt", 'value'))
123
118
  @asset.store
124
119
  end
125
-
126
120
  end
127
121
 
128
122
  describe "when fetched from the bucket" do
@@ -131,45 +125,42 @@ describe "Asset" do
131
125
  end
132
126
 
133
127
  it "should be return new_asset? => false" do
134
- @asset.new_asset?.should == false
128
+ expect(@asset.new_asset?).to(eq(false))
135
129
  end
136
130
 
137
131
  it "should indicate that it exists" do
138
-
139
- @asset.exist?.should == true
132
+ expect(@asset.exist?).to(eq(true))
140
133
  end
141
134
 
142
-
143
135
  it "should read the value from the bucket" do
144
- @asset.value.should == 'value'
136
+ expect(@asset.value).to(eq('value'))
145
137
  end
146
138
 
147
-
148
139
  it "should simply ignore calls to delete" do
149
- @cloud.should_receive(:delete).and_return(true)
140
+ expect(@cloud).to(receive(:delete).and_return(true))
150
141
 
151
142
  @asset.delete
152
143
  end
153
144
 
154
145
  it "should ask the bucket to create a full url" do
155
- @cloud.should_receive(:url_for).with('products/key.txt', {}).and_return('http://assets/products/key.txt')
146
+ expect(@cloud).to(receive(:url_for).with('products/key.txt', {}).and_return('http://assets/products/key.txt'))
156
147
 
157
- @asset.url.should == 'http://assets/products/key.txt'
148
+ expect(@asset.url).to(eq('http://assets/products/key.txt'))
158
149
  end
159
150
 
160
151
  it "should ask the bucket whether or not it is versioned" do
161
152
  bucket = double('Bucket')
162
- @cloud.should_receive(:buckets).and_return(:products => bucket)
163
- bucket.should_receive(:versioned?).and_return(true)
153
+ expect(@cloud).to(receive(:buckets).and_return(products: bucket))
154
+ expect(bucket).to(receive(:versioned?).and_return(true))
164
155
 
165
- @asset.versioned?.should == true
156
+ expect(@asset.versioned?).to(eq(true))
166
157
  end
167
158
 
168
159
  it "should validate its key" do
169
160
  asset = AssetCloud::Asset.new(@cloud, "products/foo, bar.txt", "data")
170
- asset.store.should == false
171
- asset.errors.size.should == 1
172
- asset.errors.first.should =~ /illegal characters/
161
+ expect(asset.store).to(eq(false))
162
+ expect(asset.errors.size).to(eq(1))
163
+ expect(asset.errors.first).to(match(/illegal characters/))
173
164
  end
174
165
  end
175
166
 
@@ -183,14 +174,14 @@ describe "Asset" do
183
174
  it "is equal if cloud and key of both assets are equal" do
184
175
  other_asset = AssetCloud::Asset.new(@cloud, @key)
185
176
 
186
- expect(@asset == other_asset).to eq(true)
177
+ expect(@asset == other_asset).to(eq(true))
187
178
  end
188
179
 
189
180
  it "is not equal if key of both assets are not equal" do
190
181
  other_key = "products/other_key.txt"
191
182
  other_asset = AssetCloud::Asset.new(@cloud, other_key)
192
183
 
193
- expect(@asset == other_asset).to eq(false)
184
+ expect(@asset == other_asset).to(eq(false))
194
185
  end
195
186
  end
196
187
 
@@ -198,15 +189,15 @@ describe "Asset" do
198
189
  it "is not equal to a non-Asset object" do
199
190
  AssetCloud::Asset.new(@cloud, "products/foo, bar.txt", "data")
200
191
 
201
- expect(@asset == "some_string").to eq(false)
202
- expect(@asset == :some_symbol).to eq(false)
203
- expect(@asset == []).to eq(false)
204
- expect(@asset == nil).to eq(false)
192
+ expect(@asset == "some_string").to(eq(false))
193
+ expect(@asset == :some_symbol).to(eq(false))
194
+ expect(@asset == []).to(eq(false))
195
+ expect(@asset.nil?).to(eq(false))
205
196
 
206
- expect(@asset <=> "some_string").to eq(nil)
207
- expect(@asset <=> :some_symbol).to eq(nil)
208
- expect(@asset <=> []).to eq(nil)
209
- expect(@asset <=> nil).to eq(nil)
197
+ expect(@asset <=> "some_string").to(eq(nil))
198
+ expect(@asset <=> :some_symbol).to(eq(nil))
199
+ expect(@asset <=> []).to(eq(nil))
200
+ expect(@asset <=> nil).to(eq(nil))
210
201
  end
211
202
  end
212
203
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  class SpecialAsset < AssetCloud::Asset
@@ -8,7 +9,7 @@ end
8
9
 
9
10
  class BasicCloud < AssetCloud::Base
10
11
  bucket :special, AssetCloud::MemoryBucket, asset_class: SpecialAsset
11
- bucket :conditional, AssetCloud::MemoryBucket, asset_class: Proc.new {|key|
12
+ bucket :conditional, AssetCloud::MemoryBucket, asset_class: proc { |key|
12
13
  LiquidAsset if key.ends_with?('.liquid')
13
14
  }
14
15
  end
@@ -17,71 +18,69 @@ describe BasicCloud do
17
18
  directory = File.dirname(__FILE__) + '/files'
18
19
 
19
20
  before do
20
- @fs = BasicCloud.new(directory , 'http://assets/files' )
21
+ @fs = BasicCloud.new(directory, 'http://assets/files')
21
22
  end
22
23
 
23
24
  it "should raise invalid bucket if none is given" do
24
- @fs['image.jpg'].exist?.should == false
25
+ expect(@fs['image.jpg'].exist?).to(eq(false))
25
26
  end
26
27
 
27
-
28
28
  it "should be backed by a file system bucket" do
29
- @fs['products/key.txt'].exist?.should == true
29
+ expect(@fs['products/key.txt'].exist?).to(eq(true))
30
30
  end
31
31
 
32
32
  it "should raise when listing non existing buckets" do
33
- @fs.ls('products').should == [AssetCloud::Asset.new(@fs, 'products/key.txt')]
33
+ expect(@fs.ls('products')).to(eq([AssetCloud::Asset.new(@fs, 'products/key.txt')]))
34
34
  end
35
35
 
36
-
37
36
  it "should allow you to create new assets" do
38
37
  obj = @fs.build('new_file.test')
39
- obj.should be_an_instance_of(AssetCloud::Asset)
40
- obj.cloud.should be_an_instance_of(BasicCloud)
38
+ expect(obj).to(be_an_instance_of(AssetCloud::Asset))
39
+ expect(obj.cloud).to(be_an_instance_of(BasicCloud))
41
40
  end
42
41
 
43
42
  it "should raise error when using with minus relative or absolute paths" do
44
- lambda { @fs['../test'] }.should raise_error(AssetCloud::IllegalPath)
45
- lambda { @fs['/test'] }.should raise_error(AssetCloud::IllegalPath)
46
- lambda { @fs['.../test'] }.should raise_error(AssetCloud::IllegalPath)
47
- lambda { @fs['./test'] }.should raise_error(AssetCloud::IllegalPath)
43
+ expect { @fs['../test'] }.to(raise_error(AssetCloud::IllegalPath))
44
+ expect { @fs['/test'] }.to(raise_error(AssetCloud::IllegalPath))
45
+ expect { @fs['.../test'] }.to(raise_error(AssetCloud::IllegalPath))
46
+ expect { @fs['./test'] }.to(raise_error(AssetCloud::IllegalPath))
48
47
  end
49
48
 
50
49
  it "should raise error when filename has trailing period" do
51
- lambda { @fs['test.'] }.should raise_error(AssetCloud::IllegalPath)
52
- lambda { @fs['/test/testfile.'] }.should raise_error(AssetCloud::IllegalPath)
53
- lambda { @fs['test/directory/.'] }.should raise_error(AssetCloud::IllegalPath)
54
- lambda { @fs['/test/testfile .'] }.should raise_error(AssetCloud::IllegalPath)
55
- lambda { @fs['test/directory /.'] }.should raise_error(AssetCloud::IllegalPath)
50
+ expect { @fs['test.'] }.to(raise_error(AssetCloud::IllegalPath))
51
+ expect { @fs['/test/testfile.'] }.to(raise_error(AssetCloud::IllegalPath))
52
+ expect { @fs['test/directory/.'] }.to(raise_error(AssetCloud::IllegalPath))
53
+ expect { @fs['/test/testfile .'] }.to(raise_error(AssetCloud::IllegalPath))
54
+ expect { @fs['test/directory /.'] }.to(raise_error(AssetCloud::IllegalPath))
56
55
  end
57
56
 
58
57
  it "should raise error when filename ends with space" do
59
- lambda { @fs['test '] }.should raise_error(AssetCloud::IllegalPath)
60
- lambda { @fs['/test/testfile '] }.should raise_error(AssetCloud::IllegalPath)
61
- lambda { @fs['test/directory/ '] }.should raise_error(AssetCloud::IllegalPath)
62
- lambda { @fs['test. '] }.should raise_error(AssetCloud::IllegalPath)
63
- lambda { @fs['/test/testfile. '] }.should raise_error(AssetCloud::IllegalPath)
64
- lambda { @fs['test/directory/. '] }.should 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. '] }.to(raise_error(AssetCloud::IllegalPath))
62
+ expect { @fs['/test/testfile. '] }.to(raise_error(AssetCloud::IllegalPath))
63
+ expect { @fs['test/directory/. '] }.to(raise_error(AssetCloud::IllegalPath))
65
64
  end
66
65
 
67
66
  it "should raise error when filename ends with slash" do
68
- lambda { @fs['test/'] }.should raise_error(AssetCloud::IllegalPath)
69
- lambda { @fs['test/directory/'] }.should raise_error(AssetCloud::IllegalPath)
70
- lambda { @fs['test /'] }.should raise_error(AssetCloud::IllegalPath)
71
- lambda { @fs['/test/testfile /'] }.should raise_error(AssetCloud::IllegalPath)
72
- lambda { @fs['test/directory//'] }.should raise_error(AssetCloud::IllegalPath)
67
+ expect { @fs['test/'] }.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))
73
72
  end
74
73
 
75
74
  it "should raise error when using with minus relative even after another directory" do
76
- lambda { @fs['test/../test'] }.should raise_error(AssetCloud::IllegalPath)
77
- lambda { @fs['test/../../test'] }.should raise_error(AssetCloud::IllegalPath)
78
- lambda { @fs['test/../../../test']}.should raise_error(AssetCloud::IllegalPath)
75
+ expect { @fs['test/../test'] }.to(raise_error(AssetCloud::IllegalPath))
76
+ expect { @fs['test/../../test'] }.to(raise_error(AssetCloud::IllegalPath))
77
+ expect { @fs['test/../../../test'] }.to(raise_error(AssetCloud::IllegalPath))
79
78
  end
80
79
 
81
80
  it "should raise an error when using names with combinations of '.' and ' '" do
82
- lambda { @fs['test. . . .. ... .. . '] }.should raise_error(AssetCloud::IllegalPath)
83
- lambda { @fs['test. .'] }.should raise_error(AssetCloud::IllegalPath)
84
- lambda { @fs['test. .test2'] }.should raise_error(AssetCloud::IllegalPath)
81
+ expect { @fs['test. . . .. ... .. . '] }.to(raise_error(AssetCloud::IllegalPath))
82
+ expect { @fs['test. .'] }.to(raise_error(AssetCloud::IllegalPath))
83
+ expect { @fs['test. .test2'] }.to(raise_error(AssetCloud::IllegalPath))
85
84
  end
86
85
 
87
86
  it "should allow filenames with repeating dots" do
@@ -125,41 +124,41 @@ describe BasicCloud do
125
124
  end
126
125
 
127
126
  it "should compute complete urls to assets" do
128
- @fs.url_for('products/[key] with spaces.txt?foo=1&bar=2').should == 'http://assets/files/products/[key]%20with%20spaces.txt?foo=1&bar=2'
127
+ 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'))
129
128
  end
130
129
 
131
130
  describe "#find" do
132
131
  it "should return the appropriate asset when one exists" do
133
132
  asset = @fs.find('products/key.txt')
134
- asset.key.should == 'products/key.txt'
135
- asset.value.should == 'value'
133
+ expect(asset.key).to(eq('products/key.txt'))
134
+ expect(asset.value).to(eq('value'))
136
135
  end
137
136
  it "should raise AssetNotFoundError when the asset doesn't exist" do
138
- lambda { @fs.find('products/not-there.txt') }.should raise_error(AssetCloud::AssetNotFoundError)
137
+ expect { @fs.find('products/not-there.txt') }.to(raise_error(AssetCloud::AssetNotFoundError))
139
138
  end
140
139
  end
141
140
 
142
141
  describe "#[]" do
143
142
  it "should return the appropriate asset when one exists" do
144
143
  asset = @fs['products/key.txt']
145
- asset.key.should == 'products/key.txt'
146
- asset.value.should == 'value'
144
+ expect(asset.key).to(eq('products/key.txt'))
145
+ expect(asset.value).to(eq('value'))
147
146
  end
148
147
  it "should not raise any errors when the asset doesn't exist" do
149
- lambda { @fs['products/not-there.txt'] }.should_not raise_error
148
+ expect { @fs['products/not-there.txt'] }.not_to(raise_error)
150
149
  end
151
150
  end
152
151
 
153
152
  describe "#move" do
154
153
  it "should return move a resource" do
155
154
  asset = @fs['products/key.txt']
156
- asset.key.should == 'products/key.txt'
157
- asset.value.should == 'value'
155
+ expect(asset.key).to(eq('products/key.txt'))
156
+ expect(asset.value).to(eq('value'))
158
157
  @fs.move('products/key.txt', 'products/key2.txt')
159
158
  new_asset = @fs['products/key2.txt']
160
- new_asset.key.should == 'products/key2.txt'
161
- new_asset.value.should == 'value'
162
- expect {@fs['products/key.txt'].value }.to raise_error(AssetCloud::AssetNotFoundError)
159
+ expect(new_asset.key).to(eq('products/key2.txt'))
160
+ expect(new_asset.value).to(eq('value'))
161
+ expect { @fs['products/key.txt'].value }.to(raise_error(AssetCloud::AssetNotFoundError))
163
162
  @fs.move('products/key2.txt', 'products/key.txt')
164
163
  end
165
164
  end
@@ -167,46 +166,45 @@ describe BasicCloud do
167
166
  describe "#[]=" do
168
167
  it "should write through the Asset object (and thus run any callbacks on the asset)" do
169
168
  special_asset = double(:special_asset)
170
- special_asset.should_receive(:value=).with('fancy fancy!')
171
- special_asset.should_receive(:store)
172
- SpecialAsset.should_receive(:at).and_return(special_asset)
169
+ expect(special_asset).to(receive(:value=).with('fancy fancy!'))
170
+ expect(special_asset).to(receive(:store))
171
+ expect(SpecialAsset).to(receive(:at).and_return(special_asset))
173
172
  @fs['special/fancy.txt'] = 'fancy fancy!'
174
173
  end
175
174
  end
176
175
 
177
176
  describe "#bucket" do
178
177
  it "should allow specifying a class to use for assets in this bucket" do
179
- @fs['assets/rails_logo.gif'].should be_instance_of(AssetCloud::Asset)
180
- @fs['special/fancy.txt'].should be_instance_of(SpecialAsset)
178
+ expect(@fs['assets/rails_logo.gif']).to(be_instance_of(AssetCloud::Asset))
179
+ expect(@fs['special/fancy.txt']).to(be_instance_of(SpecialAsset))
181
180
 
182
- @fs.build('assets/foo').should be_instance_of(AssetCloud::Asset)
183
- @fs.build('special/foo').should be_instance_of(SpecialAsset)
181
+ expect(@fs.build('assets/foo')).to(be_instance_of(AssetCloud::Asset))
182
+ expect(@fs.build('special/foo')).to(be_instance_of(SpecialAsset))
184
183
  end
185
184
 
186
185
  it "should allow specifying a proc that determines the class to use, using the default bucket when returning nil" do
187
- @fs.build('conditional/default.js').should be_instance_of(AssetCloud::Asset)
188
- @fs.build('conditional/better.liquid').should be_instance_of(LiquidAsset)
186
+ expect(@fs.build('conditional/default.js')).to(be_instance_of(AssetCloud::Asset))
187
+ expect(@fs.build('conditional/better.liquid')).to(be_instance_of(LiquidAsset))
189
188
  end
190
189
 
191
190
  it "should raise " do
192
- expect { BasicCloud.bucket(AssetCloud::MemoryBucket, asset_class: Proc.new {}) }.to(raise_error(ArgumentError))
191
+ expect { BasicCloud.bucket(AssetCloud::MemoryBucket, asset_class: proc {}) }.to(raise_error(ArgumentError))
193
192
  end
194
193
  end
195
194
 
196
195
  describe "MATCH_BUCKET" do
197
196
  it "should match following stuff " do
198
-
199
197
  'products/key.txt' =~ AssetCloud::Base::MATCH_BUCKET
200
- $1.should == 'products'
198
+ expect(Regexp.last_match(1)).to(eq('products'))
201
199
 
202
200
  'products/subpath/key.txt' =~ AssetCloud::Base::MATCH_BUCKET
203
- $1.should == 'products'
201
+ expect(Regexp.last_match(1)).to(eq('products'))
204
202
 
205
203
  'key.txt' =~ AssetCloud::Base::MATCH_BUCKET
206
- $1.should == nil
204
+ expect(Regexp.last_match(1)).to(eq(nil))
207
205
 
208
206
  'products' =~ AssetCloud::Base::MATCH_BUCKET
209
- $1.should == 'products'
207
+ expect(Regexp.last_match(1)).to(eq('products'))
210
208
  end
211
209
  end
212
210
  end