summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-08-30 19:10:53 -0400
committerRobert Speicher <rspeicher@gmail.com>2015-08-30 19:12:55 -0400
commit77053a6c217e06770a348ac989992afbd41697f6 (patch)
tree11df50675162be2045777c1f59c312d359e0d6cf
parent74b995d17b095e326177e7c0e452f0df3a1ab885 (diff)
downloadgitlab-ci-77053a6c217e06770a348ac989992afbd41697f6.tar.gz
Convert to RSpec3 syntax via transpecrs-rspec3
Command: transpec -c 'bundle exec rspec spec -t ~feature' \ -o should,oneliner,should_receive
-rw-r--r--spec/features/admin/runners_spec.rb2
-rw-r--r--spec/features/projects_spec.rb2
-rw-r--r--spec/features/runners_spec.rb4
-rw-r--r--spec/features/triggers_spec.rb4
-rw-r--r--spec/features/variables_spec.rb2
-rw-r--r--spec/helpers/application_helper_spec.rb6
-rw-r--r--spec/helpers/runners_helper_spec.rb6
-rw-r--r--spec/helpers/user_helper_spec.rb12
-rw-r--r--spec/helpers/user_sessions_helper_spec.rb22
-rw-r--r--spec/lib/ansi2html_spec.rb66
-rw-r--r--spec/lib/charts_spec.rb2
-rw-r--r--spec/lib/gitlab_ci_yaml_processor_spec.rb30
-rw-r--r--spec/lib/upgrader_spec.rb4
-rw-r--r--spec/mailers/notify_spec.rb8
-rw-r--r--spec/models/build_spec.rb88
-rw-r--r--spec/models/commit_spec.rb96
-rw-r--r--spec/models/mail_service_spec.rb24
-rw-r--r--spec/models/network_spec.rb8
-rw-r--r--spec/models/project_services/hip_chat_service_spec.rb4
-rw-r--r--spec/models/project_services/slack_message_spec.rb44
-rw-r--r--spec/models/project_services/slack_service_spec.rb6
-rw-r--r--spec/models/project_spec.rb70
-rw-r--r--spec/models/runner_spec.rb10
-rw-r--r--spec/models/service_spec.rb4
-rw-r--r--spec/models/trigger_spec.rb4
-rw-r--r--spec/models/user_spec.rb12
-rw-r--r--spec/models/variable_spec.rb6
-rw-r--r--spec/models/web_hook_spec.rb28
-rw-r--r--spec/requests/api/builds_spec.rb26
-rw-r--r--spec/requests/api/commits_spec.rb16
-rw-r--r--spec/requests/api/forks_spec.rb6
-rw-r--r--spec/requests/api/projects_spec.rb68
-rw-r--r--spec/requests/api/runners_spec.rb30
-rw-r--r--spec/requests/api/triggers_spec.rb26
-rw-r--r--spec/requests/builds_spec.rb4
-rw-r--r--spec/requests/commits_spec.rb4
-rw-r--r--spec/services/create_commit_service_spec.rb32
-rw-r--r--spec/services/create_project_service_spec.rb10
-rw-r--r--spec/services/create_trigger_request_service_spec.rb14
-rw-r--r--spec/services/event_service_spec.rb6
-rw-r--r--spec/services/image_for_build_service_spec.rb24
-rw-r--r--spec/services/register_build_service_spec.rb36
-rw-r--r--spec/services/web_hook_service_spec.rb4
43 files changed, 440 insertions, 440 deletions
diff --git a/spec/features/admin/runners_spec.rb b/spec/features/admin/runners_spec.rb
index 1df4875..56f81eb 100644
--- a/spec/features/admin/runners_spec.rb
+++ b/spec/features/admin/runners_spec.rb
@@ -42,7 +42,7 @@ describe "Admin Runners", feature: true do
end
describe 'runner info' do
- it { find_field('runner_token').value.should eq runner.token }
+ it { expect(find_field('runner_token').value).to eq runner.token }
end
describe 'projects' do
diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb
index 142c663..7861e53 100644
--- a/spec/features/projects_spec.rb
+++ b/spec/features/projects_spec.rb
@@ -39,7 +39,7 @@ describe "Projects", feature: true do
expect(page).to have_content 'was successfully updated'
- find_field('Timeout').value.should eq '70'
+ expect(find_field('Timeout').value).to eq '70'
end
end
diff --git a/spec/features/runners_spec.rb b/spec/features/runners_spec.rb
index 829e5db..05fb7e0 100644
--- a/spec/features/runners_spec.rb
+++ b/spec/features/runners_spec.rb
@@ -60,7 +60,7 @@ describe "Runners", feature: true do
click_on "Remove runner"
end
- Runner.exists?(id: @specific_runner).should be_falsey
+ expect(Runner.exists?(id: @specific_runner)).to be_falsey
end
end
@@ -75,7 +75,7 @@ describe "Runners", feature: true do
click_on "Enable shared runners"
- @project.reload.shared_runners_enabled.should be_truthy
+ expect(@project.reload.shared_runners_enabled).to be_truthy
end
end
diff --git a/spec/features/triggers_spec.rb b/spec/features/triggers_spec.rb
index 9a1bc77..b8f4616 100644
--- a/spec/features/triggers_spec.rb
+++ b/spec/features/triggers_spec.rb
@@ -11,7 +11,7 @@ describe 'Variables', feature: true do
context 'create a trigger' do
before do
click_on 'Add Trigger'
- @project.triggers.count.should eq 1
+ expect(@project.triggers.count).to eq 1
end
it 'contains trigger token' do
@@ -20,7 +20,7 @@ describe 'Variables', feature: true do
it 'revokes the trigger' do
click_on 'Revoke'
- @project.triggers.count.should eq 0
+ expect(@project.triggers.count).to eq 0
end
end
end
diff --git a/spec/features/variables_spec.rb b/spec/features/variables_spec.rb
index f0b0cd8..9cf3632 100644
--- a/spec/features/variables_spec.rb
+++ b/spec/features/variables_spec.rb
@@ -19,7 +19,7 @@ describe "Variables", feature: true do
click_on "Save changes"
expect(page).to have_content("Variables were successfully updated.")
- @project.variables.count.should eq 1
+ expect(@project.variables.count).to eq 1
end
end
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index 4e2ba8d..a7b6151 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -11,12 +11,12 @@ describe ApplicationHelper do
}
intervals_in_words.each do |interval, expectation|
- duration_in_words(Time.now + interval, Time.now).should eq expectation
+ expect(duration_in_words(Time.now + interval, Time.now)).to eq expectation
end
end
it "calculates interval from now if there is no finished_at" do
- duration_in_words(nil, Time.now - 5).should eq "5 seconds"
+ expect(duration_in_words(nil, Time.now - 5)).to eq "5 seconds"
end
end
@@ -30,7 +30,7 @@ describe ApplicationHelper do
}
intervals_in_words.each do |interval, expectation|
- time_interval_in_words(interval).should eq expectation
+ expect(time_interval_in_words(interval)).to eq expectation
end
end
end
diff --git a/spec/helpers/runners_helper_spec.rb b/spec/helpers/runners_helper_spec.rb
index 02d497b..a93032e 100644
--- a/spec/helpers/runners_helper_spec.rb
+++ b/spec/helpers/runners_helper_spec.rb
@@ -3,16 +3,16 @@ require 'spec_helper'
describe RunnersHelper do
it "returns - not contacted yet" do
runner = FactoryGirl.build :runner
- runner_status_icon(runner).should include("not connected yet")
+ expect(runner_status_icon(runner)).to include("not connected yet")
end
it "returns offline text" do
runner = FactoryGirl.build(:runner, contacted_at: 1.day.ago, active: true)
- runner_status_icon(runner).should include("Runner is offline")
+ expect(runner_status_icon(runner)).to include("Runner is offline")
end
it "returns online text" do
runner = FactoryGirl.build(:runner, contacted_at: 1.hour.ago, active: true)
- runner_status_icon(runner).should include("Runner is online")
+ expect(runner_status_icon(runner)).to include("Runner is online")
end
end
diff --git a/spec/helpers/user_helper_spec.rb b/spec/helpers/user_helper_spec.rb
index 19fcb11..e6e6ab4 100644
--- a/spec/helpers/user_helper_spec.rb
+++ b/spec/helpers/user_helper_spec.rb
@@ -8,7 +8,7 @@ describe UserHelper do
let (:avatar_url) { nil }
it 'should return a generic avatar' do
- user_avatar_url(user).should eq 'no_avatar.png'
+ expect(user_avatar_url(user)).to eq 'no_avatar.png'
end
end
@@ -17,11 +17,11 @@ describe UserHelper do
let (:avatar_url) { "#{base_url}?s=40&d=mm" }
it 'should return gravatar with default size' do
- user_avatar_url(user).should eq "#{base_url}?s=40&d=identicon"
+ expect(user_avatar_url(user)).to eq "#{base_url}?s=40&d=identicon"
end
it 'should return gravatar with custom size' do
- user_avatar_url(user, 120).should eq "#{base_url}?s=120&d=identicon"
+ expect(user_avatar_url(user, 120)).to eq "#{base_url}?s=120&d=identicon"
end
end
@@ -30,11 +30,11 @@ describe UserHelper do
let (:avatar_url) { "#{base_url}?s=40&d=mm" }
it 'should return gravatar with default size' do
- user_avatar_url(user).should eq "#{base_url}?s=40&d=identicon"
+ expect(user_avatar_url(user)).to eq "#{base_url}?s=40&d=identicon"
end
it 'should return gravatar with custom size' do
- user_avatar_url(user, 120).should eq "#{base_url}?s=120&d=identicon"
+ expect(user_avatar_url(user, 120)).to eq "#{base_url}?s=120&d=identicon"
end
end
@@ -42,7 +42,7 @@ describe UserHelper do
let (:avatar_url) { 'http://example.local/avatar.png' }
it 'should return custom avatar' do
- user_avatar_url(user).should eq avatar_url
+ expect(user_avatar_url(user)).to eq avatar_url
end
end
end
diff --git a/spec/helpers/user_sessions_helper_spec.rb b/spec/helpers/user_sessions_helper_spec.rb
index ad2a50f..553e90c 100644
--- a/spec/helpers/user_sessions_helper_spec.rb
+++ b/spec/helpers/user_sessions_helper_spec.rb
@@ -7,17 +7,17 @@ describe UserSessionsHelper do
let (:return_to) { 'b' }
it 'should return null if return_to is also null' do
- generate_oauth_hmac(salt, nil).should be_nil
+ expect(generate_oauth_hmac(salt, nil)).to be_nil
end
it 'should return not null if return_to is also not null' do
- generate_oauth_hmac(salt, return_to).should_not be_nil
+ expect(generate_oauth_hmac(salt, return_to)).not_to be_nil
end
it 'should return different hmacs for different salts' do
secret1 = generate_oauth_hmac(salt, return_to)
secret2 = generate_oauth_hmac(salt2, return_to)
- secret1.should_not eq(secret2)
+ expect(secret1).not_to eq(secret2)
end
end
@@ -25,13 +25,13 @@ describe UserSessionsHelper do
let (:return_to) { 'b' }
it 'should return null if return_to is also null' do
- generate_oauth_state(nil).should be_nil
+ expect(generate_oauth_state(nil)).to be_nil
end
it 'should return two different states for same return_to' do
state1 = generate_oauth_state(return_to)
state2 = generate_oauth_state(return_to)
- state1.should_not eq(state2)
+ expect(state1).not_to eq(state2)
end
end
@@ -40,7 +40,7 @@ describe UserSessionsHelper do
let (:state) { generate_oauth_state(return_to) }
it 'should return return_to' do
- get_ouath_state_return_to(state).should eq(return_to)
+ expect(get_ouath_state_return_to(state)).to eq(return_to)
end
end
@@ -53,17 +53,17 @@ describe UserSessionsHelper do
let (:invalid3) { 'aa:bb:' }
it 'should validate oauth state' do
- is_oauth_state_valid?(state).should be_truthy
+ expect(is_oauth_state_valid?(state)).to be_truthy
end
it 'should not validate forged state' do
- is_oauth_state_valid?(forged).should be_falsey
+ expect(is_oauth_state_valid?(forged)).to be_falsey
end
it 'should not validate invalid state' do
- is_oauth_state_valid?(invalid).should be_falsey
- is_oauth_state_valid?(invalid2).should be_falsey
- is_oauth_state_valid?(invalid3).should be_falsey
+ expect(is_oauth_state_valid?(invalid)).to be_falsey
+ expect(is_oauth_state_valid?(invalid2)).to be_falsey
+ expect(is_oauth_state_valid?(invalid3)).to be_falsey
end
end
end
diff --git a/spec/lib/ansi2html_spec.rb b/spec/lib/ansi2html_spec.rb
index d674c97..db922fc 100644
--- a/spec/lib/ansi2html_spec.rb
+++ b/spec/lib/ansi2html_spec.rb
@@ -3,131 +3,131 @@ require 'spec_helper'
describe Ansi2html do
it "prints non-ansi as-is" do
- described_class::convert("Hello").should eq 'Hello'
+ expect(described_class::convert("Hello")).to eq 'Hello'
end
it "strips non-color-changing controll sequences" do
- described_class::convert("Hello \e[2Kworld").should eq 'Hello world'
+ expect(described_class::convert("Hello \e[2Kworld")).to eq 'Hello world'
end
it "prints simply red" do
- described_class::convert("\e[31mHello\e[0m").should eq '<span class="term-fg-red">Hello</span>'
+ expect(described_class::convert("\e[31mHello\e[0m")).to eq '<span class="term-fg-red">Hello</span>'
end
it "prints simply red without trailing reset" do
- described_class::convert("\e[31mHello").should eq '<span class="term-fg-red">Hello</span>'
+ expect(described_class::convert("\e[31mHello")).to eq '<span class="term-fg-red">Hello</span>'
end
it "prints simply yellow" do
- described_class::convert("\e[33mHello\e[0m").should eq '<span class="term-fg-yellow">Hello</span>'
+ expect(described_class::convert("\e[33mHello\e[0m")).to eq '<span class="term-fg-yellow">Hello</span>'
end
it "prints default on blue" do
- described_class::convert("\e[39;44mHello").should eq '<span class="term-bg-blue">Hello</span>'
+ expect(described_class::convert("\e[39;44mHello")).to eq '<span class="term-bg-blue">Hello</span>'
end
it "prints red on blue" do
- described_class::convert("\e[31;44mHello").should eq '<span class="term-fg-red term-bg-blue">Hello</span>'
+ expect(described_class::convert("\e[31;44mHello")).to eq '<span class="term-fg-red term-bg-blue">Hello</span>'
end
it "resets colors after red on blue" do
- described_class::convert("\e[31;44mHello\e[0m world").should eq '<span class="term-fg-red term-bg-blue">Hello</span> world'
+ expect(described_class::convert("\e[31;44mHello\e[0m world")).to eq '<span class="term-fg-red term-bg-blue">Hello</span> world'
end
it "performs color change from red/blue to yellow/blue" do
- described_class::convert("\e[31;44mHello \e[33mworld").should eq '<span class="term-fg-red term-bg-blue">Hello </span><span class="term-fg-yellow term-bg-blue">world</span>'
+ expect(described_class::convert("\e[31;44mHello \e[33mworld")).to eq '<span class="term-fg-red term-bg-blue">Hello </span><span class="term-fg-yellow term-bg-blue">world</span>'
end
it "performs color change from red/blue to yellow/green" do
- described_class::convert("\e[31;44mHello \e[33;42mworld").should eq '<span class="term-fg-red term-bg-blue">Hello </span><span class="term-fg-yellow term-bg-green">world</span>'
+ expect(described_class::convert("\e[31;44mHello \e[33;42mworld")).to eq '<span class="term-fg-red term-bg-blue">Hello </span><span class="term-fg-yellow term-bg-green">world</span>'
end
it "performs color change from red/blue to reset to yellow/green" do
- described_class::convert("\e[31;44mHello\e[0m \e[33;42mworld").should eq '<span class="term-fg-red term-bg-blue">Hello</span> <span class="term-fg-yellow term-bg-green">world</span>'
+ expect(described_class::convert("\e[31;44mHello\e[0m \e[33;42mworld")).to eq '<span class="term-fg-red term-bg-blue">Hello</span> <span class="term-fg-yellow term-bg-green">world</span>'
end
it "ignores unsupported codes" do
- described_class::convert("\e[51mHello\e[0m").should eq 'Hello'
+ expect(described_class::convert("\e[51mHello\e[0m")).to eq 'Hello'
end
it "prints light red" do
- described_class::convert("\e[91mHello\e[0m").should eq '<span class="term-fg-l-red">Hello</span>'
+ expect(described_class::convert("\e[91mHello\e[0m")).to eq '<span class="term-fg-l-red">Hello</span>'
end
it "prints default on light red" do
- described_class::convert("\e[101mHello\e[0m").should eq '<span class="term-bg-l-red">Hello</span>'
+ expect(described_class::convert("\e[101mHello\e[0m")).to eq '<span class="term-bg-l-red">Hello</span>'
end
it "performs color change from red/blue to default/blue" do
- described_class::convert("\e[31;44mHello \e[39mworld").should eq '<span class="term-fg-red term-bg-blue">Hello </span><span class="term-bg-blue">world</span>'
+ expect(described_class::convert("\e[31;44mHello \e[39mworld")).to eq '<span class="term-fg-red term-bg-blue">Hello </span><span class="term-bg-blue">world</span>'
end
it "performs color change from light red/blue to default/blue" do
- described_class::convert("\e[91;44mHello \e[39mworld").should eq '<span class="term-fg-l-red term-bg-blue">Hello </span><span class="term-bg-blue">world</span>'
+ expect(described_class::convert("\e[91;44mHello \e[39mworld")).to eq '<span class="term-fg-l-red term-bg-blue">Hello </span><span class="term-bg-blue">world</span>'
end
it "prints bold text" do
- described_class::convert("\e[1mHello").should eq '<span class="term-bold">Hello</span>'
+ expect(described_class::convert("\e[1mHello")).to eq '<span class="term-bold">Hello</span>'
end
it "resets bold text" do
- described_class::convert("\e[1mHello\e[21m world").should eq '<span class="term-bold">Hello</span> world'
- described_class::convert("\e[1mHello\e[22m world").should eq '<span class="term-bold">Hello</span> world'
+ expect(described_class::convert("\e[1mHello\e[21m world")).to eq '<span class="term-bold">Hello</span> world'
+ expect(described_class::convert("\e[1mHello\e[22m world")).to eq '<span class="term-bold">Hello</span> world'
end
it "prints italic text" do
- described_class::convert("\e[3mHello").should eq '<span class="term-italic">Hello</span>'
+ expect(described_class::convert("\e[3mHello")).to eq '<span class="term-italic">Hello</span>'
end
it "resets italic text" do
- described_class::convert("\e[3mHello\e[23m world").should eq '<span class="term-italic">Hello</span> world'
+ expect(described_class::convert("\e[3mHello\e[23m world")).to eq '<span class="term-italic">Hello</span> world'
end
it "prints underlined text" do
- described_class::convert("\e[4mHello").should eq '<span class="term-underline">Hello</span>'
+ expect(described_class::convert("\e[4mHello")).to eq '<span class="term-underline">Hello</span>'
end
it "resets underlined text" do
- described_class::convert("\e[4mHello\e[24m world").should eq '<span class="term-underline">Hello</span> world'
+ expect(described_class::convert("\e[4mHello\e[24m world")).to eq '<span class="term-underline">Hello</span> world'
end
it "prints concealed text" do
- described_class::convert("\e[8mHello").should eq '<span class="term-conceal">Hello</span>'
+ expect(described_class::convert("\e[8mHello")).to eq '<span class="term-conceal">Hello</span>'
end
it "resets concealed text" do
- described_class::convert("\e[8mHello\e[28m world").should eq '<span class="term-conceal">Hello</span> world'
+ expect(described_class::convert("\e[8mHello\e[28m world")).to eq '<span class="term-conceal">Hello</span> world'
end
it "prints crossed-out text" do
- described_class::convert("\e[9mHello").should eq '<span class="term-cross">Hello</span>'
+ expect(described_class::convert("\e[9mHello")).to eq '<span class="term-cross">Hello</span>'
end
it "resets crossed-out text" do
- described_class::convert("\e[9mHello\e[29m world").should eq '<span class="term-cross">Hello</span> world'
+ expect(described_class::convert("\e[9mHello\e[29m world")).to eq '<span class="term-cross">Hello</span> world'
end
it "can print 256 xterm fg colors" do
- described_class::convert("\e[38;5;16mHello").should eq '<span class="xterm-fg-16">Hello</span>'
+ expect(described_class::convert("\e[38;5;16mHello")).to eq '<span class="xterm-fg-16">Hello</span>'
end
it "can print 256 xterm fg colors on normal magenta background" do
- described_class::convert("\e[38;5;16;45mHello").should eq '<span class="xterm-fg-16 term-bg-magenta">Hello</span>'
+ expect(described_class::convert("\e[38;5;16;45mHello")).to eq '<span class="xterm-fg-16 term-bg-magenta">Hello</span>'
end
it "can print 256 xterm bg colors" do
- described_class::convert("\e[48;5;240mHello").should eq '<span class="xterm-bg-240">Hello</span>'
+ expect(described_class::convert("\e[48;5;240mHello")).to eq '<span class="xterm-bg-240">Hello</span>'
end
it "can print 256 xterm bg colors on normal magenta foreground" do
- described_class::convert("\e[48;5;16;35mHello").should eq '<span class="term-fg-magenta xterm-bg-16">Hello</span>'
+ expect(described_class::convert("\e[48;5;16;35mHello")).to eq '<span class="term-fg-magenta xterm-bg-16">Hello</span>'
end
it "prints bold colored text vividly" do
- described_class::convert("\e[1;31mHello\e[0m").should eq '<span class="term-fg-l-red term-bold">Hello</span>'
+ expect(described_class::convert("\e[1;31mHello\e[0m")).to eq '<span class="term-fg-l-red term-bold">Hello</span>'
end
it "prints bold light colored text correctly" do
- described_class::convert("\e[1;91mHello\e[0m").should eq '<span class="term-fg-l-red term-bold">Hello</span>'
+ expect(described_class::convert("\e[1;91mHello\e[0m")).to eq '<span class="term-fg-l-red term-bold">Hello</span>'
end
end
diff --git a/spec/lib/charts_spec.rb b/spec/lib/charts_spec.rb
index 60d1b5a..2f27723 100644
--- a/spec/lib/charts_spec.rb
+++ b/spec/lib/charts_spec.rb
@@ -9,6 +9,6 @@ describe Charts::BuildTime do
it 'should return build times in minutes' do
chart = described_class.new(@project)
- chart.build_times.should eq [2]
+ expect(chart.build_times).to eq [2]
end
end
diff --git a/spec/lib/gitlab_ci_yaml_processor_spec.rb b/spec/lib/gitlab_ci_yaml_processor_spec.rb
index aa83f2b..127b8be 100644
--- a/spec/lib/gitlab_ci_yaml_processor_spec.rb
+++ b/spec/lib/gitlab_ci_yaml_processor_spec.rb
@@ -13,8 +13,8 @@ describe GitlabCiYamlProcessor do
config_processor = described_class.new(config)
- config_processor.builds_for_stage_and_ref(type, "master").size.should eq 1
- config_processor.builds_for_stage_and_ref(type, "master").first.should eq({
+ expect(config_processor.builds_for_stage_and_ref(type, "master").size).to eq 1
+ expect(config_processor.builds_for_stage_and_ref(type, "master").first).to eq({
stage: "test",
except: nil,
name: :rspec,
@@ -34,7 +34,7 @@ describe GitlabCiYamlProcessor do
config_processor = described_class.new(config)
- config_processor.builds_for_stage_and_ref(type, "master").size.should eq 0
+ expect(config_processor.builds_for_stage_and_ref(type, "master").size).to eq 0
end
it "does not return builds if only has regexp with another branch" do
@@ -45,7 +45,7 @@ describe GitlabCiYamlProcessor do
config_processor = described_class.new(config)
- config_processor.builds_for_stage_and_ref(type, "master").size.should eq 0
+ expect(config_processor.builds_for_stage_and_ref(type, "master").size).to eq 0
end
it "returns builds if only has specified this branch" do
@@ -56,7 +56,7 @@ describe GitlabCiYamlProcessor do
config_processor = described_class.new(config)
- config_processor.builds_for_stage_and_ref(type, "master").size.should eq 1
+ expect(config_processor.builds_for_stage_and_ref(type, "master").size).to eq 1
end
it "does not build tags" do
@@ -67,7 +67,7 @@ describe GitlabCiYamlProcessor do
config_processor = described_class.new(config)
- config_processor.builds_for_stage_and_ref(type, "0-1", true).size.should eq 0
+ expect(config_processor.builds_for_stage_and_ref(type, "0-1", true).size).to eq 0
end
it "returns builds if only has a list of branches including specified" do
@@ -78,7 +78,7 @@ describe GitlabCiYamlProcessor do
config_processor = described_class.new(config)
- config_processor.builds_for_stage_and_ref(type, "deploy").size.should eq 1
+ expect(config_processor.builds_for_stage_and_ref(type, "deploy").size).to eq 1
end
it "returns build only for specified type" do
@@ -93,9 +93,9 @@ describe GitlabCiYamlProcessor do
config_processor = described_class.new(config)
- config_processor.builds_for_stage_and_ref("production", "deploy").size.should eq 0
- config_processor.builds_for_stage_and_ref(type, "deploy").size.should eq 1
- config_processor.builds_for_stage_and_ref("deploy", "deploy").size.should eq 2
+ expect(config_processor.builds_for_stage_and_ref("production", "deploy").size).to eq 0
+ expect(config_processor.builds_for_stage_and_ref(type, "deploy").size).to eq 1
+ expect(config_processor.builds_for_stage_and_ref("deploy", "deploy").size).to eq 2
end
end
@@ -110,8 +110,8 @@ describe GitlabCiYamlProcessor do
config_processor = described_class.new(config)
- config_processor.builds_for_stage_and_ref("test", "master").size.should eq 1
- config_processor.builds_for_stage_and_ref("test", "master").first.should eq({
+ expect(config_processor.builds_for_stage_and_ref("test", "master").size).to eq 1
+ expect(config_processor.builds_for_stage_and_ref("test", "master").first).to eq({
except: nil,
stage: "test",
name: :rspec,
@@ -136,8 +136,8 @@ describe GitlabCiYamlProcessor do
config_processor = described_class.new(config)
- config_processor.builds_for_stage_and_ref("test", "master").size.should eq 1
- config_processor.builds_for_stage_and_ref("test", "master").first.should eq({
+ expect(config_processor.builds_for_stage_and_ref("test", "master").size).to eq 1
+ expect(config_processor.builds_for_stage_and_ref("test", "master").first).to eq({
except: nil,
stage: "test",
name: :rspec,
@@ -166,7 +166,7 @@ describe GitlabCiYamlProcessor do
})
config_processor = described_class.new(config)
- config_processor.variables.should eq variables
+ expect(config_processor.variables).to eq variables
end
end
diff --git a/spec/lib/upgrader_spec.rb b/spec/lib/upgrader_spec.rb
index 90c28cf..64f6f95 100644
--- a/spec/lib/upgrader_spec.rb
+++ b/spec/lib/upgrader_spec.rb
@@ -5,13 +5,13 @@ describe Upgrader do
let(:current_version) { GitlabCi::VERSION }
describe 'current_version_raw' do
- it { upgrader.current_version_raw.should eq current_version }
+ it { expect(upgrader.current_version_raw).to eq current_version }
end
describe 'latest_version?' do
it 'should be true if newest version' do
allow(upgrader).to receive_messages(latest_version_raw: current_version)
- upgrader.latest_version?.should be_truthy
+ expect(upgrader.latest_version?).to be_truthy
end
end
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb
index 5211c66..efb202f 100644
--- a/spec/mailers/notify_spec.rb
+++ b/spec/mailers/notify_spec.rb
@@ -14,11 +14,11 @@ describe Notify do
subject { described_class.build_success_email(@build.id, 'wow@example.com') }
it 'has the correct subject' do
- should have_subject /Build success for/
+ is_expected.to have_subject /Build success for/
end
it 'contains name of project' do
- should have_body_text /build successful/
+ is_expected.to have_body_text /build successful/
end
end
@@ -26,11 +26,11 @@ describe Notify do
subject { described_class.build_fail_email(@build.id, 'wow@example.com') }
it 'has the correct subject' do
- should have_subject /Build failed for/
+ is_expected.to have_subject /Build failed for/
end
it 'contains name of project' do
- should have_body_text /build failed/
+ is_expected.to have_body_text /build failed/
end
end
end
diff --git a/spec/models/build_spec.rb b/spec/models/build_spec.rb
index 04f0f0f..cb080d2 100644
--- a/spec/models/build_spec.rb
+++ b/spec/models/build_spec.rb
@@ -30,14 +30,14 @@ describe Build do
let(:commit) { FactoryGirl.create :commit, project: project }
let(:build) { FactoryGirl.create :build, commit: commit }
- it { should belong_to(:commit) }
- it { should validate_presence_of :status }
+ it { is_expected.to belong_to(:commit) }
+ it { is_expected.to validate_presence_of :status }
- it { should respond_to :success? }
- it { should respond_to :failed? }
- it { should respond_to :running? }
- it { should respond_to :pending? }
- it { should respond_to :trace_html }
+ it { is_expected.to respond_to :success? }
+ it { is_expected.to respond_to :failed? }
+ it { is_expected.to respond_to :running? }
+ it { is_expected.to respond_to :pending? }
+ it { is_expected.to respond_to :trace_html }
describe '.first_pending' do
let(:first) { FactoryGirl.create :build, commit: commit, status: 'pending', created_at: Date.yesterday }
@@ -45,8 +45,8 @@ describe Build do
before { first; second }
subject { Build.first_pending }
- it { should be_a(Build) }
- it('returns with the first pending build') { should eq(first) }
+ it { is_expected.to be_a(Build) }
+ it('returns with the first pending build') { is_expected.to eq(first) }
end
describe '.create_from' do
@@ -69,14 +69,14 @@ describe Build do
context 'without started_at' do
before { build.started_at = nil }
- it { should be_falsey }
+ it { is_expected.to be_falsey }
end
%w(running success failed).each do |status|
context "if build status is #{status}" do
before { build.status = status }
- it { should be_truthy }
+ it { is_expected.to be_truthy }
end
end
@@ -84,7 +84,7 @@ describe Build do
context "if build status is #{status}" do
before { build.status = status }
- it { should be_falsey }
+ it { is_expected.to be_falsey }
end
end
end
@@ -96,7 +96,7 @@ describe Build do
context "if build.status is #{state}" do
before { build.status = state }
- it { should be_truthy }
+ it { is_expected.to be_truthy }
end
end
@@ -104,7 +104,7 @@ describe Build do
context "if build.status is #{state}" do
before { build.status = state }
- it { should be_falsey }
+ it { is_expected.to be_falsey }
end
end
end
@@ -116,7 +116,7 @@ describe Build do
context "if build.status is #{state}" do
before { build.status = state }
- it { should be_truthy }
+ it { is_expected.to be_truthy }
end
end
@@ -124,7 +124,7 @@ describe Build do
context "if build.status is #{state}" do
before { build.status = state }
- it { should be_falsey }
+ it { is_expected.to be_falsey }
end
end
end
@@ -138,13 +138,13 @@ describe Build do
context 'and build.status is success' do
before { build.status = 'success' }
- it { should be_falsey }
+ it { is_expected.to be_falsey }
end
context 'and build.status is failed' do
before { build.status = 'failed' }
- it { should be_falsey }
+ it { is_expected.to be_falsey }
end
end
@@ -154,13 +154,13 @@ describe Build do
context 'and build.status is success' do
before { build.status = 'success' }
- it { should be_falsey }
+ it { is_expected.to be_falsey }
end
context 'and build.status is failed' do
before { build.status = 'failed' }
- it { should be_truthy }
+ it { is_expected.to be_truthy }
end
end
end
@@ -168,13 +168,13 @@ describe Build do
describe '#trace' do
subject { build.trace_html }
- it { should be_empty }
+ it { is_expected.to be_empty }
context 'if build.trace contains text' do
let(:text) { 'example output' }
before { build.trace = text }
- it { should include(text) }
+ it { is_expected.to include(text) }
it { expect(subject.length).to be >= text.length }
end
end
@@ -182,13 +182,13 @@ describe Build do
describe '#timeout' do
subject { build.timeout }
- it { should eq(commit.project.timeout) }
+ it { is_expected.to eq(commit.project.timeout) }
end
describe '#duration' do
subject { build.duration }
- it { should eq(120.0) }
+ it { is_expected.to eq(120.0) }
context 'if the building process has not started yet' do
before do
@@ -196,7 +196,7 @@ describe Build do
build.finished_at = nil
end
- it { should be_nil }
+ it { is_expected.to be_nil }
end
context 'if the building process has started' do
@@ -205,8 +205,8 @@ describe Build do
build.finished_at = nil
end
- it { should be_a(Float) }
- it { should > 0.0 }
+ it { is_expected.to be_a(Float) }
+ it { is_expected.to be > 0.0 }
end
end
@@ -221,86 +221,86 @@ describe Build do
}
subject { build.options }
- it { should eq(options) }
+ it { is_expected.to eq(options) }
end
describe '#ref' do
subject { build.ref }
- it { should eq(commit.ref) }
+ it { is_expected.to eq(commit.ref) }
end
describe '#sha' do
subject { build.sha }
- it { should eq(commit.sha) }
+ it { is_expected.to eq(commit.sha) }
end
describe '#short_sha' do
subject { build.short_sha }
- it { should eq(commit.short_sha) }
+ it { is_expected.to eq(commit.short_sha) }
end
describe '#before_sha' do
subject { build.before_sha }
- it { should eq(commit.before_sha) }
+ it { is_expected.to eq(commit.before_sha) }
end
describe '#allow_git_fetch' do
subject { build.allow_git_fetch }
- it { should eq(project.allow_git_fetch) }
+ it { is_expected.to eq(project.allow_git_fetch) }
end
describe '#project' do
subject { build.project }
- it { should eq(commit.project) }
+ it { is_expected.to eq(commit.project) }
end
describe '#project_id' do
subject { build.project_id }
- it { should eq(commit.project_id) }
+ it { is_expected.to eq(commit.project_id) }
end
describe '#project_name' do
subject { build.project_name }
- it { should eq(project.name) }
+ it { is_expected.to eq(project.name) }
end
describe '#repo_url' do
subject { build.repo_url }
- it { should eq(project.repo_url_with_auth) }
+ it { is_expected.to eq(project.repo_url_with_auth) }
end
describe '#extract_coverage' do
context 'valid content & regex' do
subject { build.extract_coverage('Coverage 1033 / 1051 LOC (98.29%) covered', '\(\d+.\d+\%\) covered') }
- it { should eq(98.29) }
+ it { is_expected.to eq(98.29) }
end
context 'valid content & bad regex' do
subject { build.extract_coverage('Coverage 1033 / 1051 LOC (98.29%) covered', 'very covered') }
- it { should be_nil }
+ it { is_expected.to be_nil }
end
context 'no coverage content & regex' do
subject { build.extract_coverage('No coverage for today :sad:', '\(\d+.\d+\%\) covered') }
- it { should be_nil }
+ it { is_expected.to be_nil }
end
context 'multiple results in content & regex' do
subject { build.extract_coverage(' (98.39%) covered. (98.29%) covered', '\(\d+.\d+\%\) covered') }
- it { should eq(98.29) }
+ it { is_expected.to eq(98.29) }
end
end
@@ -314,7 +314,7 @@ describe Build do
]
}
- it { should eq(variables) }
+ it { is_expected.to eq(variables) }
context 'and secure variables' do
let(:secure_variables) {
@@ -327,7 +327,7 @@ describe Build do
build.project.variables << Variable.new(key: 'SECRET_KEY', value: 'secret_value')
end
- it { should eq(variables + secure_variables) }
+ it { is_expected.to eq(variables + secure_variables) }
context 'and trigger variables' do
let(:trigger) { FactoryGirl.create :trigger, project: project }
@@ -342,7 +342,7 @@ describe Build do
build.trigger_request = trigger_request
end
- it { should eq(variables + secure_variables + trigger_variables) }
+ it { is_expected.to eq(variables + secure_variables + trigger_variables) }
end
end
end
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb
index f5b30f7..24b6520 100644
--- a/spec/models/commit_spec.rb
+++ b/spec/models/commit_spec.rb
@@ -23,16 +23,16 @@ describe Commit do
let(:commit_with_project) { FactoryGirl.create :commit, project: project }
let(:config_processor) { GitlabCiYamlProcessor.new(gitlab_ci_yaml) }
- it { should belong_to(:project) }
- it { should have_many(:builds) }
- it { should validate_presence_of :before_sha }
- it { should validate_presence_of :sha }
- it { should validate_presence_of :ref }
- it { should validate_presence_of :push_data }
+ it { is_expected.to belong_to(:project) }
+ it { is_expected.to have_many(:builds) }
+ it { is_expected.to validate_presence_of :before_sha }
+ it { is_expected.to validate_presence_of :sha }
+ it { is_expected.to validate_presence_of :ref }
+ it { is_expected.to validate_presence_of :push_data }
- it { should respond_to :git_author_name }
- it { should respond_to :git_author_email }
- it { should respond_to :short_sha }
+ it { is_expected.to respond_to :git_author_name }
+ it { is_expected.to respond_to :git_author_email }
+ it { is_expected.to respond_to :short_sha }
describe '#last_build' do
subject { commit.last_build }
@@ -41,8 +41,8 @@ describe Commit do
@second = FactoryGirl.create :build, commit: commit
end
- it { should be_a(Build) }
- it('returns with the most recently created build') { should eq(@second) }
+ it { is_expected.to be_a(Build) }
+ it('returns with the most recently created build') { is_expected.to eq(@second) }
end
describe '#retry' do
@@ -68,7 +68,7 @@ describe Commit do
commit = FactoryGirl.create :commit, project: project
expected = 'commit_pusher_email'
allow(commit).to receive(:push_data) { { user_email: expected } }
- commit.project_recipients.should eq [expected]
+ expect(commit.project_recipients).to eq [expected]
end
it 'should return commit_pusher_email and additional recipients' do
@@ -78,7 +78,7 @@ describe Commit do
commit = FactoryGirl.create :commit, project: project
expected = 'commit_pusher_email'
allow(commit).to receive(:push_data) { { user_email: expected } }
- commit.project_recipients.should eq ['rec1', 'rec2', expected]
+ expect(commit.project_recipients).to eq ['rec1', 'rec2', expected]
end
it 'should return recipients' do
@@ -86,7 +86,7 @@ describe Commit do
email_add_pusher: false,
email_recipients: 'rec1 rec2'
commit = FactoryGirl.create :commit, project: project
- commit.project_recipients.should eq ['rec1', 'rec2']
+ expect(commit.project_recipients).to eq ['rec1', 'rec2']
end
it 'should return unique recipients only' do
@@ -96,7 +96,7 @@ describe Commit do
commit = FactoryGirl.create :commit, project: project
expected = 'rec2'
allow(commit).to receive(:push_data) { { user_email: expected } }
- commit.project_recipients.should eq ['rec1', 'rec2']
+ expect(commit.project_recipients).to eq ['rec1', 'rec2']
end
end
end
@@ -108,7 +108,7 @@ describe Commit do
commit.valid_commit_sha
end
- it('commit errors should not be empty') { commit.errors.should_not be_empty }
+ it('commit errors should not be empty') { expect(commit.errors).not_to be_empty }
end
end
@@ -116,7 +116,7 @@ describe Commit do
subject { commit_with_project.compare? }
context 'if commit.before_sha are not nil' do
- it { should be_truthy }
+ it { is_expected.to be_truthy }
end
end
@@ -124,14 +124,14 @@ describe Commit do
subject { commit.short_before_sha }
it { expect(subject.length).to eq 8 }
- it { commit.before_sha.should start_with(subject) }
+ it { expect(commit.before_sha).to start_with(subject) }
end
describe '#short_sha' do
subject { commit.short_sha }
it { expect(subject.length).to eq 8 }
- it { commit.sha.should start_with(subject) }
+ it { expect(commit.sha).to start_with(subject) }
end
describe '#create_next_builds' do
@@ -140,19 +140,19 @@ describe Commit do
end
it "creates builds for next type" do
- commit.create_builds.should be_truthy
+ expect(commit.create_builds).to be_truthy
commit.builds.reload
- commit.builds.size.should eq 2
+ expect(commit.builds.size).to eq 2
- commit.create_next_builds(nil).should be_truthy
+ expect(commit.create_next_builds(nil)).to be_truthy
commit.builds.reload
- commit.builds.size.should eq 4
+ expect(commit.builds.size).to eq 4
- commit.create_next_builds(nil).should be_truthy
+ expect(commit.create_next_builds(nil)).to be_truthy
commit.builds.reload
- commit.builds.size.should eq 5
+ expect(commit.builds.size).to eq 5
- commit.create_next_builds(nil).should be_falsey
+ expect(commit.create_next_builds(nil)).to be_falsey
end
end
@@ -162,9 +162,9 @@ describe Commit do
end
it 'creates builds' do
- commit.create_builds.should be_truthy
+ expect(commit.create_builds).to be_truthy
commit.builds.reload
- commit.builds.size.should eq 2
+ expect(commit.builds.size).to eq 2
end
context 'for build triggers' do
@@ -172,29 +172,29 @@ describe Commit do
let(:trigger_request) { FactoryGirl.create :trigger_request, commit: commit, trigger: trigger }
it 'creates builds' do
- commit.create_builds(trigger_request).should be_truthy
+ expect(commit.create_builds(trigger_request)).to be_truthy
commit.builds.reload
- commit.builds.size.should eq 2
+ expect(commit.builds.size).to eq 2
end
it 'rebuilds commit' do
- commit.create_builds.should be_truthy
+ expect(commit.create_builds).to be_truthy
commit.builds.reload
- commit.builds.size.should eq 2
+ expect(commit.builds.size).to eq 2
- commit.create_builds(trigger_request).should be_truthy
+ expect(commit.create_builds(trigger_request)).to be_truthy
commit.builds.reload
- commit.builds.size.should eq 4
+ expect(commit.builds.size).to eq 4
end
it 'creates next builds' do
- commit.create_builds(trigger_request).should be_truthy
+ expect(commit.create_builds(trigger_request)).to be_truthy
commit.builds.reload
- commit.builds.size.should eq 2
+ expect(commit.builds.size).to eq 2
- commit.create_next_builds(trigger_request).should be_truthy
+ expect(commit.create_next_builds(trigger_request)).to be_truthy
commit.builds.reload
- commit.builds.size.should eq 4
+ expect(commit.builds.size).to eq 4
end
context 'for [ci skip]' do
@@ -204,11 +204,11 @@ describe Commit do
end
it 'rebuilds commit' do
- commit.status.should eq 'skipped'
- commit.create_builds(trigger_request).should be_truthy
+ expect(commit.status).to eq 'skipped'
+ expect(commit.create_builds(trigger_request)).to be_truthy
commit.builds.reload
- commit.builds.size.should eq 2
- commit.status.should eq 'pending'
+ expect(commit.builds.size).to eq 2
+ expect(commit.status).to eq 'pending'
end
end
end
@@ -222,13 +222,13 @@ describe Commit do
build = FactoryGirl.create :build, commit: commit, finished_at: Time.now - 60
build1 = FactoryGirl.create :build, commit: commit, finished_at: Time.now - 120
- commit.finished_at.to_i.should eq build.finished_at.to_i
+ expect(commit.finished_at.to_i).to eq build.finished_at.to_i
end
it "returns nil if there is no finished build" do
build = FactoryGirl.create :not_started_build, commit: commit
- commit.finished_at.should be_nil
+ expect(commit.finished_at).to be_nil
end
end
@@ -239,26 +239,26 @@ describe Commit do
it "calculates average when there are two builds with coverage" do
FactoryGirl.create :build, name: "rspec", coverage: 30, commit: commit
FactoryGirl.create :build, name: "rubocop", coverage: 40, commit: commit
- commit.coverage.should eq "35.00"
+ expect(commit.coverage).to eq "35.00"
end
it "calculates average when there are two builds with coverage and one with nil" do
FactoryGirl.create :build, name: "rspec", coverage: 30, commit: commit
FactoryGirl.create :build, name: "rubocop", coverage: 40, commit: commit
FactoryGirl.create :build, commit: commit
- commit.coverage.should eq "35.00"
+ expect(commit.coverage).to eq "35.00"
end
it "calculates average when there are two builds with coverage and one is retried" do
FactoryGirl.create :build, name: "rspec", coverage: 30, commit: commit
FactoryGirl.create :build, name: "rubocop", coverage: 30, commit: commit
FactoryGirl.create :build, name: "rubocop", coverage: 40, commit: commit
- commit.coverage.should eq "35.00"
+ expect(commit.coverage).to eq "35.00"
end
it "calculates average when there is one build without coverage" do
FactoryGirl.create :build, commit: commit
- commit.coverage.should be_nil
+ expect(commit.coverage).to be_nil
end
end
end
diff --git a/spec/models/mail_service_spec.rb b/spec/models/mail_service_spec.rb
index 3fccc63..27803aa 100644
--- a/spec/models/mail_service_spec.rb
+++ b/spec/models/mail_service_spec.rb
@@ -16,7 +16,7 @@ require 'spec_helper'
describe MailService do
describe "Associations" do
- it { should belong_to :project }
+ it { is_expected.to belong_to :project }
end
describe "Validations" do
@@ -45,8 +45,8 @@ describe MailService do
end
def should_email(email)
- Notify.should_receive(:build_fail_email).with(build.id, email)
- Notify.should_not_receive(:build_success_email).with(build.id, email)
+ expect(Notify).to receive(:build_fail_email).with(build.id, email)
+ expect(Notify).not_to receive(:build_success_email).with(build.id, email)
end
end
@@ -65,8 +65,8 @@ describe MailService do
end
def should_email(email)
- Notify.should_receive(:build_success_email).with(build.id, email)
- Notify.should_not_receive(:build_fail_email).with(build.id, email)
+ expect(Notify).to receive(:build_success_email).with(build.id, email)
+ expect(Notify).not_to receive(:build_fail_email).with(build.id, email)
end
end
@@ -91,8 +91,8 @@ describe MailService do
end
def should_email(email)
- Notify.should_receive(:build_success_email).with(build.id, email)
- Notify.should_not_receive(:build_fail_email).with(build.id, email)
+ expect(Notify).to receive(:build_success_email).with(build.id, email)
+ expect(Notify).not_to receive(:build_fail_email).with(build.id, email)
end
end
@@ -117,8 +117,8 @@ describe MailService do
end
def should_email(email)
- Notify.should_not_receive(:build_success_email).with(build.id, email)
- Notify.should_not_receive(:build_fail_email).with(build.id, email)
+ expect(Notify).not_to receive(:build_success_email).with(build.id, email)
+ expect(Notify).not_to receive(:build_fail_email).with(build.id, email)
end
end
@@ -138,7 +138,7 @@ describe MailService do
end
it do
- mail.can_test?.should eq true
+ expect(mail.can_test?).to eq true
end
end
@@ -164,8 +164,8 @@ describe MailService do
end
def should_email(email)
- Notify.should_not_receive(:build_success_email).with(build.id, email)
- Notify.should_not_receive(:build_fail_email).with(build.id, email)
+ expect(Notify).not_to receive(:build_success_email).with(build.id, email)
+ expect(Notify).not_to receive(:build_fail_email).with(build.id, email)
end
end
end
diff --git a/spec/models/network_spec.rb b/spec/models/network_spec.rb
index 3eac46c..9c40e32 100644
--- a/spec/models/network_spec.rb
+++ b/spec/models/network_spec.rb
@@ -13,7 +13,7 @@ describe Network do
allow(network.class).to receive(:put) { response }
end
- it { should be_truthy }
+ it { is_expected.to be_truthy }
end
context 'on failure' do
@@ -23,7 +23,7 @@ describe Network do
allow(network.class).to receive(:put) { response }
end
- it { should be_nil }
+ it { is_expected.to be_nil }
end
end
@@ -39,7 +39,7 @@ describe Network do
allow(network.class).to receive(:delete) { response }
end
- it { should equal(parsed_response) }
+ it { is_expected.to equal(parsed_response) }
end
context 'on failure' do
@@ -48,7 +48,7 @@ describe Network do
allow(network.class).to receive(:delete) { response }
end
- it { should be_nil }
+ it { is_expected.to be_nil }
end
end
end
diff --git a/spec/models/project_services/hip_chat_service_spec.rb b/spec/models/project_services/hip_chat_service_spec.rb
index baaecfd..71cdf4f 100644
--- a/spec/models/project_services/hip_chat_service_spec.rb
+++ b/spec/models/project_services/hip_chat_service_spec.rb
@@ -24,8 +24,8 @@ describe HipChatService do
subject.active = true
end
- it { should validate_presence_of :hipchat_room }
- it { should validate_presence_of :hipchat_token }
+ it { is_expected.to validate_presence_of :hipchat_room }
+ it { is_expected.to validate_presence_of :hipchat_token }
end
end
diff --git a/spec/models/project_services/slack_message_spec.rb b/spec/models/project_services/slack_message_spec.rb
index fdbe340..6bfdd48 100644
--- a/spec/models/project_services/slack_message_spec.rb
+++ b/spec/models/project_services/slack_message_spec.rb
@@ -19,11 +19,11 @@ describe SlackMessage do
it 'returns a message with succeeded build' do
build.update(status: "success")
- subject.color.should eq color
- subject.fallback.should include('Build')
- subject.fallback.should include("\##{build.id}")
- subject.fallback.should include('succeeded')
- subject.attachments.first[:fields].should be_empty
+ expect(subject.color).to eq color
+ expect(subject.fallback).to include('Build')
+ expect(subject.fallback).to include("\##{build.id}")
+ expect(subject.fallback).to include('succeeded')
+ expect(subject.attachments.first[:fields]).to be_empty
end
end
@@ -33,11 +33,11 @@ describe SlackMessage do
it 'returns a message with failed build' do
build.update(status: "failed")
- subject.color.should eq color
- subject.fallback.should include('Build')
- subject.fallback.should include("\##{build.id}")
- subject.fallback.should include('failed')
- subject.attachments.first[:fields].should be_empty
+ expect(subject.color).to eq color
+ expect(subject.fallback).to include('Build')
+ expect(subject.fallback).to include("\##{build.id}")
+ expect(subject.fallback).to include('failed')
+ expect(subject.attachments.first[:fields]).to be_empty
end
end
end
@@ -53,11 +53,11 @@ describe SlackMessage do
commit.builds.update_all(status: "success")
commit.reload
- subject.color.should eq color
- subject.fallback.should include('Commit')
- subject.fallback.should include("\##{commit.id}")
- subject.fallback.should include('succeeded')
- subject.attachments.first[:fields].should be_empty
+ expect(subject.color).to eq color
+ expect(subject.fallback).to include('Commit')
+ expect(subject.fallback).to include("\##{commit.id}")
+ expect(subject.fallback).to include('succeeded')
+ expect(subject.attachments.first[:fields]).to be_empty
end
end
@@ -71,13 +71,13 @@ describe SlackMessage do
first_build.update(status: "success")
second_build.update(status: "failed")
- subject.color.should eq color
- subject.fallback.should include('Commit')
- subject.fallback.should include("\##{commit.id}")
- subject.fallback.should include('failed')
- subject.attachments.first[:fields].size.should eq 1
- subject.attachments.first[:fields].first[:title].should eq second_build.name
- subject.attachments.first[:fields].first[:value].should include("\##{second_build.id}")
+ expect(subject.color).to eq color
+ expect(subject.fallback).to include('Commit')
+ expect(subject.fallback).to include("\##{commit.id}")
+ expect(subject.fallback).to include('failed')
+ expect(subject.attachments.first[:fields].size).to eq 1
+ expect(subject.attachments.first[:fields].first[:title]).to eq second_build.name
+ expect(subject.attachments.first[:fields].first[:value]).to include("\##{second_build.id}")
end
end
end
diff --git a/spec/models/project_services/slack_service_spec.rb b/spec/models/project_services/slack_service_spec.rb
index 80d7c07..2a00415 100644
--- a/spec/models/project_services/slack_service_spec.rb
+++ b/spec/models/project_services/slack_service_spec.rb
@@ -16,7 +16,7 @@ require 'spec_helper'
describe SlackService do
describe "Associations" do
- it { should belong_to :project }
+ it { is_expected.to belong_to :project }
end
describe "Validations" do
@@ -25,7 +25,7 @@ describe SlackService do
subject.active = true
end
- it { should validate_presence_of :webhook }
+ it { is_expected.to validate_presence_of :webhook }
end
end
@@ -52,7 +52,7 @@ describe SlackService do
slack.execute(build)
SlackNotifierWorker.drain
- WebMock.should have_requested(:post, webhook_url).once
+ expect(WebMock).to have_requested(:post, webhook_url).once
end
end
end
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index ec30fa8..cc6a900 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -30,21 +30,21 @@ require 'spec_helper'
describe Project do
subject { FactoryGirl.build :project }
- it { should have_many(:commits) }
+ it { is_expected.to have_many(:commits) }
- it { should validate_presence_of :name }
- it { should validate_presence_of :timeout }
- it { should validate_presence_of :default_ref }
+ it { is_expected.to validate_presence_of :name }
+ it { is_expected.to validate_presence_of :timeout }
+ it { is_expected.to validate_presence_of :default_ref }
describe 'before_validation' do
it 'should set an random token if none provided' do
project = FactoryGirl.create :project_without_token
- project.token.should_not eq ""
+ expect(project.token).not_to eq ""
end
it 'should not set an random toke if one provided' do
project = FactoryGirl.create :project
- project.token.should eq "iPWx6WM4lhHNedGfBpPJNP"
+ expect(project.token).to eq "iPWx6WM4lhHNedGfBpPJNP"
end
end
@@ -57,7 +57,7 @@ describe Project do
FactoryGirl.create :commit, committed_at: 1.hour.ago, project: newest_project
FactoryGirl.create :commit, committed_at: 2.hour.ago, project: oldest_project
- described_class.ordered_by_last_commit_date.should eq [newest_project, oldest_project, project_without_commits]
+ expect(described_class.ordered_by_last_commit_date).to eq [newest_project, oldest_project, project_without_commits]
end
end
@@ -70,26 +70,26 @@ describe Project do
FactoryGirl.create(:build, commit: commit)
end
- it { project.status.should eq 'pending' }
- it { project.last_commit.should be_kind_of(Commit) }
- it { project.human_status.should eq 'pending' }
+ it { expect(project.status).to eq 'pending' }
+ it { expect(project.last_commit).to be_kind_of(Commit) }
+ it { expect(project.human_status).to eq 'pending' }
end
end
describe '#email_notification?' do
it do
project = FactoryGirl.create :project, email_add_pusher: true
- project.email_notification?.should eq true
+ expect(project.email_notification?).to eq true
end
it do
project = FactoryGirl.create :project, email_add_pusher: false, email_recipients: 'test tesft'
- project.email_notification?.should eq true
+ expect(project.email_notification?).to eq true
end
it do
project = FactoryGirl.create :project, email_add_pusher: false, email_recipients: ''
- project.email_notification?.should eq false
+ expect(project.email_notification?).to eq false
end
end
@@ -98,28 +98,28 @@ describe Project do
project = FactoryGirl.create :project, email_add_pusher: true
allow(project).to receive(:broken?).and_return(true)
allow(project).to receive(:success?).and_return(true)
- project.broken_or_success?.should eq true
+ expect(project.broken_or_success?).to eq true
}
it {
project = FactoryGirl.create :project, email_add_pusher: true
allow(project).to receive(:broken?).and_return(true)
allow(project).to receive(:success?).and_return(false)
- project.broken_or_success?.should eq true
+ expect(project.broken_or_success?).to eq true
}
it {
project = FactoryGirl.create :project, email_add_pusher: true
allow(project).to receive(:broken?).and_return(false)
allow(project).to receive(:success?).and_return(true)
- project.broken_or_success?.should eq true
+ expect(project.broken_or_success?).to eq true
}
it {
project = FactoryGirl.create :project, email_add_pusher: true
allow(project).to receive(:broken?).and_return(false)
allow(project).to receive(:success?).and_return(false)
- project.broken_or_success?.should eq false
+ expect(project.broken_or_success?).to eq false
}
end
@@ -128,14 +128,14 @@ describe Project do
let(:parsed_project) { described_class.parse(project_dump) }
- it { parsed_project.should be_valid }
- it { parsed_project.should be_kind_of(described_class) }
- it { parsed_project.name.should eq("GitLab / api.gitlab.org") }
- it { parsed_project.gitlab_id.should eq(189) }
- it { parsed_project.gitlab_url.should eq("http://demo.gitlab.com/gitlab/api-gitlab-org") }
+ it { expect(parsed_project).to be_valid }
+ it { expect(parsed_project).to be_kind_of(described_class) }
+ it { expect(parsed_project.name).to eq("GitLab / api.gitlab.org") }
+ it { expect(parsed_project.gitlab_id).to eq(189) }
+ it { expect(parsed_project.gitlab_url).to eq("http://demo.gitlab.com/gitlab/api-gitlab-org") }
it "parses plain hash" do
- described_class.parse(project_dump).name.should eq("GitLab / api.gitlab.org")
+ expect(described_class.parse(project_dump).name).to eq("GitLab / api.gitlab.org")
end
end
@@ -143,43 +143,43 @@ describe Project do
let(:project) { FactoryGirl.create :project }
subject { project.repo_url_with_auth }
- it { should be_a(String) }
- it { should end_with(".git") }
- it { should start_with(project.gitlab_url[0..6]) }
- it { should include(project.token) }
- it { should include('gitlab-ci-token') }
- it { should include(project.gitlab_url[7..-1]) }
+ it { is_expected.to be_a(String) }
+ it { is_expected.to end_with(".git") }
+ it { is_expected.to start_with(project.gitlab_url[0..6]) }
+ it { is_expected.to include(project.token) }
+ it { is_expected.to include('gitlab-ci-token') }
+ it { is_expected.to include(project.gitlab_url[7..-1]) }
end
describe '.search' do
let!(:project) { FactoryGirl.create(:project, name: "foo") }
- it { described_class.search('fo').should include(project) }
- it { described_class.search('bar').should be_empty }
+ it { expect(described_class.search('fo')).to include(project) }
+ it { expect(described_class.search('bar')).to be_empty }
end
describe '#any_runners' do
it "there are no runners available" do
project = FactoryGirl.create(:project)
- project.any_runners?.should be_falsey
+ expect(project.any_runners?).to be_falsey
end
it "there is a specific runner" do
project = FactoryGirl.create(:project)
project.runners << FactoryGirl.create(:specific_runner)
- project.any_runners?.should be_truthy
+ expect(project.any_runners?).to be_truthy
end
it "there is a shared runner" do
project = FactoryGirl.create(:project, shared_runners_enabled: true)
FactoryGirl.create(:shared_runner)
- project.any_runners?.should be_truthy
+ expect(project.any_runners?).to be_truthy
end
it "there is a shared runner, but they are prohibited to use" do
project = FactoryGirl.create(:project)
FactoryGirl.create(:shared_runner)
- project.any_runners?.should be_falsey
+ expect(project.any_runners?).to be_falsey
end
end
end
diff --git a/spec/models/runner_spec.rb b/spec/models/runner_spec.rb
index 0621a95..650b3a1 100644
--- a/spec/models/runner_spec.rb
+++ b/spec/models/runner_spec.rb
@@ -43,9 +43,9 @@ describe Runner do
before { shared_runner.assign_to(project) }
- it { shared_runner.should be_specific }
- it { shared_runner.projects.should eq [project] }
- it { shared_runner.only_for?(project).should be_truthy }
+ it { expect(shared_runner).to be_specific }
+ it { expect(shared_runner.projects).to eq [project] }
+ it { expect(shared_runner.only_for?(project)).to be_truthy }
end
describe "belongs_to_one_project?" do
@@ -56,7 +56,7 @@ describe Runner do
project.runners << runner
project1.runners << runner
- runner.belongs_to_one_project?.should be_falsey
+ expect(runner.belongs_to_one_project?).to be_falsey
end
it "returns true" do
@@ -64,7 +64,7 @@ describe Runner do
project = FactoryGirl.create(:project)
project.runners << runner
- runner.belongs_to_one_project?.should be_truthy
+ expect(runner.belongs_to_one_project?).to be_truthy
end
end
end
diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb
index 7380c81..7d10551 100644
--- a/spec/models/service_spec.rb
+++ b/spec/models/service_spec.rb
@@ -17,7 +17,7 @@ require 'spec_helper'
describe Service do
describe "Associations" do
- it { should belong_to :project }
+ it { is_expected.to belong_to :project }
end
describe "Mass assignment" do
@@ -40,7 +40,7 @@ describe Service do
end
describe '#can_test' do
- it { @testable.should eq true }
+ it { expect(@testable).to eq true }
end
end
end
diff --git a/spec/models/trigger_spec.rb b/spec/models/trigger_spec.rb
index 6c327ec..4d58a4c 100644
--- a/spec/models/trigger_spec.rb
+++ b/spec/models/trigger_spec.rb
@@ -6,12 +6,12 @@ describe Trigger do
describe 'before_validation' do
it 'should set an random token if none provided' do
trigger = FactoryGirl.create :trigger_without_token, project: project
- trigger.token.should_not be_nil
+ expect(trigger.token).not_to be_nil
end
it 'should not set an random token if one provided' do
trigger = FactoryGirl.create :trigger, project: project
- trigger.token.should eq 'token'
+ expect(trigger.token).to eq 'token'
end
end
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 9989e3d..affd2cb 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -42,13 +42,13 @@ describe User do
it "returns false for reporter" do
allow(@user).to receive(:project_info).and_return(project_with_reporter_access)
- @user.has_developer_access?(1).should be_falsey
+ expect(@user.has_developer_access?(1)).to be_falsey
end
it "returns true for owner" do
allow(@user).to receive(:project_info).and_return(project_with_owner_access)
- @user.has_developer_access?(1).should be_truthy
+ expect(@user.has_developer_access?(1)).to be_truthy
end
end
@@ -66,13 +66,13 @@ describe User do
it "returns projects" do
allow_any_instance_of(described_class).to receive(:can_manage_project?).and_return(true)
- user.authorized_projects.count.should eq 2
+ expect(user.authorized_projects.count).to eq 2
end
it "empty list if user miss manage permission" do
allow_any_instance_of(described_class).to receive(:can_manage_project?).and_return(false)
- user.authorized_projects.count.should eq 0
+ expect(user.authorized_projects.count).to eq 0
end
end
@@ -93,8 +93,8 @@ describe User do
project.runners << runner
project1.runners << runner1
- user.authorized_runners.should include(runner, runner1)
- user.authorized_runners.should_not include(runner2)
+ expect(user.authorized_runners).to include(runner, runner1)
+ expect(user.authorized_runners).not_to include(runner2)
end
end
end
diff --git a/spec/models/variable_spec.rb b/spec/models/variable_spec.rb
index c089df9..a41ba4e 100644
--- a/spec/models/variable_spec.rb
+++ b/spec/models/variable_spec.rb
@@ -24,15 +24,15 @@ describe Variable do
describe '#value' do
it 'stores the encrypted value' do
- subject.encrypted_value.should_not be_nil
+ expect(subject.encrypted_value).not_to be_nil
end
it 'stores an iv for value' do
- subject.encrypted_value_iv.should_not be_nil
+ expect(subject.encrypted_value_iv).not_to be_nil
end
it 'stores a salt for value' do
- subject.encrypted_value_salt.should_not be_nil
+ expect(subject.encrypted_value_salt).not_to be_nil
end
it 'fails to decrypt if iv is incorrect' do
diff --git a/spec/models/web_hook_spec.rb b/spec/models/web_hook_spec.rb
index 100d9a9..735440e 100644
--- a/spec/models/web_hook_spec.rb
+++ b/spec/models/web_hook_spec.rb
@@ -13,22 +13,22 @@ require 'spec_helper'
describe WebHook do
describe "Associations" do
- it { should belong_to :project }
+ it { is_expected.to belong_to :project }
end
describe "Validations" do
- it { should validate_presence_of(:url) }
+ it { is_expected.to validate_presence_of(:url) }
context "url format" do
- it { should allow_value("http://example.com").for(:url) }
- it { should allow_value("https://excample.com").for(:url) }
- it { should allow_value("http://test.com/api").for(:url) }
- it { should allow_value("http://test.com/api?key=abc").for(:url) }
- it { should allow_value("http://test.com/api?key=abc&type=def").for(:url) }
-
- it { should_not allow_value("example.com").for(:url) }
- it { should_not allow_value("ftp://example.com").for(:url) }
- it { should_not allow_value("herp-and-derp").for(:url) }
+ it { is_expected.to allow_value("http://example.com").for(:url) }
+ it { is_expected.to allow_value("https://excample.com").for(:url) }
+ it { is_expected.to allow_value("http://test.com/api").for(:url) }
+ it { is_expected.to allow_value("http://test.com/api?key=abc").for(:url) }
+ it { is_expected.to allow_value("http://test.com/api?key=abc&type=def").for(:url) }
+
+ it { is_expected.not_to allow_value("example.com").for(:url) }
+ it { is_expected.not_to allow_value("ftp://example.com").for(:url) }
+ it { is_expected.not_to allow_value("herp-and-derp").for(:url) }
end
end
@@ -43,18 +43,18 @@ describe WebHook do
it "POSTs to the web hook URL" do
@web_hook.execute(@data)
- WebMock.should have_requested(:post, @web_hook.url).once
+ expect(WebMock).to have_requested(:post, @web_hook.url).once
end
it "POSTs the data as JSON" do
json = @data.to_json
@web_hook.execute(@data)
- WebMock.should have_requested(:post, @web_hook.url).with(body: json).once
+ expect(WebMock).to have_requested(:post, @web_hook.url).with(body: json).once
end
it "catches exceptions" do
- described_class.should_receive(:post).and_raise("Some HTTP Post error")
+ expect(described_class).to receive(:post).and_raise("Some HTTP Post error")
expect { @web_hook.execute(@data) }.
to raise_error(RuntimeError, 'Some HTTP Post error')
diff --git a/spec/requests/api/builds_spec.rb b/spec/requests/api/builds_spec.rb
index b579b36..4c01167 100644
--- a/spec/requests/api/builds_spec.rb
+++ b/spec/requests/api/builds_spec.rb
@@ -22,15 +22,15 @@ describe API::API do
post api("/builds/register"), token: runner.token, info: {platform: :darwin}
- response.status.should eq 201
- json_response['sha'].should eq build.sha
- runner.reload.platform.should eq "darwin"
+ expect(response.status).to eq 201
+ expect(json_response['sha']).to eq build.sha
+ expect(runner.reload.platform).to eq "darwin"
end
it "should return 404 error if no pending build found" do
post api("/builds/register"), token: runner.token
- response.status.should eq 404
+ expect(response.status).to eq 404
end
it "should return 404 error if no builds for specific runner" do
@@ -39,7 +39,7 @@ describe API::API do
post api("/builds/register"), token: runner.token
- response.status.should eq 404
+ expect(response.status).to eq 404
end
it "should return 404 error if no builds for shared runner" do
@@ -48,7 +48,7 @@ describe API::API do
post api("/builds/register"), token: shared_runner.token
- response.status.should eq 404
+ expect(response.status).to eq 404
end
it "returns options" do
@@ -57,8 +57,8 @@ describe API::API do
post api("/builds/register"), token: runner.token, info: {platform: :darwin}
- response.status.should eq 201
- json_response["options"].should eq({"image" => "ruby:2.1", "services" => ["postgres"]})
+ expect(response.status).to eq 201
+ expect(json_response["options"]).to eq({"image" => "ruby:2.1", "services" => ["postgres"]})
end
it "returns variables" do
@@ -68,8 +68,8 @@ describe API::API do
post api("/builds/register"), token: runner.token, info: {platform: :darwin}
- response.status.should eq 201
- json_response["variables"].should eq [
+ expect(response.status).to eq 201
+ expect(json_response["variables"]).to eq [
{"key" => "DB_NAME", "value" => "postgres", "public" => true},
{"key" => "SECRET_KEY", "value" => "secret_value", "public" => false},
]
@@ -85,8 +85,8 @@ describe API::API do
post api("/builds/register"), token: runner.token, info: {platform: :darwin}
- response.status.should eq 201
- json_response["variables"].should eq [
+ expect(response.status).to eq 201
+ expect(json_response["variables"]).to eq [
{"key" => "DB_NAME", "value" => "postgres", "public" => true},
{"key" => "SECRET_KEY", "value" => "secret_value", "public" => false},
{"key" => "TRIGGER_KEY", "value" => "TRIGGER_VALUE", "public" => false},
@@ -101,7 +101,7 @@ describe API::API do
it "should update a running build" do
build.run!
put api("/builds/#{build.id}"), token: runner.token
- response.status.should eq 200
+ expect(response.status).to eq 200
end
it 'Should not override trace information when no trace is given' do
diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb
index 60763eb..99cdbc3 100644
--- a/spec/requests/api/commits_spec.rb
+++ b/spec/requests/api/commits_spec.rb
@@ -19,10 +19,10 @@ describe API::API, 'Commits' do
it "should return commits per project" do
get api("/commits"), options
- response.status.should eq 200
- json_response.count.should eq 1
- json_response.first["project_id"].should eq project.id
- json_response.first["sha"].should eq commit.sha
+ expect(response.status).to eq 200
+ expect(json_response.count).to eq 1
+ expect(json_response.first["project_id"]).to eq project.id
+ expect(json_response.first["sha"]).to eq commit.sha
end
end
@@ -51,15 +51,15 @@ describe API::API, 'Commits' do
it "should create a build" do
post api("/commits"), options.merge(data: data)
- response.status.should eq 201
- json_response['sha'].should eq "da1560886d4f094c3e6c9ef40349f7d38b5d27d7"
+ expect(response.status).to eq 201
+ expect(json_response['sha']).to eq "da1560886d4f094c3e6c9ef40349f7d38b5d27d7"
end
it "should return 400 error if no data passed" do
post api("/commits"), options
- response.status.should eq 400
- json_response['message'].should eq "400 (Bad request) \"data\" not given"
+ expect(response.status).to eq 400
+ expect(json_response['message']).to eq "400 (Bad request) \"data\" not given"
end
end
end
diff --git a/spec/requests/api/forks_spec.rb b/spec/requests/api/forks_spec.rb
index 1dd9c05..c884e4b 100644
--- a/spec/requests/api/forks_spec.rb
+++ b/spec/requests/api/forks_spec.rb
@@ -41,8 +41,8 @@ describe API::API do
it "should create a project with valid data" do
post api("/forks"), options
- response.status.should eq 201
- json_response['name'].should eq "Gitlab.org / Underscore"
+ expect(response.status).to eq 201
+ expect(json_response['name']).to eq "Gitlab.org / Underscore"
end
end
@@ -53,7 +53,7 @@ describe API::API do
it "should error with invalid data" do
post api("/forks"), options
- response.status.should eq 400
+ expect(response.status).to eq 400
end
end
end
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index 290d7cf..597f8dd 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -25,10 +25,10 @@ describe API::API do
it "should return all projects on the CI instance" do
get api("/projects"), options
- response.status.should eq 200
- json_response.count.should eq 2
- json_response.first["id"].should eq project1.id
- json_response.last["id"].should eq project2.id
+ expect(response.status).to eq 200
+ expect(json_response.count).to eq 2
+ expect(json_response.first["id"]).to eq project1.id
+ expect(json_response.last["id"]).to eq project2.id
end
end
@@ -40,8 +40,8 @@ describe API::API do
it "should return all projects on the CI instance" do
get api("/projects/owned"), options
- response.status.should eq 200
- json_response.count.should eq 0
+ expect(response.status).to eq 200
+ expect(json_response.count).to eq 0
end
end
end
@@ -58,19 +58,19 @@ describe API::API do
it "should create webhook for specified project" do
post api("/projects/#{project.id}/webhooks"), options
- response.status.should eq 201
- json_response["url"].should eq webhook[:web_hook]
+ expect(response.status).to eq 201
+ expect(json_response["url"]).to eq webhook[:web_hook]
end
it "fails to create webhook for non existsing project" do
post api("/projects/non-existant-id/webhooks"), options
- response.status.should eq 404
+ expect(response.status).to eq 404
end
it "non-manager is not authorized" do
allow_any_instance_of(User).to receive(:can_manage_project?).and_return(false)
post api("/projects/#{project.id}/webhooks"), options
- response.status.should eq 401
+ expect(response.status).to eq 401
end
end
@@ -83,14 +83,14 @@ describe API::API do
it "fails to create webhook for not valid url" do
post api("/projects/#{project.id}/webhooks"), options
- response.status.should eq 400
+ expect(response.status).to eq 400
end
end
context "Missed web_hook parameter" do
it "fails to create webhook for not provided url" do
post api("/projects/#{project.id}/webhooks"), options
- response.status.should eq 400
+ expect(response.status).to eq 400
end
end
end
@@ -101,15 +101,15 @@ describe API::API do
context "with an existing project" do
it "should retrieve the project info" do
get api("/projects/#{project.id}"), options
- response.status.should eq 200
- json_response['id'].should eq project.id
+ expect(response.status).to eq 200
+ expect(json_response['id']).to eq project.id
end
end
context "with a non-existing project" do
it "should return 404 error if project not found" do
get api("/projects/non_existent_id"), options
- response.status.should eq 404
+ expect(response.status).to eq 404
end
end
end
@@ -124,19 +124,19 @@ describe API::API do
it "should update a specific project's information" do
put api("/projects/#{project.id}"), options
- response.status.should eq 200
- json_response["name"].should eq project_info[:name]
+ expect(response.status).to eq 200
+ expect(json_response["name"]).to eq project_info[:name]
end
it "fails to update a non-existing project" do
put api("/projects/non-existant-id"), options
- response.status.should eq 404
+ expect(response.status).to eq 404
end
it "non-manager is not authorized" do
allow_any_instance_of(User).to receive(:can_manage_project?).and_return(false)
put api("/projects/#{project.id}"), options
- response.status.should eq 401
+ expect(response.status).to eq 401
end
end
@@ -145,7 +145,7 @@ describe API::API do
it "should delete a specific project" do
delete api("/projects/#{project.id}"), options
- response.status.should eq 200
+ expect(response.status).to eq 200
expect { project.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
@@ -153,12 +153,12 @@ describe API::API do
it "non-manager is not authorized" do
allow_any_instance_of(User).to receive(:can_manage_project?).and_return(false)
delete api("/projects/#{project.id}"), options
- response.status.should eq 401
+ expect(response.status).to eq 401
end
it "is getting not found error" do
delete api("/projects/not-existing_id"), options
- response.status.should eq 404
+ expect(response.status).to eq 404
end
end
@@ -181,8 +181,8 @@ describe API::API do
it "should create a project with valid data" do
post api("/projects"), options
- response.status.should eq 201
- json_response['name'].should eq project_info[:name]
+ expect(response.status).to eq 201
+ expect(json_response['name']).to eq project_info[:name]
end
end
@@ -193,7 +193,7 @@ describe API::API do
it "should error with invalid data" do
post api("/projects"), options
- response.status.should eq 400
+ expect(response.status).to eq 400
end
end
@@ -203,24 +203,24 @@ describe API::API do
it "should add the project to the runner" do
post api("/projects/#{project.id}/runners/#{runner.id}"), options
- response.status.should eq 201
+ expect(response.status).to eq 201
project.reload
- project.runners.first.id.should eq runner.id
+ expect(project.runners.first.id).to eq runner.id
end
it "should fail if it tries to link a non-existing project or runner" do
post api("/projects/#{project.id}/runners/non-existing"), options
- response.status.should eq 404
+ expect(response.status).to eq 404
post api("/projects/non-existing/runners/#{runner.id}"), options
- response.status.should eq 404
+ expect(response.status).to eq 404
end
it "non-manager is not authorized" do
allow_any_instance_of(User).to receive(:can_manage_project?).and_return(false)
post api("/projects/#{project.id}/runners/#{runner.id}"), options
- response.status.should eq 401
+ expect(response.status).to eq 401
end
end
@@ -233,18 +233,18 @@ describe API::API do
end
it "should remove the project from the runner" do
- project.runners.should be_present
+ expect(project.runners).to be_present
delete api("/projects/#{project.id}/runners/#{runner.id}"), options
- response.status.should eq 200
+ expect(response.status).to eq 200
project.reload
- project.runners.should be_empty
+ expect(project.runners).to be_empty
end
it "non-manager is not authorized" do
allow_any_instance_of(User).to receive(:can_manage_project?).and_return(false)
post api("/projects/#{project.id}/runners/#{runner.id}"), options
- response.status.should eq 401
+ expect(response.status).to eq 401
end
end
end
diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb
index a6fc43c..f97afeb 100644
--- a/spec/requests/api/runners_spec.rb
+++ b/spec/requests/api/runners_spec.rb
@@ -24,10 +24,10 @@ describe API::API do
it "should retrieve a list of all runners" do
get api("/runners"), options
- response.status.should eq 200
- json_response.count.should eq 5
- json_response.last.should have_key("id")
- json_response.last.should have_key("token")
+ expect(response.status).to eq 200
+ expect(json_response.count).to eq 5
+ expect(json_response.last).to have_key("id")
+ expect(json_response.last).to have_key("token")
end
end
@@ -35,41 +35,41 @@ describe API::API do
describe "should create a runner if token provided" do
before { post api("/runners/register"), token: GitlabCi::REGISTRATION_TOKEN }
- it { response.status.should eq 201 }
+ it { expect(response.status).to eq 201 }
end
describe "should create a runner with description" do
before { post api("/runners/register"), token: GitlabCi::REGISTRATION_TOKEN, description: "server.hostname" }
- it { response.status.should eq 201 }
- it { Runner.first.description.should eq "server.hostname" }
+ it { expect(response.status).to eq 201 }
+ it { expect(Runner.first.description).to eq "server.hostname" }
end
describe "should create a runner with tags" do
before { post api("/runners/register"), token: GitlabCi::REGISTRATION_TOKEN, tag_list: "tag1, tag2" }
- it { response.status.should eq 201 }
- it { Runner.first.tag_list.sort.should eq ["tag1", "tag2"] }
+ it { expect(response.status).to eq 201 }
+ it { expect(Runner.first.tag_list.sort).to eq ["tag1", "tag2"] }
end
describe "should create a runner if project token provided" do
let(:project) { FactoryGirl.create(:project) }
before { post api("/runners/register"), token: project.token }
- it { response.status.should eq 201 }
- it { project.runners.size.should eq 1 }
+ it { expect(response.status).to eq 201 }
+ it { expect(project.runners.size).to eq 1 }
end
it "should return 403 error if token is invalid" do
post api("/runners/register"), token: 'invalid'
- response.status.should eq 403
+ expect(response.status).to eq 403
end
it "should return 400 error if no token" do
post api("/runners/register")
- response.status.should eq 400
+ expect(response.status).to eq 400
end
end
@@ -77,7 +77,7 @@ describe API::API do
let!(:runner) { FactoryGirl.create(:runner) }
before { delete api("/runners/delete"), token: runner.token }
- it { response.status.should eq 200 }
- it { Runner.count.should eq 0 }
+ it { expect(response.status).to eq 200 }
+ it { expect(Runner.count).to eq 0 }
end
end
diff --git a/spec/requests/api/triggers_spec.rb b/spec/requests/api/triggers_spec.rb
index fc7394c..e477a59 100644
--- a/spec/requests/api/triggers_spec.rb
+++ b/spec/requests/api/triggers_spec.rb
@@ -17,17 +17,17 @@ describe API::API do
context 'Handles errors' do
it 'should return bad request if token is missing' do
post api("/projects/#{project.id}/refs/master/trigger")
- response.status.should eq 400
+ expect(response.status).to eq 400
end
it 'should return not found if project is not found' do
post api('/projects/0/refs/master/trigger'), options
- response.status.should eq 404
+ expect(response.status).to eq 404
end
it 'should return unauthorized if token is for different project' do
post api("/projects/#{project2.id}/refs/master/trigger"), options
- response.status.should eq 401
+ expect(response.status).to eq 401
end
end
@@ -38,15 +38,15 @@ describe API::API do
it 'should create builds' do
post api("/projects/#{project.id}/refs/master/trigger"), options
- response.status.should eq 201
+ expect(response.status).to eq 201
@commit.builds.reload
- @commit.builds.size.should eq 2
+ expect(@commit.builds.size).to eq 2
end
it 'should return bad request with no builds created if there\'s no commit for that ref' do
post api("/projects/#{project.id}/refs/other-branch/trigger"), options
- response.status.should eq 400
- json_response['message'].should eq 'No builds created'
+ expect(response.status).to eq 400
+ expect(json_response['message']).to eq 'No builds created'
end
context 'Validates variables' do
@@ -56,21 +56,21 @@ describe API::API do
it 'should validate variables to be a hash' do
post api("/projects/#{project.id}/refs/master/trigger"), options.merge(variables: 'value')
- response.status.should eq 400
- json_response['message'].should eq 'variables needs to be a hash'
+ expect(response.status).to eq 400
+ expect(json_response['message']).to eq 'variables needs to be a hash'
end
it 'should validate variables needs to be a map of key-valued strings' do
post api("/projects/#{project.id}/refs/master/trigger"), options.merge(variables: {key: %w(1 2)})
- response.status.should eq 400
- json_response['message'].should eq 'variables needs to be a map of key-valued strings'
+ expect(response.status).to eq 400
+ expect(json_response['message']).to eq 'variables needs to be a map of key-valued strings'
end
it 'create trigger request with variables' do
post api("/projects/#{project.id}/refs/master/trigger"), options.merge(variables: variables)
- response.status.should eq 201
+ expect(response.status).to eq 201
@commit.builds.reload
- @commit.builds.first.trigger_request.variables.should eq variables
+ expect(@commit.builds.first.trigger_request.variables).to eq variables
end
end
end
diff --git a/spec/requests/builds_spec.rb b/spec/requests/builds_spec.rb
index a245087..28dda2b 100644
--- a/spec/requests/builds_spec.rb
+++ b/spec/requests/builds_spec.rb
@@ -12,7 +12,7 @@ describe "Builds" do
get status_project_build_path(@project, @build), format: :json
end
- it { response.status.should eq 200 }
- it { response.body.should include(@build.sha) }
+ it { expect(response.status).to eq 200 }
+ it { expect(response.body).to include(@build.sha) }
end
end
diff --git a/spec/requests/commits_spec.rb b/spec/requests/commits_spec.rb
index e257997..d992253 100644
--- a/spec/requests/commits_spec.rb
+++ b/spec/requests/commits_spec.rb
@@ -11,7 +11,7 @@ describe "Commits" do
get status_project_ref_commit_path(@project, @commit.ref, @commit.sha), format: :json
end
- it { response.status.should eq 200 }
- it { response.body.should include(@commit.sha) }
+ it { expect(response.status).to eq 200 }
+ it { expect(response.body).to include(@commit.sha) }
end
end
diff --git a/spec/services/create_commit_service_spec.rb b/spec/services/create_commit_service_spec.rb
index 05793eb..209e088 100644
--- a/spec/services/create_commit_service_spec.rb
+++ b/spec/services/create_commit_service_spec.rb
@@ -16,11 +16,11 @@ describe CreateCommitService do
)
end
- it { commit.should be_kind_of(Commit) }
- it { commit.should be_valid }
- it { commit.should be_persisted }
- it { commit.should eq project.commits.last }
- it { commit.builds.first.should be_kind_of(Build) }
+ it { expect(commit).to be_kind_of(Commit) }
+ it { expect(commit).to be_valid }
+ it { expect(commit).to be_persisted }
+ it { expect(commit).to eq project.commits.last }
+ it { expect(commit.builds.first).to be_kind_of(Build) }
end
context "skip tag if there is no build for it" do
@@ -32,7 +32,7 @@ describe CreateCommitService do
ci_yaml_file: gitlab_ci_yaml,
commits: [ { message: "Message" } ]
)
- result.should be_persisted
+ expect(result).to be_persisted
end
it "creates commit if there is no appropriate job but deploy job has right ref setting" do
@@ -45,7 +45,7 @@ describe CreateCommitService do
ci_yaml_file: config,
commits: [ { message: "Message" } ]
)
- result.should be_persisted
+ expect(result).to be_persisted
end
end
@@ -59,8 +59,8 @@ describe CreateCommitService do
commits: commits,
ci_yaml_file: gitlab_ci_yaml
)
- commit.builds.any?.should be_falsey
- commit.status.should eq "skipped"
+ expect(commit.builds.any?).to be_falsey
+ expect(commit.status).to eq "skipped"
end
it "does not skips builds creation if there is no [ci skip] tag in commit message" do
@@ -74,7 +74,7 @@ describe CreateCommitService do
ci_yaml_file: gitlab_ci_yaml
)
- commit.builds.first.name.should eq "staging"
+ expect(commit.builds.first.name).to eq "staging"
end
it "skips builds creation if there is [ci skip] tag in commit message and yaml is invalid" do
@@ -86,8 +86,8 @@ describe CreateCommitService do
commits: commits,
ci_yaml_file: "invalid: file"
)
- commit.builds.any?.should be_falsey
- commit.status.should eq "skipped"
+ expect(commit.builds.any?).to be_falsey
+ expect(commit.status).to eq "skipped"
end
end
@@ -100,7 +100,7 @@ describe CreateCommitService do
commits: commits,
ci_yaml_file: gitlab_ci_yaml
)
- commit.builds.count(:all).should eq 2
+ expect(commit.builds.count(:all)).to eq 2
commit = service.execute(project,
ref: 'refs/heads/master',
@@ -109,7 +109,7 @@ describe CreateCommitService do
commits: commits,
ci_yaml_file: gitlab_ci_yaml
)
- commit.builds.count(:all).should eq 2
+ expect(commit.builds.count(:all)).to eq 2
end
it "creates commit with failed status if yaml is invalid" do
@@ -123,8 +123,8 @@ describe CreateCommitService do
ci_yaml_file: "invalid: file"
)
- commit.status.should eq "failed"
- commit.builds.any?.should be_falsey
+ expect(commit.status).to eq "failed"
+ expect(commit.builds.any?).to be_falsey
end
end
end
diff --git a/spec/services/create_project_service_spec.rb b/spec/services/create_project_service_spec.rb
index 1a1a433..085d5e9 100644
--- a/spec/services/create_project_service_spec.rb
+++ b/spec/services/create_project_service_spec.rb
@@ -11,8 +11,8 @@ describe CreateProjectService do
context 'valid params' do
let(:project) { service.execute(current_user, project_dump, 'http://localhost/projects/:project_id') }
- it { project.should be_kind_of(Project) }
- it { project.should be_persisted }
+ it { expect(project).to be_kind_of(Project) }
+ it { expect(project).to be_persisted }
end
context 'without project dump' do
@@ -32,9 +32,9 @@ describe CreateProjectService do
project = service.execute(current_user, project_dump, 'http://localhost/projects/:project_id', origin_project)
- project.shared_runners_enabled.should be_truthy
- project.public.should be_truthy
- project.allow_git_fetch.should be_truthy
+ expect(project.shared_runners_enabled).to be_truthy
+ expect(project.public).to be_truthy
+ expect(project.allow_git_fetch).to be_truthy
end
end
end
diff --git a/spec/services/create_trigger_request_service_spec.rb b/spec/services/create_trigger_request_service_spec.rb
index cb9a1e6..0634753 100644
--- a/spec/services/create_trigger_request_service_spec.rb
+++ b/spec/services/create_trigger_request_service_spec.rb
@@ -13,14 +13,14 @@ describe CreateTriggerRequestService do
@commit = FactoryGirl.create :commit, project: project
end
- it { subject.should be_kind_of(TriggerRequest) }
- it { subject.commit.should eq @commit }
+ it { expect(subject).to be_kind_of(TriggerRequest) }
+ it { expect(subject.commit).to eq @commit }
end
context 'no commit for ref' do
subject { service.execute(project, trigger, 'other-branch') }
- it { subject.should be_nil }
+ it { expect(subject).to be_nil }
end
context 'no builds created' do
@@ -30,7 +30,7 @@ describe CreateTriggerRequestService do
FactoryGirl.create :commit_without_jobs, project: project
end
- it { subject.should be_nil }
+ it { expect(subject).to be_nil }
end
context 'for multiple commits' do
@@ -43,9 +43,9 @@ describe CreateTriggerRequestService do
end
context 'retries latest one' do
- it { subject.should be_kind_of(TriggerRequest) }
- it { subject.should be_persisted }
- it { subject.commit.should eq @commit2 }
+ it { expect(subject).to be_kind_of(TriggerRequest) }
+ it { expect(subject).to be_persisted }
+ it { expect(subject.commit).to eq @commit2 }
end
end
end
diff --git a/spec/services/event_service_spec.rb b/spec/services/event_service_spec.rb
index 1d41673..3333c19 100644
--- a/spec/services/event_service_spec.rb
+++ b/spec/services/event_service_spec.rb
@@ -12,7 +12,7 @@ describe EventService do
it "creates event" do
described_class.new.remove_project(user, project)
- Event.admin.last.description.should eq "Project \"GitLab / gitlab-shell\" has been removed by root"
+ expect(Event.admin.last.description).to eq "Project \"GitLab / gitlab-shell\" has been removed by root"
end
end
@@ -20,7 +20,7 @@ describe EventService do
it "creates event" do
described_class.new.create_project(user, project)
- Event.admin.last.description.should eq "Project \"GitLab / gitlab-shell\" has been created by root"
+ expect(Event.admin.last.description).to eq "Project \"GitLab / gitlab-shell\" has been created by root"
end
end
@@ -28,7 +28,7 @@ describe EventService do
it "creates event" do
described_class.new.change_project_settings(user, project)
- Event.last.description.should eq "User \"root\" updated projects settings"
+ expect(Event.last.description).to eq "User \"root\" updated projects settings"
end
end
end
diff --git a/spec/services/image_for_build_service_spec.rb b/spec/services/image_for_build_service_spec.rb
index af85904..d9c9c76 100644
--- a/spec/services/image_for_build_service_spec.rb
+++ b/spec/services/image_for_build_service_spec.rb
@@ -13,34 +13,34 @@ describe ImageForBuildService do
before { build.run! }
let(:image) { service.execute(project, ref: 'master') }
- it { image.should be_kind_of(OpenStruct) }
- it { image.path.to_s.should include('public/build-running.svg') }
- it { image.name.should eq 'build-running.svg' }
+ it { expect(image).to be_kind_of(OpenStruct) }
+ it { expect(image.path.to_s).to include('public/build-running.svg') }
+ it { expect(image.name).to eq 'build-running.svg' }
end
context 'unknown branch name' do
let(:image) { service.execute(project, ref: 'feature') }
- it { image.should be_kind_of(OpenStruct) }
- it { image.path.to_s.should include('public/build-unknown.svg') }
- it { image.name.should eq 'build-unknown.svg' }
+ it { expect(image).to be_kind_of(OpenStruct) }
+ it { expect(image.path.to_s).to include('public/build-unknown.svg') }
+ it { expect(image.name).to eq 'build-unknown.svg' }
end
context 'commit sha' do
before { build.run! }
let(:image) { service.execute(project, sha: build.sha) }
- it { image.should be_kind_of(OpenStruct) }
- it { image.path.to_s.should include('public/build-running.svg') }
- it { image.name.should eq 'build-running.svg' }
+ it { expect(image).to be_kind_of(OpenStruct) }
+ it { expect(image.path.to_s).to include('public/build-running.svg') }
+ it { expect(image.name).to eq 'build-running.svg' }
end
context 'unknown commit sha' do
let(:image) { service.execute(project, sha: '0000000') }
- it { image.should be_kind_of(OpenStruct) }
- it { image.path.to_s.should include('public/build-unknown.svg') }
- it { image.name.should eq 'build-unknown.svg' }
+ it { expect(image).to be_kind_of(OpenStruct) }
+ it { expect(image.path.to_s).to include('public/build-unknown.svg') }
+ it { expect(image.name).to eq 'build-unknown.svg' }
end
end
end
diff --git a/spec/services/register_build_service_spec.rb b/spec/services/register_build_service_spec.rb
index 4202335..ee8e499 100644
--- a/spec/services/register_build_service_spec.rb
+++ b/spec/services/register_build_service_spec.rb
@@ -18,29 +18,29 @@ describe RegisterBuildService do
pending_build.tag_list = ["linux"]
pending_build.save
specific_runner.tag_list = ["linux"]
- service.execute(specific_runner).should eq pending_build
+ expect(service.execute(specific_runner)).to eq pending_build
end
it "does not pick build with different tag" do
pending_build.tag_list = ["linux"]
pending_build.save
specific_runner.tag_list = ["win32"]
- service.execute(specific_runner).should be_falsey
+ expect(service.execute(specific_runner)).to be_falsey
end
it "picks build without tag" do
- service.execute(specific_runner).should eq pending_build
+ expect(service.execute(specific_runner)).to eq pending_build
end
it "does not pick build with tag" do
pending_build.tag_list = ["linux"]
pending_build.save
- service.execute(specific_runner).should be_falsey
+ expect(service.execute(specific_runner)).to be_falsey
end
it "pick build without tag" do
specific_runner.tag_list = ["win32"]
- service.execute(specific_runner).should eq pending_build
+ expect(service.execute(specific_runner)).to eq pending_build
end
end
@@ -53,19 +53,19 @@ describe RegisterBuildService do
context 'shared runner' do
let(:build) { service.execute(shared_runner) }
- it { build.should be_kind_of(Build) }
- it { build.should be_valid }
- it { build.should be_running }
- it { build.runner.should eq shared_runner }
+ it { expect(build).to be_kind_of(Build) }
+ it { expect(build).to be_valid }
+ it { expect(build).to be_running }
+ it { expect(build.runner).to eq shared_runner }
end
context 'specific runner' do
let(:build) { service.execute(specific_runner) }
- it { build.should be_kind_of(Build) }
- it { build.should be_valid }
- it { build.should be_running }
- it { build.runner.should eq specific_runner }
+ it { expect(build).to be_kind_of(Build) }
+ it { expect(build).to be_valid }
+ it { expect(build).to be_running }
+ it { expect(build.runner).to eq specific_runner }
end
end
@@ -73,16 +73,16 @@ describe RegisterBuildService do
context 'shared runner' do
let(:build) { service.execute(shared_runner) }
- it { build.should be_nil }
+ it { expect(build).to be_nil }
end
context 'specific runner' do
let(:build) { service.execute(specific_runner) }
- it { build.should be_kind_of(Build) }
- it { build.should be_valid }
- it { build.should be_running }
- it { build.runner.should eq specific_runner }
+ it { expect(build).to be_kind_of(Build) }
+ it { expect(build).to be_valid }
+ it { expect(build).to be_running }
+ it { expect(build.runner).to eq specific_runner }
end
end
end
diff --git a/spec/services/web_hook_service_spec.rb b/spec/services/web_hook_service_spec.rb
index fae6d5a..93f5b4f 100644
--- a/spec/services/web_hook_service_spec.rb
+++ b/spec/services/web_hook_service_spec.rb
@@ -9,13 +9,13 @@ describe WebHookService do
describe '#execute' do
it "should execute successfully" do
stub_request(:post, hook.url).to_return(status: 200)
- described_class.new.build_end(build).should be_truthy
+ expect(described_class.new.build_end(build)).to be_truthy
end
end
context 'build_data' do
it "contains all needed fields" do
- build_data(build).should include(
+ expect(build_data(build)).to include(
:build_id,
:project_id,
:ref,