dpl 1.6.1.travis.447.1 → 1.6.1.travis.449.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,98 +8,98 @@ describe DPL::Provider::RubyGems do
8
8
  described_class.new(DummyContext.new, :app => 'example', :api_key => 'foo')
9
9
  end
10
10
 
11
- describe :api do
11
+ describe "#api" do
12
12
  example "with an api key" do
13
- ::Gems.should_receive(:key=).with('foo')
13
+ expect(::Gems).to receive(:key=).with('foo')
14
14
  provider.setup_auth
15
15
  end
16
16
 
17
17
  example "with a username and password" do
18
18
  provider.options.update(:user => 'test', :password => 'blah')
19
19
  provider.options.delete(:api_key)
20
- ::Gems.should_receive(:username=).with('test')
21
- ::Gems.should_receive(:password=).with('blah')
20
+ expect(::Gems).to receive(:username=).with('test')
21
+ expect(::Gems).to receive(:password=).with('blah')
22
22
  provider.setup_auth
23
23
  end
24
24
  end
25
25
 
26
- describe :check_auth do
26
+ describe "#check_auth" do
27
27
  example do
28
28
  provider.options.update(:user => 'test', :password => 'blah')
29
29
  provider.options.delete(:api_key)
30
- provider.should_receive(:log).with("Authenticated with username test")
30
+ expect(provider).to receive(:log).with("Authenticated with username test")
31
31
  provider.check_auth
32
32
  end
33
33
  end
34
34
 
35
- describe :check_app do
35
+ describe "#check_app" do
36
36
  example do
37
- ::Gems.should_receive(:info).with('example').and_return({'name' => 'example'})
38
- provider.should_receive(:log).with("Found gem example")
37
+ expect(::Gems).to receive(:info).with('example').and_return({'name' => 'example'})
38
+ expect(provider).to receive(:log).with("Found gem example")
39
39
  provider.check_app
40
40
  end
41
41
  end
42
42
 
43
- describe :push_app do
43
+ describe "#push_app" do
44
44
  after(:each) do
45
- File.should_receive(:new).with('File').and_return('Test file')
46
- provider.should_receive(:log).with('Yes!')
45
+ expect(File).to receive(:new).with('File').and_return('Test file')
46
+ expect(provider).to receive(:log).with('Yes!')
47
47
  provider.push_app
48
48
  end
49
49
 
50
50
  example "with options[:app]" do
51
51
  provider.options.update(:app => 'example')
52
- provider.context.should_receive(:shell).with("gem build example.gemspec")
53
- Dir.should_receive(:glob).with('example-*.gem').and_yield('File')
54
- ::Gems.should_receive(:push).with('Test file').and_return('Yes!')
52
+ expect(provider.context).to receive(:shell).with("gem build example.gemspec")
53
+ expect(Dir).to receive(:glob).with('example-*.gem').and_yield('File')
54
+ expect(::Gems).to receive(:push).with('Test file').and_return('Yes!')
55
55
  end
56
56
 
57
57
  example "with options[:gem]" do
58
58
  provider.options.update(:gem => 'example-gem')
59
- provider.context.should_receive(:shell).with("gem build example-gem.gemspec")
60
- Dir.should_receive(:glob).with('example-gem-*.gem').and_yield('File')
61
- ::Gems.should_receive(:push).with('Test file').and_return('Yes!')
59
+ expect(provider.context).to receive(:shell).with("gem build example-gem.gemspec")
60
+ expect(Dir).to receive(:glob).with('example-gem-*.gem').and_yield('File')
61
+ expect(::Gems).to receive(:push).with('Test file').and_return('Yes!')
62
62
  end
63
63
 
64
64
  example "with options[:gemspec]" do
65
65
  provider.options.update(:gemspec => 'blah.gemspec')
66
- provider.context.should_receive(:shell).with("gem build blah.gemspec")
67
- Dir.should_receive(:glob).with('blah-*.gem').and_yield('File')
68
- ::Gems.should_receive(:push).with('Test file').and_return('Yes!')
66
+ expect(provider.context).to receive(:shell).with("gem build blah.gemspec")
67
+ expect(Dir).to receive(:glob).with('blah-*.gem').and_yield('File')
68
+ expect(::Gems).to receive(:push).with('Test file').and_return('Yes!')
69
69
  end
70
70
 
71
71
  example "with options[:host]" do
72
72
  provider.options.update(:host => 'http://example.com')
73
- provider.context.should_receive(:shell).with("gem build example.gemspec")
74
- Dir.should_receive(:glob).with('example-*.gem').and_yield('File')
75
- ::Gems.should_receive(:push).with('Test file', host='http://example.com').and_return('Yes!')
73
+ expect(provider.context).to receive(:shell).with("gem build example.gemspec")
74
+ expect(Dir).to receive(:glob).with('example-*.gem').and_yield('File')
75
+ expect(::Gems).to receive(:push).with('Test file', host='http://example.com').and_return('Yes!')
76
76
  end
77
77
  end
78
78
 
79
- describe :setup_gem do
79
+ describe "#setup_gem" do
80
80
  example "with options[:gem] and options[:app] set" do
81
81
  provider.options.update(:gem => 'test', :app => 'blah')
82
82
  provider.setup_gem
83
- provider.options[:gem].should be == 'test'
83
+ expect(provider.options[:gem]).to eq('test')
84
84
  end
85
85
 
86
86
  example "with options[:app] set" do
87
87
  provider.options.update(:app => 'foo')
88
88
  provider.setup_gem
89
- provider.options[:gem].should be == 'foo'
89
+ expect(provider.options[:gem]).to eq('foo')
90
90
  end
91
91
 
92
92
  example "with options[:gem] set" do
93
93
  provider.options.update(:gem => 'bar')
94
94
  provider.setup_gem
95
- provider.options[:gem].should be == 'bar'
95
+ expect(provider.options[:gem]).to eq('bar')
96
96
  end
97
97
  end
98
98
 
99
- describe :gemspec do
99
+ describe "#gemspec" do
100
100
  example do
101
101
  provider.options.update(:gemspec => 'test.gemspec')
102
- provider.gemspec.should be == 'test'
102
+ expect(provider.gemspec).to eq('test')
103
103
  end
104
104
  end
105
105
  end
@@ -3,85 +3,85 @@ require 'aws-sdk'
3
3
  require 'dpl/provider/s3'
4
4
 
5
5
  describe DPL::Provider::S3 do
6
-
6
+
7
7
  before (:each) do
8
8
  AWS.stub!
9
9
  end
10
-
10
+
11
11
  subject :provider do
12
12
  described_class.new(DummyContext.new, :access_key_id => 'qwertyuiopasdfghjklz', :secret_access_key => 'qwertyuiopasdfghjklzqwertyuiopasdfghjklz', :bucket => 'my-bucket')
13
13
  end
14
14
 
15
- describe :check_auth do
15
+ describe "#check_auth" do
16
16
  example do
17
- provider.should_receive(:setup_auth)
18
- provider.should_receive(:log).with("Logging in with Access Key: ****************jklz")
17
+ expect(provider).to receive(:setup_auth)
18
+ expect(provider).to receive(:log).with("Logging in with Access Key: ****************jklz")
19
19
  provider.check_auth
20
20
  end
21
21
  end
22
22
 
23
- describe :upload_path do
23
+ describe "#upload_path" do
24
24
  example "Without :upload_dir"do
25
25
  filename = "testfile.file"
26
26
 
27
- provider.upload_path(filename).should == "testfile.file"
27
+ expect(provider.upload_path(filename)).to eq("testfile.file")
28
28
  end
29
29
 
30
30
  example "With :upload_dir" do
31
31
  provider.options.update(:upload_dir => 'BUILD3')
32
32
  filename = "testfile.file"
33
33
 
34
- provider.upload_path(filename).should == "BUILD3/testfile.file"
34
+ expect(provider.upload_path(filename)).to eq("BUILD3/testfile.file")
35
35
  end
36
36
  end
37
37
 
38
- describe :setup_auth do
38
+ describe "#setup_auth" do
39
39
  example "Without :region" do
40
- AWS.should_receive(:config).with(:access_key_id => 'qwertyuiopasdfghjklz', :secret_access_key => 'qwertyuiopasdfghjklzqwertyuiopasdfghjklz', :region => 'us-east-1').once.and_call_original
40
+ expect(AWS).to receive(:config).with(:access_key_id => 'qwertyuiopasdfghjklz', :secret_access_key => 'qwertyuiopasdfghjklzqwertyuiopasdfghjklz', :region => 'us-east-1').once.and_call_original
41
41
  provider.setup_auth
42
42
  end
43
43
  example "With :region" do
44
44
  provider.options.update(:region => 'us-west-2')
45
45
 
46
- AWS.should_receive(:config).with(:access_key_id => 'qwertyuiopasdfghjklz', :secret_access_key => 'qwertyuiopasdfghjklzqwertyuiopasdfghjklz', :region => 'us-west-2').once
46
+ expect(AWS).to receive(:config).with(:access_key_id => 'qwertyuiopasdfghjklz', :secret_access_key => 'qwertyuiopasdfghjklzqwertyuiopasdfghjklz', :region => 'us-west-2').once
47
47
  provider.setup_auth
48
48
  end
49
49
  end
50
-
51
- describe :needs_key? do
50
+
51
+ describe "#needs_key?" do
52
52
  example do
53
- provider.needs_key?.should == false
53
+ expect(provider.needs_key?).to eq(false)
54
54
  end
55
55
  end
56
56
 
57
- describe :push_app do
57
+ describe "#push_app" do
58
58
  example "Without local_dir" do
59
- Dir.should_receive(:chdir).with(Dir.pwd)
59
+ expect(Dir).to receive(:chdir).with(Dir.pwd)
60
60
  provider.push_app
61
61
  end
62
62
 
63
63
  example "With local_dir" do
64
64
  provider.options.update(:local_dir => 'BUILD')
65
-
66
- Dir.should_receive(:chdir).with('BUILD')
65
+
66
+ expect(Dir).to receive(:chdir).with('BUILD')
67
67
  provider.push_app
68
68
  end
69
69
 
70
70
  example "Sends MIME type" do
71
- Dir.should_receive(:glob).and_yield(__FILE__)
72
- AWS::S3::ObjectCollection.any_instance.should_receive(:create).with(anything(), anything(), hash_including(:content_type => 'application/x-ruby'))
71
+ expect(Dir).to receive(:glob).and_yield(__FILE__)
72
+ expect_any_instance_of(AWS::S3::ObjectCollection).to receive(:create).with(anything(), anything(), hash_including(:content_type => 'application/x-ruby'))
73
73
  provider.push_app
74
74
  end
75
75
  end
76
76
 
77
- describe :api do
77
+ describe "#api" do
78
78
  example "Without Endpoint" do
79
- AWS::S3.should_receive(:new).with(:endpoint => 's3.amazonaws.com')
79
+ expect(AWS::S3).to receive(:new).with(:endpoint => 's3.amazonaws.com')
80
80
  provider.api
81
81
  end
82
82
  example "With Endpoint" do
83
83
  provider.options.update(:endpoint => 's3test.com.s3-website-us-west-2.amazonaws.com')
84
- AWS::S3.should_receive(:new).with(:endpoint => 's3test.com.s3-website-us-west-2.amazonaws.com')
84
+ expect(AWS::S3).to receive(:new).with(:endpoint => 's3test.com.s3-website-us-west-2.amazonaws.com')
85
85
  provider.api
86
86
  end
87
87
  end
@@ -7,154 +7,154 @@ describe DPL::Provider do
7
7
 
8
8
  before { stub_const "DPL::Provider::Example", example_provider }
9
9
 
10
- describe :new do
11
- example { described_class.new(DummyContext.new, :provider => "example") .should be_an(example_provider) }
12
- example { described_class.new(DummyContext.new, :provider => "Example") .should be_an(example_provider) }
13
- example { described_class.new(DummyContext.new, :provider => "exa_mple").should be_an(example_provider) }
14
- example { described_class.new(DummyContext.new, :provider => "exa-mple").should be_an(example_provider) }
10
+ describe "#new" do
11
+ example { expect(described_class.new(DummyContext.new, :provider => "example")) .to be_an(example_provider) }
12
+ example { expect(described_class.new(DummyContext.new, :provider => "Example")) .to be_an(example_provider) }
13
+ example { expect(described_class.new(DummyContext.new, :provider => "exa_mple")).to be_an(example_provider) }
14
+ example { expect(described_class.new(DummyContext.new, :provider => "exa-mple")).to be_an(example_provider) }
15
15
  end
16
16
 
17
- describe :requires do
17
+ describe "#requires" do
18
18
  before do
19
- example_provider.should_receive(:require).with("foo")
19
+ expect(example_provider).to receive(:require).with("foo")
20
20
  end
21
21
 
22
22
  example "installed" do
23
- example_provider.should_receive(:gem).with("foo", "~> 1.4")
23
+ expect(example_provider).to receive(:gem).with("foo", "~> 1.4")
24
24
  example_provider.requires("foo", :version => "~> 1.4")
25
25
  end
26
26
 
27
27
  example "missing" do
28
- example_provider.should_receive(:gem).with("foo", "~> 1.4").and_raise(LoadError)
29
- example_provider.context.should_receive(:shell).with('gem install foo -v "~> 1.4"', retry: true)
28
+ expect(example_provider).to receive(:gem).with("foo", "~> 1.4").and_raise(LoadError)
29
+ expect(example_provider.context).to receive(:shell).with('gem install foo -v "~> 1.4"', retry: true)
30
30
  example_provider.requires("foo", :version => "~> 1.4")
31
31
  end
32
32
  end
33
33
 
34
- describe :apt_get do
34
+ describe "#apt_get" do
35
35
  example "installed" do
36
- example_provider.should_receive(:`).with("which foo").and_return("/bin/foo\n")
37
- example_provider.should_not_receive(:system)
36
+ expect(example_provider).to receive(:`).with("which foo").and_return("/bin/foo\n")
37
+ expect(example_provider).not_to receive(:system)
38
38
  example_provider.apt_get("foo")
39
39
  end
40
40
 
41
41
  example "missing" do
42
- example_provider.should_receive(:`).with("which foo").and_return("")
43
- example_provider.context.should_receive(:shell).with("sudo apt-get -qq install foo", retry: true)
42
+ expect(example_provider).to receive(:`).with("which foo").and_return("")
43
+ expect(example_provider.context).to receive(:shell).with("sudo apt-get -qq install foo", retry: true)
44
44
  example_provider.apt_get("foo")
45
45
  end
46
46
  end
47
47
 
48
- describe :pip do
48
+ describe "#pip" do
49
49
  example "installed" do
50
- example_provider.should_receive(:`).with("which foo").and_return("/bin/foo\n")
51
- example_provider.should_not_receive(:system)
50
+ expect(example_provider).to receive(:`).with("which foo").and_return("/bin/foo\n")
51
+ expect(example_provider).not_to receive(:system)
52
52
  example_provider.pip("foo")
53
53
  end
54
54
 
55
55
  example "missing" do
56
- example_provider.should_receive(:`).with("which foo").and_return("")
57
- example_provider.context.should_receive(:shell).with("sudo pip install foo", retry: true)
56
+ expect(example_provider).to receive(:`).with("which foo").and_return("")
57
+ expect(example_provider.context).to receive(:shell).with("sudo pip install foo", retry: true)
58
58
  example_provider.pip("foo")
59
59
  end
60
60
  end
61
61
 
62
- describe :deploy do
62
+ describe "#deploy" do
63
63
  before do
64
- provider.should_receive(:check_auth)
65
- provider.should_receive(:check_app)
66
- provider.should_receive(:push_app)
67
- provider.should_receive(:run).with("foo")
68
- provider.should_receive(:run).with("bar")
64
+ expect(provider).to receive(:check_auth)
65
+ expect(provider).to receive(:check_app)
66
+ expect(provider).to receive(:push_app)
67
+ expect(provider).to receive(:run).with("foo")
68
+ expect(provider).to receive(:run).with("bar")
69
69
  end
70
70
 
71
71
  example "needs key" do
72
- provider.should_receive(:remove_key)
73
- provider.should_receive(:create_key)
74
- provider.should_receive(:setup_key)
75
- provider.should_receive(:setup_git_ssh)
72
+ expect(provider).to receive(:remove_key)
73
+ expect(provider).to receive(:create_key)
74
+ expect(provider).to receive(:setup_key)
75
+ expect(provider).to receive(:setup_git_ssh)
76
76
  provider.deploy
77
77
  end
78
78
 
79
79
  example "does not need key" do
80
- provider.stub(:needs_key? => false)
80
+ allow(provider).to receive_messages(:needs_key? => false)
81
81
  provider.deploy
82
82
  end
83
83
  end
84
84
 
85
- describe :cleanup do
85
+ describe "#cleanup" do
86
86
  example do
87
- provider.context.should_receive(:shell).with('mv .dpl ~/dpl')
88
- provider.context.should_receive(:shell).with('git stash --all')
89
- provider.context.should_receive(:shell).with('mv ~/dpl .dpl')
87
+ expect(provider.context).to receive(:shell).with('mv .dpl ~/dpl')
88
+ expect(provider.context).to receive(:shell).with('git stash --all')
89
+ expect(provider.context).to receive(:shell).with('mv ~/dpl .dpl')
90
90
  provider.cleanup
91
91
  end
92
92
 
93
93
  example "skip cleanup" do
94
- provider.options.should_receive(:[]).with(:skip_cleanup).and_return("true")
95
- provider.context.should_not_receive(:shell)
94
+ expect(provider.options).to receive(:[]).with(:skip_cleanup).and_return("true")
95
+ expect(provider.context).not_to receive(:shell)
96
96
  provider.cleanup
97
97
  end
98
98
  end
99
99
 
100
- describe :uncleanup do
100
+ describe "#uncleanup" do
101
101
  example do
102
- provider.context.should_receive(:shell).with('git stash pop')
102
+ expect(provider.context).to receive(:shell).with('git stash pop')
103
103
  provider.uncleanup
104
104
  end
105
105
 
106
106
  example "skip cleanup" do
107
- provider.options.should_receive(:[]).with(:skip_cleanup).and_return("true")
108
- provider.context.should_not_receive(:shell)
107
+ expect(provider.options).to receive(:[]).with(:skip_cleanup).and_return("true")
108
+ expect(provider.context).not_to receive(:shell)
109
109
  provider.uncleanup
110
110
  end
111
111
  end
112
112
 
113
- describe :create_key do
113
+ describe "#create_key" do
114
114
  example do
115
- provider.context.should_receive(:shell).with('ssh-keygen -t rsa -N "" -C foo -f thekey')
115
+ expect(provider.context).to receive(:shell).with('ssh-keygen -t rsa -N "" -C foo -f thekey')
116
116
  provider.create_key('thekey')
117
117
  end
118
118
  end
119
119
 
120
- describe :setup_git_ssh do
120
+ describe "#setup_git_ssh" do
121
121
  after { FileUtils.rm ENV.delete('GIT_SSH') }
122
122
 
123
123
  example do
124
124
  provider.setup_git_ssh('foo', 'bar')
125
- ENV['GIT_SSH'].should be == File.expand_path('foo')
125
+ expect(ENV['GIT_SSH']).to eq(File.expand_path('foo'))
126
126
  end
127
127
  end
128
128
 
129
- describe :log do
129
+ describe "#log" do
130
130
  example do
131
- $stderr.should_receive(:puts).with("foo")
131
+ expect($stderr).to receive(:puts).with("foo")
132
132
  provider.log("foo")
133
133
  end
134
134
  end
135
135
 
136
- describe :shell do
136
+ describe "#shell" do
137
137
  example do
138
- example_provider.should_receive(:system).with("command")
138
+ expect(example_provider).to receive(:system).with("command")
139
139
  example_provider.shell("command")
140
140
  end
141
141
  end
142
142
 
143
- describe :npm_g do
143
+ describe "#npm_g" do
144
144
  example do
145
- example_provider.context.should_receive(:shell).with("npm install -g foo", retry: true)
145
+ expect(example_provider.context).to receive(:shell).with("npm install -g foo", retry: true)
146
146
  example_provider.npm_g("foo")
147
147
  end
148
148
  end
149
149
 
150
- describe :run do
150
+ describe "#run" do
151
151
  example do
152
- provider.should_receive(:error).with("running commands not supported")
152
+ expect(provider).to receive(:error).with("running commands not supported")
153
153
  provider.run "blah"
154
154
  end
155
155
  end
156
156
 
157
- describe :error do
157
+ describe "#error" do
158
158
  example do
159
159
  expect { provider.error("Foo") }.to raise_error("Foo")
160
160
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'simplecov'
2
2
  require 'dpl/error'
3
3
  require 'dpl/provider'
4
+ require 'rspec/its'
4
5
 
5
6
  SimpleCov.start do
6
7
  coverage_dir '.coverage'