diff options
Diffstat (limited to 'spec/lib')
27 files changed, 292 insertions, 290 deletions
diff --git a/spec/lib/disable_email_interceptor_spec.rb b/spec/lib/disable_email_interceptor_spec.rb index 8bf6ee2ed50..06d5450688b 100644 --- a/spec/lib/disable_email_interceptor_spec.rb +++ b/spec/lib/disable_email_interceptor_spec.rb @@ -6,7 +6,7 @@ describe DisableEmailInterceptor do end it 'should not send emails' do - Gitlab.config.gitlab.stub(:email_enabled).and_return(false) + allow(Gitlab.config.gitlab).to receive(:email_enabled).and_return(false) expect { deliver_mail }.not_to change(ActionMailer::Base.deliveries, :count) diff --git a/spec/lib/extracts_path_spec.rb b/spec/lib/extracts_path_spec.rb index 7b3818ea5c8..ac602eac154 100644 --- a/spec/lib/extracts_path_spec.rb +++ b/spec/lib/extracts_path_spec.rb @@ -14,44 +14,46 @@ describe ExtractsPath do describe '#extract_ref' do it "returns an empty pair when no @project is set" do @project = nil - extract_ref('master/CHANGELOG').should == ['', ''] + expect(extract_ref('master/CHANGELOG')).to eq(['', '']) end context "without a path" do it "extracts a valid branch" do - extract_ref('master').should == ['master', ''] + expect(extract_ref('master')).to eq(['master', '']) end it "extracts a valid tag" do - extract_ref('v2.0.0').should == ['v2.0.0', ''] + expect(extract_ref('v2.0.0')).to eq(['v2.0.0', '']) end it "extracts a valid commit ref without a path" do - extract_ref('f4b14494ef6abf3d144c28e4af0c20143383e062').should == + expect(extract_ref('f4b14494ef6abf3d144c28e4af0c20143383e062')).to eq( ['f4b14494ef6abf3d144c28e4af0c20143383e062', ''] + ) end it "falls back to a primitive split for an invalid ref" do - extract_ref('stable').should == ['stable', ''] + expect(extract_ref('stable')).to eq(['stable', '']) end end context "with a path" do it "extracts a valid branch" do - extract_ref('foo/bar/baz/CHANGELOG').should == ['foo/bar/baz', 'CHANGELOG'] + expect(extract_ref('foo/bar/baz/CHANGELOG')).to eq(['foo/bar/baz', 'CHANGELOG']) end it "extracts a valid tag" do - extract_ref('v2.0.0/CHANGELOG').should == ['v2.0.0', 'CHANGELOG'] + expect(extract_ref('v2.0.0/CHANGELOG')).to eq(['v2.0.0', 'CHANGELOG']) end it "extracts a valid commit SHA" do - extract_ref('f4b14494ef6abf3d144c28e4af0c20143383e062/CHANGELOG').should == + expect(extract_ref('f4b14494ef6abf3d144c28e4af0c20143383e062/CHANGELOG')).to eq( ['f4b14494ef6abf3d144c28e4af0c20143383e062', 'CHANGELOG'] + ) end it "falls back to a primitive split for an invalid ref" do - extract_ref('stable/CHANGELOG').should == ['stable', 'CHANGELOG'] + expect(extract_ref('stable/CHANGELOG')).to eq(['stable', 'CHANGELOG']) end end end diff --git a/spec/lib/git_ref_validator_spec.rb b/spec/lib/git_ref_validator_spec.rb index b2469c18395..4633b6f3934 100644 --- a/spec/lib/git_ref_validator_spec.rb +++ b/spec/lib/git_ref_validator_spec.rb @@ -1,20 +1,20 @@ require 'spec_helper' describe Gitlab::GitRefValidator do - it { Gitlab::GitRefValidator.validate('feature/new').should be_true } - it { Gitlab::GitRefValidator.validate('implement_@all').should be_true } - it { Gitlab::GitRefValidator.validate('my_new_feature').should be_true } - it { Gitlab::GitRefValidator.validate('#1').should be_true } - it { Gitlab::GitRefValidator.validate('feature/~new/').should be_false } - it { Gitlab::GitRefValidator.validate('feature/^new/').should be_false } - it { Gitlab::GitRefValidator.validate('feature/:new/').should be_false } - it { Gitlab::GitRefValidator.validate('feature/?new/').should be_false } - it { Gitlab::GitRefValidator.validate('feature/*new/').should be_false } - it { Gitlab::GitRefValidator.validate('feature/[new/').should be_false } - it { Gitlab::GitRefValidator.validate('feature/new/').should be_false } - it { Gitlab::GitRefValidator.validate('feature/new.').should be_false } - it { Gitlab::GitRefValidator.validate('feature\@{').should be_false } - it { Gitlab::GitRefValidator.validate('feature\new').should be_false } - it { Gitlab::GitRefValidator.validate('feature//new').should be_false } - it { Gitlab::GitRefValidator.validate('feature new').should be_false } + it { expect(Gitlab::GitRefValidator.validate('feature/new')).to be_truthy } + it { expect(Gitlab::GitRefValidator.validate('implement_@all')).to be_truthy } + it { expect(Gitlab::GitRefValidator.validate('my_new_feature')).to be_truthy } + it { expect(Gitlab::GitRefValidator.validate('#1')).to be_truthy } + it { expect(Gitlab::GitRefValidator.validate('feature/~new/')).to be_falsey } + it { expect(Gitlab::GitRefValidator.validate('feature/^new/')).to be_falsey } + it { expect(Gitlab::GitRefValidator.validate('feature/:new/')).to be_falsey } + it { expect(Gitlab::GitRefValidator.validate('feature/?new/')).to be_falsey } + it { expect(Gitlab::GitRefValidator.validate('feature/*new/')).to be_falsey } + it { expect(Gitlab::GitRefValidator.validate('feature/[new/')).to be_falsey } + it { expect(Gitlab::GitRefValidator.validate('feature/new/')).to be_falsey } + it { expect(Gitlab::GitRefValidator.validate('feature/new.')).to be_falsey } + it { expect(Gitlab::GitRefValidator.validate('feature\@{')).to be_falsey } + it { expect(Gitlab::GitRefValidator.validate('feature\new')).to be_falsey } + it { expect(Gitlab::GitRefValidator.validate('feature//new')).to be_falsey } + it { expect(Gitlab::GitRefValidator.validate('feature new')).to be_falsey } end diff --git a/spec/lib/gitlab/backend/shell_spec.rb b/spec/lib/gitlab/backend/shell_spec.rb index f00ec0fa401..27279465c1a 100644 --- a/spec/lib/gitlab/backend/shell_spec.rb +++ b/spec/lib/gitlab/backend/shell_spec.rb @@ -8,11 +8,11 @@ describe Gitlab::Shell do Project.stub(find: project) end - it { should respond_to :add_key } - it { should respond_to :remove_key } - it { should respond_to :add_repository } - it { should respond_to :remove_repository } - it { should respond_to :fork_repository } + it { is_expected.to respond_to :add_key } + it { is_expected.to respond_to :remove_key } + it { is_expected.to respond_to :add_repository } + it { is_expected.to respond_to :remove_repository } + it { is_expected.to respond_to :fork_repository } - it { gitlab_shell.url_to_repo('diaspora').should == Gitlab.config.gitlab_shell.ssh_path_prefix + "diaspora.git" } + it { expect(gitlab_shell.url_to_repo('diaspora')).to eq(Gitlab.config.gitlab_shell.ssh_path_prefix + "diaspora.git") } end diff --git a/spec/lib/gitlab/closing_issue_extractor_spec.rb b/spec/lib/gitlab/closing_issue_extractor_spec.rb index 0a1f3fa351d..c96ee78e5fd 100644 --- a/spec/lib/gitlab/closing_issue_extractor_spec.rb +++ b/spec/lib/gitlab/closing_issue_extractor_spec.rb @@ -9,122 +9,122 @@ describe Gitlab::ClosingIssueExtractor do context 'with a single reference' do it do message = "Awesome commit (Closes ##{iid1})" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end it do message = "Awesome commit (closes ##{iid1})" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end it do message = "Closed ##{iid1}" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end it do message = "closed ##{iid1}" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end it do message = "Closing ##{iid1}" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end it do message = "closing ##{iid1}" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end it do message = "Close ##{iid1}" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end it do message = "close ##{iid1}" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end it do message = "Awesome commit (Fixes ##{iid1})" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end it do message = "Awesome commit (fixes ##{iid1})" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end it do message = "Fixed ##{iid1}" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end it do message = "fixed ##{iid1}" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end it do message = "Fixing ##{iid1}" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end it do message = "fixing ##{iid1}" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end it do message = "Fix ##{iid1}" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end it do message = "fix ##{iid1}" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end it do message = "Awesome commit (Resolves ##{iid1})" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end it do message = "Awesome commit (resolves ##{iid1})" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end it do message = "Resolved ##{iid1}" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end it do message = "resolved ##{iid1}" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end it do message = "Resolving ##{iid1}" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end it do message = "resolving ##{iid1}" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end it do message = "Resolve ##{iid1}" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end it do message = "resolve ##{iid1}" - subject.closed_by_message_in_project(message, project).should == [issue] + expect(subject.closed_by_message_in_project(message, project)).to eq([issue]) end end @@ -137,37 +137,37 @@ describe Gitlab::ClosingIssueExtractor do it 'fetches issues in single line message' do message = "Closes ##{iid1} and fix ##{iid2}" - subject.closed_by_message_in_project(message, project). - should == [issue, other_issue] + expect(subject.closed_by_message_in_project(message, project)). + to eq([issue, other_issue]) end it 'fetches comma-separated issues references in single line message' do message = "Closes ##{iid1}, closes ##{iid2}" - subject.closed_by_message_in_project(message, project). - should == [issue, other_issue] + expect(subject.closed_by_message_in_project(message, project)). + to eq([issue, other_issue]) end it 'fetches comma-separated issues numbers in single line message' do message = "Closes ##{iid1}, ##{iid2} and ##{iid3}" - subject.closed_by_message_in_project(message, project). - should == [issue, other_issue, third_issue] + expect(subject.closed_by_message_in_project(message, project)). + to eq([issue, other_issue, third_issue]) end it 'fetches issues in multi-line message' do message = "Awesome commit (closes ##{iid1})\nAlso fixes ##{iid2}" - subject.closed_by_message_in_project(message, project). - should == [issue, other_issue] + expect(subject.closed_by_message_in_project(message, project)). + to eq([issue, other_issue]) end it 'fetches issues in hybrid message' do message = "Awesome commit (closes ##{iid1})\n"\ "Also fixing issues ##{iid2}, ##{iid3} and #4" - subject.closed_by_message_in_project(message, project). - should == [issue, other_issue, third_issue] + expect(subject.closed_by_message_in_project(message, project)). + to eq([issue, other_issue, third_issue]) end end end diff --git a/spec/lib/gitlab/diff/file_spec.rb b/spec/lib/gitlab/diff/file_spec.rb index cf0b5c282c1..40eb45e37ca 100644 --- a/spec/lib/gitlab/diff/file_spec.rb +++ b/spec/lib/gitlab/diff/file_spec.rb @@ -11,11 +11,11 @@ describe Gitlab::Diff::File do describe :diff_lines do let(:diff_lines) { diff_file.diff_lines } - it { diff_lines.size.should == 30 } - it { diff_lines.first.should be_kind_of(Gitlab::Diff::Line) } + it { expect(diff_lines.size).to eq(30) } + it { expect(diff_lines.first).to be_kind_of(Gitlab::Diff::Line) } end describe :mode_changed? do - it { diff_file.mode_changed?.should be_false } + it { expect(diff_file.mode_changed?).to be_falsey } end end diff --git a/spec/lib/gitlab/diff/parser_spec.rb b/spec/lib/gitlab/diff/parser_spec.rb index 35b78260acd..918f6d0ead4 100644 --- a/spec/lib/gitlab/diff/parser_spec.rb +++ b/spec/lib/gitlab/diff/parser_spec.rb @@ -50,43 +50,43 @@ eos @lines = parser.parse(diff.lines) end - it { @lines.size.should == 30 } + it { expect(@lines.size).to eq(30) } describe 'lines' do describe 'first line' do let(:line) { @lines.first } - it { line.type.should == 'match' } - it { line.old_pos.should == 6 } - it { line.new_pos.should == 6 } - it { line.text.should == '@@ -6,12 +6,18 @@ module Popen' } + it { expect(line.type).to eq('match') } + it { expect(line.old_pos).to eq(6) } + it { expect(line.new_pos).to eq(6) } + it { expect(line.text).to eq('@@ -6,12 +6,18 @@ module Popen') } end describe 'removal line' do let(:line) { @lines[10] } - it { line.type.should == 'old' } - it { line.old_pos.should == 14 } - it { line.new_pos.should == 13 } - it { line.text.should == '- options = { chdir: path }' } + it { expect(line.type).to eq('old') } + it { expect(line.old_pos).to eq(14) } + it { expect(line.new_pos).to eq(13) } + it { expect(line.text).to eq('- options = { chdir: path }') } end describe 'addition line' do let(:line) { @lines[16] } - it { line.type.should == 'new' } - it { line.old_pos.should == 15 } - it { line.new_pos.should == 18 } - it { line.text.should == '+ options = {' } + it { expect(line.type).to eq('new') } + it { expect(line.old_pos).to eq(15) } + it { expect(line.new_pos).to eq(18) } + it { expect(line.text).to eq('+ options = {') } end describe 'unchanged line' do let(:line) { @lines.last } - it { line.type.should == nil } - it { line.old_pos.should == 24 } - it { line.new_pos.should == 31 } - it { line.text.should == ' @cmd_output << stderr.read' } + it { expect(line.type).to eq(nil) } + it { expect(line.old_pos).to eq(24) } + it { expect(line.new_pos).to eq(31) } + it { expect(line.text).to eq(' @cmd_output << stderr.read') } end end end diff --git a/spec/lib/gitlab/git_access_spec.rb b/spec/lib/gitlab/git_access_spec.rb index fbcaa405f8d..666398eedd4 100644 --- a/spec/lib/gitlab/git_access_spec.rb +++ b/spec/lib/gitlab/git_access_spec.rb @@ -9,17 +9,17 @@ describe Gitlab::GitAccess do describe 'push to none protected branch' do it "returns true if user is a master" do project.team << [user, :master] - Gitlab::GitAccess.can_push_to_branch?(user, project, "random_branch").should be_true + expect(Gitlab::GitAccess.can_push_to_branch?(user, project, "random_branch")).to be_truthy end it "returns true if user is a developer" do project.team << [user, :developer] - Gitlab::GitAccess.can_push_to_branch?(user, project, "random_branch").should be_true + expect(Gitlab::GitAccess.can_push_to_branch?(user, project, "random_branch")).to be_truthy end it "returns false if user is a reporter" do project.team << [user, :reporter] - Gitlab::GitAccess.can_push_to_branch?(user, project, "random_branch").should be_false + expect(Gitlab::GitAccess.can_push_to_branch?(user, project, "random_branch")).to be_falsey end end @@ -30,17 +30,17 @@ describe Gitlab::GitAccess do it "returns true if user is a master" do project.team << [user, :master] - Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name).should be_true + expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_truthy end it "returns false if user is a developer" do project.team << [user, :developer] - Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name).should be_false + expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_falsey end it "returns false if user is a reporter" do project.team << [user, :reporter] - Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name).should be_false + expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_falsey end end @@ -51,17 +51,17 @@ describe Gitlab::GitAccess do it "returns true if user is a master" do project.team << [user, :master] - Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name).should be_true + expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_truthy end it "returns true if user is a developer" do project.team << [user, :developer] - Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name).should be_true + expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_truthy end it "returns false if user is a reporter" do project.team << [user, :reporter] - Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name).should be_false + expect(Gitlab::GitAccess.can_push_to_branch?(user, project, @branch.name)).to be_falsey end end @@ -74,7 +74,7 @@ describe Gitlab::GitAccess do context 'pull code' do subject { access.download_access_check(user, project) } - it { subject.allowed?.should be_true } + it { expect(subject.allowed?).to be_truthy } end end @@ -84,7 +84,7 @@ describe Gitlab::GitAccess do context 'pull code' do subject { access.download_access_check(user, project) } - it { subject.allowed?.should be_false } + it { expect(subject.allowed?).to be_falsey } end end @@ -97,7 +97,7 @@ describe Gitlab::GitAccess do context 'pull code' do subject { access.download_access_check(user, project) } - it { subject.allowed?.should be_false } + it { expect(subject.allowed?).to be_falsey } end end @@ -105,7 +105,7 @@ describe Gitlab::GitAccess do context 'pull code' do subject { access.download_access_check(user, project) } - it { subject.allowed?.should be_false } + it { expect(subject.allowed?).to be_falsey } end end @@ -117,13 +117,13 @@ describe Gitlab::GitAccess do before { key.projects << project } subject { access.download_access_check(key, project) } - it { subject.allowed?.should be_true } + it { expect(subject.allowed?).to be_truthy } end context 'denied' do subject { access.download_access_check(key, project) } - it { subject.allowed?.should be_false } + it { expect(subject.allowed?).to be_falsey } end end end @@ -207,7 +207,7 @@ describe Gitlab::GitAccess do context action do subject { access.push_access_check(user, project, changes[action]) } - it { subject.allowed?.should allowed ? be_true : be_false } + it { expect(subject.allowed?).to allowed ? be_truthy : be_falsey } end end end @@ -223,7 +223,7 @@ describe Gitlab::GitAccess do context action do subject { access.push_access_check(user, project, changes[action]) } - it { subject.allowed?.should allowed ? be_true : be_false } + it { expect(subject.allowed?).to allowed ? be_truthy : be_falsey } end end end diff --git a/spec/lib/gitlab/git_access_wiki_spec.rb b/spec/lib/gitlab/git_access_wiki_spec.rb index 4ff45c0c616..c31c6764091 100644 --- a/spec/lib/gitlab/git_access_wiki_spec.rb +++ b/spec/lib/gitlab/git_access_wiki_spec.rb @@ -13,7 +13,7 @@ describe Gitlab::GitAccessWiki do subject { access.push_access_check(user, project, changes) } - it { subject.allowed?.should be_true } + it { expect(subject.allowed?).to be_truthy } end def changes diff --git a/spec/lib/gitlab/github/project_creator.rb b/spec/lib/gitlab/github/project_creator.rb index 0bade5619a5..3686ddbf170 100644 --- a/spec/lib/gitlab/github/project_creator.rb +++ b/spec/lib/gitlab/github/project_creator.rb @@ -13,13 +13,13 @@ describe Gitlab::Github::ProjectCreator do let(:namespace){ create(:namespace) } it 'creates project' do - Project.any_instance.stub(:add_import_job) + allow_any_instance_of(Project).to receive(:add_import_job) project_creator = Gitlab::Github::ProjectCreator.new(repo, namespace, user) project_creator.execute project = Project.last - project.import_url.should == "https://asdffg@gitlab.com/asd/vim.git" - project.visibility_level.should == Gitlab::VisibilityLevel::PRIVATE + expect(project.import_url).to eq("https://asdffg@gitlab.com/asd/vim.git") + expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE) end end diff --git a/spec/lib/gitlab/gitlab_import/project_creator.rb b/spec/lib/gitlab/gitlab_import/project_creator.rb index 51f3534ed60..e5d917830b0 100644 --- a/spec/lib/gitlab/gitlab_import/project_creator.rb +++ b/spec/lib/gitlab/gitlab_import/project_creator.rb @@ -13,13 +13,13 @@ describe Gitlab::GitlabImport::ProjectCreator do let(:namespace){ create(:namespace) } it 'creates project' do - Project.any_instance.stub(:add_import_job) + allow_any_instance_of(Project).to receive(:add_import_job) project_creator = Gitlab::GitlabImport::ProjectCreator.new(repo, namespace, user) project_creator.execute project = Project.last - project.import_url.should == "https://oauth2:asdffg@gitlab.com/asd/vim.git" - project.visibility_level.should == Gitlab::VisibilityLevel::PRIVATE + expect(project.import_url).to eq("https://oauth2:asdffg@gitlab.com/asd/vim.git") + expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE) end end diff --git a/spec/lib/gitlab/gitlab_markdown_helper_spec.rb b/spec/lib/gitlab/gitlab_markdown_helper_spec.rb index 540618a5603..ab613193f41 100644 --- a/spec/lib/gitlab/gitlab_markdown_helper_spec.rb +++ b/spec/lib/gitlab/gitlab_markdown_helper_spec.rb @@ -5,24 +5,24 @@ describe Gitlab::MarkdownHelper do %w(textile rdoc org creole wiki mediawiki rst adoc asciidoc asc).each do |type| it "returns true for #{type} files" do - Gitlab::MarkdownHelper.markup?("README.#{type}").should be_true + expect(Gitlab::MarkdownHelper.markup?("README.#{type}")).to be_truthy end end it 'returns false when given a non-markup filename' do - Gitlab::MarkdownHelper.markup?('README.rb').should_not be_true + expect(Gitlab::MarkdownHelper.markup?('README.rb')).not_to be_truthy end end describe '#gitlab_markdown?' do %w(mdown md markdown).each do |type| it "returns true for #{type} files" do - Gitlab::MarkdownHelper.gitlab_markdown?("README.#{type}").should be_true + expect(Gitlab::MarkdownHelper.gitlab_markdown?("README.#{type}")).to be_truthy end end it 'returns false when given a non-markdown filename' do - Gitlab::MarkdownHelper.gitlab_markdown?('README.rb').should_not be_true + expect(Gitlab::MarkdownHelper.gitlab_markdown?('README.rb')).not_to be_truthy end end end diff --git a/spec/lib/gitlab/ldap/access_spec.rb b/spec/lib/gitlab/ldap/access_spec.rb index 4573b8696c4..a2b05249147 100644 --- a/spec/lib/gitlab/ldap/access_spec.rb +++ b/spec/lib/gitlab/ldap/access_spec.rb @@ -10,7 +10,7 @@ describe Gitlab::LDAP::Access do context 'when the user cannot be found' do before { Gitlab::LDAP::Person.stub(find_by_dn: nil) } - it { should be_false } + it { is_expected.to be_falsey } end context 'when the user is found' do @@ -19,13 +19,13 @@ describe Gitlab::LDAP::Access do context 'and the user is diabled via active directory' do before { Gitlab::LDAP::Person.stub(disabled_via_active_directory?: true) } - it { should be_false } + it { is_expected.to be_falsey } end context 'and has no disabled flag in active diretory' do before { Gitlab::LDAP::Person.stub(disabled_via_active_directory?: false) } - it { should be_true } + it { is_expected.to be_truthy } end context 'without ActiveDirectory enabled' do @@ -34,7 +34,7 @@ describe Gitlab::LDAP::Access do Gitlab::LDAP::Config.any_instance.stub(active_directory: false) end - it { should be_true } + it { is_expected.to be_truthy } end end end diff --git a/spec/lib/gitlab/ldap/adapter_spec.rb b/spec/lib/gitlab/ldap/adapter_spec.rb index 19347e47378..b609e4b38f2 100644 --- a/spec/lib/gitlab/ldap/adapter_spec.rb +++ b/spec/lib/gitlab/ldap/adapter_spec.rb @@ -12,20 +12,20 @@ describe Gitlab::LDAP::Adapter do context "and the result is non-empty" do before { ldap.stub(search: [:foo]) } - it { should be_true } + it { is_expected.to be_truthy } end context "and the result is empty" do before { ldap.stub(search: []) } - it { should be_false } + it { is_expected.to be_falsey } end end context "when the search encounters an error" do before { ldap.stub(search: nil, get_operation_result: double(code: 1, message: 'some error')) } - it { should be_false } + it { is_expected.to be_falsey } end end end diff --git a/spec/lib/gitlab/ldap/authentication_spec.rb b/spec/lib/gitlab/ldap/authentication_spec.rb index 11fdf108756..8afc2b21f46 100644 --- a/spec/lib/gitlab/ldap/authentication_spec.rb +++ b/spec/lib/gitlab/ldap/authentication_spec.rb @@ -19,7 +19,7 @@ describe Gitlab::LDAP::Authentication do klass.any_instance.stub(adapter: double(:adapter, bind_as: double(:ldap_user, dn: dn) )) - expect(klass.login(login, password)).to be_true + expect(klass.login(login, password)).to be_truthy end it "is false if the user does not exist" do @@ -27,27 +27,27 @@ describe Gitlab::LDAP::Authentication do klass.any_instance.stub(adapter: double(:adapter, bind_as: double(:ldap_user, dn: dn) )) - expect(klass.login(login, password)).to be_false + expect(klass.login(login, password)).to be_falsey end it "is false if authentication fails" do user # try only to fake the LDAP call klass.any_instance.stub(adapter: double(:adapter, bind_as: nil)) - expect(klass.login(login, password)).to be_false + expect(klass.login(login, password)).to be_falsey end it "fails if ldap is disabled" do Gitlab::LDAP::Config.stub(enabled?: false) - expect(klass.login(login, password)).to be_false + expect(klass.login(login, password)).to be_falsey end it "fails if no login is supplied" do - expect(klass.login('', password)).to be_false + expect(klass.login('', password)).to be_falsey end it "fails if no password is supplied" do - expect(klass.login(login, '')).to be_false + expect(klass.login(login, '')).to be_falsey end end end
\ No newline at end of file diff --git a/spec/lib/gitlab/ldap/config_spec.rb b/spec/lib/gitlab/ldap/config_spec.rb index 3ebb8aae243..2df2beca7a6 100644 --- a/spec/lib/gitlab/ldap/config_spec.rb +++ b/spec/lib/gitlab/ldap/config_spec.rb @@ -4,7 +4,7 @@ describe Gitlab::LDAP::Config do let(:config) { Gitlab::LDAP::Config.new provider } let(:provider) { 'ldapmain' } - describe :initalize do + describe '#initalize' do it 'requires a provider' do expect{ Gitlab::LDAP::Config.new }.to raise_error ArgumentError end diff --git a/spec/lib/gitlab/ldap/user_spec.rb b/spec/lib/gitlab/ldap/user_spec.rb index 63ffc21ba3b..4f93545feb6 100644 --- a/spec/lib/gitlab/ldap/user_spec.rb +++ b/spec/lib/gitlab/ldap/user_spec.rb @@ -16,17 +16,17 @@ describe Gitlab::LDAP::User do describe :changed? do it "marks existing ldap user as changed" do existing_user = create(:omniauth_user, extern_uid: 'my-uid', provider: 'ldapmain') - expect(gl_user.changed?).to be_true + expect(gl_user.changed?).to be_truthy end it "marks existing non-ldap user if the email matches as changed" do existing_user = create(:user, email: 'john@example.com') - expect(gl_user.changed?).to be_true + expect(gl_user.changed?).to be_truthy end it "dont marks existing ldap user as changed" do existing_user = create(:omniauth_user, email: 'john@example.com', extern_uid: 'my-uid', provider: 'ldapmain') - expect(gl_user.changed?).to be_false + expect(gl_user.changed?).to be_falsey end end diff --git a/spec/lib/gitlab/oauth/user_spec.rb b/spec/lib/gitlab/oauth/user_spec.rb index 88307515789..adfae5e5b4b 100644 --- a/spec/lib/gitlab/oauth/user_spec.rb +++ b/spec/lib/gitlab/oauth/user_spec.rb @@ -19,12 +19,12 @@ describe Gitlab::OAuth::User do it "finds an existing user based on uid and provider (facebook)" do auth = double(info: double(name: 'John'), uid: 'my-uid', provider: 'my-provider') - expect( oauth_user.persisted? ).to be_true + expect( oauth_user.persisted? ).to be_truthy end it "returns false if use is not found in database" do auth_hash.stub(uid: 'non-existing') - expect( oauth_user.persisted? ).to be_false + expect( oauth_user.persisted? ).to be_falsey end end @@ -62,8 +62,8 @@ describe Gitlab::OAuth::User do it do oauth_user.save - gl_user.should be_valid - gl_user.should_not be_blocked + expect(gl_user).to be_valid + expect(gl_user).not_to be_blocked end end @@ -72,8 +72,8 @@ describe Gitlab::OAuth::User do it do oauth_user.save - gl_user.should be_valid - gl_user.should be_blocked + expect(gl_user).to be_valid + expect(gl_user).to be_blocked end end end @@ -89,8 +89,8 @@ describe Gitlab::OAuth::User do it do oauth_user.save - gl_user.should be_valid - gl_user.should_not be_blocked + expect(gl_user).to be_valid + expect(gl_user).not_to be_blocked end end @@ -99,8 +99,8 @@ describe Gitlab::OAuth::User do it do oauth_user.save - gl_user.should be_valid - gl_user.should_not be_blocked + expect(gl_user).to be_valid + expect(gl_user).not_to be_blocked end end end diff --git a/spec/lib/gitlab/popen_spec.rb b/spec/lib/gitlab/popen_spec.rb index 76d506eb3c0..cd9d0456b25 100644 --- a/spec/lib/gitlab/popen_spec.rb +++ b/spec/lib/gitlab/popen_spec.rb @@ -13,8 +13,8 @@ describe 'Gitlab::Popen', no_db: true do @output, @status = @klass.new.popen(%W(ls), path) end - it { @status.should be_zero } - it { @output.should include('cache') } + it { expect(@status).to be_zero } + it { expect(@output).to include('cache') } end context 'non-zero status' do @@ -22,8 +22,8 @@ describe 'Gitlab::Popen', no_db: true do @output, @status = @klass.new.popen(%W(cat NOTHING), path) end - it { @status.should == 1 } - it { @output.should include('No such file or directory') } + it { expect(@status).to eq(1) } + it { expect(@output).to include('No such file or directory') } end context 'unsafe string command' do @@ -37,8 +37,8 @@ describe 'Gitlab::Popen', no_db: true do @output, @status = @klass.new.popen(%W(ls)) end - it { @status.should be_zero } - it { @output.should include('spec') } + it { expect(@status).to be_zero } + it { expect(@output).to include('spec') } end end diff --git a/spec/lib/gitlab/push_data_builder_spec.rb b/spec/lib/gitlab/push_data_builder_spec.rb index 691fd133637..da25d45f1ff 100644 --- a/spec/lib/gitlab/push_data_builder_spec.rb +++ b/spec/lib/gitlab/push_data_builder_spec.rb @@ -8,12 +8,12 @@ describe 'Gitlab::PushDataBuilder' do describe :build_sample do let(:data) { Gitlab::PushDataBuilder.build_sample(project, user) } - it { data.should be_a(Hash) } - it { data[:before].should == '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9' } - it { data[:after].should == '5937ac0a7beb003549fc5fd26fc247adbce4a52e' } - it { data[:ref].should == 'refs/heads/master' } - it { data[:commits].size.should == 3 } - it { data[:total_commits_count].should == 3 } + it { expect(data).to be_a(Hash) } + it { expect(data[:before]).to eq('6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') } + it { expect(data[:after]).to eq('5937ac0a7beb003549fc5fd26fc247adbce4a52e') } + it { expect(data[:ref]).to eq('refs/heads/master') } + it { expect(data[:commits].size).to eq(3) } + it { expect(data[:total_commits_count]).to eq(3) } end describe :build do @@ -25,12 +25,12 @@ describe 'Gitlab::PushDataBuilder' do 'refs/tags/v1.1.0') end - it { data.should be_a(Hash) } - it { data[:before].should == Gitlab::Git::BLANK_SHA } - it { data[:checkout_sha].should == '5937ac0a7beb003549fc5fd26fc247adbce4a52e' } - it { data[:after].should == '8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b' } - it { data[:ref].should == 'refs/tags/v1.1.0' } - it { data[:commits].should be_empty } - it { data[:total_commits_count].should be_zero } + it { expect(data).to be_a(Hash) } + it { expect(data[:before]).to eq(Gitlab::Git::BLANK_SHA) } + it { expect(data[:checkout_sha]).to eq('5937ac0a7beb003549fc5fd26fc247adbce4a52e') } + it { expect(data[:after]).to eq('8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b') } + it { expect(data[:ref]).to eq('refs/tags/v1.1.0') } + it { expect(data[:commits]).to be_empty } + it { expect(data[:total_commits_count]).to be_zero } end end diff --git a/spec/lib/gitlab/reference_extractor_spec.rb b/spec/lib/gitlab/reference_extractor_spec.rb index 5f45df4e8c3..0847c31258c 100644 --- a/spec/lib/gitlab/reference_extractor_spec.rb +++ b/spec/lib/gitlab/reference_extractor_spec.rb @@ -3,51 +3,51 @@ require 'spec_helper' describe Gitlab::ReferenceExtractor do it 'extracts username references' do subject.analyze('this contains a @user reference', nil) - subject.users.should == [{ project: nil, id: 'user' }] + expect(subject.users).to eq([{ project: nil, id: 'user' }]) end it 'extracts issue references' do subject.analyze('this one talks about issue #1234', nil) - subject.issues.should == [{ project: nil, id: '1234' }] + expect(subject.issues).to eq([{ project: nil, id: '1234' }]) end it 'extracts JIRA issue references' do subject.analyze('this one talks about issue JIRA-1234', nil) - subject.issues.should == [{ project: nil, id: 'JIRA-1234' }] + expect(subject.issues).to eq([{ project: nil, id: 'JIRA-1234' }]) end it 'extracts merge request references' do subject.analyze("and here's !43, a merge request", nil) - subject.merge_requests.should == [{ project: nil, id: '43' }] + expect(subject.merge_requests).to eq([{ project: nil, id: '43' }]) end it 'extracts snippet ids' do subject.analyze('snippets like $12 get extracted as well', nil) - subject.snippets.should == [{ project: nil, id: '12' }] + expect(subject.snippets).to eq([{ project: nil, id: '12' }]) end it 'extracts commit shas' do subject.analyze('commit shas 98cf0ae3 are pulled out as Strings', nil) - subject.commits.should == [{ project: nil, id: '98cf0ae3' }] + expect(subject.commits).to eq([{ project: nil, id: '98cf0ae3' }]) end it 'extracts multiple references and preserves their order' do subject.analyze('@me and @you both care about this', nil) - subject.users.should == [ + expect(subject.users).to eq([ { project: nil, id: 'me' }, { project: nil, id: 'you' } - ] + ]) end it 'leaves the original note unmodified' do text = 'issue #123 is just the worst, @user' subject.analyze(text, nil) - text.should == 'issue #123 is just the worst, @user' + expect(text).to eq('issue #123 is just the worst, @user') end it 'handles all possible kinds of references' do accessors = Gitlab::Markdown::TYPES.map { |t| "#{t}s".to_sym } - subject.should respond_to(*accessors) + expect(subject).to respond_to(*accessors) end context 'with a project' do @@ -62,7 +62,7 @@ describe Gitlab::ReferenceExtractor do project.team << [@u_bar, :guest] subject.analyze('@foo, @baduser, @bar, and @offteam', project) - subject.users_for(project).should == [@u_foo, @u_bar] + expect(subject.users_for(project)).to eq([@u_foo, @u_bar]) end it 'accesses valid issue objects' do @@ -70,7 +70,7 @@ describe Gitlab::ReferenceExtractor do @i1 = create(:issue, project: project) subject.analyze("##{@i0.iid}, ##{@i1.iid}, and #999.", project) - subject.issues_for(project).should == [@i0, @i1] + expect(subject.issues_for(project)).to eq([@i0, @i1]) end it 'accesses valid merge requests' do @@ -78,7 +78,7 @@ describe Gitlab::ReferenceExtractor do @m1 = create(:merge_request, source_project: project, target_project: project, source_branch: 'bbb') subject.analyze("!999, !#{@m1.iid}, and !#{@m0.iid}.", project) - subject.merge_requests_for(project).should == [@m1, @m0] + expect(subject.merge_requests_for(project)).to eq([@m1, @m0]) end it 'accesses valid snippets' do @@ -87,7 +87,7 @@ describe Gitlab::ReferenceExtractor do @s2 = create(:project_snippet) subject.analyze("$#{@s0.id}, $999, $#{@s2.id}, $#{@s1.id}", project) - subject.snippets_for(project).should == [@s0, @s1] + expect(subject.snippets_for(project)).to eq([@s0, @s1]) end it 'accesses valid commits' do @@ -96,9 +96,9 @@ describe Gitlab::ReferenceExtractor do subject.analyze("this references commits #{commit.sha[0..6]} and 012345", project) extracted = subject.commits_for(project) - extracted.should have(1).item - extracted[0].sha.should == commit.sha - extracted[0].message.should == commit.message + expect(extracted.size).to eq(1) + expect(extracted[0].sha).to eq(commit.sha) + expect(extracted[0].message).to eq(commit.message) end end end diff --git a/spec/lib/gitlab/regex_spec.rb b/spec/lib/gitlab/regex_spec.rb index a3aae7771bd..1db9f15b790 100644 --- a/spec/lib/gitlab/regex_spec.rb +++ b/spec/lib/gitlab/regex_spec.rb @@ -2,20 +2,20 @@ require 'spec_helper' describe Gitlab::Regex do describe 'path regex' do - it { 'gitlab-ce'.should match(Gitlab::Regex.path_regex) } - it { 'gitlab_git'.should match(Gitlab::Regex.path_regex) } - it { '_underscore.js'.should match(Gitlab::Regex.path_regex) } - it { '100px.com'.should match(Gitlab::Regex.path_regex) } - it { '?gitlab'.should_not match(Gitlab::Regex.path_regex) } - it { 'git lab'.should_not match(Gitlab::Regex.path_regex) } - it { 'gitlab.git'.should_not match(Gitlab::Regex.path_regex) } + it { expect('gitlab-ce').to match(Gitlab::Regex.path_regex) } + it { expect('gitlab_git').to match(Gitlab::Regex.path_regex) } + it { expect('_underscore.js').to match(Gitlab::Regex.path_regex) } + it { expect('100px.com').to match(Gitlab::Regex.path_regex) } + it { expect('?gitlab').not_to match(Gitlab::Regex.path_regex) } + it { expect('git lab').not_to match(Gitlab::Regex.path_regex) } + it { expect('gitlab.git').not_to match(Gitlab::Regex.path_regex) } end describe 'project name regex' do - it { 'gitlab-ce'.should match(Gitlab::Regex.project_name_regex) } - it { 'GitLab CE'.should match(Gitlab::Regex.project_name_regex) } - it { '100 lines'.should match(Gitlab::Regex.project_name_regex) } - it { 'gitlab.git'.should match(Gitlab::Regex.project_name_regex) } - it { '?gitlab'.should_not match(Gitlab::Regex.project_name_regex) } + it { expect('gitlab-ce').to match(Gitlab::Regex.project_name_regex) } + it { expect('GitLab CE').to match(Gitlab::Regex.project_name_regex) } + it { expect('100 lines').to match(Gitlab::Regex.project_name_regex) } + it { expect('gitlab.git').to match(Gitlab::Regex.project_name_regex) } + it { expect('?gitlab').not_to match(Gitlab::Regex.project_name_regex) } end end diff --git a/spec/lib/gitlab/satellite/action_spec.rb b/spec/lib/gitlab/satellite/action_spec.rb index 3eb1258d67e..28e3d64ee2b 100644 --- a/spec/lib/gitlab/satellite/action_spec.rb +++ b/spec/lib/gitlab/satellite/action_spec.rb @@ -6,7 +6,7 @@ describe 'Gitlab::Satellite::Action' do describe '#prepare_satellite!' do it 'should be able to fetch timeout from conf' do - Gitlab::Satellite::Action::DEFAULT_OPTIONS[:git_timeout].should == 30.seconds + expect(Gitlab::Satellite::Action::DEFAULT_OPTIONS[:git_timeout]).to eq(30.seconds) end it 'create a repository with a parking branch and one remote: origin' do @@ -15,22 +15,22 @@ describe 'Gitlab::Satellite::Action' do #now lets dirty it up starting_remote_count = repo.git.list_remotes.size - starting_remote_count.should >= 1 + expect(starting_remote_count).to be >= 1 #kind of hookey way to add a second remote origin_uri = repo.git.remote({v: true}).split(" ")[1] begin repo.git.remote({raise: true}, 'add', 'another-remote', origin_uri) repo.git.branch({raise: true}, 'a-new-branch') - repo.heads.size.should > (starting_remote_count) - repo.git.remote().split(" ").size.should > (starting_remote_count) + expect(repo.heads.size).to be > (starting_remote_count) + expect(repo.git.remote().split(" ").size).to be > (starting_remote_count) rescue end repo.git.config({}, "user.name", "#{user.name} -- foo") repo.git.config({}, "user.email", "#{user.email} -- foo") - repo.config['user.name'].should =="#{user.name} -- foo" - repo.config['user.email'].should =="#{user.email} -- foo" + expect(repo.config['user.name']).to eq("#{user.name} -- foo") + expect(repo.config['user.email']).to eq("#{user.email} -- foo") #These must happen in the context of the satellite directory... @@ -42,13 +42,13 @@ describe 'Gitlab::Satellite::Action' do #verify it's clean heads = repo.heads.map(&:name) - heads.size.should == 1 - heads.include?(Gitlab::Satellite::Satellite::PARKING_BRANCH).should == true + expect(heads.size).to eq(1) + expect(heads.include?(Gitlab::Satellite::Satellite::PARKING_BRANCH)).to eq(true) remotes = repo.git.remote().split(' ') - remotes.size.should == 1 - remotes.include?('origin').should == true - repo.config['user.name'].should ==user.name - repo.config['user.email'].should ==user.email + expect(remotes.size).to eq(1) + expect(remotes.include?('origin')).to eq(true) + expect(repo.config['user.name']).to eq(user.name) + expect(repo.config['user.email']).to eq(user.email) end end @@ -61,16 +61,16 @@ describe 'Gitlab::Satellite::Action' do #set assumptions FileUtils.rm_f(project.satellite.lock_file) - File.exists?(project.satellite.lock_file).should be_false + expect(File.exists?(project.satellite.lock_file)).to be_falsey satellite_action = Gitlab::Satellite::Action.new(user, project) satellite_action.send(:in_locked_and_timed_satellite) do |sat_repo| - repo.should == sat_repo - (File.exists? project.satellite.lock_file).should be_true + expect(repo).to eq(sat_repo) + expect(File.exists? project.satellite.lock_file).to be_truthy called = true end - called.should be_true + expect(called).to be_truthy end @@ -80,19 +80,19 @@ describe 'Gitlab::Satellite::Action' do # Set base assumptions if File.exists? project.satellite.lock_file - FileLockStatusChecker.new(project.satellite.lock_file).flocked?.should be_false + expect(FileLockStatusChecker.new(project.satellite.lock_file).flocked?).to be_falsey end satellite_action = Gitlab::Satellite::Action.new(user, project) satellite_action.send(:in_locked_and_timed_satellite) do |sat_repo| called = true - repo.should == sat_repo - (File.exists? project.satellite.lock_file).should be_true - FileLockStatusChecker.new(project.satellite.lock_file).flocked?.should be_true + expect(repo).to eq(sat_repo) + expect(File.exists? project.satellite.lock_file).to be_truthy + expect(FileLockStatusChecker.new(project.satellite.lock_file).flocked?).to be_truthy end - called.should be_true - FileLockStatusChecker.new(project.satellite.lock_file).flocked?.should be_false + expect(called).to be_truthy + expect(FileLockStatusChecker.new(project.satellite.lock_file).flocked?).to be_falsey end diff --git a/spec/lib/gitlab/satellite/merge_action_spec.rb b/spec/lib/gitlab/satellite/merge_action_spec.rb index 479a73a1081..915e3ff0e51 100644 --- a/spec/lib/gitlab/satellite/merge_action_spec.rb +++ b/spec/lib/gitlab/satellite/merge_action_spec.rb @@ -13,9 +13,9 @@ describe 'Gitlab::Satellite::MergeAction' do describe '#commits_between' do def verify_commits(commits, first_commit_sha, last_commit_sha) - commits.each { |commit| commit.class.should == Gitlab::Git::Commit } - commits.first.id.should == first_commit_sha - commits.last.id.should == last_commit_sha + commits.each { |commit| expect(commit.class).to eq(Gitlab::Git::Commit) } + expect(commits.first.id).to eq(first_commit_sha) + expect(commits.last.id).to eq(last_commit_sha) end context 'on fork' do @@ -35,7 +35,7 @@ describe 'Gitlab::Satellite::MergeAction' do describe '#format_patch' do def verify_content(patch) sample_compare.commits.each do |commit| - patch.include?(commit).should be_true + expect(patch.include?(commit)).to be_truthy end end @@ -57,11 +57,11 @@ describe 'Gitlab::Satellite::MergeAction' do describe '#diffs_between_satellite tested against diff_in_satellite' do def is_a_matching_diff(diff, diffs) diff_count = diff.scan('diff --git').size - diff_count.should >= 1 - diffs.size.should == diff_count + expect(diff_count).to be >= 1 + expect(diffs.size).to eq(diff_count) diffs.each do |a_diff| - a_diff.class.should == Gitlab::Git::Diff - (diff.include? a_diff.diff).should be_true + expect(a_diff.class).to eq(Gitlab::Git::Diff) + expect(diff.include? a_diff.diff).to be_truthy end end @@ -82,23 +82,23 @@ describe 'Gitlab::Satellite::MergeAction' do describe '#can_be_merged?' do context 'on fork' do - it { Gitlab::Satellite::MergeAction.new( + it { expect(Gitlab::Satellite::MergeAction.new( merge_request_fork.author, - merge_request_fork).can_be_merged?.should be_true } + merge_request_fork).can_be_merged?).to be_truthy } - it { Gitlab::Satellite::MergeAction.new( + it { expect(Gitlab::Satellite::MergeAction.new( merge_request_fork_with_conflict.author, - merge_request_fork_with_conflict).can_be_merged?.should be_false } + merge_request_fork_with_conflict).can_be_merged?).to be_falsey } end context 'between branches' do - it { Gitlab::Satellite::MergeAction.new( + it { expect(Gitlab::Satellite::MergeAction.new( merge_request.author, - merge_request).can_be_merged?.should be_true } + merge_request).can_be_merged?).to be_truthy } - it { Gitlab::Satellite::MergeAction.new( + it { expect(Gitlab::Satellite::MergeAction.new( merge_request_with_conflict.author, - merge_request_with_conflict).can_be_merged?.should be_false } + merge_request_with_conflict).can_be_merged?).to be_falsey } end end end diff --git a/spec/lib/gitlab/upgrader_spec.rb b/spec/lib/gitlab/upgrader_spec.rb index 2b254d6b3a6..ce3ea6c260a 100644 --- a/spec/lib/gitlab/upgrader_spec.rb +++ b/spec/lib/gitlab/upgrader_spec.rb @@ -5,20 +5,20 @@ describe Gitlab::Upgrader do let(:current_version) { Gitlab::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 + expect(upgrader.latest_version?).to be_truthy end end describe 'latest_version_raw' do it 'should be latest version for GitLab 5' do upgrader.stub(current_version_raw: "5.3.0") - upgrader.latest_version_raw.should == "v5.4.2" + expect(upgrader.latest_version_raw).to eq("v5.4.2") end end end diff --git a/spec/lib/gitlab/version_info_spec.rb b/spec/lib/gitlab/version_info_spec.rb index 94dccf7a4e5..5afeb1c1ec3 100644 --- a/spec/lib/gitlab/version_info_spec.rb +++ b/spec/lib/gitlab/version_info_spec.rb @@ -12,58 +12,58 @@ describe 'Gitlab::VersionInfo', no_db: true do end context '>' do - it { @v2_0_0.should > @v1_1_0 } - it { @v1_1_0.should > @v1_0_1 } - it { @v1_0_1.should > @v1_0_0 } - it { @v1_0_0.should > @v0_1_0 } - it { @v0_1_0.should > @v0_0_1 } + it { expect(@v2_0_0).to be > @v1_1_0 } + it { expect(@v1_1_0).to be > @v1_0_1 } + it { expect(@v1_0_1).to be > @v1_0_0 } + it { expect(@v1_0_0).to be > @v0_1_0 } + it { expect(@v0_1_0).to be > @v0_0_1 } end context '>=' do - it { @v2_0_0.should >= Gitlab::VersionInfo.new(2, 0, 0) } - it { @v2_0_0.should >= @v1_1_0 } + it { expect(@v2_0_0).to be >= Gitlab::VersionInfo.new(2, 0, 0) } + it { expect(@v2_0_0).to be >= @v1_1_0 } end context '<' do - it { @v0_0_1.should < @v0_1_0 } - it { @v0_1_0.should < @v1_0_0 } - it { @v1_0_0.should < @v1_0_1 } - it { @v1_0_1.should < @v1_1_0 } - it { @v1_1_0.should < @v2_0_0 } + it { expect(@v0_0_1).to be < @v0_1_0 } + it { expect(@v0_1_0).to be < @v1_0_0 } + it { expect(@v1_0_0).to be < @v1_0_1 } + it { expect(@v1_0_1).to be < @v1_1_0 } + it { expect(@v1_1_0).to be < @v2_0_0 } end context '<=' do - it { @v0_0_1.should <= Gitlab::VersionInfo.new(0, 0, 1) } - it { @v0_0_1.should <= @v0_1_0 } + it { expect(@v0_0_1).to be <= Gitlab::VersionInfo.new(0, 0, 1) } + it { expect(@v0_0_1).to be <= @v0_1_0 } end context '==' do - it { @v0_0_1.should == Gitlab::VersionInfo.new(0, 0, 1) } - it { @v0_1_0.should == Gitlab::VersionInfo.new(0, 1, 0) } - it { @v1_0_0.should == Gitlab::VersionInfo.new(1, 0, 0) } + it { expect(@v0_0_1).to eq(Gitlab::VersionInfo.new(0, 0, 1)) } + it { expect(@v0_1_0).to eq(Gitlab::VersionInfo.new(0, 1, 0)) } + it { expect(@v1_0_0).to eq(Gitlab::VersionInfo.new(1, 0, 0)) } end context '!=' do - it { @v0_0_1.should_not == @v0_1_0 } + it { expect(@v0_0_1).not_to eq(@v0_1_0) } end context 'unknown' do - it { @unknown.should_not be @v0_0_1 } - it { @unknown.should_not be Gitlab::VersionInfo.new } + it { expect(@unknown).not_to be @v0_0_1 } + it { expect(@unknown).not_to be Gitlab::VersionInfo.new } it { expect{@unknown > @v0_0_1}.to raise_error(ArgumentError) } it { expect{@unknown < @v0_0_1}.to raise_error(ArgumentError) } end context 'parse' do - it { Gitlab::VersionInfo.parse("1.0.0").should == @v1_0_0 } - it { Gitlab::VersionInfo.parse("1.0.0.1").should == @v1_0_0 } - it { Gitlab::VersionInfo.parse("git 1.0.0b1").should == @v1_0_0 } - it { Gitlab::VersionInfo.parse("git 1.0b1").should_not be_valid } + it { expect(Gitlab::VersionInfo.parse("1.0.0")).to eq(@v1_0_0) } + it { expect(Gitlab::VersionInfo.parse("1.0.0.1")).to eq(@v1_0_0) } + it { expect(Gitlab::VersionInfo.parse("git 1.0.0b1")).to eq(@v1_0_0) } + it { expect(Gitlab::VersionInfo.parse("git 1.0b1")).not_to be_valid } end context 'to_s' do - it { @v1_0_0.to_s.should == "1.0.0" } - it { @unknown.to_s.should == "Unknown" } + it { expect(@v1_0_0.to_s).to eq("1.0.0") } + it { expect(@unknown.to_s).to eq("Unknown") } end end diff --git a/spec/lib/votes_spec.rb b/spec/lib/votes_spec.rb index a88a10d927f..df243a26008 100644 --- a/spec/lib/votes_spec.rb +++ b/spec/lib/votes_spec.rb @@ -5,107 +5,107 @@ describe Issue, 'Votes' do describe "#upvotes" do it "with no notes has a 0/0 score" do - issue.upvotes.should == 0 + expect(issue.upvotes).to eq(0) end it "should recognize non-+1 notes" do add_note "No +1 here" - issue.should have(1).note - issue.notes.first.upvote?.should be_false - issue.upvotes.should == 0 + expect(issue.notes.size).to eq(1) + expect(issue.notes.first.upvote?).to be_falsey + expect(issue.upvotes).to eq(0) end it "should recognize a single +1 note" do add_note "+1 This is awesome" - issue.upvotes.should == 1 + expect(issue.upvotes).to eq(1) end it 'should recognize multiple +1 notes' do add_note '+1 This is awesome', create(:user) add_note '+1 I want this', create(:user) - issue.upvotes.should == 2 + expect(issue.upvotes).to eq(2) end it 'should not count 2 +1 votes from the same user' do add_note '+1 This is awesome' add_note '+1 I want this' - issue.upvotes.should == 1 + expect(issue.upvotes).to eq(1) end end describe "#downvotes" do it "with no notes has a 0/0 score" do - issue.downvotes.should == 0 + expect(issue.downvotes).to eq(0) end it "should recognize non--1 notes" do add_note "Almost got a -1" - issue.should have(1).note - issue.notes.first.downvote?.should be_false - issue.downvotes.should == 0 + expect(issue.notes.size).to eq(1) + expect(issue.notes.first.downvote?).to be_falsey + expect(issue.downvotes).to eq(0) end it "should recognize a single -1 note" do add_note "-1 This is bad" - issue.downvotes.should == 1 + expect(issue.downvotes).to eq(1) end it "should recognize multiple -1 notes" do add_note('-1 This is bad', create(:user)) add_note('-1 Away with this', create(:user)) - issue.downvotes.should == 2 + expect(issue.downvotes).to eq(2) end end describe "#votes_count" do it "with no notes has a 0/0 score" do - issue.votes_count.should == 0 + expect(issue.votes_count).to eq(0) end it "should recognize non notes" do add_note "No +1 here" - issue.should have(1).note - issue.votes_count.should == 0 + expect(issue.notes.size).to eq(1) + expect(issue.votes_count).to eq(0) end it "should recognize a single +1 note" do add_note "+1 This is awesome" - issue.votes_count.should == 1 + expect(issue.votes_count).to eq(1) end it "should recognize a single -1 note" do add_note "-1 This is bad" - issue.votes_count.should == 1 + expect(issue.votes_count).to eq(1) end it "should recognize multiple notes" do add_note('+1 This is awesome', create(:user)) add_note('-1 This is bad', create(:user)) add_note('+1 I want this', create(:user)) - issue.votes_count.should == 3 + expect(issue.votes_count).to eq(3) end it 'should not count 2 -1 votes from the same user' do add_note '-1 This is suspicious' add_note '-1 This is bad' - issue.votes_count.should == 1 + expect(issue.votes_count).to eq(1) end end describe "#upvotes_in_percent" do it "with no notes has a 0% score" do - issue.upvotes_in_percent.should == 0 + expect(issue.upvotes_in_percent).to eq(0) end it "should count a single 1 note as 100%" do add_note "+1 This is awesome" - issue.upvotes_in_percent.should == 100 + expect(issue.upvotes_in_percent).to eq(100) end it 'should count multiple +1 notes as 100%' do add_note('+1 This is awesome', create(:user)) add_note('+1 I want this', create(:user)) - issue.upvotes_in_percent.should == 100 + expect(issue.upvotes_in_percent).to eq(100) end it 'should count fractions for multiple +1 and -1 notes correctly' do @@ -113,24 +113,24 @@ describe Issue, 'Votes' do add_note('+1 I want this', create(:user)) add_note('-1 This is bad', create(:user)) add_note('+1 me too', create(:user)) - issue.upvotes_in_percent.should == 75 + expect(issue.upvotes_in_percent).to eq(75) end end describe "#downvotes_in_percent" do it "with no notes has a 0% score" do - issue.downvotes_in_percent.should == 0 + expect(issue.downvotes_in_percent).to eq(0) end it "should count a single -1 note as 100%" do add_note "-1 This is bad" - issue.downvotes_in_percent.should == 100 + expect(issue.downvotes_in_percent).to eq(100) end it 'should count multiple -1 notes as 100%' do add_note('-1 This is bad', create(:user)) add_note('-1 Away with this', create(:user)) - issue.downvotes_in_percent.should == 100 + expect(issue.downvotes_in_percent).to eq(100) end it 'should count fractions for multiple +1 and -1 notes correctly' do @@ -138,7 +138,7 @@ describe Issue, 'Votes' do add_note('+1 I want this', create(:user)) add_note('-1 This is bad', create(:user)) add_note('+1 me too', create(:user)) - issue.downvotes_in_percent.should == 25 + expect(issue.downvotes_in_percent).to eq(25) end end @@ -151,8 +151,8 @@ describe Issue, 'Votes' do add_note('+1 this looks good now') add_note('+1 This is awesome', create(:user)) add_note('+1 me too', create(:user)) - issue.downvotes.should == 0 - issue.upvotes.should == 5 + expect(issue.downvotes).to eq(0) + expect(issue.upvotes).to eq(5) end it 'should count each users vote only once' do @@ -161,8 +161,8 @@ describe Issue, 'Votes' do add_note '+1 I still like this' add_note '+1 I really like this' add_note '+1 Give me this now!!!!' - issue.downvotes.should == 0 - issue.upvotes.should == 1 + expect(issue.downvotes).to eq(0) + expect(issue.upvotes).to eq(1) end it 'should count a users vote only once without caring about comments' do @@ -171,8 +171,8 @@ describe Issue, 'Votes' do add_note 'Another comment' add_note '+1 vote' add_note 'final comment' - issue.downvotes.should == 0 - issue.upvotes.should == 1 + expect(issue.downvotes).to eq(0) + expect(issue.upvotes).to eq(1) end end |