asset_cloud 2.5.3 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@ class S3Cloud < AssetCloud::Base
5
5
  bucket :tmp, AssetCloud::S3Bucket
6
6
  attr_accessor :s3_connection, :s3_bucket_name
7
7
 
8
- def s3_bucket(key)
8
+ def s3_bucket(_key)
9
9
  s3_connection.bucket(s3_bucket_name)
10
10
  end
11
11
  end
@@ -14,7 +14,7 @@ describe AssetCloud::S3Bucket do
14
14
  directory = File.dirname(__FILE__) + '/files'
15
15
 
16
16
  before(:all) do
17
- @cloud = S3Cloud.new(directory , 'http://assets/files')
17
+ @cloud = S3Cloud.new(directory, 'http://assets/files')
18
18
  @cloud.s3_connection = MockS3Interface.new('a', 'b')
19
19
  @cloud.s3_bucket_name = 'asset-cloud-test'
20
20
 
@@ -30,32 +30,32 @@ describe AssetCloud::S3Bucket do
30
30
  collection = ["#{@cloud.url}/tmp/blah.gif", "#{@cloud.url}/tmp/add_to_cart.gif"].map do |key|
31
31
  MockS3Interface::S3Object.new(nil, key)
32
32
  end
33
- expect_any_instance_of(MockS3Interface::Bucket).to receive(:objects).and_return(collection)
33
+ expect_any_instance_of(MockS3Interface::Bucket).to(receive(:objects).and_return(collection))
34
34
 
35
35
  ls = @bucket.ls('tmp')
36
36
 
37
- expect(ls).to all(be_an(AssetCloud::Asset))
38
- expect(ls.map(&:key) - ['tmp/blah.gif', 'tmp/add_to_cart.gif']).to be_empty
37
+ expect(ls).to(all(be_an(AssetCloud::Asset)))
38
+ expect(ls.map(&:key) - ['tmp/blah.gif', 'tmp/add_to_cart.gif']).to(be_empty)
39
39
  end
40
40
 
41
41
  it "#delete should not ignore errors when deleting" do
42
- expect_any_instance_of(MockS3Interface::NullS3Object).to receive(:delete).and_raise(StandardError)
42
+ expect_any_instance_of(MockS3Interface::NullS3Object).to(receive(:delete).and_raise(StandardError))
43
43
 
44
- expect { @bucket.delete('assets/fail.gif') }.to raise_error(StandardError)
44
+ expect { @bucket.delete('assets/fail.gif') }.to(raise_error(StandardError))
45
45
  end
46
46
 
47
47
  it "#delete should always return true" do
48
- expect_any_instance_of(MockS3Interface::NullS3Object).to receive(:delete).and_return(nil)
48
+ expect_any_instance_of(MockS3Interface::NullS3Object).to(receive(:delete).and_return(nil))
49
49
 
50
- @bucket.delete('assets/fail.gif').should == true
50
+ expect(@bucket.delete('assets/fail.gif')).to(eq(true))
51
51
  end
52
52
 
53
53
  it "#stat should get metadata from S3" do
54
54
  value = 'hello world'
55
55
  @cloud.build('tmp/new_file.test', value).store
56
56
  metadata = @bucket.stat('tmp/new_file.test')
57
- metadata.size.should == value.size
58
- metadata.updated_at.should == Time.parse("Mon Aug 27 17:37:51 UTC 2007")
57
+ expect(metadata.size).to(eq(value.size))
58
+ expect(metadata.updated_at).to(eq(Time.parse("Mon Aug 27 17:37:51 UTC 2007")))
59
59
  end
60
60
 
61
61
  it "#read " do
@@ -63,6 +63,6 @@ describe AssetCloud::S3Bucket do
63
63
  key = 'tmp/new_file.txt'
64
64
  @bucket.write(key, value)
65
65
  data = @bucket.read(key)
66
- data.should == value
66
+ expect(data).to(eq(value))
67
67
  end
68
68
  end
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
1
2
  require 'rubygems'
2
3
  require 'rspec'
3
4
  require 'pry-byebug' if RUBY_VERSION >= '2.0.0'
4
5
  require 'active_support/all'
5
- $:<< File.dirname(__FILE__) + "/../lib"
6
+ $LOAD_PATH << File.dirname(__FILE__) + "/../lib"
6
7
  require 'asset_cloud'
7
8
  require 'asset_cloud/buckets/s3_bucket'
8
9
  require 'asset_cloud/buckets/gcs_bucket'
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  class ValidatedAsset < AssetCloud::Asset
4
5
  validate :no_cats
5
6
 
6
7
  private
8
+
7
9
  def no_cats
8
10
  add_error('no cats allowed!') if value =~ /cat/i
9
11
  add_warning('bad dog!', 'wet dog smell!') if value =~ /dog/i
@@ -11,7 +13,7 @@ class ValidatedAsset < AssetCloud::Asset
11
13
  end
12
14
 
13
15
  class BasicCloud < AssetCloud::Base
14
- bucket :dog_pound, AssetCloud::MemoryBucket, :asset_class => ValidatedAsset
16
+ bucket :dog_pound, AssetCloud::MemoryBucket, asset_class: ValidatedAsset
15
17
  end
16
18
 
17
19
  describe ValidatedAsset do
@@ -23,41 +25,41 @@ describe ValidatedAsset do
23
25
 
24
26
  describe "#store" do
25
27
  it "should not store the asset unless validations pass" do
26
- @cloud.should_receive(:write).with('dog_pound/fido', 'dog').and_return(true)
28
+ expect(@cloud).to(receive(:write).with('dog_pound/fido', 'dog').and_return(true))
27
29
 
28
30
  @cat.store
29
- @cat.store.should == false
30
- @cat.errors.should == ['no cats allowed!']
31
- @dog.store.should == true
31
+ expect(@cat.store).to(eq(false))
32
+ expect(@cat.errors).to(eq(['no cats allowed!']))
33
+ expect(@dog.store).to(eq(true))
32
34
  end
33
35
 
34
36
  it "should store asset with warnings and save them in the warnings array" do
35
- @dog.store.should == true
36
- @dog.warnings.should == ['bad dog!', 'wet dog smell!']
37
- @cat.store.should == false
38
- @cat.warnings.should == []
37
+ expect(@dog.store).to(eq(true))
38
+ expect(@dog.warnings).to(eq(['bad dog!', 'wet dog smell!']))
39
+ expect(@cat.store).to(eq(false))
40
+ expect(@cat.warnings).to(eq([]))
39
41
  end
40
42
  end
41
43
 
42
44
  describe "#store!" do
43
45
  it "should raise AssetNotFound with error message when validation fails" do
44
- expect { @cat.store! }.to raise_error(AssetCloud::AssetNotSaved, "Validation failed: no cats allowed!")
46
+ expect { @cat.store! }.to(raise_error(AssetCloud::AssetNotSaved, "Validation failed: no cats allowed!"))
45
47
  end
46
48
 
47
49
  it "should return true when validations pass" do
48
- @dog.store!.should == true
50
+ expect(@dog.store!).to(eq(true))
49
51
  end
50
52
  end
51
53
 
52
54
  describe "#valid?" do
53
55
  it "should clear errors, run validations, and return validity" do
54
56
  @cat.store
55
- @cat.errors.should == ['no cats allowed!']
56
- @cat.valid?.should == false
57
- @cat.errors.should == ['no cats allowed!']
57
+ expect(@cat.errors).to(eq(['no cats allowed!']))
58
+ expect(@cat.valid?).to(eq(false))
59
+ expect(@cat.errors).to(eq(['no cats allowed!']))
58
60
  @cat.value = 'disguised feline'
59
- @cat.valid?.should == true
60
- @cat.errors.should be_empty
61
+ expect(@cat.valid?).to(eq(true))
62
+ expect(@cat.errors).to(be_empty)
61
63
  end
62
64
  end
63
65
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  class VersionedMemoryCloud < AssetCloud::Base
@@ -8,7 +9,7 @@ describe AssetCloud::VersionedMemoryBucket do
8
9
  directory = File.dirname(__FILE__) + '/files'
9
10
 
10
11
  before do
11
- @fs = VersionedMemoryCloud.new(directory , 'http://assets/files' )
12
+ @fs = VersionedMemoryCloud.new(directory, 'http://assets/files')
12
13
  %w{one two three}.each do |content|
13
14
  @fs.write("memory/foo", content)
14
15
  end
@@ -16,21 +17,20 @@ describe AssetCloud::VersionedMemoryBucket do
16
17
 
17
18
  describe '#versioned?' do
18
19
  it "should return true" do
19
- @fs.buckets[:memory].versioned?.should == true
20
+ expect(@fs.buckets[:memory].versioned?).to(eq(true))
20
21
  end
21
22
  end
22
23
 
23
24
  describe '#read_version' do
24
25
  it "should return the appropriate data when given a key and version" do
25
- @fs.read_version('memory/foo', 1).should == 'one'
26
- @fs.read_version('memory/foo', 3).should == 'three'
26
+ expect(@fs.read_version('memory/foo', 1)).to(eq('one'))
27
+ expect(@fs.read_version('memory/foo', 3)).to(eq('three'))
27
28
  end
28
29
  end
29
30
 
30
31
  describe '#versions' do
31
32
  it "should return a list of available version identifiers for the given key" do
32
- @fs.versions('memory/foo').should == [1,2,3]
33
+ expect(@fs.versions('memory/foo')).to(eq([1, 2, 3]))
33
34
  end
34
35
  end
35
-
36
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asset_cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.3
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-07 00:00:00.000000000 Z
11
+ date: 2020-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: mocha
56
+ name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: pry
70
+ name: pry-byebug
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: pry-byebug
84
+ name: rubocop-shopify
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
@@ -102,6 +102,8 @@ extra_rdoc_files: []
102
102
  files:
103
103
  - ".github/probots.yml"
104
104
  - ".gitignore"
105
+ - ".rubocop.yml"
106
+ - ".rubocop_todo.yml"
105
107
  - ".travis.yml"
106
108
  - Gemfile
107
109
  - History.md
@@ -130,6 +132,7 @@ files:
130
132
  - lib/asset_cloud/validations.rb
131
133
  - shipit.rubygems.yml
132
134
  - spec/active_record_bucket_spec.rb
135
+ - spec/asset_cloud/metadata_spec.rb
133
136
  - spec/asset_extension_spec.rb
134
137
  - spec/asset_spec.rb
135
138
  - spec/base_spec.rb
@@ -175,6 +178,7 @@ specification_version: 4
175
178
  summary: An abstraction layer around arbitrary and diverse asset stores.
176
179
  test_files:
177
180
  - spec/active_record_bucket_spec.rb
181
+ - spec/asset_cloud/metadata_spec.rb
178
182
  - spec/asset_extension_spec.rb
179
183
  - spec/asset_spec.rb
180
184
  - spec/base_spec.rb