fix rspec deprecation warnings in cucumber setup

This commit is contained in:
Joshua Hoblitt 2016-03-26 10:28:28 -07:00
parent c8b0acb231
commit e796725a15
3 changed files with 26 additions and 23 deletions

View File

@ -1,15 +1,16 @@
Given(/^I have catalog meta\-data$/) do
JPM.stub(:repository_path).and_return(
File.expand_path(File.dirname(__FILE__) + '/../../spec/fixtures/update-center.json'))
allow(JPM).to receive(:repository_path) do
File.expand_path(File.dirname(__FILE__) + '/../../spec/fixtures/update-center.json')
end
end
Given(/^an update\-center\.json doesn't already exist$/) do
# Found in Aruba::Api
in_current_dir do
cd('.') do
# Relative path, since our Dir.pwd will be tmp/aruba already
repo = './update-center.json'
JPM.stub(:repository_path).and_return(repo)
allow(JPM).to receive(:repository_path) { repo }
# If the thing exists already, nuke it!
if File.exists? repo
@ -20,11 +21,11 @@ end
Given(/^an update\-center\.json already exists$/) do
# Found in Aruba::Api
in_current_dir do
cd('.') do
# Relative path, since our Dir.pwd will be tmp/aruba already
repo = './update-center.json'
JPM.stub(:repository_path).and_return(repo)
allow(JPM).to receive(:repository_path) { repo }
File.open(repo, 'w+') do |fd|
fd.write("\n{}\n")
end
@ -34,7 +35,7 @@ end
Given(/^I have a site with a custom update\-center\.json$/) do
# Relative path, since our Dir.pwd will be tmp/aruba already
repo = './update-center.json'
JPM.stub(:repository_path).and_return(repo)
allow(JPM).to receive(:repository_path) { repo }
# If the thing exists already, nuke it!
if File.exists? repo
@ -43,6 +44,6 @@ Given(/^I have a site with a custom update\-center\.json$/) do
response = double('Mock HTTPResponse', :body => '')
JPM.should_receive(:fetch).with('http://aruba.bdd/update-center.json').and_return(response)
expect(JPM).to receive(:fetch).with('http://aruba.bdd/update-center.json') { response }
end

View File

@ -1,25 +1,27 @@
Given(/^Jenkins isn't installed$/) do
JPM.stub(:installed? => false)
allow(JPM).to receive(:installed?) { false }
end
Given(/^Jenkins is installed$/) do
JPM.stub(:installed? => true)
allow(JPM).to receive(:installed?) { false }
end
Given(/^there are no plugins available$/) do
JPM.stub(:plugins => [])
allow(JPM).to receive(:plugins) { [] }
end
Given(/^there are plugins available$/) do
JPM.stub(:has_plugins? => true)
JPM.stub(:plugins => [
{
:name => 'greenballs',
:version => '1.0'
},
{
:name => 'ant',
:version => '1.1'
},
])
allow(JPM).to receive(:has_plugins?) { true }
allow(JPM).to receive(:plugins) do
[
{
:name => 'greenballs',
:version => '1.0'
},
{
:name => 'ant',
:version => '1.1'
},
]
end
end

View File

@ -1,4 +1,4 @@
Before '@install-success' do
JPM::Catalog.any_instance.stub(:download).and_return(true)
expect(JPM::Catalog).to receive(:download) { true }
end