summaryrefslogtreecommitdiff
path: root/spec/unit/knife/cookbook_site_download_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/knife/cookbook_site_download_spec.rb')
-rw-r--r--spec/unit/knife/cookbook_site_download_spec.rb68
1 files changed, 34 insertions, 34 deletions
diff --git a/spec/unit/knife/cookbook_site_download_spec.rb b/spec/unit/knife/cookbook_site_download_spec.rb
index 35c6544d58..52e82a7f0b 100644
--- a/spec/unit/knife/cookbook_site_download_spec.rb
+++ b/spec/unit/knife/cookbook_site_download_spec.rb
@@ -16,22 +16,22 @@
# limitations under the License.
#
-require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
describe Chef::Knife::CookbookSiteDownload do
- describe 'run' do
+ describe "run" do
before do
@knife = Chef::Knife::CookbookSiteDownload.new
- @knife.name_args = ['apache2']
- @noauth_rest = double('no auth rest')
+ @knife.name_args = ["apache2"]
+ @noauth_rest = double("no auth rest")
@stderr = StringIO.new
- @cookbook_api_url = 'https://supermarket.chef.io/api/v1/cookbooks'
- @version = '1.0.2'
- @version_us = @version.gsub '.', '_'
- @current_data = { 'deprecated' => false,
- 'latest_version' => "#{@cookbook_api_url}/apache2/versions/#{@version_us}",
- 'replacement' => 'other_apache2' }
+ @cookbook_api_url = "https://supermarket.chef.io/api/v1/cookbooks"
+ @version = "1.0.2"
+ @version_us = @version.gsub ".", "_"
+ @current_data = { "deprecated" => false,
+ "latest_version" => "#{@cookbook_api_url}/apache2/versions/#{@version_us}",
+ "replacement" => "other_apache2" }
allow(@knife.ui).to receive(:stderr).and_return(@stderr)
allow(@knife).to receive(:noauth_rest).and_return(@noauth_rest)
@@ -40,12 +40,12 @@ describe Chef::Knife::CookbookSiteDownload do
and_return(@current_data)
end
- context 'when the cookbook is deprecated and not forced' do
+ context "when the cookbook is deprecated and not forced" do
before do
- @current_data['deprecated'] = true
+ @current_data["deprecated"] = true
end
- it 'should warn with info about the replacement' do
+ it "should warn with info about the replacement" do
expect(@knife.ui).to receive(:warn).
with(/.+deprecated.+replaced by other_apache2.+/i)
expect(@knife.ui).to receive(:warn).
@@ -54,33 +54,33 @@ describe Chef::Knife::CookbookSiteDownload do
end
end
- context 'when' do
+ context "when" do
before do
- @cookbook_data = { 'version' => @version,
- 'file' => "http://example.com/apache2_#{@version_us}.tgz" }
+ @cookbook_data = { "version" => @version,
+ "file" => "http://example.com/apache2_#{@version_us}.tgz" }
@temp_file = double( :path => "/tmp/apache2_#{@version_us}.tgz" )
@file = File.join(Dir.pwd, "apache2-#{@version}.tar.gz")
expect(@noauth_rest).to receive(:sign_on_redirect=).with(false)
end
- context 'downloading the latest version' do
+ context "downloading the latest version" do
before do
expect(@noauth_rest).to receive(:get).
- with(@current_data['latest_version']).
+ with(@current_data["latest_version"]).
and_return(@cookbook_data)
expect(@noauth_rest).to receive(:get).
- with(@cookbook_data['file'], true).
+ with(@cookbook_data["file"], true).
and_return(@temp_file)
end
- context 'and it is deprecated and with --force' do
+ context "and it is deprecated and with --force" do
before do
- @current_data['deprecated'] = true
+ @current_data["deprecated"] = true
@knife.config[:force] = true
end
- it 'should download the latest version' do
+ it "should download the latest version" do
expect(@knife.ui).to receive(:warn).
with(/.+deprecated.+replaced by other_apache2.+/i)
expect(FileUtils).to receive(:cp).with(@temp_file.path, @file)
@@ -91,51 +91,51 @@ describe Chef::Knife::CookbookSiteDownload do
end
- it 'should download the latest version' do
+ it "should download the latest version" do
expect(FileUtils).to receive(:cp).with(@temp_file.path, @file)
@knife.run
expect(@stderr.string).to match /downloading apache2.+version.+#{Regexp.escape(@version)}/i
expect(@stderr.string).to match /cookbook save.+#{Regexp.escape(@file)}/i
end
- context 'with -f or --file' do
+ context "with -f or --file" do
before do
- @file = '/opt/chef/cookbooks/apache2.tar.gz'
+ @file = "/opt/chef/cookbooks/apache2.tar.gz"
@knife.config[:file] = @file
expect(FileUtils).to receive(:cp).with(@temp_file.path, @file)
end
- it 'should download the cookbook to the desired file' do
+ it "should download the cookbook to the desired file" do
@knife.run
expect(@stderr.string).to match /downloading apache2.+version.+#{Regexp.escape(@version)}/i
expect(@stderr.string).to match /cookbook save.+#{Regexp.escape(@file)}/i
end
end
- it 'should provide an accessor to the version' do
+ it "should provide an accessor to the version" do
allow(FileUtils).to receive(:cp).and_return(true)
expect(@knife.version).to eq(@version)
@knife.run
end
end
- context 'downloading a cookbook of a specific version' do
+ context "downloading a cookbook of a specific version" do
before do
- @version = '1.0.1'
- @version_us = @version.gsub '.', '_'
- @cookbook_data = { 'version' => @version,
- 'file' => "http://example.com/apache2_#{@version_us}.tgz" }
+ @version = "1.0.1"
+ @version_us = @version.gsub ".", "_"
+ @cookbook_data = { "version" => @version,
+ "file" => "http://example.com/apache2_#{@version_us}.tgz" }
@temp_file = double(:path => "/tmp/apache2_#{@version_us}.tgz")
@file = File.join(Dir.pwd, "apache2-#{@version}.tar.gz")
@knife.name_args << @version
end
- it 'should download the desired version' do
+ it "should download the desired version" do
expect(@noauth_rest).to receive(:get).
with("#{@cookbook_api_url}/apache2/versions/#{@version_us}").
and_return(@cookbook_data)
expect(@noauth_rest).to receive(:get).
- with(@cookbook_data['file'], true).
+ with(@cookbook_data["file"], true).
and_return(@temp_file)
expect(FileUtils).to receive(:cp).with(@temp_file.path, @file)
@knife.run