spec/cfoundry/v2/app_spec.rb in cfoundry-2.2.0.rc1 vs spec/cfoundry/v2/app_spec.rb in cfoundry-2.2.0.rc2
- old
+ new
@@ -58,11 +58,11 @@
describe "#summarize!" do
let(:app) { build(:app) }
it "assigns :instances as #total_instances" do
- stub(app).summary { {:instances => 4} }
+ app.stub(:summary) { {:instances => 4} }
app.summarize!
expect(app.total_instances).to eq(4)
end
@@ -71,18 +71,18 @@
shared_examples_for "something may stage the app" do
subject { build(:app, :client => client) }
let(:response) { {:body => '{ "foo": "bar" }'} }
before do
- stub(client.base).put("v2", "apps", subject.guid, anything) do
+ client.base.stub(:put).with("v2", "apps", subject.guid, anything) do
response
end
end
context "when asynchronous is true" do
it "sends the PUT request with &stage_async=true" do
- mock(client.base).put(
+ client.base.should_receive(:put).with(
"v2", "apps", subject.guid,
hash_including(
:params => {:stage_async => true},
:return_response => true)) do
response
@@ -109,11 +109,11 @@
end
end
context "when asynchronous is false" do
it "sends the PUT request with &stage_async=false" do
- mock(client.base).put(
+ client.base.should_receive(:put).with(
"v2", "apps", subject.guid,
hash_including(:params => {:stage_async => false})) do
response
end
@@ -142,11 +142,11 @@
describe "changes" do
subject { build(:app, :client => client) }
let(:response) { {:body => {"foo" => "bar"}.to_json} }
before do
- stub(client.base).put("v2", "apps", subject.guid, anything) do
+ client.base.stub(:put).with("v2", "apps", subject.guid, anything) do
response
end
end
it "applies the changes from the response JSON" do
@@ -165,17 +165,17 @@
describe "#stream_update_log" do
let(:base_url) { "http://example.com/log" }
def mock_log(url = anything)
- mock(client).stream_url(url) do |_, blk|
+ client.should_receive(:stream_url).with(url) do |_, &blk|
blk.call(yield)
end.ordered
end
def stub_log(url = anything)
- stub(client).stream_url(url) do |_, blk|
+ client.stub(:stream_url).with(url) do |_, blk|
blk.call(yield)
end.ordered
end
it "yields chunks from the response to the block" do
@@ -238,26 +238,26 @@
end
end
describe "delete!" do
it "defaults to recursive" do
- mock(client.base).delete("v2", :apps, subject.guid, {:params => {:recursive => true}})
+ client.base.should_receive(:delete).with("v2", :apps, subject.guid, {:params => {:recursive => true}})
subject.delete!
end
end
it "accepts and ignores an options hash" do
- mock(client.base).delete("v2", :apps, subject.guid, {:params => {:recursive => true}})
+ client.base.should_receive(:delete).with("v2", :apps, subject.guid, {:params => {:recursive => true}})
subject.delete!(:recursive => false)
end
describe "#health" do
describe "when staging failed for an app" do
it "returns 'STAGING FAILED' as state" do
- stub(client.base).instances(subject.guid) { raise CFoundry::StagingError }
- stub(subject).state { "STARTED" }
+ client.base.stub(:instances).with(subject.guid) { raise CFoundry::StagingError }
+ subject.stub(:state) { "STARTED" }
expect(subject.health).to eq("STAGING FAILED")
end
end
end