Commit 976bffef authored by Robert Speicher's avatar Robert Speicher
Browse files

Update `stub` syntax usages

parent 983b7209
......@@ -10,7 +10,7 @@ describe Upgrader do
describe 'latest_version?' do
it 'should be true if newest version' do
upgrader.stub(latest_version_raw: current_version)
allow(upgrader).to receive_messages(latest_version_raw: current_version)
upgrader.latest_version?.should be_truthy
end
end
......
......@@ -67,7 +67,7 @@ describe Commit do
email_recipients: ''
commit = FactoryGirl.create :commit, project: project
expected = 'commit_pusher_email'
commit.stub(:push_data) { { user_email: expected } }
allow(commit).to receive(:push_data) { { user_email: expected } }
commit.project_recipients.should eq [expected]
end
......@@ -77,7 +77,7 @@ describe Commit do
email_recipients: 'rec1 rec2'
commit = FactoryGirl.create :commit, project: project
expected = 'commit_pusher_email'
commit.stub(:push_data) { { user_email: expected } }
allow(commit).to receive(:push_data) { { user_email: expected } }
commit.project_recipients.should eq ['rec1', 'rec2', expected]
end
......@@ -95,7 +95,7 @@ describe Commit do
email_recipients: 'rec1 rec1 rec2'
commit = FactoryGirl.create :commit, project: project
expected = 'rec2'
commit.stub(:push_data) { { user_email: expected } }
allow(commit).to receive(:push_data) { { user_email: expected } }
commit.project_recipients.should eq ['rec1', 'rec2']
end
end
......@@ -136,7 +136,7 @@ describe Commit do
describe '#create_next_builds' do
before do
commit.stub(:config_processor).and_return(config_processor)
allow(commit).to receive(:config_processor).and_return(config_processor)
end
it "creates builds for next type" do
......@@ -158,7 +158,7 @@ describe Commit do
describe '#create_builds' do
before do
commit.stub(:config_processor).and_return(config_processor)
allow(commit).to receive(:config_processor).and_return(config_processor)
end
it 'creates builds' do
......
......@@ -36,9 +36,7 @@ describe MailService do
let(:build) { FactoryGirl.create(:build, status: :failed, commit: commit) }
before do
mail.stub(
project: project
)
allow(mail).to receive_messages(project: project)
end
it do
......@@ -58,9 +56,7 @@ describe MailService do
let(:build) { FactoryGirl.create(:build, status: :success, commit: commit) }
before do
mail.stub(
project: project
)
allow(mail).to receive_messages(project: project)
end
it do
......@@ -85,9 +81,7 @@ describe MailService do
let(:build) { FactoryGirl.create(:build, status: :success, commit: commit) }
before do
mail.stub(
project: project
)
allow(mail).to receive_messages(project: project)
end
it do
......@@ -113,9 +107,7 @@ describe MailService do
let(:build) { FactoryGirl.create(:build, status: :success, commit: commit) }
before do
mail.stub(
project: project
)
allow(mail).to receive_messages(project: project)
end
it do
......@@ -141,9 +133,7 @@ describe MailService do
let(:build) { FactoryGirl.create(:build, status: :success, commit: commit) }
before do
mail.stub(
project: project
)
allow(mail).to receive_messages(project: project)
build
end
......@@ -163,9 +153,7 @@ describe MailService do
let(:build) { FactoryGirl.create(:build, status: :failed, commit: commit) }
before do
mail.stub(
project: project
)
allow(mail).to receive_messages(project: project)
end
it do
......
......@@ -9,8 +9,8 @@ describe Network do
context 'on success' do
before do
response = double
response.stub(:code) { 200 }
network.class.stub(:put) { response }
allow(response).to receive(:code) { 200 }
allow(network.class).to receive(:put) { response }
end
it { should be_truthy }
......@@ -19,8 +19,8 @@ describe Network do
context 'on failure' do
before do
response = double
response.stub(:code) { 404 }
network.class.stub(:put) { response }
allow(response).to receive(:code) { 404 }
allow(network.class).to receive(:put) { response }
end
it { should be_nil }
......@@ -34,9 +34,9 @@ describe Network do
context 'on success' do
let(:parsed_response) { 'parsed' }
before do
response.stub(:code) { 200 }
response.stub(:parsed_response) { parsed_response }
network.class.stub(:delete) { response }
allow(response).to receive(:code) { 200 }
allow(response).to receive(:parsed_response) { parsed_response }
allow(network.class).to receive(:delete) { response }
end
it { should equal(parsed_response) }
......@@ -44,8 +44,8 @@ describe Network do
context 'on failure' do
before do
response.stub(:code) { 404 }
network.class.stub(:delete) { response }
allow(response).to receive(:code) { 404 }
allow(network.class).to receive(:delete) { response }
end
it { should be_nil }
......
......@@ -39,7 +39,7 @@ describe HipChatService do
let(:api_url) { 'https://api.hipchat.com/v2/room/123/notification?auth_token=a1b2c3d4e5f6' }
before do
service.stub(
allow(service).to receive_messages(
project: project,
project_id: project.id,
notify_only_broken_builds: false,
......
......@@ -38,7 +38,7 @@ describe SlackService do
let(:notify_only_broken_builds) { false }
before do
slack.stub(
allow(slack).to receive_messages(
project: project,
project_id: project.id,
webhook: webhook_url,
......
......@@ -96,29 +96,29 @@ describe Project do
describe '#broken_or_success?' do
it {
project = FactoryGirl.create :project, email_add_pusher: true
project.stub(:broken?).and_return(true)
project.stub(:success?).and_return(true)
allow(project).to receive(:broken?).and_return(true)
allow(project).to receive(:success?).and_return(true)
project.broken_or_success?.should eq true
}
it {
project = FactoryGirl.create :project, email_add_pusher: true
project.stub(:broken?).and_return(true)
project.stub(:success?).and_return(false)
allow(project).to receive(:broken?).and_return(true)
allow(project).to receive(:success?).and_return(false)
project.broken_or_success?.should eq true
}
it {
project = FactoryGirl.create :project, email_add_pusher: true
project.stub(:broken?).and_return(false)
project.stub(:success?).and_return(true)
allow(project).to receive(:broken?).and_return(false)
allow(project).to receive(:success?).and_return(true)
project.broken_or_success?.should eq true
}
it {
project = FactoryGirl.create :project, email_add_pusher: true
project.stub(:broken?).and_return(false)
project.stub(:success?).and_return(false)
allow(project).to receive(:broken?).and_return(false)
allow(project).to receive(:success?).and_return(false)
project.broken_or_success?.should eq false
}
end
......
......@@ -34,9 +34,7 @@ describe Service do
let (:build) { FactoryGirl.create :build, commit: commit }
before do
@service.stub(
project: project
)
allow(@service).to receive_messages(project: project)
build
@testable = @service.can_test?
end
......
......@@ -40,13 +40,13 @@ describe User do
end
it "returns false for reporter" do
@user.stub(:project_info).and_return(project_with_reporter_access)
allow(@user).to receive(:project_info).and_return(project_with_reporter_access)
@user.has_developer_access?(1).should be_falsey
end
it "returns true for owner" do
@user.stub(:project_info).and_return(project_with_owner_access)
allow(@user).to receive(:project_info).and_return(project_with_owner_access)
@user.has_developer_access?(1).should be_truthy
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment