summaryrefslogtreecommitdiff
path: root/spec/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/application_helper_spec.rb79
-rw-r--r--spec/helpers/broadcast_messages_helper_spec.rb4
-rw-r--r--spec/helpers/diff_helper_spec.rb28
-rw-r--r--spec/helpers/gitlab_markdown_helper_spec.rb233
-rw-r--r--spec/helpers/issues_helper_spec.rb38
-rw-r--r--spec/helpers/merge_requests_helper.rb2
-rw-r--r--spec/helpers/notifications_helper_spec.rb8
-rw-r--r--spec/helpers/oauth_helper_spec.rb6
-rw-r--r--spec/helpers/projects_helper_spec.rb6
-rw-r--r--spec/helpers/search_helper_spec.rb14
-rw-r--r--spec/helpers/submodule_helper_spec.rb34
-rw-r--r--spec/helpers/tab_helper_spec.rb30
-rw-r--r--spec/helpers/tree_helper_spec.rb4
13 files changed, 244 insertions, 242 deletions
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index a46883b3c99..9c8c8ab4b0f 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -3,20 +3,20 @@ require 'spec_helper'
describe ApplicationHelper do
describe 'current_controller?' do
before do
- controller.stub(:controller_name).and_return('foo')
+ allow(controller).to receive(:controller_name).and_return('foo')
end
it 'returns true when controller matches argument' do
- current_controller?(:foo).should be_true
+ expect(current_controller?(:foo)).to be_truthy
end
it 'returns false when controller does not match argument' do
- current_controller?(:bar).should_not be_true
+ expect(current_controller?(:bar)).not_to be_truthy
end
it 'should take any number of arguments' do
- current_controller?(:baz, :bar).should_not be_true
- current_controller?(:baz, :bar, :foo).should be_true
+ expect(current_controller?(:baz, :bar)).not_to be_truthy
+ expect(current_controller?(:baz, :bar, :foo)).to be_truthy
end
end
@@ -26,16 +26,16 @@ describe ApplicationHelper do
end
it 'returns true when action matches argument' do
- current_action?(:foo).should be_true
+ expect(current_action?(:foo)).to be_truthy
end
it 'returns false when action does not match argument' do
- current_action?(:bar).should_not be_true
+ expect(current_action?(:bar)).not_to be_truthy
end
it 'should take any number of arguments' do
- current_action?(:baz, :bar).should_not be_true
- current_action?(:baz, :bar, :foo).should be_true
+ expect(current_action?(:baz, :bar)).not_to be_truthy
+ expect(current_action?(:baz, :bar, :foo)).to be_truthy
end
end
@@ -46,13 +46,13 @@ describe ApplicationHelper do
group = create(:group)
group.avatar = File.open(avatar_file_path)
group.save!
- group_icon(group.path).to_s.should match("/uploads/group/avatar/#{ group.id }/gitlab_logo.png")
+ expect(group_icon(group.path).to_s).to match("/uploads/group/avatar/#{ group.id }/gitlab_logo.png")
end
it 'should give default avatar_icon when no avatar is present' do
group = create(:group)
group.save!
- group_icon(group.path).should match('group_avatar.png')
+ expect(group_icon(group.path)).to match('group_avatar.png')
end
end
@@ -63,17 +63,18 @@ describe ApplicationHelper do
project = create(:project)
project.avatar = File.open(avatar_file_path)
project.save!
- project_icon(project.to_param).to_s.should ==
+ expect(project_icon(project.to_param).to_s).to eq(
"<img alt=\"Gitlab logo\" src=\"/uploads/project/avatar/#{ project.id }/gitlab_logo.png\" />"
+ )
end
it 'should give uploaded icon when present' do
project = create(:project)
project.save!
- Project.any_instance.stub(:avatar_in_git).and_return(true)
+ allow_any_instance_of(Project).to receive(:avatar_in_git).and_return(true)
- project_icon(project.to_param).to_s.should match(
+ expect(project_icon(project.to_param).to_s).to match(
image_tag(project_avatar_path(project)))
end
end
@@ -85,7 +86,7 @@ describe ApplicationHelper do
user = create(:user)
user.avatar = File.open(avatar_file_path)
user.save!
- avatar_icon(user.email).to_s.should match("/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
+ expect(avatar_icon(user.email).to_s).to match("/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
end
it 'should return an url for the avatar with relative url' do
@@ -95,13 +96,13 @@ describe ApplicationHelper do
user = create(:user)
user.avatar = File.open(avatar_file_path)
user.save!
- avatar_icon(user.email).to_s.should match("/gitlab/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
+ expect(avatar_icon(user.email).to_s).to match("/gitlab/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
end
it 'should call gravatar_icon when no avatar is present' do
user = create(:user, email: 'test@example.com')
user.save!
- avatar_icon(user.email).to_s.should == 'http://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=40&d=identicon'
+ expect(avatar_icon(user.email).to_s).to eq('http://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=40&d=identicon')
end
end
@@ -110,42 +111,42 @@ describe ApplicationHelper do
it 'should return a generic avatar path when Gravatar is disabled' do
ApplicationSetting.any_instance.stub(gravatar_enabled?: false)
- gravatar_icon(user_email).should match('no_avatar.png')
+ expect(gravatar_icon(user_email)).to match('no_avatar.png')
end
it 'should return a generic avatar path when email is blank' do
- gravatar_icon('').should match('no_avatar.png')
+ expect(gravatar_icon('')).to match('no_avatar.png')
end
it 'should return default gravatar url' do
Gitlab.config.gitlab.stub(https: false)
- gravatar_icon(user_email).should match('http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118')
+ expect(gravatar_icon(user_email)).to match('http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118')
end
it 'should use SSL when appropriate' do
Gitlab.config.gitlab.stub(https: true)
- gravatar_icon(user_email).should match('https://secure.gravatar.com')
+ expect(gravatar_icon(user_email)).to match('https://secure.gravatar.com')
end
it 'should return custom gravatar path when gravatar_url is set' do
allow(self).to receive(:request).and_return(double(:ssl? => false))
- Gitlab.config.gravatar.stub(:plain_url).and_return('http://example.local/?s=%{size}&hash=%{hash}')
- gravatar_icon(user_email, 20).should == 'http://example.local/?s=20&hash=b58c6f14d292556214bd64909bcdb118'
+ allow(Gitlab.config.gravatar).to receive(:plain_url).and_return('http://example.local/?s=%{size}&hash=%{hash}')
+ expect(gravatar_icon(user_email, 20)).to eq('http://example.local/?s=20&hash=b58c6f14d292556214bd64909bcdb118')
end
it 'should accept a custom size' do
allow(self).to receive(:request).and_return(double(:ssl? => false))
- gravatar_icon(user_email, 64).should match(/\?s=64/)
+ expect(gravatar_icon(user_email, 64)).to match(/\?s=64/)
end
it 'should use default size when size is wrong' do
allow(self).to receive(:request).and_return(double(:ssl? => false))
- gravatar_icon(user_email, nil).should match(/\?s=40/)
+ expect(gravatar_icon(user_email, nil)).to match(/\?s=40/)
end
it 'should be case insensitive' do
allow(self).to receive(:request).and_return(double(:ssl? => false))
- gravatar_icon(user_email).should == gravatar_icon(user_email.upcase + ' ')
+ expect(gravatar_icon(user_email)).to eq(gravatar_icon(user_email.upcase + ' '))
end
end
@@ -163,28 +164,28 @@ describe ApplicationHelper do
end
it 'includes a list of branch names' do
- options[0][0].should == 'Branches'
- options[0][1].should include('master', 'feature')
+ expect(options[0][0]).to eq('Branches')
+ expect(options[0][1]).to include('master', 'feature')
end
it 'includes a list of tag names' do
- options[1][0].should == 'Tags'
- options[1][1].should include('v1.0.0','v1.1.0')
+ expect(options[1][0]).to eq('Tags')
+ expect(options[1][1]).to include('v1.0.0','v1.1.0')
end
it 'includes a specific commit ref if defined' do
# Must be an instance variable
@ref = '2ed06dc41dbb5936af845b87d79e05bbf24c73b8'
- options[2][0].should == 'Commit'
- options[2][1].should == [@ref]
+ expect(options[2][0]).to eq('Commit')
+ expect(options[2][1]).to eq([@ref])
end
it 'sorts tags in a natural order' do
# Stub repository.tag_names to make sure we get some valid testing data
expect(@project.repository).to receive(:tag_names).and_return(['v1.0.9', 'v1.0.10', 'v2.0', 'v3.1.4.2', 'v1.0.9a'])
- options[1][1].should == ['v3.1.4.2', 'v2.0', 'v1.0.10', 'v1.0.9a', 'v1.0.9']
+ expect(options[1][1]).to eq(['v3.1.4.2', 'v2.0', 'v1.0.10', 'v1.0.9a', 'v1.0.9'])
end
end
@@ -192,7 +193,7 @@ describe ApplicationHelper do
context 'with current_user is nil' do
it 'should return a string' do
allow(self).to receive(:current_user).and_return(nil)
- user_color_scheme_class.should be_kind_of(String)
+ expect(user_color_scheme_class).to be_kind_of(String)
end
end
@@ -202,7 +203,7 @@ describe ApplicationHelper do
it 'should return a string' do
current_user = double(:color_scheme_id => color_scheme_id)
allow(self).to receive(:current_user).and_return(current_user)
- user_color_scheme_class.should be_kind_of(String)
+ expect(user_color_scheme_class).to be_kind_of(String)
end
end
end
@@ -213,17 +214,17 @@ describe ApplicationHelper do
let(:a_tag) { '<a href="#">Foo</a>' }
it 'allows the a tag' do
- simple_sanitize(a_tag).should == a_tag
+ expect(simple_sanitize(a_tag)).to eq(a_tag)
end
it 'allows the span tag' do
input = '<span class="foo">Bar</span>'
- simple_sanitize(input).should == input
+ expect(simple_sanitize(input)).to eq(input)
end
it 'disallows other tags' do
input = "<strike><b>#{a_tag}</b></strike>"
- simple_sanitize(input).should == a_tag
+ expect(simple_sanitize(input)).to eq(a_tag)
end
end
@@ -254,7 +255,7 @@ describe ApplicationHelper do
let(:content) { 'Noël' }
it 'should preserve encoding' do
- content.encoding.name.should == 'UTF-8'
+ expect(content.encoding.name).to eq('UTF-8')
expect(render_markup('foo.rst', content).encoding.name).to eq('UTF-8')
end
end
diff --git a/spec/helpers/broadcast_messages_helper_spec.rb b/spec/helpers/broadcast_messages_helper_spec.rb
index 1338ce4873d..cf310b893e0 100644
--- a/spec/helpers/broadcast_messages_helper_spec.rb
+++ b/spec/helpers/broadcast_messages_helper_spec.rb
@@ -6,7 +6,7 @@ describe BroadcastMessagesHelper do
context "default style" do
it "should have no style" do
- broadcast_styling(broadcast_message).should match('')
+ expect(broadcast_styling(broadcast_message)).to match('')
end
end
@@ -14,7 +14,7 @@ describe BroadcastMessagesHelper do
before { broadcast_message.stub(color: "#f2dede", font: "#b94a48") }
it "should have a customized style" do
- broadcast_styling(broadcast_message).should match('background-color:#f2dede;color:#b94a48')
+ expect(broadcast_styling(broadcast_message)).to match('background-color:#f2dede;color:#b94a48')
end
end
end
diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb
index b07742a6ee2..75da43a68a6 100644
--- a/spec/helpers/diff_helper_spec.rb
+++ b/spec/helpers/diff_helper_spec.rb
@@ -10,58 +10,58 @@ describe DiffHelper do
describe 'diff_hard_limit_enabled?' do
it 'should return true if param is provided' do
- controller.stub(:params).and_return { { :force_show_diff => true } }
- diff_hard_limit_enabled?.should be_true
+ allow(controller).to receive(:params) { { :force_show_diff => true } }
+ expect(diff_hard_limit_enabled?).to be_truthy
end
it 'should return false if param is not provided' do
- diff_hard_limit_enabled?.should be_false
+ expect(diff_hard_limit_enabled?).to be_falsey
end
end
describe 'allowed_diff_size' do
it 'should return hard limit for a diff if force diff is true' do
- controller.stub(:params).and_return { { :force_show_diff => true } }
- allowed_diff_size.should eq(1000)
+ allow(controller).to receive(:params) { { :force_show_diff => true } }
+ expect(allowed_diff_size).to eq(1000)
end
it 'should return safe limit for a diff if force diff is false' do
- allowed_diff_size.should eq(100)
+ expect(allowed_diff_size).to eq(100)
end
end
describe 'parallel_diff' do
it 'should return an array of arrays containing the parsed diff' do
- parallel_diff(diff_file, 0).should match_array(parallel_diff_result_array)
+ expect(parallel_diff(diff_file, 0)).to match_array(parallel_diff_result_array)
end
end
describe 'generate_line_code' do
it 'should generate correct line code' do
- generate_line_code(diff_file.file_path, diff_file.diff_lines.first).should == '2f6fcd96b88b36ce98c38da085c795a27d92a3dd_6_6'
+ expect(generate_line_code(diff_file.file_path, diff_file.diff_lines.first)).to eq('2f6fcd96b88b36ce98c38da085c795a27d92a3dd_6_6')
end
end
describe 'unfold_bottom_class' do
it 'should return empty string when bottom line shouldnt be unfolded' do
- unfold_bottom_class(false).should == ''
+ expect(unfold_bottom_class(false)).to eq('')
end
it 'should return js class when bottom lines should be unfolded' do
- unfold_bottom_class(true).should == 'js-unfold-bottom'
+ expect(unfold_bottom_class(true)).to eq('js-unfold-bottom')
end
end
describe 'diff_line_content' do
it 'should return non breaking space when line is empty' do
- diff_line_content(nil).should eq(" &nbsp;")
+ expect(diff_line_content(nil)).to eq(" &nbsp;")
end
it 'should return the line itself' do
- diff_line_content(diff_file.diff_lines.first.text).should eq("@@ -6,12 +6,18 @@ module Popen")
- diff_line_content(diff_file.diff_lines.first.type).should eq("match")
- diff_line_content(diff_file.diff_lines.first.new_pos).should eq(6)
+ expect(diff_line_content(diff_file.diff_lines.first.text)).to eq("@@ -6,12 +6,18 @@ module Popen")
+ expect(diff_line_content(diff_file.diff_lines.first.type)).to eq("match")
+ expect(diff_line_content(diff_file.diff_lines.first.new_pos)).to eq(6)
end
end
diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb
index d633287b2a9..87d45faa207 100644
--- a/spec/helpers/gitlab_markdown_helper_spec.rb
+++ b/spec/helpers/gitlab_markdown_helper_spec.rb
@@ -30,26 +30,26 @@ describe GitlabMarkdownHelper do
it "should return unaltered text if project is nil" do
actual = "Testing references: ##{issue.iid}"
- gfm(actual).should_not == actual
+ expect(gfm(actual)).not_to eq(actual)
@project = nil
- gfm(actual).should == actual
+ expect(gfm(actual)).to eq(actual)
end
it "should not alter non-references" do
actual = expected = "_Please_ *stop* 'helping' and all the other b*$#%' you do."
- gfm(actual).should == expected
+ expect(gfm(actual)).to eq(expected)
end
it "should not touch HTML entities" do
- @project.issues.stub(:where).with(id: '39').and_return([issue])
+ allow(@project.issues).to receive(:where).with(id: '39').and_return([issue])
actual = 'We&#39;ll accept good pull requests.'
- gfm(actual).should == "We'll accept good pull requests."
+ expect(gfm(actual)).to eq("We'll accept good pull requests.")
end
it "should forward HTML options to links" do
- gfm("Fixed in #{commit.id}", @project, class: 'foo').
- should have_selector('a.gfm.foo')
+ expect(gfm("Fixed in #{commit.id}", @project, class: 'foo')).
+ to have_selector('a.gfm.foo')
end
describe "referencing a commit" do
@@ -57,38 +57,38 @@ describe GitlabMarkdownHelper do
it "should link using a full id" do
actual = "Reverts #{commit.id}"
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should link using a short id" do
actual = "Backported from #{commit.short_id}"
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should link with adjacent text" do
actual = "Reverted (see #{commit.id})"
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should keep whitespace intact" do
actual = "Changes #{commit.id} dramatically"
expected = /Changes <a.+>#{commit.id}<\/a> dramatically/
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should not link with an invalid id" do
actual = expected = "What happened in #{commit.id.reverse}"
- gfm(actual).should == expected
+ expect(gfm(actual)).to eq(expected)
end
it "should include a title attribute" do
actual = "Reverts #{commit.id}"
- gfm(actual).should match(/title="#{commit.link_title}"/)
+ expect(gfm(actual)).to match(/title="#{commit.link_title}"/)
end
it "should include standard gfm classes" do
actual = "Reverts #{commit.id}"
- gfm(actual).should match(/class="\s?gfm gfm-commit\s?"/)
+ expect(gfm(actual)).to match(/class="\s?gfm gfm-commit\s?"/)
end
end
@@ -101,37 +101,37 @@ describe GitlabMarkdownHelper do
end
it "should link using a simple name" do
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should link using a name with dots" do
user.update_attributes(name: "alphA.Beta")
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should link using name with underscores" do
user.update_attributes(name: "ping_pong_king")
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should link with adjacent text" do
actual = "Mail the admin (@#{user.username})"
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should keep whitespace intact" do
actual = "Yes, @#{user.username} is right."
expected = /Yes, <a.+>@#{user.username}<\/a> is right/
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should not link with an invalid id" do
actual = expected = "@#{user.username.reverse} you are right."
- gfm(actual).should == expected
+ expect(gfm(actual)).to eq(expected)
end
it "should include standard gfm classes" do
- gfm(actual).should match(/class="\s?gfm gfm-team_member\s?"/)
+ expect(gfm(actual)).to match(/class="\s?gfm gfm-team_member\s?"/)
end
end
@@ -148,37 +148,37 @@ describe GitlabMarkdownHelper do
let(:expected) { polymorphic_path([project, object]) }
it "should link using a valid id" do
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should link with adjacent text" do
# Wrap the reference in parenthesis
- gfm(actual.gsub(reference, "(#{reference})")).should match(expected)
+ expect(gfm(actual.gsub(reference, "(#{reference})"))).to match(expected)
# Append some text to the end of the reference
- gfm(actual.gsub(reference, "#{reference}, right?")).should match(expected)
+ expect(gfm(actual.gsub(reference, "#{reference}, right?"))).to match(expected)
end
it "should keep whitespace intact" do
actual = "Referenced #{reference} already."
expected = /Referenced <a.+>[^\s]+<\/a> already/
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should not link with an invalid id" do
# Modify the reference string so it's still parsed, but is invalid
reference.gsub!(/^(.)(\d+)$/, '\1' + ('\2' * 2))
- gfm(actual).should == actual
+ expect(gfm(actual)).to eq(actual)
end
it "should include a title attribute" do
title = "#{object.class.to_s.titlecase}: #{object.title}"
- gfm(actual).should match(/title="#{title}"/)
+ expect(gfm(actual)).to match(/title="#{title}"/)
end
it "should include standard gfm classes" do
css = object.class.to_s.underscore
- gfm(actual).should match(/class="\s?gfm gfm-#{css}\s?"/)
+ expect(gfm(actual)).to match(/class="\s?gfm gfm-#{css}\s?"/)
end
end
@@ -204,19 +204,19 @@ describe GitlabMarkdownHelper do
end
it 'should link using a valid id' do
- gfm(actual).should match(
+ expect(gfm(actual)).to match(
/#{expected}.*#{Regexp.escape(full_reference)}/
)
end
it 'should link with adjacent text' do
# Wrap the reference in parenthesis
- gfm(actual.gsub(full_reference, "(#{full_reference})")).should(
+ expect(gfm(actual.gsub(full_reference, "(#{full_reference})"))).to(
match(expected)
)
# Append some text to the end of the reference
- gfm(actual.gsub(full_reference, "#{full_reference}, right?")).should(
+ expect(gfm(actual.gsub(full_reference, "#{full_reference}, right?"))).to(
match(expected)
)
end
@@ -224,7 +224,7 @@ describe GitlabMarkdownHelper do
it 'should keep whitespace intact' do
actual = "Referenced #{full_reference} already."
expected = /Referenced <a.+>[^\s]+<\/a> already/
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it 'should not link with an invalid id' do
@@ -234,7 +234,7 @@ describe GitlabMarkdownHelper do
else
reference.gsub!(/^(.)(\d+)$/, '\1' + ('\2' * 2))
end
- gfm(actual).should == actual
+ expect(gfm(actual)).to eq(actual)
end
it 'should include a title attribute' do
@@ -243,12 +243,12 @@ describe GitlabMarkdownHelper do
else
title = "#{object.class.to_s.titlecase}: #{object.title}"
end
- gfm(actual).should match(/title="#{title}"/)
+ expect(gfm(actual)).to match(/title="#{title}"/)
end
it 'should include standard gfm classes' do
css = object.class.to_s.underscore
- gfm(actual).should match(/class="\s?gfm gfm-#{css}\s?"/)
+ expect(gfm(actual)).to match(/class="\s?gfm gfm-#{css}\s?"/)
end
end
@@ -307,36 +307,36 @@ describe GitlabMarkdownHelper do
end
it "should link using a valid id" do
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should link with adjacent text" do
# Wrap the reference in parenthesis
- gfm(actual.gsub(reference, "(#{reference})")).should match(expected)
+ expect(gfm(actual.gsub(reference, "(#{reference})"))).to match(expected)
# Append some text to the end of the reference
- gfm(actual.gsub(reference, "#{reference}, right?")).should match(expected)
+ expect(gfm(actual.gsub(reference, "#{reference}, right?"))).to match(expected)
end
it "should keep whitespace intact" do
actual = "Referenced #{reference} already."
expected = /Referenced <a.+>[^\s]+<\/a> already/
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should not link with an invalid id" do
# Modify the reference string so it's still parsed, but is invalid
invalid_reference = actual.gsub(/(\d+)$/, "r45")
- gfm(invalid_reference).should == invalid_reference
+ expect(gfm(invalid_reference)).to eq(invalid_reference)
end
it "should include a title attribute" do
title = "Issue in JIRA tracker"
- gfm(actual).should match(/title="#{title}"/)
+ expect(gfm(actual)).to match(/title="#{title}"/)
end
it "should include standard gfm classes" do
- gfm(actual).should match(/class="\s?gfm gfm-issue\s?"/)
+ expect(gfm(actual)).to match(/class="\s?gfm gfm-issue\s?"/)
end
end
@@ -354,37 +354,37 @@ describe GitlabMarkdownHelper do
let(:expected) { project_snippet_path(project, object) }
it "should link using a valid id" do
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should link with adjacent text" do
# Wrap the reference in parenthesis
- gfm(actual.gsub(reference, "(#{reference})")).should match(expected)
+ expect(gfm(actual.gsub(reference, "(#{reference})"))).to match(expected)
# Append some text to the end of the reference
- gfm(actual.gsub(reference, "#{reference}, right?")).should match(expected)
+ expect(gfm(actual.gsub(reference, "#{reference}, right?"))).to match(expected)
end
it "should keep whitespace intact" do
actual = "Referenced #{reference} already."
expected = /Referenced <a.+>[^\s]+<\/a> already/
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should not link with an invalid id" do
# Modify the reference string so it's still parsed, but is invalid
reference.gsub!(/^(.)(\d+)$/, '\1' + ('\2' * 2))
- gfm(actual).should == actual
+ expect(gfm(actual)).to eq(actual)
end
it "should include a title attribute" do
title = "Snippet: #{object.title}"
- gfm(actual).should match(/title="#{title}"/)
+ expect(gfm(actual)).to match(/title="#{title}"/)
end
it "should include standard gfm classes" do
css = object.class.to_s.underscore
- gfm(actual).should match(/class="\s?gfm gfm-snippet\s?"/)
+ expect(gfm(actual)).to match(/class="\s?gfm gfm-snippet\s?"/)
end
end
@@ -394,63 +394,63 @@ describe GitlabMarkdownHelper do
it "should link to the merge request" do
expected = project_merge_request_path(project, merge_request)
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should link to the commit" do
expected = project_commit_path(project, commit)
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
it "should link to the issue" do
expected = project_issue_path(project, issue)
- gfm(actual).should match(expected)
+ expect(gfm(actual)).to match(expected)
end
end
describe "emoji" do
it "matches at the start of a string" do
- gfm(":+1:").should match(/<img/)
+ expect(gfm(":+1:")).to match(/<img/)
end
it "matches at the end of a string" do
- gfm("This gets a :-1:").should match(/<img/)
+ expect(gfm("This gets a :-1:")).to match(/<img/)
end
it "matches with adjacent text" do
- gfm("+1 (:+1:)").should match(/<img/)
+ expect(gfm("+1 (:+1:)")).to match(/<img/)
end
it "has a title attribute" do
- gfm(":-1:").should match(/title=":-1:"/)
+ expect(gfm(":-1:")).to match(/title=":-1:"/)
end
it "has an alt attribute" do
- gfm(":-1:").should match(/alt=":-1:"/)
+ expect(gfm(":-1:")).to match(/alt=":-1:"/)
end
it "has an emoji class" do
- gfm(":+1:").should match('class="emoji"')
+ expect(gfm(":+1:")).to match('class="emoji"')
end
it "sets height and width" do
actual = gfm(":+1:")
- actual.should match(/width="20"/)
- actual.should match(/height="20"/)
+ expect(actual).to match(/width="20"/)
+ expect(actual).to match(/height="20"/)
end
it "keeps whitespace intact" do
- gfm('This deserves a :+1: big time.').
- should match(/deserves a <img.+> big time/)
+ expect(gfm('This deserves a :+1: big time.')).
+ to match(/deserves a <img.+> big time/)
end
it "ignores invalid emoji" do
- gfm(":invalid-emoji:").should_not match(/<img/)
+ expect(gfm(":invalid-emoji:")).not_to match(/<img/)
end
it "should work independent of reference links (i.e. without @project being set)" do
@project = nil
- gfm(":+1:").should match(/<img/)
+ expect(gfm(":+1:")).to match(/<img/)
end
end
end
@@ -467,34 +467,34 @@ describe GitlabMarkdownHelper do
groups = actual.split("</a>")
# Leading commit link
- groups[0].should match(/href="#{commit_path}"/)
- groups[0].should match(/This should finally fix $/)
+ expect(groups[0]).to match(/href="#{commit_path}"/)
+ expect(groups[0]).to match(/This should finally fix $/)
# First issue link
- groups[1].should match(/href="#{project_issue_url(project, issues[0])}"/)
- groups[1].should match(/##{issues[0].iid}$/)
+ expect(groups[1]).to match(/href="#{project_issue_url(project, issues[0])}"/)
+ expect(groups[1]).to match(/##{issues[0].iid}$/)
# Internal commit link
- groups[2].should match(/href="#{commit_path}"/)
- groups[2].should match(/ and /)
+ expect(groups[2]).to match(/href="#{commit_path}"/)
+ expect(groups[2]).to match(/ and /)
# Second issue link
- groups[3].should match(/href="#{project_issue_url(project, issues[1])}"/)
- groups[3].should match(/##{issues[1].iid}$/)
+ expect(groups[3]).to match(/href="#{project_issue_url(project, issues[1])}"/)
+ expect(groups[3]).to match(/##{issues[1].iid}$/)
# Trailing commit link
- groups[4].should match(/href="#{commit_path}"/)
- groups[4].should match(/ for real$/)
+ expect(groups[4]).to match(/href="#{commit_path}"/)
+ expect(groups[4]).to match(/ for real$/)
end
it "should forward HTML options" do
actual = link_to_gfm("Fixed in #{commit.id}", commit_path, class: 'foo')
- actual.should have_selector 'a.gfm.gfm-commit.foo'
+ expect(actual).to have_selector 'a.gfm.gfm-commit.foo'
end
it "escapes HTML passed in as the body" do
actual = "This is a <h1>test</h1> - see ##{issues[0].iid}"
- link_to_gfm(actual, commit_path).should match('&lt;h1&gt;test&lt;/h1&gt;')
+ expect(link_to_gfm(actual, commit_path)).to match('&lt;h1&gt;test&lt;/h1&gt;')
end
end
@@ -502,25 +502,25 @@ describe GitlabMarkdownHelper do
it "should handle references in paragraphs" do
actual = "\n\nLorem ipsum dolor sit amet. #{commit.id} Nam pulvinar sapien eget.\n"
expected = project_commit_path(project, commit)
- markdown(actual).should match(expected)
+ expect(markdown(actual)).to match(expected)
end
it "should handle references in headers" do
actual = "\n# Working around ##{issue.iid}\n## Apply !#{merge_request.iid}"
- markdown(actual, {no_header_anchors:true}).should match(%r{<h1[^<]*>Working around <a.+>##{issue.iid}</a></h1>})
- markdown(actual, {no_header_anchors:true}).should match(%r{<h2[^<]*>Apply <a.+>!#{merge_request.iid}</a></h2>})
+ expect(markdown(actual, {no_header_anchors:true})).to match(%r{<h1[^<]*>Working around <a.+>##{issue.iid}</a></h1>})
+ expect(markdown(actual, {no_header_anchors:true})).to match(%r{<h2[^<]*>Apply <a.+>!#{merge_request.iid}</a></h2>})
end
it "should add ids and links to headers" do
# Test every rule except nested tags.
text = '..Ab_c-d. e..'
id = 'ab_c-d-e'
- markdown("# #{text}").should match(%r{<h1 id="#{id}">#{text}<a href="[^"]*##{id}"></a></h1>})
- markdown("# #{text}", {no_header_anchors:true}).should == "<h1>#{text}</h1>"
+ expect(markdown("# #{text}")).to match(%r{<h1 id="#{id}">#{text}<a href="[^"]*##{id}"></a></h1>})
+ expect(markdown("# #{text}", {no_header_anchors:true})).to eq("<h1>#{text}</h1>")
id = 'link-text'
- markdown("# [link text](url) ![img alt](url)").should match(
+ expect(markdown("# [link text](url) ![img alt](url)")).to match(
%r{<h1 id="#{id}"><a href="[^"]*url">link text</a> <img[^>]*><a href="[^"]*##{id}"></a></h1>}
)
end
@@ -530,32 +530,32 @@ describe GitlabMarkdownHelper do
actual = "\n* dark: ##{issue.iid}\n* light by @#{member.user.username}"
- markdown(actual).should match(%r{<li>dark: <a.+>##{issue.iid}</a></li>})
- markdown(actual).should match(%r{<li>light by <a.+>@#{member.user.username}</a></li>})
+ expect(markdown(actual)).to match(%r{<li>dark: <a.+>##{issue.iid}</a></li>})
+ expect(markdown(actual)).to match(%r{<li>light by <a.+>@#{member.user.username}</a></li>})
end
it "should not link the apostrophe to issue 39" do
project.team << [user, :master]
- project.issues.stub(:where).with(iid: '39').and_return([issue])
+ allow(project.issues).to receive(:where).with(iid: '39').and_return([issue])
actual = "Yes, it is @#{member.user.username}'s task."
expected = /Yes, it is <a.+>@#{member.user.username}<\/a>'s task/
- markdown(actual).should match(expected)
+ expect(markdown(actual)).to match(expected)
end
it "should not link the apostrophe to issue 39 in code blocks" do
project.team << [user, :master]
- project.issues.stub(:where).with(iid: '39').and_return([issue])
+ allow(project.issues).to receive(:where).with(iid: '39').and_return([issue])
actual = "Yes, `it is @#{member.user.username}'s task.`"
expected = /Yes, <code>it is @gfm\'s task.<\/code>/
- markdown(actual).should match(expected)
+ expect(markdown(actual)).to match(expected)
end
it "should handle references in <em>" do
actual = "Apply _!#{merge_request.iid}_ ASAP"
- markdown(actual).should match(%r{Apply <em><a.+>!#{merge_request.iid}</a></em>})
+ expect(markdown(actual)).to match(%r{Apply <em><a.+>!#{merge_request.iid}</a></em>})
end
it "should handle tables" do
@@ -564,91 +564,92 @@ describe GitlabMarkdownHelper do
| cell 1 | cell 2 |
| cell 3 | cell 4 |}
- markdown(actual).should match(/\A<table/)
+ expect(markdown(actual)).to match(/\A<table/)
end
it "should leave code blocks untouched" do
- helper.stub(:user_color_scheme_class).and_return(:white)
+ allow(helper).to receive(:user_color_scheme_class).and_return(:white)
target_html = "<pre class=\"code highlight white plaintext\"><code>some code from $40\nhere too\n</code></pre>\n"
- helper.markdown("\n some code from $#{snippet.id}\n here too\n").should == target_html
- helper.markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n").should == target_html
+ expect(helper.markdown("\n some code from $#{snippet.id}\n here too\n")).to eq(target_html)
+ expect(helper.markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n")).to eq(target_html)
end
it "should leave inline code untouched" do
- markdown("\nDon't use `$#{snippet.id}` here.\n").should ==
+ expect(markdown("\nDon't use `$#{snippet.id}` here.\n")).to eq(
"<p>Don't use <code>$#{snippet.id}</code> here.</p>\n"
+ )
end
it "should leave ref-like autolinks untouched" do
- markdown("look at http://example.tld/#!#{merge_request.iid}").should == "<p>look at <a href=\"http://example.tld/#!#{merge_request.iid}\">http://example.tld/#!#{merge_request.iid}</a></p>\n"
+ expect(markdown("look at http://example.tld/#!#{merge_request.iid}")).to eq("<p>look at <a href=\"http://example.tld/#!#{merge_request.iid}\">http://example.tld/#!#{merge_request.iid}</a></p>\n")
end
it "should leave ref-like href of 'manual' links untouched" do
- markdown("why not [inspect !#{merge_request.iid}](http://example.tld/#!#{merge_request.iid})").should == "<p>why not <a href=\"http://example.tld/#!#{merge_request.iid}\">inspect </a><a class=\"gfm gfm-merge_request \" href=\"#{project_merge_request_url(project, merge_request)}\" title=\"Merge Request: #{merge_request.title}\">!#{merge_request.iid}</a><a href=\"http://example.tld/#!#{merge_request.iid}\"></a></p>\n"
+ expect(markdown("why not [inspect !#{merge_request.iid}](http://example.tld/#!#{merge_request.iid})")).to eq("<p>why not <a href=\"http://example.tld/#!#{merge_request.iid}\">inspect </a><a class=\"gfm gfm-merge_request \" href=\"#{project_merge_request_url(project, merge_request)}\" title=\"Merge Request: #{merge_request.title}\">!#{merge_request.iid}</a><a href=\"http://example.tld/#!#{merge_request.iid}\"></a></p>\n")
end
it "should leave ref-like src of images untouched" do
- markdown("screen shot: ![some image](http://example.tld/#!#{merge_request.iid})").should == "<p>screen shot: <img src=\"http://example.tld/#!#{merge_request.iid}\" alt=\"some image\"></p>\n"
+ expect(markdown("screen shot: ![some image](http://example.tld/#!#{merge_request.iid})")).to eq("<p>screen shot: <img src=\"http://example.tld/#!#{merge_request.iid}\" alt=\"some image\"></p>\n")
end
it "should generate absolute urls for refs" do
- markdown("##{issue.iid}").should include(project_issue_url(project, issue))
+ expect(markdown("##{issue.iid}")).to include(project_issue_url(project, issue))
end
it "should generate absolute urls for emoji" do
- markdown(':smile:').should(
+ expect(markdown(':smile:')).to(
include(%(src="#{Gitlab.config.gitlab.url}/assets/emoji/smile.png))
)
end
it "should generate absolute urls for emoji if relative url is present" do
- Gitlab.config.gitlab.stub(:url).and_return('http://localhost/gitlab/root')
- markdown(":smile:").should include("src=\"http://localhost/gitlab/root/assets/emoji/smile.png")
+ allow(Gitlab.config.gitlab).to receive(:url).and_return('http://localhost/gitlab/root')
+ expect(markdown(":smile:")).to include("src=\"http://localhost/gitlab/root/assets/emoji/smile.png")
end
it "should generate absolute urls for emoji if asset_host is present" do
- Gitlab::Application.config.stub(:asset_host).and_return("https://cdn.example.com")
+ allow(Gitlab::Application.config).to receive(:asset_host).and_return("https://cdn.example.com")
ActionView::Base.any_instance.stub_chain(:config, :asset_host).and_return("https://cdn.example.com")
- markdown(":smile:").should include("src=\"https://cdn.example.com/assets/emoji/smile.png")
+ expect(markdown(":smile:")).to include("src=\"https://cdn.example.com/assets/emoji/smile.png")
end
it "should handle relative urls for a file in master" do
actual = "[GitLab API doc](doc/api/README.md)\n"
expected = "<p><a href=\"/#{project.path_with_namespace}/blob/#{@ref}/doc/api/README.md\">GitLab API doc</a></p>\n"
- markdown(actual).should match(expected)
+ expect(markdown(actual)).to match(expected)
end
it "should handle relative urls for a directory in master" do
actual = "[GitLab API doc](doc/api)\n"
expected = "<p><a href=\"/#{project.path_with_namespace}/tree/#{@ref}/doc/api\">GitLab API doc</a></p>\n"
- markdown(actual).should match(expected)
+ expect(markdown(actual)).to match(expected)
end
it "should handle absolute urls" do
actual = "[GitLab](https://www.gitlab.com)\n"
expected = "<p><a href=\"https://www.gitlab.com\">GitLab</a></p>\n"
- markdown(actual).should match(expected)
+ expect(markdown(actual)).to match(expected)
end
it "should handle relative urls in reference links for a file in master" do
actual = "[GitLab API doc][GitLab readme]\n [GitLab readme]: doc/api/README.md\n"
expected = "<p><a href=\"/#{project.path_with_namespace}/blob/#{@ref}/doc/api/README.md\">GitLab API doc</a></p>\n"
- markdown(actual).should match(expected)
+ expect(markdown(actual)).to match(expected)
end
it "should handle relative urls in reference links for a directory in master" do
actual = "[GitLab API doc directory][GitLab readmes]\n [GitLab readmes]: doc/api/\n"
expected = "<p><a href=\"/#{project.path_with_namespace}/tree/#{@ref}/doc/api\">GitLab API doc directory</a></p>\n"
- markdown(actual).should match(expected)
+ expect(markdown(actual)).to match(expected)
end
it "should not handle malformed relative urls in reference links for a file in master" do
actual = "[GitLab readme]: doc/api/README.md\n"
expected = ""
- markdown(actual).should match(expected)
+ expect(markdown(actual)).to match(expected)
end
end
@@ -661,29 +662,29 @@ describe GitlabMarkdownHelper do
it "should not touch relative urls" do
actual = "[GitLab API doc][GitLab readme]\n [GitLab readme]: doc/api/README.md\n"
expected = "<p><a href=\"doc/api/README.md\">GitLab API doc</a></p>\n"
- markdown(actual).should match(expected)
+ expect(markdown(actual)).to match(expected)
end
end
describe "#render_wiki_content" do
before do
@wiki = double('WikiPage')
- @wiki.stub(:content).and_return('wiki content')
+ allow(@wiki).to receive(:content).and_return('wiki content')
end
it "should use GitLab Flavored Markdown for markdown files" do
- @wiki.stub(:format).and_return(:markdown)
+ allow(@wiki).to receive(:format).and_return(:markdown)
- helper.should_receive(:markdown).with('wiki content')
+ expect(helper).to receive(:markdown).with('wiki content')
helper.render_wiki_content(@wiki)
end
it "should use the Gollum renderer for all other file types" do
- @wiki.stub(:format).and_return(:rdoc)
+ allow(@wiki).to receive(:format).and_return(:rdoc)
formatted_content_stub = double('formatted_content')
- formatted_content_stub.should_receive(:html_safe)
- @wiki.stub(:formatted_content).and_return(formatted_content_stub)
+ expect(formatted_content_stub).to receive(:html_safe)
+ allow(@wiki).to receive(:formatted_content).and_return(formatted_content_stub)
helper.render_wiki_content(@wiki)
end
diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb
index ebcc26852cc..7a8fd25e02d 100644
--- a/spec/helpers/issues_helper_spec.rb
+++ b/spec/helpers/issues_helper_spec.rb
@@ -8,18 +8,18 @@ describe IssuesHelper do
describe "title_for_issue" do
it "should return issue title if used internal tracker" do
@project = project
- title_for_issue(issue.iid).should eq issue.title
+ expect(title_for_issue(issue.iid)).to eq issue.title
end
it "should always return empty string if used external tracker" do
@project = ext_project
- title_for_issue(rand(100)).should eq ""
+ expect(title_for_issue(rand(100))).to eq ""
end
it "should always return empty string if project nil" do
@project = nil
- title_for_issue(rand(100)).should eq ""
+ expect(title_for_issue(rand(100))).to eq ""
end
end
@@ -33,29 +33,29 @@ describe IssuesHelper do
it "should return internal path if used internal tracker" do
@project = project
- url_for_project_issues.should match(int_expected)
+ expect(url_for_project_issues).to match(int_expected)
end
it "should return path to external tracker" do
@project = ext_project
- url_for_project_issues.should match(ext_expected)
+ expect(url_for_project_issues).to match(ext_expected)
end
it "should return empty string if project nil" do
@project = nil
- url_for_project_issues.should eq ""
+ expect(url_for_project_issues).to eq ""
end
describe "when external tracker was enabled and then config removed" do
before do
@project = ext_project
- Gitlab.config.stub(:issues_tracker).and_return(nil)
+ allow(Gitlab.config).to receive(:issues_tracker).and_return(nil)
end
it "should return path to external tracker" do
- url_for_project_issues.should match(ext_expected)
+ expect(url_for_project_issues).to match(ext_expected)
end
end
end
@@ -71,34 +71,34 @@ describe IssuesHelper do
it "should return internal path if used internal tracker" do
@project = project
- url_for_issue(issue.iid).should match(int_expected)
+ expect(url_for_issue(issue.iid)).to match(int_expected)
end
it "should return path to external tracker" do
@project = ext_project
- url_for_issue(issue.iid).should match(ext_expected)
+ expect(url_for_issue(issue.iid)).to match(ext_expected)
end
it "should return empty string if project nil" do
@project = nil
- url_for_issue(issue.iid).should eq ""
+ expect(url_for_issue(issue.iid)).to eq ""
end
describe "when external tracker was enabled and then config removed" do
before do
@project = ext_project
- Gitlab.config.stub(:issues_tracker).and_return(nil)
+ allow(Gitlab.config).to receive(:issues_tracker).and_return(nil)
end
it "should return external path" do
- url_for_issue(issue.iid).should match(ext_expected)
+ expect(url_for_issue(issue.iid)).to match(ext_expected)
end
end
end
- describe :url_for_new_issue do
+ describe '#url_for_new_issue' do
let(:issues_url) { ext_project.external_issue_tracker.new_issue_url }
let(:ext_expected) do
issues_url.gsub(':project_id', ext_project.id.to_s)
@@ -108,29 +108,29 @@ describe IssuesHelper do
it "should return internal path if used internal tracker" do
@project = project
- url_for_new_issue.should match(int_expected)
+ expect(url_for_new_issue).to match(int_expected)
end
it "should return path to external tracker" do
@project = ext_project
- url_for_new_issue.should match(ext_expected)
+ expect(url_for_new_issue).to match(ext_expected)
end
it "should return empty string if project nil" do
@project = nil
- url_for_new_issue.should eq ""
+ expect(url_for_new_issue).to eq ""
end
describe "when external tracker was enabled and then config removed" do
before do
@project = ext_project
- Gitlab.config.stub(:issues_tracker).and_return(nil)
+ allow(Gitlab.config).to receive(:issues_tracker).and_return(nil)
end
it "should return internal path" do
- url_for_new_issue.should match(ext_expected)
+ expect(url_for_new_issue).to match(ext_expected)
end
end
end
diff --git a/spec/helpers/merge_requests_helper.rb b/spec/helpers/merge_requests_helper.rb
index 5a317c4886b..5262d644048 100644
--- a/spec/helpers/merge_requests_helper.rb
+++ b/spec/helpers/merge_requests_helper.rb
@@ -7,6 +7,6 @@ describe MergeRequestsHelper do
[build(:issue, iid: 1), build(:issue, iid: 2), build(:issue, iid: 3)]
end
- it { should eq('#1, #2, and #3') }
+ it { is_expected.to eq('#1, #2, and #3') }
end
end
diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb
index dcc3318e4f9..482cb33e94f 100644
--- a/spec/helpers/notifications_helper_spec.rb
+++ b/spec/helpers/notifications_helper_spec.rb
@@ -11,7 +11,7 @@ describe NotificationsHelper do
before { notification.stub(disabled?: true) }
it "has a red icon" do
- notification_icon(notification).should match('class="fa fa-volume-off ns-mute"')
+ expect(notification_icon(notification)).to match('class="fa fa-volume-off ns-mute"')
end
end
@@ -19,7 +19,7 @@ describe NotificationsHelper do
before { notification.stub(participating?: true) }
it "has a blue icon" do
- notification_icon(notification).should match('class="fa fa-volume-down ns-part"')
+ expect(notification_icon(notification)).to match('class="fa fa-volume-down ns-part"')
end
end
@@ -27,12 +27,12 @@ describe NotificationsHelper do
before { notification.stub(watch?: true) }
it "has a green icon" do
- notification_icon(notification).should match('class="fa fa-volume-up ns-watch"')
+ expect(notification_icon(notification)).to match('class="fa fa-volume-up ns-watch"')
end
end
it "has a blue icon" do
- notification_icon(notification).should match('class="fa fa-circle-o ns-default"')
+ expect(notification_icon(notification)).to match('class="fa fa-circle-o ns-default"')
end
end
end
diff --git a/spec/helpers/oauth_helper_spec.rb b/spec/helpers/oauth_helper_spec.rb
index 453699136e9..088c342fa13 100644
--- a/spec/helpers/oauth_helper_spec.rb
+++ b/spec/helpers/oauth_helper_spec.rb
@@ -4,17 +4,17 @@ describe OauthHelper do
describe "additional_providers" do
it 'returns all enabled providers' do
allow(helper).to receive(:enabled_oauth_providers) { [:twitter, :github] }
- helper.additional_providers.should include(*[:twitter, :github])
+ expect(helper.additional_providers).to include(*[:twitter, :github])
end
it 'does not return ldap provider' do
allow(helper).to receive(:enabled_oauth_providers) { [:twitter, :ldapmain] }
- helper.additional_providers.should include(:twitter)
+ expect(helper.additional_providers).to include(:twitter)
end
it 'returns empty array' do
allow(helper).to receive(:enabled_oauth_providers) { [] }
- helper.additional_providers.should == []
+ expect(helper.additional_providers).to eq([])
end
end
end \ No newline at end of file
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb
index 281d4862199..0f78725e3d9 100644
--- a/spec/helpers/projects_helper_spec.rb
+++ b/spec/helpers/projects_helper_spec.rb
@@ -3,9 +3,9 @@ require 'spec_helper'
describe ProjectsHelper do
describe "#project_status_css_class" do
it "returns appropriate class" do
- project_status_css_class("started").should == "active"
- project_status_css_class("failed").should == "danger"
- project_status_css_class("finished").should == "success"
+ expect(project_status_css_class("started")).to eq("active")
+ expect(project_status_css_class("failed")).to eq("danger")
+ expect(project_status_css_class("finished")).to eq("success")
end
end
end
diff --git a/spec/helpers/search_helper_spec.rb b/spec/helpers/search_helper_spec.rb
index 733f2754727..b327f4f911a 100644
--- a/spec/helpers/search_helper_spec.rb
+++ b/spec/helpers/search_helper_spec.rb
@@ -13,7 +13,7 @@ describe SearchHelper do
end
it "it returns nil" do
- search_autocomplete_opts("q").should be_nil
+ expect(search_autocomplete_opts("q")).to be_nil
end
end
@@ -25,29 +25,29 @@ describe SearchHelper do
end
it "includes Help sections" do
- search_autocomplete_opts("hel").size.should == 9
+ expect(search_autocomplete_opts("hel").size).to eq(9)
end
it "includes default sections" do
- search_autocomplete_opts("adm").size.should == 1
+ expect(search_autocomplete_opts("adm").size).to eq(1)
end
it "includes the user's groups" do
create(:group).add_owner(user)
- search_autocomplete_opts("gro").size.should == 1
+ expect(search_autocomplete_opts("gro").size).to eq(1)
end
it "includes the user's projects" do
project = create(:project, namespace: create(:namespace, owner: user))
- search_autocomplete_opts(project.name).size.should == 1
+ expect(search_autocomplete_opts(project.name).size).to eq(1)
end
context "with a current project" do
before { @project = create(:project) }
it "includes project-specific sections" do
- search_autocomplete_opts("Files").size.should == 1
- search_autocomplete_opts("Commits").size.should == 1
+ expect(search_autocomplete_opts("Files").size).to eq(1)
+ expect(search_autocomplete_opts("Commits").size).to eq(1)
end
end
end
diff --git a/spec/helpers/submodule_helper_spec.rb b/spec/helpers/submodule_helper_spec.rb
index 41c9f038c26..3d80dc9d0a4 100644
--- a/spec/helpers/submodule_helper_spec.rb
+++ b/spec/helpers/submodule_helper_spec.rb
@@ -19,28 +19,28 @@ describe SubmoduleHelper do
Gitlab.config.gitlab_shell.stub(ssh_port: 22) # set this just to be sure
Gitlab.config.gitlab_shell.stub(ssh_path_prefix: Settings.send(:build_gitlab_shell_ssh_path_prefix))
stub_url([ config.user, '@', config.host, ':gitlab-org/gitlab-ce.git' ].join(''))
- submodule_links(submodule_item).should == [ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ]
+ expect(submodule_links(submodule_item)).to eq([ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ])
end
it 'should detect ssh on non-standard port' do
Gitlab.config.gitlab_shell.stub(ssh_port: 2222)
Gitlab.config.gitlab_shell.stub(ssh_path_prefix: Settings.send(:build_gitlab_shell_ssh_path_prefix))
stub_url([ 'ssh://', config.user, '@', config.host, ':2222/gitlab-org/gitlab-ce.git' ].join(''))
- submodule_links(submodule_item).should == [ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ]
+ expect(submodule_links(submodule_item)).to eq([ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ])
end
it 'should detect http on standard port' do
Gitlab.config.gitlab.stub(port: 80)
Gitlab.config.gitlab.stub(url: Settings.send(:build_gitlab_url))
stub_url([ 'http://', config.host, '/gitlab-org/gitlab-ce.git' ].join(''))
- submodule_links(submodule_item).should == [ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ]
+ expect(submodule_links(submodule_item)).to eq([ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ])
end
it 'should detect http on non-standard port' do
Gitlab.config.gitlab.stub(port: 3000)
Gitlab.config.gitlab.stub(url: Settings.send(:build_gitlab_url))
stub_url([ 'http://', config.host, ':3000/gitlab-org/gitlab-ce.git' ].join(''))
- submodule_links(submodule_item).should == [ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ]
+ expect(submodule_links(submodule_item)).to eq([ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ])
end
it 'should work with relative_url_root' do
@@ -48,67 +48,67 @@ describe SubmoduleHelper do
Gitlab.config.gitlab.stub(relative_url_root: '/gitlab/root')
Gitlab.config.gitlab.stub(url: Settings.send(:build_gitlab_url))
stub_url([ 'http://', config.host, '/gitlab/root/gitlab-org/gitlab-ce.git' ].join(''))
- submodule_links(submodule_item).should == [ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ]
+ expect(submodule_links(submodule_item)).to eq([ project_path('gitlab-org/gitlab-ce'), project_tree_path('gitlab-org/gitlab-ce', 'hash') ])
end
end
context 'submodule on github.com' do
it 'should detect ssh' do
stub_url('git@github.com:gitlab-org/gitlab-ce.git')
- submodule_links(submodule_item).should == [ 'https://github.com/gitlab-org/gitlab-ce', 'https://github.com/gitlab-org/gitlab-ce/tree/hash' ]
+ expect(submodule_links(submodule_item)).to eq([ 'https://github.com/gitlab-org/gitlab-ce', 'https://github.com/gitlab-org/gitlab-ce/tree/hash' ])
end
it 'should detect http' do
stub_url('http://github.com/gitlab-org/gitlab-ce.git')
- submodule_links(submodule_item).should == [ 'https://github.com/gitlab-org/gitlab-ce', 'https://github.com/gitlab-org/gitlab-ce/tree/hash' ]
+ expect(submodule_links(submodule_item)).to eq([ 'https://github.com/gitlab-org/gitlab-ce', 'https://github.com/gitlab-org/gitlab-ce/tree/hash' ])
end
it 'should detect https' do
stub_url('https://github.com/gitlab-org/gitlab-ce.git')
- submodule_links(submodule_item).should == [ 'https://github.com/gitlab-org/gitlab-ce', 'https://github.com/gitlab-org/gitlab-ce/tree/hash' ]
+ expect(submodule_links(submodule_item)).to eq([ 'https://github.com/gitlab-org/gitlab-ce', 'https://github.com/gitlab-org/gitlab-ce/tree/hash' ])
end
it 'should return original with non-standard url' do
stub_url('http://github.com/gitlab-org/gitlab-ce')
- submodule_links(submodule_item).should == [ repo.submodule_url_for, nil ]
+ expect(submodule_links(submodule_item)).to eq([ repo.submodule_url_for, nil ])
stub_url('http://github.com/another/gitlab-org/gitlab-ce.git')
- submodule_links(submodule_item).should == [ repo.submodule_url_for, nil ]
+ expect(submodule_links(submodule_item)).to eq([ repo.submodule_url_for, nil ])
end
end
context 'submodule on gitlab.com' do
it 'should detect ssh' do
stub_url('git@gitlab.com:gitlab-org/gitlab-ce.git')
- submodule_links(submodule_item).should == [ 'https://gitlab.com/gitlab-org/gitlab-ce', 'https://gitlab.com/gitlab-org/gitlab-ce/tree/hash' ]
+ expect(submodule_links(submodule_item)).to eq([ 'https://gitlab.com/gitlab-org/gitlab-ce', 'https://gitlab.com/gitlab-org/gitlab-ce/tree/hash' ])
end
it 'should detect http' do
stub_url('http://gitlab.com/gitlab-org/gitlab-ce.git')
- submodule_links(submodule_item).should == [ 'https://gitlab.com/gitlab-org/gitlab-ce', 'https://gitlab.com/gitlab-org/gitlab-ce/tree/hash' ]
+ expect(submodule_links(submodule_item)).to eq([ 'https://gitlab.com/gitlab-org/gitlab-ce', 'https://gitlab.com/gitlab-org/gitlab-ce/tree/hash' ])
end
it 'should detect https' do
stub_url('https://gitlab.com/gitlab-org/gitlab-ce.git')
- submodule_links(submodule_item).should == [ 'https://gitlab.com/gitlab-org/gitlab-ce', 'https://gitlab.com/gitlab-org/gitlab-ce/tree/hash' ]
+ expect(submodule_links(submodule_item)).to eq([ 'https://gitlab.com/gitlab-org/gitlab-ce', 'https://gitlab.com/gitlab-org/gitlab-ce/tree/hash' ])
end
it 'should return original with non-standard url' do
stub_url('http://gitlab.com/gitlab-org/gitlab-ce')
- submodule_links(submodule_item).should == [ repo.submodule_url_for, nil ]
+ expect(submodule_links(submodule_item)).to eq([ repo.submodule_url_for, nil ])
stub_url('http://gitlab.com/another/gitlab-org/gitlab-ce.git')
- submodule_links(submodule_item).should == [ repo.submodule_url_for, nil ]
+ expect(submodule_links(submodule_item)).to eq([ repo.submodule_url_for, nil ])
end
end
context 'submodule on unsupported' do
it 'should return original' do
stub_url('http://mygitserver.com/gitlab-org/gitlab-ce')
- submodule_links(submodule_item).should == [ repo.submodule_url_for, nil ]
+ expect(submodule_links(submodule_item)).to eq([ repo.submodule_url_for, nil ])
stub_url('http://mygitserver.com/gitlab-org/gitlab-ce.git')
- submodule_links(submodule_item).should == [ repo.submodule_url_for, nil ]
+ expect(submodule_links(submodule_item)).to eq([ repo.submodule_url_for, nil ])
end
end
end
diff --git a/spec/helpers/tab_helper_spec.rb b/spec/helpers/tab_helper_spec.rb
index fa8a3f554f7..fc0ceecfbe7 100644
--- a/spec/helpers/tab_helper_spec.rb
+++ b/spec/helpers/tab_helper_spec.rb
@@ -5,40 +5,40 @@ describe TabHelper do
describe 'nav_link' do
before do
- controller.stub(:controller_name).and_return('foo')
+ allow(controller).to receive(:controller_name).and_return('foo')
allow(self).to receive(:action_name).and_return('foo')
end
it "captures block output" do
- nav_link { "Testing Blocks" }.should match(/Testing Blocks/)
+ expect(nav_link { "Testing Blocks" }).to match(/Testing Blocks/)
end
it "performs checks on the current controller" do
- nav_link(controller: :foo).should match(/<li class="active">/)
- nav_link(controller: :bar).should_not match(/active/)
- nav_link(controller: [:foo, :bar]).should match(/active/)
+ expect(nav_link(controller: :foo)).to match(/<li class="active">/)
+ expect(nav_link(controller: :bar)).not_to match(/active/)
+ expect(nav_link(controller: [:foo, :bar])).to match(/active/)
end
it "performs checks on the current action" do
- nav_link(action: :foo).should match(/<li class="active">/)
- nav_link(action: :bar).should_not match(/active/)
- nav_link(action: [:foo, :bar]).should match(/active/)
+ expect(nav_link(action: :foo)).to match(/<li class="active">/)
+ expect(nav_link(action: :bar)).not_to match(/active/)
+ expect(nav_link(action: [:foo, :bar])).to match(/active/)
end
it "performs checks on both controller and action when both are present" do
- nav_link(controller: :bar, action: :foo).should_not match(/active/)
- nav_link(controller: :foo, action: :bar).should_not match(/active/)
- nav_link(controller: :foo, action: :foo).should match(/active/)
+ expect(nav_link(controller: :bar, action: :foo)).not_to match(/active/)
+ expect(nav_link(controller: :foo, action: :bar)).not_to match(/active/)
+ expect(nav_link(controller: :foo, action: :foo)).to match(/active/)
end
it "accepts a path shorthand" do
- nav_link(path: 'foo#bar').should_not match(/active/)
- nav_link(path: 'foo#foo').should match(/active/)
+ expect(nav_link(path: 'foo#bar')).not_to match(/active/)
+ expect(nav_link(path: 'foo#foo')).to match(/active/)
end
it "passes extra html options to the list element" do
- nav_link(action: :foo, html_options: {class: 'home'}).should match(/<li class="home active">/)
- nav_link(html_options: {class: 'active'}).should match(/<li class="active">/)
+ expect(nav_link(action: :foo, html_options: {class: 'home'})).to match(/<li class="home active">/)
+ expect(nav_link(html_options: {class: 'active'})).to match(/<li class="active">/)
end
end
end
diff --git a/spec/helpers/tree_helper_spec.rb b/spec/helpers/tree_helper_spec.rb
index 8aa50c4c778..8271e00f41b 100644
--- a/spec/helpers/tree_helper_spec.rb
+++ b/spec/helpers/tree_helper_spec.rb
@@ -13,7 +13,7 @@ describe TreeHelper do
let(:tree_item) { double(name: "files", path: "files") }
it "should return the directory name" do
- flatten_tree(tree_item).should match('files')
+ expect(flatten_tree(tree_item)).to match('files')
end
end
@@ -21,7 +21,7 @@ describe TreeHelper do
let(:tree_item) { double(name: "foo", path: "foo") }
it "should return the flattened path" do
- flatten_tree(tree_item).should match('foo/bar')
+ expect(flatten_tree(tree_item)).to match('foo/bar')
end
end
end