Skip to content

Commit

Permalink
create a separate matcher to avoid failures
Browse files Browse the repository at this point in the history
  • Loading branch information
dfop02 committed Aug 24, 2023
1 parent babf887 commit bb22ccd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
8 changes: 4 additions & 4 deletions bundler/spec/plugins/install_spec.rb
Expand Up @@ -251,7 +251,7 @@ def exec(command, args)
expect(out).to include("Bundle complete!")

expect(the_bundle).to include_gems("rack 1.0.0")
plugin_should_be_installed("foo", version: "1.4.0")
plugin_should_be_installed_with_version("foo", "1.4.0")

gemfile <<-G
source '#{file_uri_for(gem_repo2)}'
Expand All @@ -265,7 +265,7 @@ def exec(command, args)
expect(out).to include("Bundle complete!")

expect(the_bundle).to include_gems("rack 1.0.0")
plugin_should_be_installed("foo", version: "1.5.0")
plugin_should_be_installed_with_version("foo", "1.5.0")
end

it "downgrade plugins version listed in gemfile" do
Expand All @@ -287,7 +287,7 @@ def exec(command, args)
expect(out).to include("Bundle complete!")

expect(the_bundle).to include_gems("rack 1.0.0")
plugin_should_be_installed("foo", version: "1.5.0")
plugin_should_be_installed_with_version("foo", "1.5.0")

gemfile <<-G
source '#{file_uri_for(gem_repo2)}'
Expand All @@ -301,7 +301,7 @@ def exec(command, args)
expect(out).to include("Bundle complete!")

expect(the_bundle).to include_gems("rack 1.0.0")
plugin_should_be_installed("foo", version: "1.4.0")
plugin_should_be_installed_with_version("foo", "1.4.0")
end

it "install only plugins not installed yet listed in gemfile" do
Expand Down
12 changes: 9 additions & 3 deletions bundler/spec/support/matchers.rb
Expand Up @@ -220,16 +220,22 @@ def indent(string, padding = 4, indent_character = " ")
RSpec::Matchers.define_negated_matcher :not_include_gems, :include_gems
RSpec::Matchers.alias_matcher :include_gem, :include_gems

def plugin_should_be_installed(*names, version: nil)
def plugin_should_be_installed(*names)
names.each do |name|
expect(Bundler::Plugin).to be_installed(name)
path = Pathname.new(Bundler::Plugin.installed?(name))

expect(File.basename(path)).to eq("#{name}-#{version}") unless version.nil?
expect(path + "plugins.rb").to exist
end
end

def plugin_should_be_installed_with_version(name, version)
expect(Bundler::Plugin).to be_installed(name)
path = Pathname.new(Bundler::Plugin.installed?(name))

expect(File.basename(path)).to eq("#{name}-#{version}")
expect(path + "plugins.rb").to exist
end

def plugin_should_not_be_installed(*names)
names.each do |name|
expect(Bundler::Plugin).not_to be_installed(name)
Expand Down

0 comments on commit bb22ccd

Please sign in to comment.