Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Baarsen <jeroenvanbaarsen@gmail.com>2015-02-12 21:17:35 +0300
committerJeroen van Baarsen <jeroenvanbaarsen@gmail.com>2015-02-12 21:17:35 +0300
commit0c4a70a306b871899bf87ce4673918abfee4d95f (patch)
treec7a702fb511209ffe0eceba245d1ffea71dce1aa /spec/support
parentde1c450abd6b367390a1295cac402344f500d41d (diff)
Updated rspec to rspec 3.x syntax
Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/db_cleaner.rb11
-rw-r--r--spec/support/mentionable_shared_examples.rb28
-rw-r--r--spec/support/taskable_shared_examples.rb4
-rw-r--r--spec/support/test_env.rb4
4 files changed, 28 insertions, 19 deletions
diff --git a/spec/support/db_cleaner.rb b/spec/support/db_cleaner.rb
index d2d532d9738..cca7652093a 100644
--- a/spec/support/db_cleaner.rb
+++ b/spec/support/db_cleaner.rb
@@ -36,4 +36,15 @@ RSpec.configure do |config|
config.after(:each) do
DatabaseCleaner.clean
end
+
+ # rspec-rails 3 will no longer automatically infer an example group's spec type
+ # from the file location. You can explicitly opt-in to the feature using this
+ # config option.
+ # To explicitly tag specs without using automatic inference, set the `:type`
+ # metadata manually:
+ #
+ # describe ThingsController, :type => :controller do
+ # # Equivalent to being in spec/controllers
+ # end
+ config.infer_spec_type_from_file_location!
end
diff --git a/spec/support/mentionable_shared_examples.rb b/spec/support/mentionable_shared_examples.rb
index ebd74206699..305592fa5a6 100644
--- a/spec/support/mentionable_shared_examples.rb
+++ b/spec/support/mentionable_shared_examples.rb
@@ -39,7 +39,7 @@ def common_mentionable_setup
# unrecognized commits.
commitmap = { '1234567890a' => mentioned_commit }
extra_commits.each { |c| commitmap[c.short_id] = c }
- mproject.repository.stub(:commit) { |sha| commitmap[sha] }
+ allow(mproject.repository).to receive(:commit) { |sha| commitmap[sha] }
set_mentionable_text.call(ref_string)
end
end
@@ -48,19 +48,19 @@ shared_examples 'a mentionable' do
common_mentionable_setup
it 'generates a descriptive back-reference' do
- subject.gfm_reference.should == backref_text
+ expect(subject.gfm_reference).to eq(backref_text)
end
it "extracts references from its reference property" do
# De-duplicate and omit itself
refs = subject.references(mproject)
- refs.should have(6).items
- refs.should include(mentioned_issue)
- refs.should include(mentioned_mr)
- refs.should include(mentioned_commit)
- refs.should include(ext_issue)
- refs.should include(ext_mr)
- refs.should include(ext_commit)
+ expect(refs.size).to eq(6)
+ expect(refs).to include(mentioned_issue)
+ expect(refs).to include(mentioned_mr)
+ expect(refs).to include(mentioned_commit)
+ expect(refs).to include(ext_issue)
+ expect(refs).to include(ext_mr)
+ expect(refs).to include(ext_commit)
end
it 'creates cross-reference notes' do
@@ -68,7 +68,7 @@ shared_examples 'a mentionable' do
ext_issue, ext_mr, ext_commit]
mentioned_objects.each do |referenced|
- Note.should_receive(:create_cross_reference_note).with(referenced, subject.local_reference, mauthor, mproject)
+ expect(Note).to receive(:create_cross_reference_note).with(referenced, subject.local_reference, mauthor, mproject)
end
subject.create_cross_references!(mproject, mauthor)
@@ -77,8 +77,8 @@ shared_examples 'a mentionable' do
it 'detects existing cross-references' do
Note.create_cross_reference_note(mentioned_issue, subject.local_reference, mauthor, mproject)
- subject.has_mentioned?(mentioned_issue).should be_true
- subject.has_mentioned?(mentioned_mr).should be_false
+ expect(subject.has_mentioned?(mentioned_issue)).to be_truthy
+ expect(subject.has_mentioned?(mentioned_mr)).to be_falsey
end
end
@@ -95,12 +95,12 @@ shared_examples 'an editable mentionable' do
"#{ext_proj.path_with_namespace}##{other_ext_issue.iid}"
[mentioned_issue, mentioned_commit, ext_issue].each do |oldref|
- Note.should_not_receive(:create_cross_reference_note).with(oldref, subject.local_reference,
+ expect(Note).not_to receive(:create_cross_reference_note).with(oldref, subject.local_reference,
mauthor, mproject)
end
[other_issue, other_ext_issue].each do |newref|
- Note.should_receive(:create_cross_reference_note).with(
+ expect(Note).to receive(:create_cross_reference_note).with(
newref,
subject.local_reference,
mauthor,
diff --git a/spec/support/taskable_shared_examples.rb b/spec/support/taskable_shared_examples.rb
index 42252675683..490f453d468 100644
--- a/spec/support/taskable_shared_examples.rb
+++ b/spec/support/taskable_shared_examples.rb
@@ -34,9 +34,9 @@ EOT
end
it 'knows if it has tasks' do
- expect(subject.tasks?).to be_true
+ expect(subject.tasks?).to be_truthy
subject.description = 'Now I have no tasks'
- expect(subject.tasks?).to be_false
+ expect(subject.tasks?).to be_falsey
end
end
diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb
index 24fee7c0379..1c150cbfe25 100644
--- a/spec/support/test_env.rb
+++ b/spec/support/test_env.rb
@@ -19,8 +19,6 @@ module TestEnv
# See gitlab.yml.example test section for paths
#
def init(opts = {})
- RSpec::Mocks::setup(self)
-
# Disable mailer for spinach tests
disable_mailer if opts[:mailer] == false
@@ -49,7 +47,7 @@ module TestEnv
end
def enable_mailer
- NotificationService.any_instance.unstub(:mailer)
+ allow_any_instance_of(NotificationService).to receive(:mailer).and_call_original
end
def setup_gitlab_shell