From 46f7ba2258b796fa53a2c276c95deb25ca4baf40 Mon Sep 17 00:00:00 2001 From: skv Date: Sun, 30 Nov 2014 11:42:07 +0300 Subject: [PATCH] update rspec to 3.1 --- Gemfile | 4 +- Gemfile.lock | 73 +++++++++++++++++++----------------- spec/blame_spec.rb | 4 +- spec/blob_snippet_spec.rb | 4 +- spec/blob_spec.rb | 48 ++++++++++++------------ spec/branch_spec.rb | 12 +++--- spec/commit_spec.rb | 78 +++++++++++++++++++-------------------- spec/compare_spec.rb | 12 +++--- spec/diff_spec.rb | 14 +++---- spec/repository_spec.rb | 74 ++++++++++++++++++------------------- spec/spec_helper.rb | 1 - spec/tag_spec.rb | 14 +++---- spec/tree_spec.rb | 64 ++++++++++++++++---------------- 13 files changed, 204 insertions(+), 198 deletions(-) diff --git a/Gemfile b/Gemfile index 6c3cfad..a1740b7 100644 --- a/Gemfile +++ b/Gemfile @@ -4,10 +4,10 @@ gemspec group :development do gem 'coveralls', require: false - gem 'rspec' + gem 'rspec', '~> 3.1.0' gem 'webmock' gem 'guard' - gem 'guard-rspec' + gem 'guard-rspec', require: false gem 'pry' gem 'rake' end diff --git a/Gemfile.lock b/Gemfile.lock index 161299c..eeeb742 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,8 +17,10 @@ GEM thread_safe (~> 0.1) tzinfo (~> 1.1) addressable (2.3.4) + celluloid (0.16.0) + timers (~> 4.0.0) charlock_holmes (0.6.9.4) - coderay (1.0.9) + coderay (1.1.0) colorize (0.5.8) coveralls (0.6.7) colorize @@ -30,61 +32,66 @@ GEM diff-lcs (1.2.5) docile (1.1.5) escape_utils (0.2.4) - ffi (1.8.1) - formatador (0.2.4) + ffi (1.9.6) + formatador (0.2.5) gitlab-linguist (3.0.0) charlock_holmes (~> 0.6.6) escape_utils (~> 0.2.4) mime-types (~> 1.19) - guard (1.8.0) + guard (2.10.0) formatador (>= 0.2.4) - listen (>= 1.0.0) - lumberjack (>= 1.0.2) - pry (>= 0.9.10) - thor (>= 0.14.6) - guard-rspec (2.5.4) - guard (>= 1.1) - rspec (~> 2.11) + listen (~> 2.7) + lumberjack (~> 1.0) + pry (>= 0.9.12) + thor (>= 0.18.1) + guard-rspec (4.3.1) + guard (~> 2.1) + rspec (>= 2.14, < 4.0) + hitimes (1.2.2) i18n (0.6.11) json (1.8.1) - listen (1.0.2) + listen (2.8.3) + celluloid (>= 0.15.2) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) - rb-kqueue (>= 0.2) - lumberjack (1.0.3) - method_source (0.8.1) + lumberjack (1.0.9) + method_source (0.8.2) mime-types (1.25.1) minitest (5.4.2) multi_json (1.10.1) - pry (0.9.12.1) - coderay (~> 1.0.5) - method_source (~> 0.8) + pry (0.10.1) + coderay (~> 1.1.0) + method_source (~> 0.8.1) slop (~> 3.4) rake (10.3.2) - rb-fsevent (0.9.3) - rb-inotify (0.9.0) - ffi (>= 0.5.0) - rb-kqueue (0.2.0) + rb-fsevent (0.9.4) + rb-inotify (0.9.5) ffi (>= 0.5.0) rest-client (1.6.7) mime-types (>= 1.16) - rspec (2.13.0) - rspec-core (~> 2.13.0) - rspec-expectations (~> 2.13.0) - rspec-mocks (~> 2.13.0) - rspec-core (2.13.1) - rspec-expectations (2.13.0) - diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.13.1) + rspec (3.1.0) + rspec-core (~> 3.1.0) + rspec-expectations (~> 3.1.0) + rspec-mocks (~> 3.1.0) + rspec-core (3.1.7) + rspec-support (~> 3.1.0) + rspec-expectations (3.1.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.1.0) + rspec-mocks (3.1.3) + rspec-support (~> 3.1.0) + rspec-support (3.1.2) rugged (0.21.2) simplecov (0.9.0) docile (~> 1.1.0) multi_json simplecov-html (~> 0.8.0) simplecov-html (0.8.0) - slop (3.4.4) - thor (0.18.1) + slop (3.6.0) + thor (0.19.1) thread_safe (0.3.4) + timers (4.0.1) + hitimes tzinfo (1.2.2) thread_safe (~> 0.1) webmock (1.11.0) @@ -101,6 +108,6 @@ DEPENDENCIES guard-rspec pry rake - rspec + rspec (~> 3.1.0) simplecov webmock diff --git a/spec/blame_spec.rb b/spec/blame_spec.rb index 959dc51..165bb48 100644 --- a/spec/blame_spec.rb +++ b/spec/blame_spec.rb @@ -9,8 +9,8 @@ context "each count" do it do blame.each do |commit, hunk_lines| - commit.should be_kind_of Gitlab::Git::Commit - hunk_lines.first.should == "# Contribute to GitLab" + expect(commit).to be_kind_of Gitlab::Git::Commit + hunk_lines.first == "# Contribute to GitLab" end end end diff --git a/spec/blob_snippet_spec.rb b/spec/blob_snippet_spec.rb index 77340d6..409d3b8 100644 --- a/spec/blob_snippet_spec.rb +++ b/spec/blob_snippet_spec.rb @@ -7,13 +7,13 @@ context 'empty lines' do let(:snippet) { Gitlab::Git::BlobSnippet.new('master', nil, nil, nil) } - it { snippet.data.should be_nil } + it { snippet.data == nil } end context 'present lines' do let(:snippet) { Gitlab::Git::BlobSnippet.new('master', ['wow', 'much'], 1, 'wow.rb') } - it { snippet.data.should == "wow\nmuch" } + it { snippet.data == "wow\nmuch" } end end end diff --git a/spec/blob_spec.rb b/spec/blob_spec.rb index 019dfe3..a038774 100644 --- a/spec/blob_spec.rb +++ b/spec/blob_spec.rb @@ -9,61 +9,61 @@ context 'file in subdir' do let(:blob) { Gitlab::Git::Blob.find(repository, SeedRepo::Commit::ID, "files/ruby/popen.rb") } - it { blob.id.should == SeedRepo::RubyBlob::ID } - it { blob.name.should == SeedRepo::RubyBlob::NAME } - it { blob.path.should == "files/ruby/popen.rb" } - it { blob.commit_id.should == SeedRepo::Commit::ID } - it { blob.data[0..10].should == SeedRepo::RubyBlob::CONTENT[0..10] } - it { blob.size.should == 669 } + it { blob.id == SeedRepo::RubyBlob::ID } + it { blob.name == SeedRepo::RubyBlob::NAME } + it { blob.path == "files/ruby/popen.rb" } + it { blob.commit_id == SeedRepo::Commit::ID } + it { blob.data[0..10] == SeedRepo::RubyBlob::CONTENT[0..10] } + it { blob.size == 669 } end context 'file in root' do let(:blob) { Gitlab::Git::Blob.find(repository, SeedRepo::Commit::ID, ".gitignore") } - it { blob.id.should == "dfaa3f97ca337e20154a98ac9d0be76ddd1fcc82" } - it { blob.name.should == ".gitignore" } - it { blob.path.should == ".gitignore" } - it { blob.commit_id.should == SeedRepo::Commit::ID } - it { blob.data[0..10].should == "*.rbc\n*.sas" } - it { blob.size.should == 241 } + it { blob.id == "dfaa3f97ca337e20154a98ac9d0be76ddd1fcc82" } + it { blob.name == ".gitignore" } + it { blob.path == ".gitignore" } + it { blob.commit_id == SeedRepo::Commit::ID } + it { blob.data[0..10] == "*.rbc\n*.sas" } + it { blob.size == 241 } end context 'non-exist file' do let(:blob) { Gitlab::Git::Blob.find(repository, SeedRepo::Commit::ID, "missing.rb") } - it { blob.should be_nil } + it { blob == nil } end context 'six submodule' do let(:blob) { Gitlab::Git::Blob.find(repository, SeedRepo::Commit::ID, 'six') } - it { blob.id.should == '409f37c4f05865e4fb208c771485f211a22c4c2d' } - it { blob.data.should == '' } + it { blob.id == '409f37c4f05865e4fb208c771485f211a22c4c2d' } + it { blob.data == '' } end end describe :raw do let(:raw_blob) { Gitlab::Git::Blob.raw(repository, SeedRepo::RubyBlob::ID) } - it { raw_blob.id.should == SeedRepo::RubyBlob::ID } - it { raw_blob.data[0..10].should == "require \'fi" } - it { raw_blob.size.should == 669 } + it { raw_blob.id == SeedRepo::RubyBlob::ID } + it { raw_blob.data[0..10] == "require \'fi" } + it { raw_blob.size == 669 } end describe 'encoding' do context 'file with russian text' do let(:blob) { Gitlab::Git::Blob.find(repository, SeedRepo::Commit::ID, "encoding/russian.rb") } - it { blob.name.should == "russian.rb" } - it { blob.data.lines.first.should == "Хороший файл" } - it { blob.size.should == 23 } + it { blob.name == "russian.rb" } + it { blob.data.lines.first == "Хороший файл" } + it { blob.size == 23 } end context 'file with Chinese text' do let(:blob) { Gitlab::Git::Blob.find(repository, SeedRepo::Commit::ID, "encoding/テスト.txt") } - it { blob.name.should == "テスト.txt" } - it { blob.data.should include("これはテスト") } - it { blob.size.should == 340 } + it { blob.name == "テスト.txt" } + it { expect(blob.data).to include("これはテスト") } + it { blob.size == 340 } end end end diff --git a/spec/branch_spec.rb b/spec/branch_spec.rb index a89a259..34e9731 100644 --- a/spec/branch_spec.rb +++ b/spec/branch_spec.rb @@ -6,21 +6,21 @@ subject { repository.branches } it { should be_kind_of Array } - its(:size) { should eq(3) } + it { subject.size == 3 } describe 'first branch' do let(:branch) { repository.branches.first } - it { branch.name.should == SeedRepo::Repo::BRANCHES.first } - it { branch.target.should == "0b4bc9a49b562e85de7cc9e834518ea6828729b9" } + it { branch.name == SeedRepo::Repo::BRANCHES.first } + it { branch.target == "0b4bc9a49b562e85de7cc9e834518ea6828729b9" } end describe 'last branch' do let(:branch) { repository.branches.last } - it { branch.name.should == SeedRepo::Repo::BRANCHES.last } - it { branch.target.should == SeedRepo::LastCommit::ID } + it { branch.name == SeedRepo::Repo::BRANCHES.last } + it { branch.target == SeedRepo::LastCommit::ID } end - it { repository.branches.size.should == SeedRepo::Repo::BRANCHES.size } + it { repository.branches.size == SeedRepo::Repo::BRANCHES.size } end diff --git a/spec/commit_spec.rb b/spec/commit_spec.rb index ce0378c..a2d48d6 100644 --- a/spec/commit_spec.rb +++ b/spec/commit_spec.rb @@ -41,21 +41,21 @@ @commit = Gitlab::Git::Commit.new(@raw_commit) end - it { @commit.short_id.should == @raw_commit.oid[0..10] } - it { @commit.id.should == @raw_commit.oid } - it { @commit.sha.should == @raw_commit.oid } - it { @commit.safe_message.should == @raw_commit.message } - it { @commit.created_at.should == @raw_commit.author[:time] } - it { @commit.date.should == @raw_commit.committer[:time] } - it { @commit.author_email.should == @author[:email] } - it { @commit.author_name.should == @author[:name] } - it { @commit.committer_name.should == @committer[:name] } - it { @commit.committer_email.should == @committer[:email] } - it { @commit.different_committer?.should be_true } - it { @commit.parents.should == @gitlab_parents } - it { @commit.parent_id.should == @parents.first.oid } - it { @commit.no_commit_message.should == "--no commit message" } - it { @commit.tree.should == @tree } + it { @commit.short_id == @raw_commit.oid[0..10] } + it { @commit.id == @raw_commit.oid } + it { @commit.sha == @raw_commit.oid } + it { @commit.safe_message == @raw_commit.message } + it { @commit.created_at == @raw_commit.author[:time] } + it { @commit.date == @raw_commit.committer[:time] } + it { @commit.author_email == @author[:email] } + it { @commit.author_name == @author[:name] } + it { @commit.committer_name == @committer[:name] } + it { @commit.committer_email == @committer[:email] } + it { @commit.different_committer? == true } + it { @commit.parents == @gitlab_parents } + it { @commit.parent_id == @parents.first.oid } + it { @commit.no_commit_message == "--no commit message" } + it { @commit.tree == @tree } after do # Erase the new commit so other tests get the original repo @@ -67,20 +67,20 @@ context 'Class methods' do describe :find do it "should return first head commit if without params" do - Gitlab::Git::Commit.last(repository).id.should == + Gitlab::Git::Commit.last(repository).id == repository.raw.head.target.oid end it "should return valid commit" do - Gitlab::Git::Commit.find(repository, SeedRepo::Commit::ID).should be_valid_commit + expect(Gitlab::Git::Commit.find(repository, SeedRepo::Commit::ID)).to be_valid_commit end it "should return valid commit for tag" do - Gitlab::Git::Commit.find(repository, 'v1.0.0').id.should == '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9' + Gitlab::Git::Commit.find(repository, 'v1.0.0').id == '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9' end it "should return nil" do - Gitlab::Git::Commit.find(repository, "+123_4532530XYZ").should be_nil + Gitlab::Git::Commit.find(repository, "+123_4532530XYZ") == nil end end @@ -88,19 +88,19 @@ context 'no path' do subject { Gitlab::Git::Commit.last_for_path(repository, 'master') } - its(:id) { should == SeedRepo::LastCommit::ID } + it { subject.id == SeedRepo::LastCommit::ID } end context 'path' do subject { Gitlab::Git::Commit.last_for_path(repository, 'master', 'files') } - its(:id) { should == SeedRepo::Commit::ID } + it { subject.id == SeedRepo::Commit::ID } end context 'ref + path' do subject { Gitlab::Git::Commit.last_for_path(repository, SeedRepo::Commit::ID, 'encoding') } - its(:id) { should == SeedRepo::BigCommit::ID } + it { subject.id == SeedRepo::BigCommit::ID } end end @@ -119,7 +119,7 @@ commits.map { |c| c.id } end - it { should have(3).elements } + it { subject.size == 3 } it { should include("874797c3a73b60d2187ed6e2fcabd289ff75171e") } it { should_not include(SeedRepo::Commit::ID) } end @@ -137,7 +137,7 @@ commits.map { |c| c.id } end - it { should have(3).elements } + it { subject.size == 3 } it { should include("2f63565e7aac07bcdadb654e253078b727143ec4") } it { should_not include(SeedRepo::Commit::ID) } end @@ -155,7 +155,7 @@ commits.map { |c| c.id } end - it { should have(3).elements } + it { subject.size == 3 } it { should include("874797c3a73b60d2187ed6e2fcabd289ff75171e") } it { should_not include(SeedRepo::Commit::ID) } end @@ -167,7 +167,7 @@ commits.map { |c| c.id } end - it { should have(1).elements } + it { subject.size == 1 } it { should include(SeedRepo::Commit::ID) } it { should_not include(SeedRepo::FirstCommit::ID) } end @@ -183,7 +183,7 @@ commits.map { |c| c.id } end - it { should have(16).elements } + it { subject.size == 16 } it { should include(SeedRepo::Commit::ID) } it { should include(SeedRepo::Commit::PARENT_ID) } it { should include(SeedRepo::FirstCommit::ID) } @@ -201,7 +201,7 @@ commits.map { |c| c.id } end - it { should have(13).elements } + it { subject.size == 13 } it { should include(SeedRepo::Commit::ID) } it { should include(SeedRepo::FirstCommit::ID) } it { should_not include(SeedRepo::LastCommit::ID) } @@ -218,7 +218,7 @@ commits.map { |c| c.id } end - it { should have(7).elements } + it { subject.size == 7 } it { should_not include(SeedRepo::Commit::PARENT_ID) } it { should_not include(SeedRepo::Commit::ID) } @@ -231,22 +231,22 @@ let(:gitlab_commit) { Gitlab::Git::Commit.new(rugged_commit) } subject { gitlab_commit } - its(:id) { should == SeedRepo::Commit::ID } + it { subject.id == SeedRepo::Commit::ID } end describe :init_from_hash do let(:commit) { Gitlab::Git::Commit.new(sample_commit_hash) } subject { commit } - its(:id) { should == sample_commit_hash[:id]} - its(:message) { should == sample_commit_hash[:message]} + it { subject.id == sample_commit_hash[:id]} + it { subject.message== sample_commit_hash[:message]} end describe :stats do subject { commit.stats } - its(:additions) { should eq(11) } - its(:deletions) { should eq(6) } + it { subject.additions == 11 } + it { subject.deletions == 6 } end describe :to_diff do @@ -257,7 +257,7 @@ end describe :has_zero_stats? do - it { commit.has_zero_stats?.should == false } + it { commit.has_zero_stats? == false } end describe :to_patch do @@ -272,22 +272,22 @@ subject { hash } it { should be_kind_of Hash } - its(:keys) { should =~ sample_commit_hash.keys } + it { hash.keys =~ sample_commit_hash.keys } end describe :diffs do subject { commit.diffs } it { should be_kind_of Array } - its(:size) { should eq(2) } - its(:first) { should be_kind_of Gitlab::Git::Diff } + it { subject.size == 2 } + it { expect(subject.first).to be_kind_of Gitlab::Git::Diff } end describe :ref_names do let(:commit) { Gitlab::Git::Commit.find(repository, 'master') } subject { commit.ref_names(repository) } - it { should have(2).elements } + it { subject.size == 2 } it { should include("master") } it { should_not include("feature") } end diff --git a/spec/compare_spec.rb b/spec/compare_spec.rb index 12ab017..861c4b3 100644 --- a/spec/compare_spec.rb +++ b/spec/compare_spec.rb @@ -9,7 +9,7 @@ compare.commits.map(&:id) end - it { should have(8).elements } + it { subject.size == 8 } it { should include(SeedRepo::Commit::PARENT_ID) } it { should_not include(SeedRepo::BigCommit::PARENT_ID) } end @@ -19,17 +19,17 @@ compare.diffs.map(&:new_path) end - it { should have(10).elements } + it { subject.size == 10 } it { should include('files/ruby/popen.rb') } it { should_not include('LICENSE') } - it { compare.timeout.should be_false } - it { compare.empty_diff?.should be_false } + it { compare.timeout == false } + it { compare.empty_diff? == false } end describe 'non-existing refs' do let(:compare) { Gitlab::Git::Compare.new(repository, 'no-such-branch', '1234567890') } - it { compare.commits.should be_empty } - it { compare.diffs.should be_empty } + it { expect(compare.commits).to be_empty } + it { expect(compare.diffs).to be_empty } end end diff --git a/spec/diff_spec.rb b/spec/diff_spec.rb index 5957afb..2ed9d4a 100644 --- a/spec/diff_spec.rb +++ b/spec/diff_spec.rb @@ -35,7 +35,7 @@ @diff = Gitlab::Git::Diff.new(@raw_diff_hash) end - it { @diff.to_hash.should == @raw_diff_hash } + it { @diff.to_hash == @raw_diff_hash } end context "init from rugged" do @@ -43,7 +43,7 @@ @diff = Gitlab::Git::Diff.new(@rugged_diff) end - it { @diff.to_hash.should == @raw_diff_hash } + it { @diff.to_hash == @raw_diff_hash } end end @@ -52,14 +52,14 @@ subject { diffs } it { should be_kind_of Array } - its(:size) { should eq(1) } + it { diffs.size == 1 } context :diff do subject { diffs.first } it { should be_kind_of Gitlab::Git::Diff } - its(:new_path) { should == 'files/ruby/feature.rb' } - its(:diff) { should include '+class Feature' } + it { subject.new_path == 'files/ruby/feature.rb' } + it { expect(subject.diff).to include '+class Feature' } end end @@ -69,7 +69,7 @@ @diffs = commit.parents[0].diff(commit).patches end - it { Gitlab::Git::Diff.new(@diffs[0]).submodule?.should == false } - it { Gitlab::Git::Diff.new(@diffs[1]).submodule?.should == true } + it { Gitlab::Git::Diff.new(@diffs[0]).submodule? == false } + it { Gitlab::Git::Diff.new(@diffs[1]).submodule? == true } end end diff --git a/spec/repository_spec.rb b/spec/repository_spec.rb index e720ad9..04495fc 100644 --- a/spec/repository_spec.rb +++ b/spec/repository_spec.rb @@ -18,37 +18,37 @@ let(:feature2) { 'feature2' } it "returns 'master' when master exists" do - repository.should_receive(:branch_names).at_least(:once).and_return([feature, master]) - repository.discover_default_branch.should == 'master' + expect(repository).to receive(:branch_names).at_least(:once).and_return([feature, master]) + repository.discover_default_branch == 'master' end it "returns non-master when master exists but default branch is set to something else" do File.write(File.join(repository.path, 'HEAD'), 'ref: refs/heads/feature') - repository.should_receive(:branch_names).at_least(:once).and_return([feature, master]) - repository.discover_default_branch.should == 'feature' + expect(repository).to receive(:branch_names).at_least(:once).and_return([feature, master]) + repository.discover_default_branch == 'feature' File.write(File.join(repository.path, 'HEAD'), 'ref: refs/heads/master') end it "returns a non-master branch when only one exists" do - repository.should_receive(:branch_names).at_least(:once).and_return([feature]) - repository.discover_default_branch.should == 'feature' + expect(repository).to receive(:branch_names).at_least(:once).and_return([feature]) + repository.discover_default_branch == 'feature' end it "returns a non-master branch when more than one exists and master does not" do - repository.should_receive(:branch_names).at_least(:once).and_return([feature, feature2]) - repository.discover_default_branch.should == 'feature' + expect(repository).to receive(:branch_names).at_least(:once).and_return([feature, feature2]) + repository.discover_default_branch == 'feature' end it "returns nil when no branch exists" do - repository.should_receive(:branch_names).at_least(:once).and_return([]) - repository.discover_default_branch.should be_nil + expect(repository).to receive(:branch_names).at_least(:once).and_return([]) + repository.discover_default_branch == nil end end describe :branch_names do subject { repository.branch_names } - it { should have(SeedRepo::Repo::BRANCHES.size).elements } + it { subject.size == SeedRepo::Repo::BRANCHES.size } it { should include("master") } it { should_not include("branch-from-space") } end @@ -57,17 +57,17 @@ subject { repository.tag_names } it { should be_kind_of Array } - it { should have(SeedRepo::Repo::TAGS.size).elements } - its(:last) { should == "v1.2.0" } + it { subject.size == SeedRepo::Repo::TAGS.size } + it { subject.last == "v1.2.0" } it { should include("v1.0.0") } it { should_not include("v5.0.0") } end shared_examples 'archive check' do |extenstion| - it { archive.should match(/tmp\/gitlab-git-test.git\/gitlab-git-test-eb49186cfa5c43380/) } - it { archive.should end_with extenstion } - it { File.exists?(archive).should be_true } - it { File.size?(archive).should_not be_nil } + it { expect(archive).to match(/tmp\/gitlab-git-test.git\/gitlab-git-test-eb49186cfa5c43380/) } + it { expect(archive).to end_with extenstion } + it { File.exists?(archive) == true } + it { expect(File.size?(archive)).not_to be_nil } end describe :archive do @@ -105,11 +105,11 @@ end describe :has_commits? do - it { repository.has_commits?.should be_true } + it { repository.has_commits? == true } end describe :empty? do - it { repository.empty?.should be_false } + it { repository.empty? == false } end describe :heads do @@ -117,12 +117,12 @@ subject { heads } it { should be_kind_of Array } - its(:size) { should eq(3) } + it { subject.size == 3 } context :head do subject { heads.first } - its(:name) { should == "feature" } + it { subject.name == "feature" } context :commit do subject { heads.first.target } @@ -137,8 +137,8 @@ subject { ref_names } it { should be_kind_of Array } - its(:first) { should == 'feature' } - its(:last) { should == 'v1.2.0' } + it { subject.first == 'feature' } + it { subject.last == 'v1.2.0' } end describe :search_files do @@ -146,15 +146,15 @@ subject { results } it { should be_kind_of Array } - its(:first) { should be_kind_of Gitlab::Git::BlobSnippet } + it { expect(subject.first).to be_kind_of Gitlab::Git::BlobSnippet } context 'blob result' do subject { results.first } - its(:ref) { should == 'master' } - its(:filename) { should == 'CHANGELOG' } - its(:startline) { should == 35 } - its(:data) { should include "Ability to filter by multiple labels" } + it { subject.ref == 'master' } + it { subject.filename == 'CHANGELOG' } + it { subject.startline == 35 } + it { expect(subject.data).to include "Ability to filter by multiple labels" } end end @@ -165,11 +165,11 @@ let(:submodules) { repository.submodules('master') } let(:submodule) { submodules.first } - it { submodules.should be_kind_of Hash } - it { submodules.empty?.should be_false } + it { expect(submodules).to be_kind_of Hash } + it { submodules.empty? == false } it 'should have valid data' do - submodule.should == [ + submodule == [ "six", { "id"=>"409f37c4f05865e4fb208c771485f211a22c4c2d", "path"=>"six", @@ -206,12 +206,12 @@ end describe :commit_count do - it { repository.commit_count("master").should == 14 } - it { repository.commit_count("feature").should == 9 } + it { repository.commit_count("master") == 14 } + it { repository.commit_count("feature") == 9 } end describe :archive_repo do - it { repository.archive_repo('master', '/tmp').should == '/tmp/gitlab-git-test.git/gitlab-git-test-eb49186cfa5c4338011f5f590fac11bd66c5c631.tar.gz' } + it { repository.archive_repo('master', '/tmp') == '/tmp/gitlab-git-test.git/gitlab-git-test-eb49186cfa5c4338011f5f590fac11bd66c5c631.tar.gz' } end describe "#reset" do @@ -251,7 +251,7 @@ end it "should not touch untracked files" do - expect(File.exist?(untracked_path)).to be_true + File.exist?(untracked_path) == true end it "should move the HEAD to the correct commit" do @@ -376,7 +376,7 @@ let(:remotes) { repository.remote_names } it "should have one entry: 'origin'" do - expect(remotes).to have(1).items + remotes.size == 1 expect(remotes.first).to eq("origin") end end @@ -437,7 +437,7 @@ it "should contain the same diffs as #diff" do diff_text = repo.diff_text("master", "feature") repo.diff("master", "feature").each do |single_diff| - expect(diff_text.include?(single_diff.diff)).to be_true + diff_text.include?(single_diff.diff) == true end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index eb39d6b..be9b619 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -32,7 +32,6 @@ TEST_MUTABLE_REPO_PATH = File.join(SUPPORT_PATH, "mutable-repo.git") RSpec.configure do |config| - config.treat_symbols_as_metadata_keys_with_true_values = true config.run_all_when_everything_filtered = true config.filter_run :focus config.order = 'random' diff --git a/spec/tag_spec.rb b/spec/tag_spec.rb index 4dee6f1..5f6a5bf 100644 --- a/spec/tag_spec.rb +++ b/spec/tag_spec.rb @@ -6,18 +6,18 @@ describe 'first tag' do let(:tag) { repository.tags.first } - it { tag.name.should == "v1.0.0" } - it { tag.target.should == "f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8" } - it { tag.message.should == "Release" } + it { tag.name == "v1.0.0" } + it { tag.target == "f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8" } + it { tag.message == "Release" } end describe 'last tag' do let(:tag) { repository.tags.last } - it { tag.name.should == "v1.2.0" } - it { tag.target.should == "10d64eed7760f2811ee2d64b44f1f7d3b364f17b" } - it { tag.message.should == "Version 1.2.0" } + it { tag.name == "v1.2.0" } + it { tag.target == "10d64eed7760f2811ee2d64b44f1f7d3b364f17b" } + it { tag.message == "Version 1.2.0" } end - it { repository.tags.size.should == 3 } + it { repository.tags.size == 3 } end diff --git a/spec/tree_spec.rb b/spec/tree_spec.rb index 9c86a49..09cf9e2 100644 --- a/spec/tree_spec.rb +++ b/spec/tree_spec.rb @@ -5,72 +5,72 @@ let(:repository) { Gitlab::Git::Repository.new(TEST_REPO_PATH) } let(:tree) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID) } - it { tree.should be_kind_of Array } - it { tree.empty?.should be_false } - it { tree.select(&:dir?).size.should == 2 } - it { tree.select(&:file?).size.should == 10 } - it { tree.select(&:submodule?).size.should == 2 } + it { expect(tree).to be_kind_of Array } + it { tree.empty? == false } + it { tree.select(&:dir?).size == 2 } + it { tree.select(&:file?).size == 10 } + it { tree.select(&:submodule?).size == 2 } describe :dir do let(:dir) { tree.select(&:dir?).first } - it { dir.should be_kind_of Gitlab::Git::Tree } - it { dir.id.should == '3c122d2b7830eca25235131070602575cf8b41a1' } - it { dir.commit_id.should == SeedRepo::Commit::ID } - it { dir.name.should == 'encoding' } - it { dir.path.should == 'encoding' } + it { expect(dir).to be_kind_of Gitlab::Git::Tree } + it { dir.id == '3c122d2b7830eca25235131070602575cf8b41a1' } + it { dir.commit_id == SeedRepo::Commit::ID } + it { dir.name == 'encoding' } + it { dir.path == 'encoding' } context :subdir do let(:subdir) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID, 'files').first } - it { subdir.should be_kind_of Gitlab::Git::Tree } - it { subdir.id.should == 'a1e8f8d745cc87e3a9248358d9352bb7f9a0aeba' } - it { subdir.commit_id.should == SeedRepo::Commit::ID } - it { subdir.name.should == 'html' } - it { subdir.path.should == 'files/html' } + it { expect(subdir).to be_kind_of Gitlab::Git::Tree } + it { subdir.id == 'a1e8f8d745cc87e3a9248358d9352bb7f9a0aeba' } + it { subdir.commit_id == SeedRepo::Commit::ID } + it { subdir.name == 'html' } + it { subdir.path == 'files/html' } end context :subdir_file do let(:subdir_file) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID, 'files/ruby').first } - it { subdir_file.should be_kind_of Gitlab::Git::Tree } - it { subdir_file.id.should == '7e3e39ebb9b2bf433b4ad17313770fbe4051649c' } - it { subdir_file.commit_id.should == SeedRepo::Commit::ID } - it { subdir_file.name.should == 'popen.rb' } - it { subdir_file.path.should == 'files/ruby/popen.rb' } + it { expect(subdir_file).to be_kind_of Gitlab::Git::Tree } + it { subdir_file.id == '7e3e39ebb9b2bf433b4ad17313770fbe4051649c' } + it { subdir_file.commit_id == SeedRepo::Commit::ID } + it { subdir_file.name == 'popen.rb' } + it { subdir_file.path == 'files/ruby/popen.rb' } end end describe :file do let(:file) { tree.select(&:file?).first } - it { file.should be_kind_of Gitlab::Git::Tree } - it { file.id.should == 'dfaa3f97ca337e20154a98ac9d0be76ddd1fcc82' } - it { file.commit_id.should == SeedRepo::Commit::ID } - it { file.name.should == '.gitignore' } + it { expect(file).to be_kind_of Gitlab::Git::Tree } + it { file.id == 'dfaa3f97ca337e20154a98ac9d0be76ddd1fcc82' } + it { file.commit_id == SeedRepo::Commit::ID } + it { file.name == '.gitignore' } end describe :readme do let(:file) { tree.select(&:readme?).first } - it { file.should be_kind_of Gitlab::Git::Tree } - it { file.name.should == 'README.md' } + it { expect(file).to be_kind_of Gitlab::Git::Tree } + it { file.name == 'README.md' } end describe :contributing do let(:file) { tree.select(&:contributing?).first } - it { file.should be_kind_of Gitlab::Git::Tree } - it { file.name.should == 'CONTRIBUTING.md' } + it { expect(file).to be_kind_of Gitlab::Git::Tree } + it { file.name == 'CONTRIBUTING.md' } end describe :submodule do let(:submodule) { tree.select(&:submodule?).first } - it { submodule.should be_kind_of Gitlab::Git::Tree } - it { submodule.id.should == '79bceae69cb5750d6567b223597999bfa91cb3b9' } - it { submodule.commit_id.should == '570e7b2abdd848b95f2f578043fc23bd6f6fd24d' } - it { submodule.name.should == 'gitlab-shell' } + it { expect(submodule).to be_kind_of Gitlab::Git::Tree } + it { submodule.id == '79bceae69cb5750d6567b223597999bfa91cb3b9' } + it { submodule.commit_id == '570e7b2abdd848b95f2f578043fc23bd6f6fd24d' } + it { submodule.name == 'gitlab-shell' } end end end