summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2015-09-08 07:39:09 +0000
committerValery Sizov <valery@gitlab.com>2015-09-08 07:39:09 +0000
commitfd6be573ee87416c103b361d5a8843600e59903e (patch)
tree9ed3124d255d4432d3acbc4265d6fc1496041380
parent305d9e20cc048a83bd4799942357cd690dacdef3 (diff)
parent77053a6c217e06770a348ac989992afbd41697f6 (diff)
downloadgitlab-ci-fd6be573ee87416c103b361d5a8843600e59903e.tar.gz
Merge branch 'rs-rspec3' into 'master'
RSpec 3 Updates CI's specs to be a bit more like CE's to make that transition a little easier. See merge request !246
-rw-r--r--.rspec2
-rw-r--r--Gemfile46
-rw-r--r--Gemfile.lock132
-rw-r--r--spec/controllers/projects_controller_spec.rb8
-rw-r--r--spec/factories/web_hook.rb2
-rw-r--r--spec/features/admin/builds_spec.rb24
-rw-r--r--spec/features/admin/events_spec.rb6
-rw-r--r--spec/features/admin/projects_spec.rb4
-rw-r--r--spec/features/admin/runners_spec.rb16
-rw-r--r--spec/features/builds_spec.rb18
-rw-r--r--spec/features/commits_spec.rb20
-rw-r--r--spec/features/events_spec.rb6
-rw-r--r--spec/features/lint_spec.rb14
-rw-r--r--spec/features/projects_spec.rb28
-rw-r--r--spec/features/runners_spec.rb20
-rw-r--r--spec/features/triggers_spec.rb8
-rw-r--r--spec/features/variables_spec.rb6
-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.rb14
-rw-r--r--spec/helpers/user_sessions_helper_spec.rb30
-rw-r--r--spec/lib/ansi2html_spec.rb66
-rw-r--r--spec/lib/charts_spec.rb21
-rw-r--r--spec/lib/gitlab_ci_yaml_processor_spec.rb134
-rw-r--r--spec/lib/upgrader_spec.rb8
-rw-r--r--spec/mailers/notify_spec.rb12
-rw-r--r--spec/models/build_spec.rb132
-rw-r--r--spec/models/commit_spec.rb132
-rw-r--r--spec/models/mail_service_spec.rb50
-rw-r--r--spec/models/network_spec.rb32
-rw-r--r--spec/models/project_services/hip_chat_message_spec.rb10
-rw-r--r--spec/models/project_services/hip_chat_service_spec.rb8
-rw-r--r--spec/models/project_services/slack_message_spec.rb46
-rw-r--r--spec/models/project_services/slack_service_spec.rb10
-rw-r--r--spec/models/project_spec.rb96
-rw-r--r--spec/models/runner_project_spec.rb16
-rw-r--r--spec/models/runner_spec.rb12
-rw-r--r--spec/models/service_spec.rb12
-rw-r--r--spec/models/trigger_spec.rb4
-rw-r--r--spec/models/user_spec.rb32
-rw-r--r--spec/models/variable_spec.rb13
-rw-r--r--spec/models/web_hook_spec.rb33
-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.rb80
-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.rb38
-rw-r--r--spec/services/create_project_service_spec.rb19
-rw-r--r--spec/services/create_trigger_request_service_spec.rb18
-rw-r--r--spec/services/event_service_spec.rb20
-rw-r--r--spec/services/image_for_build_service_spec.rb28
-rw-r--r--spec/services/register_build_service_spec.rb40
-rw-r--r--spec/services/web_hook_service_spec.rb8
-rw-r--r--spec/spec_helper.rb46
-rw-r--r--spec/support/capybara.rb21
-rw-r--r--spec/support/login_helpers.rb2
-rw-r--r--spec/support/stub_gitlab_calls.rb6
-rw-r--r--spec/support/webmock.rb4
62 files changed, 853 insertions, 884 deletions
diff --git a/.rspec b/.rspec
index 4e1e0d2..ad3f5b7 100644
--- a/.rspec
+++ b/.rspec
@@ -1 +1 @@
---color
+--color --format Fuubar
diff --git a/Gemfile b/Gemfile
index f8ffdde..651f5ba 100644
--- a/Gemfile
+++ b/Gemfile
@@ -103,37 +103,39 @@ gem "unf"
group :development do
gem 'brakeman', require: false
- gem 'rack-mini-profiler', require: false
gem 'annotate'
- gem 'quiet_assets'
gem "letter_opener"
- gem "spring-commands-rspec"
+ gem 'quiet_assets'
+ gem 'rack-mini-profiler', require: false
end
group :development, :test do
- gem 'spring', '~> 1.3.6'
- gem 'minitest'
- gem 'pry'
- gem 'rspec-rails'
- gem 'capybara'
- gem 'poltergeist', '~> 1.5.1'
+ gem 'byebug', platform: :mri
+ gem 'fuubar', '~> 2.0.0'
+ gem 'pry-rails'
+
+ gem "database_cleaner", '~> 1.4.0'
gem 'factory_girl_rails'
- gem "ffaker"
- gem "byebug"
- gem "database_cleaner"
- gem 'shoulda-matchers'
- gem 'guard-rspec'
- gem 'rb-fsevent', require: darwin_only('rb-fsevent')
- gem 'growl', require: darwin_only('growl')
- gem 'rb-inotify', require: linux_only('rb-inotify')
-
- gem "simplecov", require: false
+ gem 'rspec-rails', '~> 3.3.0'
+ gem 'rubocop', '0.28.0', require: false
+
+ gem 'capybara', '~> 2.4.0'
+ gem 'capybara-screenshot', '~> 1.0.0'
+ gem 'poltergeist', '~> 1.6.0'
+
+ gem 'spring', '~> 1.3.6'
+ gem 'spring-commands-rspec', '~> 1.0.0'
+
+ gem 'minitest'
+ gem 'ffaker', '~> 2.0.0'
+
gem 'coveralls', '~> 0.8.2', require: false
- gem 'rubocop', '0.28.0', require: false
end
group :test do
- gem 'webmock'
- gem 'email_spec'
+ gem 'simplecov', require: false
+ gem 'shoulda-matchers', '~> 2.8.0', require: false
+ gem 'email_spec', '~> 1.6.0'
+ gem 'webmock', '~> 1.21.0'
end
diff --git a/Gemfile.lock b/Gemfile.lock
index 5d648b3..b31b666 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -35,7 +35,7 @@ GEM
tzinfo (~> 1.1)
acts-as-taggable-on (3.4.3)
activerecord (>= 3.2, < 5)
- addressable (2.3.5)
+ addressable (2.3.8)
annotate (2.6.0)
activerecord (>= 2.3.0)
rake (>= 0.8.7)
@@ -64,12 +64,15 @@ GEM
byebug (3.2.0)
columnize (~> 0.8)
debugger-linecache (~> 1.2)
- capybara (2.1.0)
+ capybara (2.4.4)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
+ capybara-screenshot (1.0.11)
+ capybara (>= 1.0, < 3)
+ launchy
celluloid (0.15.2)
timers (~> 1.1.0)
chronic (0.10.2)
@@ -93,9 +96,9 @@ GEM
simplecov (~> 0.10.0)
term-ansicolor (~> 1.3)
thor (~> 0.19.1)
- crack (0.4.1)
- safe_yaml (~> 0.9.0)
- database_cleaner (1.3.0)
+ crack (0.4.2)
+ safe_yaml (~> 1.0.0)
+ database_cleaner (1.4.1)
debugger-linecache (1.2.0)
default_value_for (3.0.0.1)
activerecord (>= 3.2.0, < 5.0)
@@ -106,7 +109,7 @@ GEM
domain_name (0.5.24)
unf (>= 0.0.5, < 1.0.0)
dotenv (0.9.0)
- email_spec (1.5.0)
+ email_spec (1.6.0)
launchy (~> 2.1)
mail (~> 2.2)
encryptor (1.3.0)
@@ -122,8 +125,7 @@ GEM
faraday (0.9.1)
multipart-post (>= 1.2, < 3)
fastercsv (1.5.5)
- ffaker (1.22.1)
- ffi (1.9.3)
+ ffaker (2.0.0)
fission (0.5.0)
CFPropertyList (~> 2.2)
fog (1.25.0)
@@ -187,6 +189,9 @@ GEM
dotenv (>= 0.7)
thor (>= 0.13.6)
formatador (0.2.4)
+ fuubar (2.0.0)
+ rspec (~> 3.0)
+ ruby-progressbar (~> 1.4)
gitlab_ci_meta (4.0)
grape (0.6.1)
activesupport
@@ -201,16 +206,6 @@ GEM
grape-entity (0.3.0)
activesupport
multi_json (>= 1.3.2)
- growl (1.0.3)
- guard (2.2.4)
- formatador (>= 0.2.4)
- listen (~> 2.1)
- lumberjack (~> 1.0)
- pry (>= 0.9.12)
- thor (>= 0.18.1)
- guard-rspec (4.2.0)
- guard (>= 2.1.1)
- rspec (>= 2.14, < 4.0)
haml (4.0.6)
tilt
haml-rails (0.5.3)
@@ -245,15 +240,10 @@ GEM
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
kgio (2.9.2)
- launchy (2.4.2)
+ launchy (2.4.3)
addressable (~> 2.3)
- letter_opener (1.1.2)
+ letter_opener (1.4.1)
launchy (~> 2.2)
- listen (2.4.0)
- celluloid (>= 0.15.2)
- rb-fsevent (>= 0.9.3)
- rb-inotify (>= 0.9)
- lumberjack (1.0.4)
mail (2.6.3)
mime-types (>= 1.16, < 3)
method_source (0.8.2)
@@ -288,16 +278,18 @@ GEM
parser (2.2.0.2)
ast (>= 1.1, < 3.0)
pg (0.17.0)
- poltergeist (1.5.1)
+ poltergeist (1.6.0)
capybara (~> 2.1)
cliver (~> 0.3.1)
multi_json (~> 1.0)
websocket-driver (>= 0.2.0)
powerpack (0.0.9)
- pry (0.9.12.4)
- coderay (~> 1.0)
- method_source (~> 0.8)
+ pry (0.10.1)
+ coderay (~> 1.1.0)
+ method_source (~> 0.8.1)
slop (~> 3.4)
+ pry-rails (0.3.4)
+ pry (>= 0.9.10)
quiet_assets (1.0.2)
railties (>= 3.1, < 5.0)
rack (1.5.5)
@@ -329,9 +321,6 @@ GEM
rainbow (2.0.0)
raindrops (0.13.0)
rake (10.4.2)
- rb-fsevent (0.9.3)
- rb-inotify (0.9.2)
- ffi (>= 0.5.0)
rbvmomi (1.8.2)
builder
nokogiri (>= 1.4.1)
@@ -344,21 +333,27 @@ GEM
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
- rspec (2.14.1)
- rspec-core (~> 2.14.0)
- rspec-expectations (~> 2.14.0)
- rspec-mocks (~> 2.14.0)
- rspec-core (2.14.7)
- rspec-expectations (2.14.4)
- diff-lcs (>= 1.1.3, < 2.0)
- rspec-mocks (2.14.4)
- rspec-rails (2.14.0)
- actionpack (>= 3.0)
- activesupport (>= 3.0)
- railties (>= 3.0)
- rspec-core (~> 2.14.0)
- rspec-expectations (~> 2.14.0)
- rspec-mocks (~> 2.14.0)
+ rspec (3.3.0)
+ rspec-core (~> 3.3.0)
+ rspec-expectations (~> 3.3.0)
+ rspec-mocks (~> 3.3.0)
+ rspec-core (3.3.2)
+ rspec-support (~> 3.3.0)
+ rspec-expectations (3.3.1)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.3.0)
+ rspec-mocks (3.3.2)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.3.0)
+ rspec-rails (3.3.2)
+ actionpack (>= 3.0, < 4.3)
+ activesupport (>= 3.0, < 4.3)
+ railties (>= 3.0, < 4.3)
+ rspec-core (~> 3.3.0)
+ rspec-expectations (~> 3.3.0)
+ rspec-mocks (~> 3.3.0)
+ rspec-support (~> 3.3.0)
+ rspec-support (3.3.0)
rubocop (0.28.0)
astrolabe (~> 1.3)
parser (>= 2.2.0.pre.7, < 3.0)
@@ -371,7 +366,7 @@ GEM
sexp_processor (~> 4.0)
ruby_parser (3.6.4)
sexp_processor (~> 4.1)
- safe_yaml (0.9.7)
+ safe_yaml (1.0.4)
sass (3.2.19)
sass-rails (4.0.5)
railties (>= 4.0.0, < 5.0)
@@ -380,7 +375,7 @@ GEM
sprockets-rails (~> 2.0)
settingslogic (2.0.9)
sexp_processor (4.5.0)
- shoulda-matchers (2.4.0)
+ shoulda-matchers (2.8.0)
activesupport (>= 3.0.0)
sidekiq (2.17.0)
celluloid (>= 0.15.2)
@@ -401,7 +396,7 @@ GEM
slim (2.0.2)
temple (~> 0.6.6)
tilt (>= 1.3.3, < 2.1)
- slop (3.4.7)
+ slop (3.6.0)
spring (1.3.6)
spring-commands-rspec (1.0.4)
spring (>= 0.9.1)
@@ -445,10 +440,12 @@ GEM
coercible (~> 1.0)
descendants_tracker (~> 0.0.1)
equalizer (~> 0.0.7)
- webmock (1.16.0)
- addressable (>= 2.2.7)
+ webmock (1.21.0)
+ addressable (>= 2.3.6)
crack (>= 0.3.2)
- websocket-driver (0.3.3)
+ websocket-driver (0.6.2)
+ websocket-extensions (>= 0.1.0)
+ websocket-extensions (0.1.2)
whenever (0.8.4)
activesupport (>= 2.3.4)
chronic (>= 0.6.3)
@@ -467,23 +464,23 @@ DEPENDENCIES
bootstrap-sass (~> 3.0)
brakeman
byebug
- capybara
+ capybara (~> 2.4.0)
+ capybara-screenshot (~> 1.0.0)
coffee-rails (~> 4.0.0)
colored
coveralls (~> 0.8.2)
- database_cleaner
+ database_cleaner (~> 1.4.0)
default_value_for (~> 3.0.0)
- email_spec
+ email_spec (~> 1.6.0)
factory_girl_rails
- ffaker
+ ffaker (~> 2.0.0)
fog (~> 1.25.0)
font-awesome-rails (~> 3.2)
foreman
+ fuubar (~> 2.0.0)
gitlab_ci_meta (~> 4.0)
grape
grape-entity
- growl
- guard-rspec
haml-rails (~> 0.5.3)
hipchat (~> 1.5.0)
httparty (= 0.11.0)
@@ -498,27 +495,25 @@ DEPENDENCIES
oauth2 (= 1.0.0)
paranoia (~> 2.0)
pg
- poltergeist (~> 1.5.1)
- pry
+ poltergeist (~> 1.6.0)
+ pry-rails
quiet_assets
rack-mini-profiler
rails (= 4.1.12)
rake
- rb-fsevent
- rb-inotify
request_store
- rspec-rails
+ rspec-rails (~> 3.3.0)
rubocop (= 0.28.0)
sass-rails (~> 4.0.5)
settingslogic
- shoulda-matchers
+ shoulda-matchers (~> 2.8.0)
sidekiq
simplecov
sinatra
slack-notifier (~> 1.0.0)
slim
spring (~> 1.3.6)
- spring-commands-rspec
+ spring-commands-rspec (~> 1.0.0)
sprockets (~> 2.12.3)
stamp
state_machine
@@ -527,5 +522,8 @@ DEPENDENCIES
unf
unicorn (~> 4.8.2)
virtus (= 1.0.1)
- webmock
+ webmock (~> 1.21.0)
whenever
+
+BUNDLED WITH
+ 1.10.6
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb
index 0069a78..326ec9a 100644
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -61,8 +61,8 @@ describe ProjectsController do
it "creates project" do
allow(controller).to receive(:reset_cache) { true }
allow(controller).to receive(:current_user) { user }
- Network.any_instance.stub(:enable_ci).and_return(true)
- Network.any_instance.stub(:project_hooks).and_return(true)
+ allow_any_instance_of(Network).to receive(:enable_ci).and_return(true)
+ allow_any_instance_of(Network).to receive(:project_hooks).and_return(true)
post :create, { project: JSON.dump(project_dump.to_h) }.with_indifferent_access
@@ -73,7 +73,7 @@ describe ProjectsController do
it "shows error" do
allow(controller).to receive(:reset_cache) { true }
allow(controller).to receive(:current_user) { user }
- User.any_instance.stub(:can_manage_project?).and_return(false)
+ allow_any_instance_of(User).to receive(:can_manage_project?).and_return(false)
post :create, { project: JSON.dump(project_dump.to_h) }.with_indifferent_access
@@ -97,7 +97,7 @@ describe ProjectsController do
it "searches projects" do
allow(controller).to receive(:reset_cache) { true }
allow(controller).to receive(:current_user) { user }
- Network.any_instance.should_receive(:projects).with(hash_including(search: 'str'), :authorized)
+ expect_any_instance_of(Network).to receive(:projects).with(hash_including(search: 'str'), :authorized)
xhr :get, :gitlab, { search: "str", format: "js" }.with_indifferent_access
diff --git a/spec/factories/web_hook.rb b/spec/factories/web_hook.rb
index 3c027fb..2b12942 100644
--- a/spec/factories/web_hook.rb
+++ b/spec/factories/web_hook.rb
@@ -1,6 +1,6 @@
FactoryGirl.define do
factory :web_hook do
- sequence(:url) { Faker::Internet.uri('http') }
+ sequence(:url) { FFaker::Internet.uri('http') }
project
end
end
diff --git a/spec/features/admin/builds_spec.rb b/spec/features/admin/builds_spec.rb
index e62e836..b27c3a2 100644
--- a/spec/features/admin/builds_spec.rb
+++ b/spec/features/admin/builds_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe "Admin Builds" do
+describe "Admin Builds", feature: true do
let(:project) { FactoryGirl.create :project }
let(:commit) { FactoryGirl.create :commit, project: project }
let(:build) { FactoryGirl.create :build, commit: commit }
@@ -16,8 +16,8 @@ describe "Admin Builds" do
visit admin_builds_path
end
- it { page.should have_content "All builds" }
- it { page.should have_content build.short_sha }
+ it { expect(page).to have_content "All builds" }
+ it { expect(page).to have_content build.short_sha }
end
describe "Tabs" do
@@ -29,7 +29,7 @@ describe "Admin Builds" do
visit admin_builds_path
- page.all(".build-link").size.should == 4
+ expect(page.all(".build-link").size).to eq 4
end
it "shows pending builds" do
@@ -44,10 +44,10 @@ describe "Admin Builds" do
click_on "Pending"
end
- page.find(".build-link").should have_content(build.id)
- page.find(".build-link").should_not have_content(build1.id)
- page.find(".build-link").should_not have_content(build2.id)
- page.find(".build-link").should_not have_content(build3.id)
+ expect(page.find(".build-link")).to have_content(build.id)
+ expect(page.find(".build-link")).not_to have_content(build1.id)
+ expect(page.find(".build-link")).not_to have_content(build2.id)
+ expect(page.find(".build-link")).not_to have_content(build3.id)
end
it "shows running builds" do
@@ -62,10 +62,10 @@ describe "Admin Builds" do
click_on "Running"
end
- page.find(".build-link").should have_content(build1.id)
- page.find(".build-link").should_not have_content(build.id)
- page.find(".build-link").should_not have_content(build2.id)
- page.find(".build-link").should_not have_content(build3.id)
+ expect(page.find(".build-link")).to have_content(build1.id)
+ expect(page.find(".build-link")).not_to have_content(build.id)
+ expect(page.find(".build-link")).not_to have_content(build2.id)
+ expect(page.find(".build-link")).not_to have_content(build3.id)
end
end
end
diff --git a/spec/features/admin/events_spec.rb b/spec/features/admin/events_spec.rb
index 469c6ed..2acf965 100644
--- a/spec/features/admin/events_spec.rb
+++ b/spec/features/admin/events_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe "Admin Events" do
+describe "Admin Events", feature: true do
let(:event) { FactoryGirl.create :admin_event }
before do
@@ -14,7 +14,7 @@ describe "Admin Events" do
visit admin_events_path
end
- it { page.should have_content "Events" }
- it { page.should have_content event.description }
+ it { expect(page).to have_content "Events" }
+ it { expect(page).to have_content event.description }
end
end
diff --git a/spec/features/admin/projects_spec.rb b/spec/features/admin/projects_spec.rb
index 6f87e36..6e88ae4 100644
--- a/spec/features/admin/projects_spec.rb
+++ b/spec/features/admin/projects_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe "Admin Projects" do
+describe "Admin Projects", feature: true do
let(:project) { FactoryGirl.create :project }
before do
@@ -14,6 +14,6 @@ describe "Admin Projects" do
visit admin_projects_path
end
- it { page.should have_content "Projects" }
+ it { expect(page).to have_content "Projects" }
end
end
diff --git a/spec/features/admin/runners_spec.rb b/spec/features/admin/runners_spec.rb
index 2827a7f..56f81eb 100644
--- a/spec/features/admin/runners_spec.rb
+++ b/spec/features/admin/runners_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe "Admin Runners" do
+describe "Admin Runners", feature: true do
before do
skip_admin_auth
login_as :user
@@ -27,8 +27,8 @@ describe "Admin Runners" do
click_button 'Search'
end
- it { page.should have_content("foo") }
- it { page.should_not have_content("bar") }
+ it { expect(page).to have_content("foo") }
+ it { expect(page).not_to have_content("bar") }
end
end
@@ -42,12 +42,12 @@ describe "Admin Runners" 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
- it { page.should have_content("foo") }
- it { page.should have_content("bar") }
+ it { expect(page).to have_content("foo") }
+ it { expect(page).to have_content("bar") }
end
describe 'search' do
@@ -56,8 +56,8 @@ describe "Admin Runners" do
click_button 'Search'
end
- it { page.should have_content("foo") }
- it { page.should_not have_content("bar") }
+ it { expect(page).to have_content("foo") }
+ it { expect(page).not_to have_content("bar") }
end
end
end
diff --git a/spec/features/builds_spec.rb b/spec/features/builds_spec.rb
index fcd7996..d342aef 100644
--- a/spec/features/builds_spec.rb
+++ b/spec/features/builds_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe "Builds" do
+describe "Builds", feature: true do
before do
@project = FactoryGirl.create :project
@commit = FactoryGirl.create :commit, project: @project
@@ -13,9 +13,9 @@ describe "Builds" do
visit project_build_path(@project, @build)
end
- it { page.should have_content @commit.sha[0..7] }
- it { page.should have_content @commit.git_commit_message }
- it { page.should have_content @commit.git_author_name }
+ it { expect(page).to have_content @commit.sha[0..7] }
+ it { expect(page).to have_content @commit.git_commit_message }
+ it { expect(page).to have_content @commit.git_author_name }
end
describe "GET /:project/builds/:id/cancel" do
@@ -25,8 +25,8 @@ describe "Builds" do
visit cancel_project_build_path(@project, @build)
end
- it { page.should have_content 'canceled' }
- it { page.should have_content 'Retry' }
+ it { expect(page).to have_content 'canceled' }
+ it { expect(page).to have_content 'Retry' }
end
describe "POST /:project/builds/:id/retry" do
@@ -37,8 +37,8 @@ describe "Builds" do
click_link 'Retry'
end
- it { page.should have_content 'pending' }
- it { page.should have_content 'Cancel' }
+ it { expect(page).to have_content 'pending' }
+ it { expect(page).to have_content 'Cancel' }
end
describe "Show page public accessible" do
@@ -52,6 +52,6 @@ describe "Builds" do
visit project_build_path(@project, @build)
end
- it { page.should have_content @commit.sha[0..7] }
+ it { expect(page).to have_content @commit.sha[0..7] }
end
end
diff --git a/spec/features/commits_spec.rb b/spec/features/commits_spec.rb
index 202f05c..8101dfc 100644
--- a/spec/features/commits_spec.rb
+++ b/spec/features/commits_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe "Commits" do
+describe "Commits", feature: true do
context "Authenticated user" do
before do
login_as :user
@@ -14,9 +14,9 @@ describe "Commits" do
visit project_ref_commit_path(@project, @commit.ref, @commit.sha)
end
- it { page.should have_content @commit.sha[0..7] }
- it { page.should have_content @commit.git_commit_message }
- it { page.should have_content @commit.git_author_name }
+ it { expect(page).to have_content @commit.sha[0..7] }
+ it { expect(page).to have_content @commit.git_commit_message }
+ it { expect(page).to have_content @commit.git_author_name }
end
describe "Cancel commit" do
@@ -24,7 +24,7 @@ describe "Commits" do
visit project_ref_commit_path(@project, @commit.ref, @commit.sha)
click_on "Cancel"
- page.should have_content "canceled"
+ expect(page).to have_content "canceled"
end
end
@@ -32,7 +32,7 @@ describe "Commits" do
it "does not show warning" do
visit project_ref_commit_path(@project, @commit.ref, @commit.sha)
- page.should_not have_content ".gitlab-ci.yml not found in this commit"
+ expect(page).not_to have_content ".gitlab-ci.yml not found in this commit"
end
it "shows warning" do
@@ -41,7 +41,7 @@ describe "Commits" do
visit project_ref_commit_path(@project, @commit.ref, @commit.sha)
- page.should have_content ".gitlab-ci.yml not found in this commit"
+ expect(page).to have_content ".gitlab-ci.yml not found in this commit"
end
end
end
@@ -58,9 +58,9 @@ describe "Commits" do
visit project_ref_commit_path(@project, @commit.ref, @commit.sha)
end
- it { page.should have_content @commit.sha[0..7] }
- it { page.should have_content @commit.git_commit_message }
- it { page.should have_content @commit.git_author_name }
+ it { expect(page).to have_content @commit.sha[0..7] }
+ it { expect(page).to have_content @commit.git_commit_message }
+ it { expect(page).to have_content @commit.git_author_name }
end
end
end
diff --git a/spec/features/events_spec.rb b/spec/features/events_spec.rb
index 77d1fba..eb14cb9 100644
--- a/spec/features/events_spec.rb
+++ b/spec/features/events_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe "Events" do
+describe "Events", feature: true do
let(:project) { FactoryGirl.create :project }
let(:event) { FactoryGirl.create :admin_event, project: project }
@@ -14,7 +14,7 @@ describe "Events" do
visit project_events_path(project)
end
- it { page.should have_content "Events" }
- it { page.should have_content event.description }
+ it { expect(page).to have_content "Events" }
+ it { expect(page).to have_content event.description }
end
end
diff --git a/spec/features/lint_spec.rb b/spec/features/lint_spec.rb
index 0b3d4e0..6848f35 100644
--- a/spec/features/lint_spec.rb
+++ b/spec/features/lint_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe "Lint" do
+describe "Lint", feature: true do
before do
login_as :user
end
@@ -11,10 +11,10 @@ describe "Lint" do
fill_in "content", with: content
click_on "Validate"
within "table" do
- page.should have_content("Job - rspec")
- page.should have_content("Job - spinach")
- page.should have_content("Deploy Job - staging")
- page.should have_content("Deploy Job - production")
+ expect(page).to have_content("Job - rspec")
+ expect(page).to have_content("Job - spinach")
+ expect(page).to have_content("Deploy Job - staging")
+ expect(page).to have_content("Deploy Job - production")
end
end
@@ -22,7 +22,7 @@ describe "Lint" do
visit lint_path
fill_in "content", with: ""
click_on "Validate"
- page.should have_content("Status: syntax is incorrect")
- page.should have_content("Error: Please provide content of .gitlab-ci.yml")
+ expect(page).to have_content("Status: syntax is incorrect")
+ expect(page).to have_content("Error: Please provide content of .gitlab-ci.yml")
end
end
diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb
index 3f21af9..7861e53 100644
--- a/spec/features/projects_spec.rb
+++ b/spec/features/projects_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe "Projects" do
+describe "Projects", feature: true do
before do
login_as :user
@project = FactoryGirl.create :project, name: "GitLab / gitlab-shell"
@@ -12,8 +12,8 @@ describe "Projects" do
visit projects_path
end
- it { page.should have_content "GitLab / gitlab-shell" }
- it { page.should have_selector ".search input#search" }
+ it { expect(page).to have_content "GitLab / gitlab-shell" }
+ it { expect(page).to have_selector ".search input#search" }
end
describe "GET /projects/:id" do
@@ -21,8 +21,8 @@ describe "Projects" do
visit project_path(@project)
end
- it { page.should have_content @project.name }
- it { page.should have_content 'All commits' }
+ it { expect(page).to have_content @project.name }
+ it { expect(page).to have_content 'All commits' }
end
describe "GET /projects/:id/edit" do
@@ -30,16 +30,16 @@ describe "Projects" do
visit edit_project_path(@project)
end
- it { page.should have_content @project.name }
- it { page.should have_content 'Build Schedule' }
+ it { expect(page).to have_content @project.name }
+ it { expect(page).to have_content 'Build Schedule' }
it "updates configuration" do
fill_in 'Timeout', with: '70'
click_button 'Save changes'
- page.should have_content 'was successfully updated'
+ 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
@@ -48,10 +48,10 @@ describe "Projects" do
visit project_charts_path(@project)
end
- it { page.should have_content 'Overall' }
- it { page.should have_content 'Builds chart for last week' }
- it { page.should have_content 'Builds chart for last month' }
- it { page.should have_content 'Builds chart for last year' }
- it { page.should have_content 'Commit duration in minutes for last 30 commits' }
+ it { expect(page).to have_content 'Overall' }
+ it { expect(page).to have_content 'Builds chart for last week' }
+ it { expect(page).to have_content 'Builds chart for last month' }
+ it { expect(page).to have_content 'Builds chart for last year' }
+ it { expect(page).to have_content 'Commit duration in minutes for last 30 commits' }
end
end
diff --git a/spec/features/runners_spec.rb b/spec/features/runners_spec.rb
index c41dc5b..05fb7e0 100644
--- a/spec/features/runners_spec.rb
+++ b/spec/features/runners_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe "Runners" do
+describe "Runners", feature: true do
before do
login_as :user
end
@@ -12,7 +12,7 @@ describe "Runners" do
stub_js_gitlab_calls
# all projects should be authorized for user
- Network.any_instance.stub(:projects).and_return([
+ allow_any_instance_of(Network).to receive(:projects).and_return([
OpenStruct.new({id: @project.gitlab_id}),
OpenStruct.new({id: @project2.gitlab_id})
])
@@ -26,9 +26,9 @@ describe "Runners" do
it "places runners in right places" do
visit project_runners_path(@project)
- page.find(".available-specific-runners").should have_content(@specific_runner2.display_name)
- page.find(".activated-specific-runners").should have_content(@specific_runner.display_name)
- page.find(".available-shared-runners").should have_content(@shared_runner.display_name)
+ expect(page.find(".available-specific-runners")).to have_content(@specific_runner2.display_name)
+ expect(page.find(".activated-specific-runners")).to have_content(@specific_runner.display_name)
+ expect(page.find(".available-shared-runners")).to have_content(@shared_runner.display_name)
end
it "enables specific runner for project" do
@@ -38,7 +38,7 @@ describe "Runners" do
click_on "Enable for this project"
end
- page.find(".activated-specific-runners").should have_content(@specific_runner2.display_name)
+ expect(page.find(".activated-specific-runners")).to have_content(@specific_runner2.display_name)
end
it "disables specific runner for project" do
@@ -50,7 +50,7 @@ describe "Runners" do
click_on "Disable for this project"
end
- page.find(".available-specific-runners").should have_content(@specific_runner.display_name)
+ expect(page.find(".available-specific-runners")).to have_content(@specific_runner.display_name)
end
it "removes specific runner for project if this is last project for that runners" do
@@ -60,7 +60,7 @@ describe "Runners" do
click_on "Remove runner"
end
- Runner.exists?(id: @specific_runner).should be_false
+ expect(Runner.exists?(id: @specific_runner)).to be_falsey
end
end
@@ -75,7 +75,7 @@ describe "Runners" do
click_on "Enable shared runners"
- @project.reload.shared_runners_enabled.should be_true
+ expect(@project.reload.shared_runners_enabled).to be_truthy
end
end
@@ -92,7 +92,7 @@ describe "Runners" do
click_on @specific_runner.short_sha
- page.should have_content(@specific_runner.platform)
+ expect(page).to have_content(@specific_runner.platform)
end
end
end
diff --git a/spec/features/triggers_spec.rb b/spec/features/triggers_spec.rb
index 2076429..b8f4616 100644
--- a/spec/features/triggers_spec.rb
+++ b/spec/features/triggers_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe 'Variables' do
+describe 'Variables', feature: true do
before do
login_as :user
@project = FactoryGirl.create :project
@@ -11,16 +11,16 @@ describe 'Variables' do
context 'create a trigger' do
before do
click_on 'Add Trigger'
- @project.triggers.count.should == 1
+ expect(@project.triggers.count).to eq 1
end
it 'contains trigger token' do
- page.should have_content(@project.triggers.first.token)
+ expect(page).to have_content(@project.triggers.first.token)
end
it 'revokes the trigger' do
click_on 'Revoke'
- @project.triggers.count.should == 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 2bb0d9d..9cf3632 100644
--- a/spec/features/variables_spec.rb
+++ b/spec/features/variables_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-describe "Variables" do
+describe "Variables", feature: true do
before do
login_as :user
end
@@ -18,8 +18,8 @@ describe "Variables" do
fill_in "Value", with: "SECRET_VALUE"
click_on "Save changes"
- page.should have_content("Variables were successfully updated.")
- @project.variables.count.should == 1
+ expect(page).to have_content("Variables were successfully updated.")
+ 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 c2b1058..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 == 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 == "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 == 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 8687820..e6e6ab4 100644
--- a/spec/helpers/user_helper_spec.rb
+++ b/spec/helpers/user_helper_spec.rb
@@ -1,14 +1,14 @@
require 'spec_helper'
describe UserHelper do
- describe :user_avatar_url do
+ describe 'user_avatar_url' do
let (:user) { User.new({'avatar_url' => avatar_url}) }
context 'no avatar' do
let (:avatar_url) { nil }
it 'should return a generic avatar' do
- user_avatar_url(user).should == '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 == "#{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 == "#{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 == "#{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 == "#{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 == 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 a2ab1f1..553e90c 100644
--- a/spec/helpers/user_sessions_helper_spec.rb
+++ b/spec/helpers/user_sessions_helper_spec.rb
@@ -1,50 +1,50 @@
require 'spec_helper'
describe UserSessionsHelper do
- describe :generate_oauth_hmac do
+ describe 'generate_oauth_hmac' do
let (:salt) { 'a' }
let (:salt2) { 'b' }
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
- describe :generate_oauth_state do
+ describe 'generate_oauth_state' 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
- describe :get_ouath_state_return_to do
+ describe 'get_ouath_state_return_to' do
let (:return_to) { 'a' }
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
- describe :is_oauth_state_valid? do
+ describe 'is_oauth_state_valid?' do
let (:return_to) { 'a' }
let (:state) { generate_oauth_state(return_to) }
let (:forged) { "forged#{state}" }
@@ -53,17 +53,17 @@ describe UserSessionsHelper do
let (:invalid3) { 'aa:bb:' }
it 'should validate oauth state' do
- is_oauth_state_valid?(state).should be_true
+ expect(is_oauth_state_valid?(state)).to be_truthy
end
it 'should not validate forged state' do
- is_oauth_state_valid?(forged).should be_false
+ expect(is_oauth_state_valid?(forged)).to be_falsey
end
it 'should not validate invalid state' do
- is_oauth_state_valid?(invalid).should be_false
- is_oauth_state_valid?(invalid2).should be_false
- is_oauth_state_valid?(invalid3).should be_false
+ 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 aa60011..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
- Ansi2html::convert("Hello").should == 'Hello'
+ expect(described_class::convert("Hello")).to eq 'Hello'
end
it "strips non-color-changing controll sequences" do
- Ansi2html::convert("Hello \e[2Kworld").should == 'Hello world'
+ expect(described_class::convert("Hello \e[2Kworld")).to eq 'Hello world'
end
it "prints simply red" do
- Ansi2html::convert("\e[31mHello\e[0m").should == '<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
- Ansi2html::convert("\e[31mHello").should == '<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
- Ansi2html::convert("\e[33mHello\e[0m").should == '<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
- Ansi2html::convert("\e[39;44mHello").should == '<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
- Ansi2html::convert("\e[31;44mHello").should == '<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
- Ansi2html::convert("\e[31;44mHello\e[0m world").should == '<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
- Ansi2html::convert("\e[31;44mHello \e[33mworld").should == '<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
- Ansi2html::convert("\e[31;44mHello \e[33;42mworld").should == '<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
- Ansi2html::convert("\e[31;44mHello\e[0m \e[33;42mworld").should == '<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
- Ansi2html::convert("\e[51mHello\e[0m").should == 'Hello'
+ expect(described_class::convert("\e[51mHello\e[0m")).to eq 'Hello'
end
it "prints light red" do
- Ansi2html::convert("\e[91mHello\e[0m").should == '<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
- Ansi2html::convert("\e[101mHello\e[0m").should == '<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
- Ansi2html::convert("\e[31;44mHello \e[39mworld").should == '<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
- Ansi2html::convert("\e[91;44mHello \e[39mworld").should == '<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
- Ansi2html::convert("\e[1mHello").should == '<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
- Ansi2html::convert("\e[1mHello\e[21m world").should == '<span class="term-bold">Hello</span> world'
- Ansi2html::convert("\e[1mHello\e[22m world").should == '<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
- Ansi2html::convert("\e[3mHello").should == '<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
- Ansi2html::convert("\e[3mHello\e[23m world").should == '<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
- Ansi2html::convert("\e[4mHello").should == '<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
- Ansi2html::convert("\e[4mHello\e[24m world").should == '<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
- Ansi2html::convert("\e[8mHello").should == '<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
- Ansi2html::convert("\e[8mHello\e[28m world").should == '<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
- Ansi2html::convert("\e[9mHello").should == '<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
- Ansi2html::convert("\e[9mHello\e[29m world").should == '<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
- Ansi2html::convert("\e[38;5;16mHello").should == '<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
- Ansi2html::convert("\e[38;5;16;45mHello").should == '<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
- Ansi2html::convert("\e[48;5;240mHello").should == '<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
- Ansi2html::convert("\e[48;5;16;35mHello").should == '<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
- Ansi2html::convert("\e[1;31mHello\e[0m").should == '<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
- Ansi2html::convert("\e[1;91mHello\e[0m").should == '<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 236cfc2..2f27723 100644
--- a/spec/lib/charts_spec.rb
+++ b/spec/lib/charts_spec.rb
@@ -1,17 +1,14 @@
require 'spec_helper'
-describe "Charts" do
-
- context "build_times" do
- before do
- @project = FactoryGirl.create(:project)
- @commit = FactoryGirl.create(:commit, project: @project)
- FactoryGirl.create(:build, commit: @commit)
- end
+describe Charts::BuildTime do
+ before do
+ @project = FactoryGirl.create(:project)
+ @commit = FactoryGirl.create(:commit, project: @project)
+ FactoryGirl.create(:build, commit: @commit)
+ end
- it 'should return build times in minutes' do
- chart = Charts::BuildTime.new(@project)
- chart.build_times.should == [2]
- end
+ it 'should return build times in minutes' do
+ chart = described_class.new(@project)
+ 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 ed3d4e8..127b8be 100644
--- a/spec/lib/gitlab_ci_yaml_processor_spec.rb
+++ b/spec/lib/gitlab_ci_yaml_processor_spec.rb
@@ -11,10 +11,10 @@ describe GitlabCiYamlProcessor do
rspec: {script: "rspec"}
})
- config_processor = GitlabCiYamlProcessor.new(config)
+ config_processor = described_class.new(config)
- config_processor.builds_for_stage_and_ref(type, "master").size.should == 1
- config_processor.builds_for_stage_and_ref(type, "master").first.should == {
+ 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,
@@ -23,7 +23,7 @@ describe GitlabCiYamlProcessor do
tags: [],
options: {},
allow_failure: false
- }
+ })
end
it "does not return builds if only has another branch" do
@@ -32,9 +32,9 @@ describe GitlabCiYamlProcessor do
rspec: {script: "rspec", only: ["deploy"]}
})
- config_processor = GitlabCiYamlProcessor.new(config)
+ config_processor = described_class.new(config)
- config_processor.builds_for_stage_and_ref(type, "master").size.should == 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
@@ -43,9 +43,9 @@ describe GitlabCiYamlProcessor do
rspec: {script: "rspec", only: ["/^deploy$/"]}
})
- config_processor = GitlabCiYamlProcessor.new(config)
+ config_processor = described_class.new(config)
- config_processor.builds_for_stage_and_ref(type, "master").size.should == 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
@@ -54,9 +54,9 @@ describe GitlabCiYamlProcessor do
rspec: {script: "rspec", only: ["master"]}
})
- config_processor = GitlabCiYamlProcessor.new(config)
+ config_processor = described_class.new(config)
- config_processor.builds_for_stage_and_ref(type, "master").size.should == 1
+ expect(config_processor.builds_for_stage_and_ref(type, "master").size).to eq 1
end
it "does not build tags" do
@@ -65,9 +65,9 @@ describe GitlabCiYamlProcessor do
rspec: {script: "rspec", except: ["tags"]}
})
- config_processor = GitlabCiYamlProcessor.new(config)
+ config_processor = described_class.new(config)
- config_processor.builds_for_stage_and_ref(type, "0-1", true).size.should == 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
@@ -76,9 +76,9 @@ describe GitlabCiYamlProcessor do
rspec: {script: "rspec", type: type, only: ["master", "deploy"]}
})
- config_processor = GitlabCiYamlProcessor.new(config)
+ config_processor = described_class.new(config)
- config_processor.builds_for_stage_and_ref(type, "deploy").size.should == 1
+ expect(config_processor.builds_for_stage_and_ref(type, "deploy").size).to eq 1
end
it "returns build only for specified type" do
@@ -91,11 +91,11 @@ describe GitlabCiYamlProcessor do
production: {script: "deploy", type: "deploy", only: ["master", "deploy"]},
})
- config_processor = GitlabCiYamlProcessor.new(config)
+ config_processor = described_class.new(config)
- config_processor.builds_for_stage_and_ref("production", "deploy").size.should == 0
- config_processor.builds_for_stage_and_ref(type, "deploy").size.should == 1
- config_processor.builds_for_stage_and_ref("deploy", "deploy").size.should == 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
@@ -108,10 +108,10 @@ describe GitlabCiYamlProcessor do
rspec: {script: "rspec"}
})
- config_processor = GitlabCiYamlProcessor.new(config)
+ config_processor = described_class.new(config)
- config_processor.builds_for_stage_and_ref("test", "master").size.should == 1
- config_processor.builds_for_stage_and_ref("test", "master").first.should == {
+ 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,
@@ -123,7 +123,7 @@ describe GitlabCiYamlProcessor do
services: ["mysql"]
},
allow_failure: false
- }
+ })
end
it "returns image and service when overridden for job" do
@@ -134,10 +134,10 @@ describe GitlabCiYamlProcessor do
rspec: {image: "ruby:2.5", services: ["postgresql"], script: "rspec"}
})
- config_processor = GitlabCiYamlProcessor.new(config)
+ config_processor = described_class.new(config)
- config_processor.builds_for_stage_and_ref("test", "master").size.should == 1
- config_processor.builds_for_stage_and_ref("test", "master").first.should == {
+ 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,
@@ -149,7 +149,7 @@ describe GitlabCiYamlProcessor do
services: ["postgresql"]
},
allow_failure: false
- }
+ })
end
end
@@ -165,147 +165,147 @@ describe GitlabCiYamlProcessor do
rspec: {script: "rspec"}
})
- config_processor = GitlabCiYamlProcessor.new(config)
- config_processor.variables.should == variables
+ config_processor = described_class.new(config)
+ expect(config_processor.variables).to eq variables
end
end
describe "Error handling" do
it "indicates that object is invalid" do
- expect{GitlabCiYamlProcessor.new("invalid_yaml\n!ccdvlf%612334@@@@")}.to raise_error(GitlabCiYamlProcessor::ValidationError)
+ expect{described_class.new("invalid_yaml\n!ccdvlf%612334@@@@")}.to raise_error(described_class::ValidationError)
end
it "returns errors if tags parameter is invalid" do
config = YAML.dump({rspec: {script: "test", tags: "mysql"}})
expect do
- GitlabCiYamlProcessor.new(config)
- end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: tags parameter should be an array of strings")
+ described_class.new(config)
+ end.to raise_error(described_class::ValidationError, "rspec job: tags parameter should be an array of strings")
end
it "returns errors if before_script parameter is invalid" do
config = YAML.dump({before_script: "bundle update", rspec: {script: "test"}})
expect do
- GitlabCiYamlProcessor.new(config)
- end.to raise_error(GitlabCiYamlProcessor::ValidationError, "before_script should be an array of strings")
+ described_class.new(config)
+ end.to raise_error(described_class::ValidationError, "before_script should be an array of strings")
end
it "returns errors if image parameter is invalid" do
config = YAML.dump({image: ["test"], rspec: {script: "test"}})
expect do
- GitlabCiYamlProcessor.new(config)
- end.to raise_error(GitlabCiYamlProcessor::ValidationError, "image should be a string")
+ described_class.new(config)
+ end.to raise_error(described_class::ValidationError, "image should be a string")
end
it "returns errors if job image parameter is invalid" do
config = YAML.dump({rspec: {script: "test", image: ["test"]}})
expect do
- GitlabCiYamlProcessor.new(config)
- end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: image should be a string")
+ described_class.new(config)
+ end.to raise_error(described_class::ValidationError, "rspec job: image should be a string")
end
it "returns errors if services parameter is not an array" do
config = YAML.dump({services: "test", rspec: {script: "test"}})
expect do
- GitlabCiYamlProcessor.new(config)
- end.to raise_error(GitlabCiYamlProcessor::ValidationError, "services should be an array of strings")
+ described_class.new(config)
+ end.to raise_error(described_class::ValidationError, "services should be an array of strings")
end
it "returns errors if services parameter is not an array of strings" do
config = YAML.dump({services: [10, "test"], rspec: {script: "test"}})
expect do
- GitlabCiYamlProcessor.new(config)
- end.to raise_error(GitlabCiYamlProcessor::ValidationError, "services should be an array of strings")
+ described_class.new(config)
+ end.to raise_error(described_class::ValidationError, "services should be an array of strings")
end
it "returns errors if job services parameter is not an array" do
config = YAML.dump({rspec: {script: "test", services: "test"}})
expect do
- GitlabCiYamlProcessor.new(config)
- end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: services should be an array of strings")
+ described_class.new(config)
+ end.to raise_error(described_class::ValidationError, "rspec job: services should be an array of strings")
end
it "returns errors if job services parameter is not an array of strings" do
config = YAML.dump({rspec: {script: "test", services: [10, "test"]}})
expect do
- GitlabCiYamlProcessor.new(config)
- end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: services should be an array of strings")
+ described_class.new(config)
+ end.to raise_error(described_class::ValidationError, "rspec job: services should be an array of strings")
end
it "returns errors if there are unknown parameters" do
config = YAML.dump({extra: "bundle update"})
expect do
- GitlabCiYamlProcessor.new(config)
- end.to raise_error(GitlabCiYamlProcessor::ValidationError, "Unknown parameter: extra")
+ described_class.new(config)
+ end.to raise_error(described_class::ValidationError, "Unknown parameter: extra")
end
it "returns errors if there are unknown parameters that are hashes, but doesn't have a script" do
config = YAML.dump({extra: {services: "test"}})
expect do
- GitlabCiYamlProcessor.new(config)
- end.to raise_error(GitlabCiYamlProcessor::ValidationError, "Unknown parameter: extra")
+ described_class.new(config)
+ end.to raise_error(described_class::ValidationError, "Unknown parameter: extra")
end
it "returns errors if there is no any jobs defined" do
config = YAML.dump({before_script: ["bundle update"]})
expect do
- GitlabCiYamlProcessor.new(config)
- end.to raise_error(GitlabCiYamlProcessor::ValidationError, "Please define at least one job")
+ described_class.new(config)
+ end.to raise_error(described_class::ValidationError, "Please define at least one job")
end
it "returns errors if job allow_failure parameter is not an boolean" do
config = YAML.dump({rspec: {script: "test", allow_failure: "string"}})
expect do
- GitlabCiYamlProcessor.new(config)
- end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: allow_failure parameter should be an boolean")
+ described_class.new(config)
+ end.to raise_error(described_class::ValidationError, "rspec job: allow_failure parameter should be an boolean")
end
it "returns errors if job stage is not a string" do
config = YAML.dump({rspec: {script: "test", type: 1, allow_failure: "string"}})
expect do
- GitlabCiYamlProcessor.new(config)
- end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: stage parameter should be build, test, deploy")
+ described_class.new(config)
+ end.to raise_error(described_class::ValidationError, "rspec job: stage parameter should be build, test, deploy")
end
it "returns errors if job stage is not a pre-defined stage" do
config = YAML.dump({rspec: {script: "test", type: "acceptance", allow_failure: "string"}})
expect do
- GitlabCiYamlProcessor.new(config)
- end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: stage parameter should be build, test, deploy")
+ described_class.new(config)
+ end.to raise_error(described_class::ValidationError, "rspec job: stage parameter should be build, test, deploy")
end
it "returns errors if job stage is not a defined stage" do
config = YAML.dump({types: ["build", "test"], rspec: {script: "test", type: "acceptance", allow_failure: "string"}})
expect do
- GitlabCiYamlProcessor.new(config)
- end.to raise_error(GitlabCiYamlProcessor::ValidationError, "rspec job: stage parameter should be build, test")
+ described_class.new(config)
+ end.to raise_error(described_class::ValidationError, "rspec job: stage parameter should be build, test")
end
it "returns errors if stages is not an array" do
config = YAML.dump({types: "test", rspec: {script: "test"}})
expect do
- GitlabCiYamlProcessor.new(config)
- end.to raise_error(GitlabCiYamlProcessor::ValidationError, "stages should be an array of strings")
+ described_class.new(config)
+ end.to raise_error(described_class::ValidationError, "stages should be an array of strings")
end
it "returns errors if stages is not an array of strings" do
config = YAML.dump({types: [true, "test"], rspec: {script: "test"}})
expect do
- GitlabCiYamlProcessor.new(config)
- end.to raise_error(GitlabCiYamlProcessor::ValidationError, "stages should be an array of strings")
+ described_class.new(config)
+ end.to raise_error(described_class::ValidationError, "stages should be an array of strings")
end
it "returns errors if variables is not a map" do
config = YAML.dump({variables: "test", rspec: {script: "test"}})
expect do
- GitlabCiYamlProcessor.new(config)
- end.to raise_error(GitlabCiYamlProcessor::ValidationError, "variables should be a map of key-valued strings")
+ described_class.new(config)
+ end.to raise_error(described_class::ValidationError, "variables should be a map of key-valued strings")
end
it "returns errors if variables is not a map of key-valued strings" do
config = YAML.dump({variables: {test: false}, rspec: {script: "test"}})
expect do
- GitlabCiYamlProcessor.new(config)
- end.to raise_error(GitlabCiYamlProcessor::ValidationError, "variables should be a map of key-valued strings")
+ described_class.new(config)
+ end.to raise_error(described_class::ValidationError, "variables should be a map of key-valued strings")
end
end
end
diff --git a/spec/lib/upgrader_spec.rb b/spec/lib/upgrader_spec.rb
index 40a9830..64f6f95 100644
--- a/spec/lib/upgrader_spec.rb
+++ b/spec/lib/upgrader_spec.rb
@@ -1,17 +1,17 @@
require 'spec_helper'
describe Upgrader do
- let(:upgrader) { Upgrader.new }
+ let(:upgrader) { described_class.new }
let(:current_version) { GitlabCi::VERSION }
describe 'current_version_raw' do
- it { upgrader.current_version_raw.should == 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
- upgrader.stub(latest_version_raw: current_version)
- upgrader.latest_version?.should be_true
+ allow(upgrader).to receive_messages(latest_version_raw: current_version)
+ expect(upgrader.latest_version?).to be_truthy
end
end
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb
index 6a2c845..efb202f 100644
--- a/spec/mailers/notify_spec.rb
+++ b/spec/mailers/notify_spec.rb
@@ -11,26 +11,26 @@ describe Notify do
end
describe 'build success' do
- subject { Notify.build_success_email(@build.id, 'wow@example.com') }
+ 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
describe 'build fail' do
- subject { Notify.build_fail_email(@build.id, 'wow@example.com') }
+ 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 7333981..cb080d2 100644
--- a/spec/models/build_spec.rb
+++ b/spec/models/build_spec.rb
@@ -30,26 +30,26 @@ 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
+ describe '.first_pending' do
let(:first) { FactoryGirl.create :build, commit: commit, status: 'pending', created_at: Date.yesterday }
let(:second) { FactoryGirl.create :build, commit: commit, status: 'pending' }
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
+ describe '.create_from' do
before do
build.status = 'success'
build.save
@@ -63,20 +63,20 @@ describe Build do
end
end
- describe :started? do
+ describe '#started?' do
subject { build.started? }
context 'without started_at' do
before { build.started_at = nil }
- it { should be_false }
+ 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_true }
+ it { is_expected.to be_truthy }
end
end
@@ -84,19 +84,19 @@ describe Build do
context "if build status is #{status}" do
before { build.status = status }
- it { should be_false }
+ it { is_expected.to be_falsey }
end
end
end
- describe :active? do
+ describe '#active?' do
subject { build.active? }
%w(pending running).each do |state|
context "if build.status is #{state}" do
before { build.status = state }
- it { should be_true }
+ it { is_expected.to be_truthy }
end
end
@@ -104,19 +104,19 @@ describe Build do
context "if build.status is #{state}" do
before { build.status = state }
- it { should be_false }
+ it { is_expected.to be_falsey }
end
end
end
- describe :complete? do
+ describe '#complete?' do
subject { build.complete? }
%w(success failed canceled).each do |state|
context "if build.status is #{state}" do
before { build.status = state }
- it { should be_true }
+ it { is_expected.to be_truthy }
end
end
@@ -124,12 +124,12 @@ describe Build do
context "if build.status is #{state}" do
before { build.status = state }
- it { should be_false }
+ it { is_expected.to be_falsey }
end
end
end
- describe :ignored? do
+ describe '#ignored?' do
subject { build.ignored? }
context 'if build is not allowed to fail' do
@@ -138,13 +138,13 @@ describe Build do
context 'and build.status is success' do
before { build.status = 'success' }
- it { should be_false }
+ it { is_expected.to be_falsey }
end
context 'and build.status is failed' do
before { build.status = 'failed' }
- it { should be_false }
+ it { is_expected.to be_falsey }
end
end
@@ -154,41 +154,41 @@ describe Build do
context 'and build.status is success' do
before { build.status = 'success' }
- it { should be_false }
+ it { is_expected.to be_falsey }
end
context 'and build.status is failed' do
before { build.status = 'failed' }
- it { should be_true }
+ it { is_expected.to be_truthy }
end
end
end
- describe :trace 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 { should have_at_least(text.length).items }
+ it { is_expected.to include(text) }
+ it { expect(subject.length).to be >= text.length }
end
end
- describe :timeout 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
+ 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,12 +205,12 @@ 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
- describe :options do
+ describe '#options' do
let(:options) {
{
:image => "ruby:2.1",
@@ -221,90 +221,90 @@ describe Build do
}
subject { build.options }
- it { should eq(options) }
+ it { is_expected.to eq(options) }
end
- describe :ref do
+ describe '#ref' do
subject { build.ref }
- it { should eq(commit.ref) }
+ it { is_expected.to eq(commit.ref) }
end
- describe :sha do
+ describe '#sha' do
subject { build.sha }
- it { should eq(commit.sha) }
+ it { is_expected.to eq(commit.sha) }
end
- describe :short_sha do
+ 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
+ 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
+ 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
+ describe '#project' do
subject { build.project }
- it { should eq(commit.project) }
+ it { is_expected.to eq(commit.project) }
end
- describe :project_id do
+ 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
+ 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
+ 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
+ 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
- describe :variables do
+ describe '#variables' do
context 'returns variables' do
subject { build.variables }
@@ -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 6f644d2..24b6520 100644
--- a/spec/models/commit_spec.rb
+++ b/spec/models/commit_spec.rb
@@ -23,29 +23,29 @@ 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 { should respond_to :git_author_name }
- it { should respond_to :git_author_email }
- it { should respond_to :short_sha }
-
- describe :last_build do
+ 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 { 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 }
before do
@first = FactoryGirl.create :build, commit: commit, created_at: Date.yesterday
@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
+ describe '#retry' do
before do
@first = FactoryGirl.create :build, commit: commit, created_at: Date.yesterday
@second = FactoryGirl.create :build, commit: commit
@@ -58,7 +58,7 @@ describe Commit do
end
end
- describe :project_recipients do
+ describe '#project_recipients' do
context 'always sending notification' do
it 'should return commit_pusher_email as only recipient when no additional recipients are given' do
@@ -67,8 +67,8 @@ describe Commit do
email_recipients: ''
commit = FactoryGirl.create :commit, project: project
expected = 'commit_pusher_email'
- commit.stub(:push_data) { { user_email: expected } }
- commit.project_recipients.should == [expected]
+ allow(commit).to receive(:push_data) { { user_email: expected } }
+ expect(commit.project_recipients).to eq [expected]
end
it 'should return commit_pusher_email and additional recipients' do
@@ -77,8 +77,8 @@ describe Commit do
email_recipients: 'rec1 rec2'
commit = FactoryGirl.create :commit, project: project
expected = 'commit_pusher_email'
- commit.stub(:push_data) { { user_email: expected } }
- commit.project_recipients.should == ['rec1', 'rec2', expected]
+ allow(commit).to receive(:push_data) { { user_email: 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 == ['rec1', 'rec2']
+ expect(commit.project_recipients).to eq ['rec1', 'rec2']
end
it 'should return unique recipients only' do
@@ -95,76 +95,76 @@ describe Commit do
email_recipients: 'rec1 rec1 rec2'
commit = FactoryGirl.create :commit, project: project
expected = 'rec2'
- commit.stub(:push_data) { { user_email: expected } }
- commit.project_recipients.should == ['rec1', 'rec2']
+ allow(commit).to receive(:push_data) { { user_email: expected } }
+ expect(commit.project_recipients).to eq ['rec1', 'rec2']
end
end
end
- describe :valid_commit_sha do
+ describe '#valid_commit_sha' do
context 'commit.sha can not start with 00000000' do
before do
commit.sha = '0' * 40
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
- describe :compare? do
+ describe '#compare?' do
subject { commit_with_project.compare? }
context 'if commit.before_sha are not nil' do
- it { should be_true }
+ it { is_expected.to be_truthy }
end
end
- describe :short_sha do
+ describe '#short_before_sha' do
subject { commit.short_before_sha }
- it { should have(8).items }
- it { commit.before_sha.should start_with(subject) }
+ it { expect(subject.length).to eq 8 }
+ it { expect(commit.before_sha).to start_with(subject) }
end
- describe :short_sha do
+ describe '#short_sha' do
subject { commit.short_sha }
- it { should have(8).items }
- it { commit.sha.should start_with(subject) }
+ it { expect(subject.length).to eq 8 }
+ it { expect(commit.sha).to start_with(subject) }
end
- describe :create_next_builds do
+ describe '#create_next_builds' do
before do
- commit.stub(:config_processor).and_return(config_processor)
+ allow(commit).to receive(:config_processor).and_return(config_processor)
end
it "creates builds for next type" do
- commit.create_builds.should be_true
+ expect(commit.create_builds).to be_truthy
commit.builds.reload
- commit.builds.size.should == 2
+ expect(commit.builds.size).to eq 2
- commit.create_next_builds(nil).should be_true
+ expect(commit.create_next_builds(nil)).to be_truthy
commit.builds.reload
- commit.builds.size.should == 4
+ expect(commit.builds.size).to eq 4
- commit.create_next_builds(nil).should be_true
+ expect(commit.create_next_builds(nil)).to be_truthy
commit.builds.reload
- commit.builds.size.should == 5
+ expect(commit.builds.size).to eq 5
- commit.create_next_builds(nil).should be_false
+ expect(commit.create_next_builds(nil)).to be_falsey
end
end
- describe :create_builds do
+ describe '#create_builds' do
before do
- commit.stub(:config_processor).and_return(config_processor)
+ allow(commit).to receive(:config_processor).and_return(config_processor)
end
it 'creates builds' do
- commit.create_builds.should be_true
+ expect(commit.create_builds).to be_truthy
commit.builds.reload
- commit.builds.size.should == 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_true
+ expect(commit.create_builds(trigger_request)).to be_truthy
commit.builds.reload
- commit.builds.size.should == 2
+ expect(commit.builds.size).to eq 2
end
it 'rebuilds commit' do
- commit.create_builds.should be_true
+ expect(commit.create_builds).to be_truthy
commit.builds.reload
- commit.builds.size.should == 2
+ expect(commit.builds.size).to eq 2
- commit.create_builds(trigger_request).should be_true
+ expect(commit.create_builds(trigger_request)).to be_truthy
commit.builds.reload
- commit.builds.size.should == 4
+ expect(commit.builds.size).to eq 4
end
it 'creates next builds' do
- commit.create_builds(trigger_request).should be_true
+ expect(commit.create_builds(trigger_request)).to be_truthy
commit.builds.reload
- commit.builds.size.should == 2
+ expect(commit.builds.size).to eq 2
- commit.create_next_builds(trigger_request).should be_true
+ expect(commit.create_next_builds(trigger_request)).to be_truthy
commit.builds.reload
- commit.builds.size.should == 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 == 'skipped'
- commit.create_builds(trigger_request).should be_true
+ expect(commit.status).to eq 'skipped'
+ expect(commit.create_builds(trigger_request)).to be_truthy
commit.builds.reload
- commit.builds.size.should == 2
- commit.status.should == '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 == 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 == "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 == "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 == "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 d66a659..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
@@ -28,7 +28,7 @@ describe MailService do
end
describe 'Sends email for' do
- let(:mail) { MailService.new }
+ let(:mail) { described_class.new }
describe 'failed build' do
let(:project) { FactoryGirl.create(:project, email_add_pusher: true) }
@@ -36,9 +36,7 @@ describe MailService do
let(:build) { FactoryGirl.create(:build, status: :failed, commit: commit) }
before do
- mail.stub(
- project: project
- )
+ allow(mail).to receive_messages(project: project)
end
it do
@@ -47,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
@@ -58,9 +56,7 @@ describe MailService do
let(:build) { FactoryGirl.create(:build, status: :success, commit: commit) }
before do
- mail.stub(
- project: project
- )
+ allow(mail).to receive_messages(project: project)
end
it do
@@ -69,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
@@ -85,9 +81,7 @@ describe MailService do
let(:build) { FactoryGirl.create(:build, status: :success, commit: commit) }
before do
- mail.stub(
- project: project
- )
+ allow(mail).to receive_messages(project: project)
end
it do
@@ -97,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
@@ -113,9 +107,7 @@ describe MailService do
let(:build) { FactoryGirl.create(:build, status: :success, commit: commit) }
before do
- mail.stub(
- project: project
- )
+ allow(mail).to receive_messages(project: project)
end
it do
@@ -125,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
@@ -141,14 +133,12 @@ describe MailService do
let(:build) { FactoryGirl.create(:build, status: :success, commit: commit) }
before do
- mail.stub(
- project: project
- )
+ allow(mail).to receive_messages(project: project)
build
end
it do
- mail.can_test?.should == true
+ expect(mail.can_test?).to eq true
end
end
@@ -163,9 +153,7 @@ describe MailService do
let(:build) { FactoryGirl.create(:build, status: :failed, commit: commit) }
before do
- mail.stub(
- project: project
- )
+ allow(mail).to receive_messages(project: project)
end
it do
@@ -176,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 b80adba..9c40e32 100644
--- a/spec/models/network_spec.rb
+++ b/spec/models/network_spec.rb
@@ -1,54 +1,54 @@
require 'spec_helper'
describe Network do
- let(:network) { Network.new }
+ let(:network) { described_class.new }
- describe :enable_ci do
+ describe '#enable_ci' do
subject { network.enable_ci '', '', '' }
context 'on success' do
before do
response = double
- response.stub(:code) { 200 }
- network.class.stub(:put) { response }
+ allow(response).to receive(:code) { 200 }
+ allow(network.class).to receive(:put) { response }
end
- it { should be_true }
+ it { is_expected.to be_truthy }
end
context 'on failure' do
before do
response = double
- response.stub(:code) { 404 }
- network.class.stub(:put) { response }
+ allow(response).to receive(:code) { 404 }
+ allow(network.class).to receive(:put) { response }
end
- it { should be_nil }
+ it { is_expected.to be_nil }
end
end
- describe :disable_ci do
+ describe '#disable_ci' do
let(:response) { double }
subject { network.disable_ci '', '' }
context 'on success' do
let(:parsed_response) { 'parsed' }
before do
- response.stub(:code) { 200 }
- response.stub(:parsed_response) { parsed_response }
- network.class.stub(:delete) { response }
+ allow(response).to receive(:code) { 200 }
+ allow(response).to receive(:parsed_response) { parsed_response }
+ allow(network.class).to receive(:delete) { response }
end
- it { should equal(parsed_response) }
+ it { is_expected.to equal(parsed_response) }
end
context 'on failure' do
before do
- response.stub(:code) { 404 }
- network.class.stub(:delete) { response }
+ allow(response).to receive(:code) { 404 }
+ allow(network.class).to receive(:delete) { response }
end
- it { should be_nil }
+ it { is_expected.to be_nil }
end
end
end
diff --git a/spec/models/project_services/hip_chat_message_spec.rb b/spec/models/project_services/hip_chat_message_spec.rb
index f1ad875..db088c7 100644
--- a/spec/models/project_services/hip_chat_message_spec.rb
+++ b/spec/models/project_services/hip_chat_message_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
describe HipChatMessage do
- subject { HipChatMessage.new(build) }
+ subject { described_class.new(build) }
let(:project) { FactoryGirl.create(:project) }
@@ -18,7 +18,7 @@ describe HipChatMessage do
build.update(status: "success")
expect( subject.status_color ).to eq 'green'
- expect( subject.notify? ).to be_false
+ expect( subject.notify? ).to be_falsey
expect( subject.to_s ).to match(/Build '[^']+' #\d+/)
expect( subject.to_s ).to match(/Successful in \d+ second\(s\)\./)
end
@@ -29,7 +29,7 @@ describe HipChatMessage do
build.update(status: "failed")
expect( subject.status_color ).to eq 'red'
- expect( subject.notify? ).to be_true
+ expect( subject.notify? ).to be_truthy
expect( subject.to_s ).to match(/Build '[^']+' #\d+/)
expect( subject.to_s ).to match(/Failed in \d+ second\(s\)\./)
end
@@ -50,7 +50,7 @@ describe HipChatMessage do
commit.reload
expect( subject.status_color ).to eq 'green'
- expect( subject.notify? ).to be_false
+ expect( subject.notify? ).to be_falsey
expect( subject.to_s ).to match(/Commit #\d+/)
expect( subject.to_s ).to match(/Successful in \d+ second\(s\)\./)
end
@@ -65,7 +65,7 @@ describe HipChatMessage do
second_build.update(status: "failed")
expect( subject.status_color ).to eq 'red'
- expect( subject.notify? ).to be_true
+ expect( subject.notify? ).to be_truthy
expect( subject.to_s ).to match(/Commit #\d+/)
expect( subject.to_s ).to match(/Failed in \d+ second\(s\)\./)
end
diff --git a/spec/models/project_services/hip_chat_service_spec.rb b/spec/models/project_services/hip_chat_service_spec.rb
index 37ce490..71cdf4f 100644
--- a/spec/models/project_services/hip_chat_service_spec.rb
+++ b/spec/models/project_services/hip_chat_service_spec.rb
@@ -24,22 +24,22 @@ 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
describe "Execute" do
- let(:service) { HipChatService.new }
+ let(:service) { described_class.new }
let(:project) { FactoryGirl.create :project }
let(:commit) { FactoryGirl.create :commit, project: project }
let(:build) { FactoryGirl.create :build, commit: commit, status: 'failed' }
let(:api_url) { 'https://api.hipchat.com/v2/room/123/notification?auth_token=a1b2c3d4e5f6' }
before do
- service.stub(
+ allow(service).to receive_messages(
project: project,
project_id: project.id,
notify_only_broken_builds: false,
diff --git a/spec/models/project_services/slack_message_spec.rb b/spec/models/project_services/slack_message_spec.rb
index 88e0f37..6bfdd48 100644
--- a/spec/models/project_services/slack_message_spec.rb
+++ b/spec/models/project_services/slack_message_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
describe SlackMessage do
- subject { SlackMessage.new(commit) }
+ subject { described_class.new(commit) }
let(:project) { FactoryGirl.create :project }
@@ -19,11 +19,11 @@ describe SlackMessage do
it 'returns a message with succeeded build' do
build.update(status: "success")
- subject.color.should == 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 == 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 == 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 == color
- subject.fallback.should include('Commit')
- subject.fallback.should include("\##{commit.id}")
- subject.fallback.should include('failed')
- subject.attachments.first[:fields].size.should == 1
- subject.attachments.first[:fields].first[:title].should == 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 e1c1428..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,12 +25,12 @@ describe SlackService do
subject.active = true
end
- it { should validate_presence_of :webhook }
+ it { is_expected.to validate_presence_of :webhook }
end
end
describe "Execute" do
- let(:slack) { SlackService.new }
+ let(:slack) { described_class.new }
let(:project) { FactoryGirl.create :project }
let(:commit) { FactoryGirl.create :commit, project: project }
let(:build) { FactoryGirl.create :build, commit: commit, status: 'failed' }
@@ -38,7 +38,7 @@ describe SlackService do
let(:notify_only_broken_builds) { false }
before do
- slack.stub(
+ allow(slack).to receive_messages(
project: project,
project_id: project.id,
webhook: webhook_url,
@@ -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 b6027a8..fcd4ee7 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 == ""
+ 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 == "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
- Project.ordered_by_last_commit_date.should == [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
@@ -88,116 +88,116 @@ describe Project do
FactoryGirl.create(:build, commit: commit)
end
- it { project.status.should == 'pending' }
- it { project.last_commit.should be_kind_of(Commit) }
- it { project.human_status.should == '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 == 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 == 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 == false
+ expect(project.email_notification?).to eq false
end
end
describe '#broken_or_success?' do
it {
project = FactoryGirl.create :project, email_add_pusher: true
- project.stub(:broken?).and_return(true)
- project.stub(:success?).and_return(true)
- project.broken_or_success?.should == true
+ allow(project).to receive(:broken?).and_return(true)
+ allow(project).to receive(:success?).and_return(true)
+ expect(project.broken_or_success?).to eq true
}
it {
project = FactoryGirl.create :project, email_add_pusher: true
- project.stub(:broken?).and_return(true)
- project.stub(:success?).and_return(false)
- project.broken_or_success?.should == true
+ allow(project).to receive(:broken?).and_return(true)
+ allow(project).to receive(:success?).and_return(false)
+ expect(project.broken_or_success?).to eq true
}
it {
project = FactoryGirl.create :project, email_add_pusher: true
- project.stub(:broken?).and_return(false)
- project.stub(:success?).and_return(true)
- project.broken_or_success?.should == true
+ allow(project).to receive(:broken?).and_return(false)
+ allow(project).to receive(:success?).and_return(true)
+ expect(project.broken_or_success?).to eq true
}
it {
project = FactoryGirl.create :project, email_add_pusher: true
- project.stub(:broken?).and_return(false)
- project.stub(:success?).and_return(false)
- project.broken_or_success?.should == false
+ allow(project).to receive(:broken?).and_return(false)
+ allow(project).to receive(:success?).and_return(false)
+ expect(project.broken_or_success?).to eq false
}
end
- describe 'Project.parse' do
+ describe '.parse' do
let(:project_dump) { YAML.load File.read(Rails.root.join('spec/support/gitlab_stubs/raw_project.yml')) }
- let(:parsed_project) { Project.parse(project_dump) }
+ let(:parsed_project) { described_class.parse(project_dump) }
- it { parsed_project.should be_valid }
- it { parsed_project.should be_kind_of(Project) }
- 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
- Project.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
- describe :repo_url_with_auth do
+ describe '#repo_url_with_auth' 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
+ describe '.search' do
let!(:project) { FactoryGirl.create(:project, name: "foo") }
- it { Project.search('fo').should include(project) }
- it { Project.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
+ describe '#any_runners' do
it "there are no runners available" do
project = FactoryGirl.create(:project)
- project.any_runners?.should be_false
+ 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_true
+ 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_true
+ 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_false
+ expect(project.any_runners?).to be_falsey
end
end
end
diff --git a/spec/models/runner_project_spec.rb b/spec/models/runner_project_spec.rb
deleted file mode 100644
index cbefb24..0000000
--- a/spec/models/runner_project_spec.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-# == Schema Information
-#
-# Table name: runner_projects
-#
-# id :integer not null, primary key
-# runner_id :integer not null
-# project_id :integer not null
-# created_at :datetime
-# updated_at :datetime
-#
-
-require 'spec_helper'
-
-describe RunnerProject do
- pending "add some examples to (or delete) #{__FILE__}"
-end
diff --git a/spec/models/runner_spec.rb b/spec/models/runner_spec.rb
index 6902c0a..650b3a1 100644
--- a/spec/models/runner_spec.rb
+++ b/spec/models/runner_spec.rb
@@ -37,15 +37,15 @@ describe Runner do
end
end
- describe :assign_to do
+ describe '#assign_to' do
let!(:project) { FactoryGirl.create :project }
let!(:shared_runner) { FactoryGirl.create(:shared_runner) }
before { shared_runner.assign_to(project) }
- it { shared_runner.should be_specific }
- it { shared_runner.projects.should == [project] }
- it { shared_runner.only_for?(project).should be_true }
+ 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_false
+ 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_true
+ 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 22a49e1..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
@@ -25,7 +25,7 @@ describe Service do
describe "Test Button" do
before do
- @service = Service.new
+ @service = described_class.new
end
describe "Testable" do
@@ -34,15 +34,13 @@ describe Service do
let (:build) { FactoryGirl.create :build, commit: commit }
before do
- @service.stub(
- project: project
- )
+ allow(@service).to receive_messages(project: project)
build
@testable = @service.can_test?
end
- describe :can_test do
- it { @testable.should == true }
+ describe '#can_test' do
+ it { expect(@testable).to eq true }
end
end
end
diff --git a/spec/models/trigger_spec.rb b/spec/models/trigger_spec.rb
index bba638e..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 == '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 73a7a7d..affd2cb 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -4,7 +4,7 @@ describe User do
describe "has_developer_access?" do
before do
- @user = User.new({})
+ @user = described_class.new({})
end
let(:project_with_owner_access) do
@@ -40,39 +40,39 @@ describe User do
end
it "returns false for reporter" do
- @user.stub(:project_info).and_return(project_with_reporter_access)
+ allow(@user).to receive(:project_info).and_return(project_with_reporter_access)
- @user.has_developer_access?(1).should be_false
+ expect(@user.has_developer_access?(1)).to be_falsey
end
it "returns true for owner" do
- @user.stub(:project_info).and_return(project_with_owner_access)
+ allow(@user).to receive(:project_info).and_return(project_with_owner_access)
- @user.has_developer_access?(1).should be_true
+ expect(@user.has_developer_access?(1)).to be_truthy
end
end
describe "authorized_projects" do
- let (:user) { User.new({}) }
+ let (:user) { described_class.new({}) }
before do
FactoryGirl.create :project, gitlab_id: 1
FactoryGirl.create :project, gitlab_id: 2
gitlab_project = OpenStruct.new({id: 1})
gitlab_project1 = OpenStruct.new({id: 2})
- User.any_instance.stub(:gitlab_projects).and_return([gitlab_project, gitlab_project1])
+ allow_any_instance_of(described_class).to receive(:gitlab_projects).and_return([gitlab_project, gitlab_project1])
end
it "returns projects" do
- User.any_instance.stub(:can_manage_project?).and_return(true)
+ allow_any_instance_of(described_class).to receive(:can_manage_project?).and_return(true)
- user.authorized_projects.count.should == 2
+ expect(user.authorized_projects.count).to eq 2
end
it "empty list if user miss manage permission" do
- User.any_instance.stub(:can_manage_project?).and_return(false)
+ allow_any_instance_of(described_class).to receive(:can_manage_project?).and_return(false)
- user.authorized_projects.count.should == 0
+ expect(user.authorized_projects.count).to eq 0
end
end
@@ -82,9 +82,9 @@ describe User do
project1 = FactoryGirl.create :project, gitlab_id: 2
gitlab_project = OpenStruct.new({id: 1})
gitlab_project1 = OpenStruct.new({id: 2})
- User.any_instance.stub(:gitlab_projects).and_return([gitlab_project, gitlab_project1])
- User.any_instance.stub(:can_manage_project?).and_return(true)
- user = User.new({})
+ allow_any_instance_of(described_class).to receive(:gitlab_projects).and_return([gitlab_project, gitlab_project1])
+ allow_any_instance_of(described_class).to receive(:can_manage_project?).and_return(true)
+ user = described_class.new({})
runner = FactoryGirl.create :specific_runner
runner1 = FactoryGirl.create :specific_runner
@@ -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 4575115..a41ba4e 100644
--- a/spec/models/variable_spec.rb
+++ b/spec/models/variable_spec.rb
@@ -14,7 +14,7 @@
require 'spec_helper'
describe Variable do
- subject { Variable.new }
+ subject { described_class.new }
let(:secret_value) { 'secret' }
@@ -22,23 +22,24 @@ describe Variable do
subject.value = secret_value
end
- describe :value 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
subject.encrypted_value_iv = nil
subject.instance_variable_set(:@value, nil)
- expect { subject.value }.to raise_error
+ expect { subject.value }.
+ to raise_error(OpenSSL::Cipher::CipherError, 'bad decrypt')
end
end
end
diff --git a/spec/models/web_hook_spec.rb b/spec/models/web_hook_spec.rb
index 0f0f175..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,22 +43,21 @@ 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
- WebHook.should_receive(:post).and_raise("Some HTTP Post error")
+ expect(described_class).to receive(:post).and_raise("Some HTTP Post error")
- lambda {
- @web_hook.execute(@data)
- }.should raise_error
+ expect { @web_hook.execute(@data) }.
+ to raise_error(RuntimeError, 'Some HTTP Post error')
end
end
end
diff --git a/spec/requests/api/builds_spec.rb b/spec/requests/api/builds_spec.rb
index be55e9f..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 == 201
- json_response['sha'].should == build.sha
- runner.reload.platform.should == "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 == 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 == 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 == 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 == 201
- json_response["options"].should == {"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 == 201
- json_response["variables"].should == [
+ 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 == 201
- json_response["variables"].should == [
+ 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 == 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 190df70..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 == 200
- json_response.count.should == 1
- json_response.first["project_id"].should == project.id
- json_response.first["sha"].should == 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 == 201
- json_response['sha'].should == "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 == 400
- json_response['message'].should == "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 af52342..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 == 201
- json_response['name'].should == "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 == 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 014a9ef..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 == 200
- json_response.count.should == 2
- json_response.first["id"].should == project1.id
- json_response.last["id"].should == 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 == 200
- json_response.count.should == 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 == 201
- json_response["url"].should == 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 == 404
+ expect(response.status).to eq 404
end
it "non-manager is not authorized" do
- User.any_instance.stub(:can_manage_project?).and_return(false)
+ allow_any_instance_of(User).to receive(:can_manage_project?).and_return(false)
post api("/projects/#{project.id}/webhooks"), options
- response.status.should == 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 == 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 == 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 == 200
- json_response['id'].should == 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 == 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 == 200
- json_response["name"].should == 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 == 404
+ expect(response.status).to eq 404
end
it "non-manager is not authorized" do
- User.any_instance.stub(:can_manage_project?).and_return(false)
+ allow_any_instance_of(User).to receive(:can_manage_project?).and_return(false)
put api("/projects/#{project.id}"), options
- response.status.should == 401
+ expect(response.status).to eq 401
end
end
@@ -145,20 +145,20 @@ describe API::API do
it "should delete a specific project" do
delete api("/projects/#{project.id}"), options
- response.status.should == 200
+ expect(response.status).to eq 200
- expect { project.reload }.to raise_error
+ expect { project.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
it "non-manager is not authorized" do
- User.any_instance.stub(:can_manage_project?).and_return(false)
+ allow_any_instance_of(User).to receive(:can_manage_project?).and_return(false)
delete api("/projects/#{project.id}"), options
- response.status.should == 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 == 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 == 201
- json_response['name'].should == 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 == 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 == 201
+ expect(response.status).to eq 201
project.reload
- project.runners.first.id.should == 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 == 404
+ expect(response.status).to eq 404
post api("/projects/non-existing/runners/#{runner.id}"), options
- response.status.should == 404
+ expect(response.status).to eq 404
end
it "non-manager is not authorized" do
- User.any_instance.stub(:can_manage_project?).and_return(false)
+ 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 == 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 == 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
- User.any_instance.stub(:can_manage_project?).and_return(false)
+ 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 == 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 47de3c2..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 == 200
- json_response.count.should == 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 == 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 == 201 }
- it { Runner.first.description.should == "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 == 201 }
- it { Runner.first.tag_list.sort.should == ["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 == 201 }
- it { project.runners.size.should == 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 == 403
+ expect(response.status).to eq 403
end
it "should return 400 error if no token" do
post api("/runners/register")
- response.status.should == 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 == 200 }
- it { Runner.count.should == 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 6e56c4b..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 == 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 == 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 == 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 == 201
+ expect(response.status).to eq 201
@commit.builds.reload
- @commit.builds.size.should == 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 == 400
- json_response['message'].should == '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 == 400
- json_response['message'].should == '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 == 400
- json_response['message'].should == '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 == 201
+ expect(response.status).to eq 201
@commit.builds.reload
- @commit.builds.first.trigger_request.variables.should == 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 73d540e..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 == 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 e9d8366..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 == 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 34e00d5..209e088 100644
--- a/spec/services/create_commit_service_spec.rb
+++ b/spec/services/create_commit_service_spec.rb
@@ -1,10 +1,10 @@
require 'spec_helper'
describe CreateCommitService do
- let(:service) { CreateCommitService.new }
+ let(:service) { described_class.new }
let(:project) { FactoryGirl.create(:project) }
- describe :execute do
+ describe '#execute' do
context 'valid params' do
let(:commit) do
service.execute(project,
@@ -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 == 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,11 +45,11 @@ describe CreateCommitService do
ci_yaml_file: config,
commits: [ { message: "Message" } ]
)
- result.should be_persisted
+ expect(result).to be_persisted
end
end
- describe :ci_skip? do
+ describe '#ci_skip?' do
it "skips builds creation if there is [ci skip] tag in commit message" do
commits = [{message: "some message[ci skip]"}]
commit = service.execute(project,
@@ -59,8 +59,8 @@ describe CreateCommitService do
commits: commits,
ci_yaml_file: gitlab_ci_yaml
)
- commit.builds.any?.should be_false
- commit.status.should == "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 == "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_false
- commit.status.should == "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 == 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 == 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 == "failed"
- commit.builds.any?.should be_false
+ 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 3161496..085d5e9 100644
--- a/spec/services/create_project_service_spec.rb
+++ b/spec/services/create_project_service_spec.rb
@@ -1,23 +1,24 @@
require 'spec_helper'
describe CreateProjectService do
- let(:service) { CreateProjectService.new }
+ let(:service) { described_class.new }
let(:current_user) { double.as_null_object }
let(:project_dump) { YAML.load File.read(Rails.root.join('spec/support/gitlab_stubs/raw_project.yml')) }
- before { Network.any_instance.stub(enable_ci: true) }
+ before { allow_any_instance_of(Network).to receive_messages(enable_ci: true) }
- describe :execute do
+ describe '#execute' 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
it 'should raise exception' do
- expect { service.execute(current_user, '', '') }.to raise_error
+ expect { service.execute(current_user, '', '') }.
+ to raise_error(NoMethodError)
end
end
@@ -31,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_true
- project.public.should be_true
- project.allow_git_fetch.should be_true
+ 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 41db01c..0634753 100644
--- a/spec/services/create_trigger_request_service_spec.rb
+++ b/spec/services/create_trigger_request_service_spec.rb
@@ -1,11 +1,11 @@
require 'spec_helper'
describe CreateTriggerRequestService do
- let(:service) { CreateTriggerRequestService.new }
+ let(:service) { described_class.new }
let(:project) { FactoryGirl.create :project }
let(:trigger) { FactoryGirl.create :trigger, project: project }
- describe :execute do
+ describe '#execute' do
context 'valid params' do
subject { service.execute(project, trigger, 'master') }
@@ -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 == @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 == @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 f7b9bf5..3333c19 100644
--- a/spec/services/event_service_spec.rb
+++ b/spec/services/event_service_spec.rb
@@ -8,27 +8,27 @@ describe EventService do
Event.destroy_all
end
- describe :remove_project do
+ describe '#remove_project' do
it "creates event" do
- EventService.new.remove_project(user, project)
+ described_class.new.remove_project(user, project)
- Event.admin.last.description.should == "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
- describe :create_project do
+ describe '#create_project' do
it "creates event" do
- EventService.new.create_project(user, project)
+ described_class.new.create_project(user, project)
- Event.admin.last.description.should == "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
- describe :change_project_settings do
+ describe '#change_project_settings' do
it "creates event" do
- EventService.new.change_project_settings(user, project)
+ described_class.new.change_project_settings(user, project)
- Event.last.description.should == "User \"root\" updated projects settings"
+ expect(Event.last.description).to eq "User \"root\" updated projects settings"
end
end
-end \ No newline at end of file
+end
diff --git a/spec/services/image_for_build_service_spec.rb b/spec/services/image_for_build_service_spec.rb
index 4c70941..d9c9c76 100644
--- a/spec/services/image_for_build_service_spec.rb
+++ b/spec/services/image_for_build_service_spec.rb
@@ -1,46 +1,46 @@
require 'spec_helper'
describe ImageForBuildService do
- let(:service) { ImageForBuildService.new }
+ let(:service) { described_class.new }
let(:project) { FactoryGirl.create(:project) }
let(:commit) { FactoryGirl.create(:commit, project: project, ref: 'master') }
let(:build) { FactoryGirl.create(:build, commit: commit) }
- describe :execute do
+ describe '#execute' do
before { build }
context 'branch name' 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 == '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 == '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 == '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 == '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 b5af777..ee8e499 100644
--- a/spec/services/register_build_service_spec.rb
+++ b/spec/services/register_build_service_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
describe RegisterBuildService do
- let!(:service) { RegisterBuildService.new }
+ let!(:service) { described_class.new }
let!(:project) { FactoryGirl.create :project }
let!(:commit) { FactoryGirl.create :commit, project: project }
let!(:pending_build) { FactoryGirl.create :build, project: project, commit: commit }
@@ -12,35 +12,35 @@ describe RegisterBuildService do
specific_runner.assign_to(project)
end
- describe :execute do
+ describe '#execute' do
context 'runner follow tag list' do
it "picks build with the same tag" do
pending_build.tag_list = ["linux"]
pending_build.save
specific_runner.tag_list = ["linux"]
- service.execute(specific_runner).should == 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_false
+ expect(service.execute(specific_runner)).to be_falsey
end
it "picks build without tag" do
- service.execute(specific_runner).should == 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_false
+ 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 == 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 == 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 == 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 == 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 2bb1539..93f5b4f 100644
--- a/spec/services/web_hook_service_spec.rb
+++ b/spec/services/web_hook_service_spec.rb
@@ -6,16 +6,16 @@ describe WebHookService do
let (:build) { FactoryGirl.create :build, commit: commit }
let (:hook) { FactoryGirl.create :web_hook, project: project }
- describe :execute do
+ describe '#execute' do
it "should execute successfully" do
stub_request(:post, hook.url).to_return(status: 200)
- WebHookService.new.build_end(build).should be_true
+ 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,
@@ -31,6 +31,6 @@ describe WebHookService do
end
def build_data(build)
- WebHookService.new.send :build_data, build
+ described_class.new.send :build_data, build
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 54d3068..1d56dee 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -9,52 +9,28 @@ if ENV['COVERALLS']
end
ENV["RAILS_ENV"] ||= 'test'
+
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
-require 'rspec/autorun'
+require 'shoulda/matchers'
require 'sidekiq/testing/inline'
-require 'capybara/poltergeist'
-
-Capybara.javascript_driver = :poltergeist
-Capybara.default_wait_time = 10
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
-require 'webmock/rspec'
-WebMock.disable_net_connect!(allow_localhost: true)
-
RSpec.configure do |config|
- config.include LoginHelpers, type: :feature
+ config.use_transactional_fixtures = false
+ config.use_instantiated_fixtures = false
+ config.mock_with :rspec
+ config.include LoginHelpers, type: :feature
+ config.include LoginHelpers, type: :request
config.include StubGitlabCalls
config.include StubGitlabData
- # ## Mock Framework
- #
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
- #
- # config.mock_with :mocha
- # config.mock_with :flexmock
- # config.mock_with :rr
-
- # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
-
- # If you're not using ActiveRecord, or you'd prefer not to run each of your
- # examples within a transaction, remove the following line or assign false
- # instead of true.
- config.use_transactional_fixtures = false
-
- # If true, the base class of anonymous controllers will be inferred
- # automatically. This will be the default behavior in future versions of
- # rspec-rails.
- config.infer_base_class_for_anonymous_controllers = false
-
- # Run specs in random order to surface order dependencies. If you find an
- # order dependency and want to debug it, you can fix the order by providing
- # the seed, which is printed after each run.
- # --seed 1234
- config.order = "random"
+ config.infer_spec_type_from_file_location!
+ config.raise_errors_for_deprecations!
end
+
+ActiveRecord::Migration.maintain_test_schema!
diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb
new file mode 100644
index 0000000..fed1ab6
--- /dev/null
+++ b/spec/support/capybara.rb
@@ -0,0 +1,21 @@
+require 'capybara/rails'
+require 'capybara/rspec'
+require 'capybara/poltergeist'
+
+# Give CI some extra time
+timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 90 : 10
+
+Capybara.javascript_driver = :poltergeist
+Capybara.register_driver :poltergeist do |app|
+ Capybara::Poltergeist::Driver.new(app, js_errors: true, timeout: timeout)
+end
+
+Capybara.default_wait_time = timeout
+Capybara.ignore_hidden_elements = true
+
+unless ENV['CI'] || ENV['CI_SERVER']
+ require 'capybara-screenshot/rspec'
+
+ # Keep only the screenshots generated from the last failing test suite
+ Capybara::Screenshot.prune_strategy = :keep_last_run
+end
diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb
index ebd9693..fde02b4 100644
--- a/spec/support/login_helpers.rb
+++ b/spec/support/login_helpers.rb
@@ -17,6 +17,6 @@ module LoginHelpers
end
def skip_admin_auth
- ApplicationController.any_instance.stub(authenticate_admin!: true)
+ allow_any_instance_of(ApplicationController).to receive_messages(authenticate_admin!: true)
end
end
diff --git a/spec/support/stub_gitlab_calls.rb b/spec/support/stub_gitlab_calls.rb
index 931ef96..7760f9c 100644
--- a/spec/support/stub_gitlab_calls.rb
+++ b/spec/support/stub_gitlab_calls.rb
@@ -10,7 +10,7 @@ module StubGitlabCalls
end
def stub_js_gitlab_calls
- Network.any_instance.stub(:projects) { project_hash_array }
+ allow_any_instance_of(Network).to receive(:projects) { project_hash_array }
end
private
@@ -42,12 +42,12 @@ module StubGitlabCalls
def stub_project_8
data = File.read(Rails.root.join('spec/support/gitlab_stubs/project_8.json'))
- Network.any_instance.stub(:project).and_return(JSON.parse(data))
+ allow_any_instance_of(Network).to receive(:project).and_return(JSON.parse(data))
end
def stub_project_8_hooks
data = File.read(Rails.root.join('spec/support/gitlab_stubs/project_8_hooks.json'))
- Network.any_instance.stub(:project_hooks).and_return(JSON.parse(data))
+ allow_any_instance_of(Network).to receive(:project_hooks).and_return(JSON.parse(data))
end
def stub_projects
diff --git a/spec/support/webmock.rb b/spec/support/webmock.rb
new file mode 100644
index 0000000..af2906b
--- /dev/null
+++ b/spec/support/webmock.rb
@@ -0,0 +1,4 @@
+require 'webmock'
+require 'webmock/rspec'
+
+WebMock.disable_net_connect!(allow_localhost: true)