Skip to content
Open
3 changes: 2 additions & 1 deletion metaforce.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ EOL

s.add_dependency 'savon', '~> 1.2.0'
s.add_dependency 'rubyzip', '~> 1.0'
s.add_dependency 'activesupport'
s.add_dependency 'activesupport', RUBY_VERSION < "1.9.3" ? [">= 2", "< 4"] : ">= 2"
s.add_dependency 'hashie', '~> 1.2.0'
s.add_dependency 'thor', '~> 0.16.0'
s.add_dependency 'listen', '~> 0.6.0'
s.add_dependency 'rb-fsevent', '~> 0.9.1'

s.add_development_dependency 'rake'
s.add_development_dependency 'rspec-its', '~>1.0.0pre'
s.add_development_dependency 'rspec'
s.add_development_dependency 'webmock'
s.add_development_dependency 'savon_spec', '~> 1.3.0'
Expand Down
16 changes: 8 additions & 8 deletions spec/lib/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

describe Metaforce::CLI do
before do
Metaforce::Client.any_instance.stub(:deploy).and_return(double('deploy job').as_null_object)
Metaforce::Client.any_instance.stub(:retrieve).and_return(double('retrieve job').as_null_object)
subject.stub(:config).and_return(nil)
allow_any_instance_of(Metaforce::Client).to receive(:deploy).and_return(double('deploy job').as_null_object)
allow_any_instance_of(Metaforce::Client).to receive(:retrieve).and_return(double('retrieve job').as_null_object)
allow(subject).to receive(:config).and_return(nil)
end

describe 'credentials' do
Expand All @@ -16,8 +16,8 @@

it 'uses supplied credentials from command line' do
subject.options = options
Metaforce.should_receive(:new).with(indifferent_hash(options).slice(:username, :password, :security_token)).and_call_original
output.should include('Deploying: ./path')
expect(Metaforce).to receive(:new).with(indifferent_hash(options).slice(:username, :password, :security_token)).and_call_original
expect(output).to include('Deploying: ./path')
end
end

Expand All @@ -27,9 +27,9 @@

it 'uses credentials from the config file' do
subject.options = options
subject.stub(:config).and_return('production' => config)
Metaforce.should_receive(:new).with(indifferent_hash(config)).and_call_original
output.should include('Deploying: ./path')
allow(subject).to receive(:config).and_return('production' => config)
expect(Metaforce).to receive(:new).with(indifferent_hash(config)).and_call_original
expect(output).to include('Deploying: ./path')
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
%w[services metadata].each do |type|
context "when the #{type} client responds to method" do
it 'proxies to the method' do
client.send(type.to_sym).should_receive(:respond_to?).with(:foobar, false).and_return(true)
client.send(type.to_sym).should_receive(:foobar)
allow(client.send(type.to_sym)).to receive(:foobar)
expect(client.send(type.to_sym)).to receive(:respond_to?).with(:foobar, false).and_return(true)
client.foobar
end
end
Expand Down
14 changes: 7 additions & 7 deletions spec/lib/job/deploy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

context 'when the path is a file' do
before do
client.should_receive(:_deploy).with(/^UEsDBA.*/, {}).and_return(Hashie::Mash.new(id: '1234'))
client.should_receive(:status).any_number_of_times.and_return(Hashie::Mash.new(done: true, state: 'Completed'))
expect(client).to receive(:_deploy).with(/^UEsDBA.*/, {}).and_return(Hashie::Mash.new(id: '1234'))
expect(client).to receive(:status).at_least(:once).and_return(Hashie::Mash.new(done: true, state: 'Completed'))
end

it { should eq job }
Expand All @@ -20,8 +20,8 @@

context 'when the path is a directory' do
before do
client.should_receive(:_deploy).with(/.*1stwAAAJI.*/, {}).and_return(Hashie::Mash.new(id: '1234'))
client.should_receive(:status).any_number_of_times.and_return(Hashie::Mash.new(done: true, state: 'Completed'))
expect(client).to receive(:_deploy).with(/.*1stwAAAJI.*/, {}).and_return(Hashie::Mash.new(id: '1234'))
expect(client).to receive(:status).at_least(:once).and_return(Hashie::Mash.new(done: true, state: 'Completed'))
end

let(:path) { File.expand_path('../../../fixtures', __FILE__) }
Expand All @@ -34,7 +34,7 @@
let(:response) { Hashie::Mash.new(success: true) }

before do
client.should_receive(:status).with(job.id, :deploy).and_return(response)
expect(client).to receive(:status).with(job.id, :deploy).and_return(response)
end

subject { job.result }
Expand All @@ -45,10 +45,10 @@
let(:response) { Hashie::Mash.new(success: true) }

before do
client.should_receive(:status).with(job.id, :deploy).and_return(response)
expect(client).to receive(:status).with(job.id, :deploy).and_return(response)
end

subject { job.success? }
it { should be_true }
it { should be_truthy }
end
end
11 changes: 7 additions & 4 deletions spec/lib/job/retrieve_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'spec_helper'
require 'base64'

describe Metaforce::Job::Retrieve do
let(:client) { double('metadata client') }
Expand All @@ -8,21 +9,23 @@
let(:response) { Hashie::Mash.new(success: true) }

before do
client.should_receive(:status).with(job.id, :retrieve).and_return(response)
expect(client).to receive(:status).with(job.id, :retrieve).and_return(response)
end

subject { job.result }
it { should eq response }
end

describe '.zip_file' do
let(:response) { Hashie::Mash.new(success: true, zip_file: 'foobar') }
zip_file_content = 'foobar'
let(:response) { Hashie::Mash.new(success: true, zip_file: zip_file_content) }

before do
client.should_receive(:status).with(job.id, :retrieve).and_return(response)
expect(client).to receive(:status).with(job.id, :retrieve).and_return(response)
end

subject { job.zip_file }
it { should eq "~\x8A\e" }
#it { should eq "~\x8A\e" }
it { should eq Base64.decode64(zip_file_content) }
end
end
34 changes: 17 additions & 17 deletions spec/lib/job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

describe '.perform' do
it 'starts a heart beat' do
job.should_receive(:start_heart_beat)
expect(job).to receive(:start_heart_beat)
job.perform
end
end
Expand All @@ -19,39 +19,39 @@
job.instance_variable_set(:@id, '1234')
end

it { should be_true }
it { should be_truthy }
end

context 'when .perform has not been called and no @id has been set' do
it { should be_false }
it { should be_falsey }
end
end

describe '.on_complete' do
it 'allows the user to register an on_complete callback' do
client.should_receive(:status).any_number_of_times.and_return(Hashie::Mash.new(done: true, state: 'Completed'))
expect(client).to receive(:status).and_return(Hashie::Mash.new(done: true, state: 'Completed'))
called = false
block = lambda { |job| called = true }
job.on_complete &block
job.perform
expect(called).to be_true
expect(called).to be_truthy
end
end

describe '.on_error' do
it 'allows the user to register an on_error callback' do
client.should_receive(:status).any_number_of_times.and_return(Hashie::Mash.new(done: true, state: 'Error'))
expect(client).to receive(:status).and_return(Hashie::Mash.new(done: true, state: 'Error'))
called = false
block = lambda { |job| called = true }
job.on_error &block
job.perform
expect(called).to be_true
expect(called).to be_truthy
end
end

describe '.status' do
before do
client.should_receive(:status)
expect(client).to receive(:status)
end

subject { job.status }
Expand All @@ -63,18 +63,18 @@

context 'when done' do
before do
client.should_receive(:status).and_return(Hashie::Mash.new(done: true))
expect(client).to receive(:status).and_return(Hashie::Mash.new(done: true))
end

it { should be_true }
it { should be_truthy }
end

context 'when not done' do
before do
client.should_receive(:status).and_return(Hashie::Mash.new(done: false))
expect(client).to receive(:status).and_return(Hashie::Mash.new(done: false))
end

it { should be_false }
it { should be_falsey }
end
end

Expand All @@ -83,29 +83,29 @@

context 'when done' do
before do
client.should_receive(:status).and_return(Hashie::Mash.new(done: true, state: 'Completed'))
expect(client).to receive(:status).and_return(Hashie::Mash.new(done: true, state: 'Completed'))
end

it { should eq 'Completed' }
end

context 'when not done' do
before do
client.should_receive(:status).once.and_return(Hashie::Mash.new(done: false))
expect(client).to receive(:status).once.and_return(Hashie::Mash.new(done: false))
end

it { should be_false }
it { should be_falsey }
end
end

%w[Queued InProgress Completed Error].each do |state|
describe ".#{state.underscore}?" do
before do
client.should_receive(:status).and_return(Hashie::Mash.new(done: true, state: state))
expect(client).to receive(:status).and_return(Hashie::Mash.new(done: true, state: state))
end

subject { job.send(:"#{state.underscore}?") }
it { should be_true }
it { should be_truthy }
end
end
end
8 changes: 4 additions & 4 deletions spec/lib/metaforce_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

context 'when environment variables are not defined' do
it 'proxies the login call' do
Metaforce::Login.should_receive(:new).with('foo', 'foobar', 'whizbang').and_call_original
Metaforce::Login.any_instance.should_receive(:login)
expect(Metaforce::Login).to receive(:new).with('foo', 'foobar', 'whizbang').and_call_original
expect_any_instance_of(Metaforce::Login).to receive(:login)
described_class.login args
end
end
Expand All @@ -33,8 +33,8 @@
end

it 'proxies the login call' do
Metaforce::Login.should_receive(:new).with('foo', 'foobar', 'whizbang').and_call_original
Metaforce::Login.any_instance.should_receive(:login)
expect(Metaforce::Login).to receive(:new).with('foo', 'foobar', 'whizbang').and_call_original
expect_any_instance_of(Metaforce::Login).to receive(:login)
described_class.login
end
end
Expand Down
32 changes: 16 additions & 16 deletions spec/lib/reporters/base_reporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
let(:problem) { Hashie::Mash.new(file_name: 'path/file', line_number: '10', problem: 'Foobar') }

it 'prints the problem' do
reporter.should_receive(:say).with(' path/file:10', :red)
reporter.should_receive(:say).with(' Foobar')
reporter.should_receive(:say).with
expect(reporter).to receive(:say).with(' path/file:10', :red)
expect(reporter).to receive(:say).with(' Foobar')
expect(reporter).to receive(:say).with( no_args )
reporter.problem(problem)
end
end
Expand All @@ -21,9 +21,9 @@
let(:problem) { Hashie::Mash.new(file_name: 'path/file', problem: 'Foobar') }

it 'prints the problem' do
reporter.should_receive(:say).with(' path/file:', :red)
reporter.should_receive(:say).with(' Foobar')
reporter.should_receive(:say).with
expect(reporter).to receive(:say).with(' path/file:', :red)
expect(reporter).to receive(:say).with(' Foobar')
expect(reporter).to receive(:say).with( no_args )
reporter.problem(problem)
end
end
Expand All @@ -32,8 +32,8 @@
describe '.report_problems' do
context 'when there are no problems' do
it 'does not report any problems' do
reporter.should_receive(:say).never
reporter.should_receive(:problem).never
expect(reporter).to receive(:say).never
expect(reporter).to receive(:problem).never
reporter.report_problems
end
end
Expand All @@ -42,10 +42,10 @@
let(:results) { Hashie::Mash.new(success: true, messages: { problem: 'Problem', file_name: 'path/file', line_number: '10' }) }

it 'prints each problem' do
reporter.should_receive(:say)
reporter.should_receive(:say).with('Problems:', :red)
reporter.should_receive(:say)
reporter.should_receive(:problem)
expect(reporter).to receive(:say)
expect(reporter).to receive(:say).with('Problems:', :red)
expect(reporter).to receive(:say)
expect(reporter).to receive(:problem)
reporter.report_problems
end
end
Expand All @@ -55,25 +55,25 @@
subject { reporter.problems? }

context 'when there are no problems' do
it { should be_false }
it { should be_falsey }
end

context 'when there are problems' do
let(:results) { Hashie::Mash.new(success: true, messages: { problem: 'Problem', file_name: 'path/file', line_number: '10' }) }
it { should be_true }
it { should be_truthy }
end
end

describe '.issues?' do
subject { reporter.issues? }

context 'when there are no problems' do
it { should be_false }
it { should be_falsey }
end

context 'when there are problems' do
let(:results) { Hashie::Mash.new(success: true, messages: { problem: 'Problem', file_name: 'path/file', line_number: '10' }) }
it { should be_true }
it { should be_truthy }
end
end
end
Loading