asset_cloud 2.5.0 → 2.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +326 -0
- data/.travis.yml +6 -0
- data/History.md +6 -0
- data/README.rdoc +8 -0
- data/Rakefile +5 -2
- data/asset_cloud.gemspec +2 -2
- data/lib/asset_cloud.rb +1 -0
- data/lib/asset_cloud/asset.rb +4 -0
- data/lib/asset_cloud/base.rb +4 -2
- data/lib/asset_cloud/buckets/gcs_bucket.rb +1 -1
- data/lib/asset_cloud/metadata.rb +10 -3
- data/spec/active_record_bucket_spec.rb +27 -27
- data/spec/asset_cloud/metadata_spec.rb +31 -0
- data/spec/asset_extension_spec.rb +21 -18
- data/spec/asset_spec.rb +47 -56
- data/spec/base_spec.rb +60 -62
- data/spec/blackhole_bucket_spec.rb +6 -5
- data/spec/bucket_chain_spec.rb +50 -50
- data/spec/bucket_spec.rb +5 -4
- data/spec/callbacks_spec.rb +31 -31
- data/spec/file_system_spec.rb +15 -16
- data/spec/find_free_key_spec.rb +17 -19
- data/spec/gcs_bucket_remote_spec.rb +18 -19
- data/spec/gcs_bucket_spec.rb +50 -36
- data/spec/memory_bucket_spec.rb +8 -9
- data/spec/mock_s3_interface.rb +4 -3
- data/spec/remote_s3_bucket_spec.rb +17 -16
- data/spec/s3_bucket_spec.rb +12 -12
- data/spec/spec_helper.rb +2 -1
- data/spec/validations_spec.rb +18 -16
- data/spec/versioned_memory_bucket_spec.rb +6 -6
- metadata +9 -5
data/lib/asset_cloud/metadata.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module AssetCloud
|
2
2
|
class Metadata
|
3
|
-
attr_accessor :exist, :size, :created_at, :updated_at, :value_hash
|
3
|
+
attr_accessor :exist, :size, :created_at, :updated_at, :value_hash, :checksum
|
4
4
|
|
5
5
|
def new?
|
6
6
|
!self.exist
|
@@ -10,9 +10,16 @@ module AssetCloud
|
|
10
10
|
self.exist
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
# rubocop:disable Metrics/ParameterLists
|
14
|
+
def initialize(exist, size = nil, created_at = nil, updated_at = nil, value_hash = nil, checksum = nil)
|
15
|
+
self.exist = exist
|
16
|
+
self.size = size
|
17
|
+
self.created_at = created_at
|
18
|
+
self.updated_at = updated_at
|
19
|
+
self.value_hash = value_hash
|
20
|
+
self.checksum = checksum
|
15
21
|
end
|
22
|
+
# rubocop:enable Metrics/ParameterLists
|
16
23
|
|
17
24
|
def self.existing
|
18
25
|
self.new(true)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
MockRecords = Object.new
|
@@ -5,7 +6,9 @@ MockRecords = Object.new
|
|
5
6
|
class MockActiveRecordBucket < AssetCloud::ActiveRecordBucket
|
6
7
|
self.key_attribute = 'name'
|
7
8
|
self.value_attribute = 'body'
|
9
|
+
|
8
10
|
protected
|
11
|
+
|
9
12
|
def records
|
10
13
|
MockRecords
|
11
14
|
end
|
@@ -19,49 +22,49 @@ describe AssetCloud::ActiveRecordBucket do
|
|
19
22
|
directory = File.dirname(__FILE__) + '/files'
|
20
23
|
|
21
24
|
before do
|
22
|
-
@cloud = RecordCloud.new(directory
|
25
|
+
@cloud = RecordCloud.new(directory, 'http://assets/files')
|
23
26
|
@bucket = @cloud.buckets[:stuff]
|
24
27
|
end
|
25
28
|
|
26
29
|
describe '#ls' do
|
27
30
|
before do
|
28
|
-
MockRecords.
|
29
|
-
@mock_connection.
|
30
|
-
(@mock_record = double("record")).
|
31
|
+
expect(MockRecords).to(receive(:connection).and_return(@mock_connection = double("connection")))
|
32
|
+
expect(@mock_connection).to(receive(:quote_column_name).with('name').and_return("`name`"))
|
33
|
+
expect(@mock_record = double("record")).to(receive(:name).and_return('stuff/a1'))
|
31
34
|
end
|
32
35
|
|
33
36
|
it "should return a list of assets which start with the given prefix" do
|
34
|
-
MockRecords.
|
37
|
+
expect(MockRecords).to(receive(:all).with(conditions: ["`name` LIKE ?", "stuff/a%"]).and_return([@mock_record]))
|
35
38
|
|
36
|
-
@bucket.ls('stuff/a').size.
|
39
|
+
expect(@bucket.ls('stuff/a').size).to(eq(1))
|
37
40
|
end
|
38
41
|
|
39
42
|
it "should return a list of all assets when a prefix is not given" do
|
40
|
-
MockRecords.
|
43
|
+
expect(MockRecords).to(receive(:all).with(conditions: ["`name` LIKE ?", "stuff%"]).and_return([@mock_record]))
|
41
44
|
|
42
|
-
@bucket.ls.size.
|
45
|
+
expect(@bucket.ls.size).to(eq(1))
|
43
46
|
end
|
44
47
|
end
|
45
48
|
|
46
49
|
describe '#read' do
|
47
50
|
it "should return the value of a key when it exists" do
|
48
|
-
(@mock_record = double("record")).
|
49
|
-
MockRecords.
|
51
|
+
expect(@mock_record = double("record")).to(receive(:body).and_return('foo'))
|
52
|
+
expect(MockRecords).to(receive(:first).with(conditions: { 'name' => 'stuff/a1' }).and_return(@mock_record))
|
50
53
|
|
51
54
|
@bucket.read('stuff/a1')
|
52
55
|
end
|
53
56
|
it "should raise AssetNotFoundError when nothing is there" do
|
54
|
-
MockRecords.
|
57
|
+
expect(MockRecords).to(receive(:first).with(conditions: { 'name' => 'stuff/a1' }).and_return(nil))
|
55
58
|
|
56
|
-
|
59
|
+
expect { @bucket.read('stuff/a1') }.to(raise_error(AssetCloud::AssetNotFoundError))
|
57
60
|
end
|
58
61
|
end
|
59
62
|
|
60
63
|
describe '#write' do
|
61
64
|
it "should write to the DB" do
|
62
|
-
(@mock_record = double("record")).
|
63
|
-
@mock_record.
|
64
|
-
MockRecords.
|
65
|
+
expect(@mock_record = double("record")).to(receive(:body=).with('foo').and_return('foo'))
|
66
|
+
expect(@mock_record).to(receive(:save!).and_return(true))
|
67
|
+
expect(MockRecords).to(receive(:find_or_initialize_by_name).with('stuff/a1').and_return(@mock_record))
|
65
68
|
|
66
69
|
@bucket.write('stuff/a1', 'foo')
|
67
70
|
end
|
@@ -69,8 +72,8 @@ describe AssetCloud::ActiveRecordBucket do
|
|
69
72
|
|
70
73
|
describe '#delete' do
|
71
74
|
it "should destroy records" do
|
72
|
-
(@mock_record = double("record")).
|
73
|
-
MockRecords.
|
75
|
+
expect(@mock_record = double("record")).to(receive(:destroy).and_return(true))
|
76
|
+
expect(MockRecords).to(receive(:first).with(conditions: { 'name' => 'stuff/a1' }).and_return(@mock_record))
|
74
77
|
|
75
78
|
@bucket.delete('stuff/a1')
|
76
79
|
end
|
@@ -78,18 +81,15 @@ describe AssetCloud::ActiveRecordBucket do
|
|
78
81
|
|
79
82
|
describe '#stat' do
|
80
83
|
it "should return appropriate metadata" do
|
81
|
-
(@mock_record = double("record")).
|
82
|
-
@mock_record.
|
83
|
-
@mock_record.
|
84
|
-
MockRecords.
|
84
|
+
expect(@mock_record = double("record")).to(receive(:created_at).and_return(1982))
|
85
|
+
expect(@mock_record).to(receive(:updated_at).and_return(2002))
|
86
|
+
expect(@mock_record).to(receive(:body).and_return('foo'))
|
87
|
+
expect(MockRecords).to(receive(:first).with(conditions: { 'name' => 'stuff/a1' }).and_return(@mock_record))
|
85
88
|
|
86
89
|
metadata = @bucket.stat('stuff/a1')
|
87
|
-
metadata.created_at.
|
88
|
-
metadata.updated_at.
|
89
|
-
metadata.size.
|
90
|
+
expect(metadata.created_at).to(eq(1982))
|
91
|
+
expect(metadata.updated_at).to(eq(2002))
|
92
|
+
expect(metadata.size).to(eq(3))
|
90
93
|
end
|
91
94
|
end
|
92
|
-
|
93
|
-
|
94
|
-
|
95
95
|
end
|
@@ -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
|
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
|
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, :
|
45
|
+
bucket :dog_pound, AssetCloud::MemoryBucket, asset_class: NoCatsAsset
|
42
46
|
bucket :cat_pen, AssetCloud::MemoryBucket
|
43
47
|
|
44
|
-
asset_extensions CssAssetExtension, :
|
45
|
-
asset_extensions XmlAssetExtension, :
|
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).
|
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.
|
67
|
-
asset.errors.
|
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.
|
74
|
-
asset.errors.
|
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.
|
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.
|
88
|
-
asset.extensions.first.
|
91
|
+
expect(asset).to(receive(:asset_callback))
|
92
|
+
expect(asset.extensions.first).to(receive(:xml_callback))
|
89
93
|
asset.value = '<dogs/>'
|
90
|
-
asset.store.
|
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.
|
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
|
110
|
-
expect { asset.my_unimplemented_extension }.to
|
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
|
data/spec/asset_spec.rb
CHANGED
@@ -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', :
|
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
|
17
|
+
expect(@asset.new_asset?).to(eq(true))
|
17
18
|
end
|
18
19
|
|
19
20
|
it "should have a key" do
|
20
|
-
@asset.key.
|
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.
|
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.
|
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.
|
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.
|
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.
|
45
|
+
expect(@asset.bucket_name).to(eq('products'))
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should have a bucket" do
|
49
|
-
@cloud.
|
50
|
-
@asset.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.
|
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.
|
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.
|
67
|
+
expect(@cloud).to(receive(:read).never)
|
68
68
|
|
69
|
-
@asset.value.
|
69
|
+
expect(@asset.value).to(eq(nil))
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should simply ignore calls to delete" do
|
73
|
-
@cloud.
|
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.
|
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.
|
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
|
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.
|
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
|
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.
|
111
|
+
expect(@cloud).to(receive(:read).never)
|
117
112
|
|
118
|
-
@asset.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.
|
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
|
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.
|
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.
|
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.
|
146
|
+
expect(@cloud).to(receive(:url_for).with('products/key.txt', {}).and_return('http://assets/products/key.txt'))
|
156
147
|
|
157
|
-
@asset.url.
|
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.
|
163
|
-
bucket.
|
153
|
+
expect(@cloud).to(receive(:buckets).and_return(products: bucket))
|
154
|
+
expect(bucket).to(receive(:versioned?).and_return(true))
|
164
155
|
|
165
|
-
@asset.versioned
|
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.
|
171
|
-
asset.errors.size.
|
172
|
-
asset.errors.first.
|
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
|
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
|
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
|
202
|
-
expect(@asset == :some_symbol).to
|
203
|
-
expect(@asset == []).to
|
204
|
-
expect(@asset
|
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
|
207
|
-
expect(@asset <=> :some_symbol).to
|
208
|
-
expect(@asset <=> []).to
|
209
|
-
expect(@asset <=> nil).to
|
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
|