diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-05-22 00:49:06 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-06-22 13:13:46 +0300 |
commit | 5a9ede472150ec78f8410ae15cf782095c8f056c (patch) | |
tree | 5cbdbfb971329960011e8b3a3544e583f9551f6c /spec/models/project_services | |
parent | dad88568f34bfda5f7fe34672bc5099c80226138 (diff) |
Update mock and stub syntax for specs
Diffstat (limited to 'spec/models/project_services')
10 files changed, 31 insertions, 36 deletions
diff --git a/spec/models/project_services/asana_service_spec.rb b/spec/models/project_services/asana_service_spec.rb index cc1f99e0c72..64bb92fba95 100644 --- a/spec/models/project_services/asana_service_spec.rb +++ b/spec/models/project_services/asana_service_spec.rb @@ -42,7 +42,7 @@ describe AsanaService, models: true do before do @asana = AsanaService.new - @asana.stub( + allow(@asana).to receive_messages( project: project, project_id: project.id, service_hook: true, diff --git a/spec/models/project_services/assembla_service_spec.rb b/spec/models/project_services/assembla_service_spec.rb index 9aee754dd63..17e9361dd5c 100644 --- a/spec/models/project_services/assembla_service_spec.rb +++ b/spec/models/project_services/assembla_service_spec.rb @@ -32,7 +32,7 @@ describe AssemblaService, models: true do before do @assembla_service = AssemblaService.new - @assembla_service.stub( + allow(@assembla_service).to receive_messages( project_id: project.id, project: project, service_hook: true, diff --git a/spec/models/project_services/buildkite_service_spec.rb b/spec/models/project_services/buildkite_service_spec.rb index 6db54243eac..9445d96c337 100644 --- a/spec/models/project_services/buildkite_service_spec.rb +++ b/spec/models/project_services/buildkite_service_spec.rb @@ -29,12 +29,10 @@ describe BuildkiteService do describe 'commits methods' do before do @project = Project.new - @project.stub( - default_branch: 'default-brancho' - ) + allow(@project).to receive(:default_branch).and_return('default-brancho') @service = BuildkiteService.new - @service.stub( + allow(@service).to receive_messages( project: @project, service_hook: true, project_url: 'https://buildkite.com/account-name/example-project', diff --git a/spec/models/project_services/flowdock_service_spec.rb b/spec/models/project_services/flowdock_service_spec.rb index e6e8fbba6a7..7e5b15cb09e 100644 --- a/spec/models/project_services/flowdock_service_spec.rb +++ b/spec/models/project_services/flowdock_service_spec.rb @@ -32,7 +32,7 @@ describe FlowdockService do before do @flowdock_service = FlowdockService.new - @flowdock_service.stub( + allow(@flowdock_service).to receive_messages( project_id: project.id, project: project, service_hook: true, diff --git a/spec/models/project_services/gemnasium_service_spec.rb b/spec/models/project_services/gemnasium_service_spec.rb index 1a7765e5c2a..9e156472316 100644 --- a/spec/models/project_services/gemnasium_service_spec.rb +++ b/spec/models/project_services/gemnasium_service_spec.rb @@ -32,7 +32,7 @@ describe GemnasiumService do before do @gemnasium_service = GemnasiumService.new - @gemnasium_service.stub( + allow(@gemnasium_service).to receive_messages( project_id: project.id, project: project, service_hook: true, diff --git a/spec/models/project_services/gitlab_ci_service_spec.rb b/spec/models/project_services/gitlab_ci_service_spec.rb index c92cf3cdae6..fedc37c9b94 100644 --- a/spec/models/project_services/gitlab_ci_service_spec.rb +++ b/spec/models/project_services/gitlab_ci_service_spec.rb @@ -21,18 +21,15 @@ require 'spec_helper' describe GitlabCiService do - describe "Associations" do - it { is_expected.to belong_to :project } - it { is_expected.to have_one :service_hook } - end - - describe "Mass assignment" do + describe 'associations' do + it { is_expected.to belong_to(:project) } + it { is_expected.to have_one(:service_hook) } end describe 'commits methods' do before do @service = GitlabCiService.new - @service.stub( + allow(@service).to receive_messages( service_hook: true, project_url: 'http://ci.gitlab.org/projects/2', token: 'verySecret' @@ -56,9 +53,9 @@ describe GitlabCiService do it "calls ci_yaml_file" do service_hook = double - service_hook.should_receive(:execute) - @service.should_receive(:service_hook).and_return(service_hook) - @service.should_receive(:ci_yaml_file).with(push_sample_data[:checkout_sha]) + expect(service_hook).to receive(:execute) + expect(@service).to receive(:service_hook).and_return(service_hook) + expect(@service).to receive(:ci_yaml_file).with(push_sample_data[:checkout_sha]) @service.execute(push_sample_data) end @@ -72,7 +69,7 @@ describe GitlabCiService do @user = create(:user) @service = GitlabCiService.new - @service.stub( + allow(@service).to receive_messages( service_hook: true, project_url: 'http://ci.gitlab.org/projects/2', token: 'verySecret', diff --git a/spec/models/project_services/hipchat_service_spec.rb b/spec/models/project_services/hipchat_service_spec.rb index e88615e1a2e..8ed03dd1da8 100644 --- a/spec/models/project_services/hipchat_service_spec.rb +++ b/spec/models/project_services/hipchat_service_spec.rb @@ -37,7 +37,7 @@ describe HipchatService do let(:push_sample_data) { Gitlab::PushDataBuilder.build_sample(project, user) } before(:each) do - hipchat.stub( + allow(hipchat).to receive_messages( project_id: project.id, project: project, room: 123456, @@ -48,7 +48,7 @@ describe HipchatService do end it 'should use v1 if version is provided' do - hipchat.stub(api_version: 'v1') + allow(hipchat).to receive(:api_version).and_return('v1') expect(HipChat::Client).to receive(:new). with(token, api_version: 'v1', @@ -59,7 +59,7 @@ describe HipchatService do end it 'should use v2 as the version when nothing is provided' do - hipchat.stub(api_version: '') + allow(hipchat).to receive(:api_version).and_return('') expect(HipChat::Client).to receive(:new). with(token, api_version: 'v2', @@ -245,12 +245,12 @@ describe HipchatService do end it "should set notfiy to true" do - hipchat.stub(notify: '1') + allow(hipchat).to receive(:notify).and_return('1') expect(hipchat.send(:message_options)).to eq({notify: true, color: 'yellow'}) end it "should set the color" do - hipchat.stub(color: 'red') + allow(hipchat).to receive(:color).and_return('red') expect(hipchat.send(:message_options)).to eq({notify: false, color: 'red'}) end end diff --git a/spec/models/project_services/irker_service_spec.rb b/spec/models/project_services/irker_service_spec.rb index 4c437aab12b..37690434ec8 100644 --- a/spec/models/project_services/irker_service_spec.rb +++ b/spec/models/project_services/irker_service_spec.rb @@ -24,8 +24,8 @@ require 'json' describe IrkerService do describe 'Associations' do - it { should belong_to :project } - it { should have_one :service_hook } + it { is_expected.to belong_to :project } + it { is_expected.to have_one :service_hook } end describe 'Validations' do @@ -66,7 +66,7 @@ describe IrkerService do let(:colorize_messages) { '1' } before do - irker.stub( + allow(irker).to receive_messages( active: true, project: project, project_id: project.id, diff --git a/spec/models/project_services/pushover_service_spec.rb b/spec/models/project_services/pushover_service_spec.rb index 5f93703b50a..ac10ffbd39b 100644 --- a/spec/models/project_services/pushover_service_spec.rb +++ b/spec/models/project_services/pushover_service_spec.rb @@ -52,7 +52,7 @@ describe PushoverService do let(:api_url) { 'https://api.pushover.net/1/messages.json' } before do - pushover.stub( + allow(pushover).to receive_messages( project: project, project_id: project.id, service_hook: true, diff --git a/spec/models/project_services/slack_service_spec.rb b/spec/models/project_services/slack_service_spec.rb index e9105677d23..69466b11f09 100644 --- a/spec/models/project_services/slack_service_spec.rb +++ b/spec/models/project_services/slack_service_spec.rb @@ -46,7 +46,7 @@ describe SlackService do let(:channel) { 'slack_channel' } before do - slack.stub( + allow(slack).to receive_messages( project: project, project_id: project.id, service_hook: true, @@ -96,7 +96,7 @@ describe SlackService do end it 'should use the username as an option for slack when configured' do - slack.stub(username: username) + allow(slack).to receive(:username).and_return(username) expect(Slack::Notifier).to receive(:new). with(webhook_url, username: username). and_return( @@ -106,7 +106,7 @@ describe SlackService do end it 'should use the channel as an option when it is configured' do - slack.stub(channel: channel) + allow(slack).to receive(:channel).and_return(channel) expect(Slack::Notifier).to receive(:new). with(webhook_url, channel: channel). and_return( @@ -130,11 +130,11 @@ describe SlackService do let(:webhook_url) { 'https://hooks.slack.com/services/SVRWFV0VVAR97N/B02R25XN3/ZBqu7xMupaEEICInN685' } before do - slack.stub( - project: project, - project_id: project.id, - service_hook: true, - webhook: webhook_url + allow(slack).to receive_messages( + project: project, + project_id: project.id, + service_hook: true, + webhook: webhook_url ) WebMock.stub_request(:post, webhook_url) |