summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjules2689 <julian@jnadeau.ca>2018-06-15 09:27:04 -0400
committerjules2689 <julian@jnadeau.ca>2018-06-15 09:27:04 -0400
commite8572b6a9070f77e39948acac4dc9289b2cf0962 (patch)
tree0ef32c4835f92f9573fb08fcf4422708d18b17d3
parent4b081829e0797a3c46f9083be7d369e0be2244ef (diff)
downloadbundler-jules2689/more-registered-events.tar.gz
Add tests for each of the hooksjules2689/more-registered-events
-rw-r--r--spec/plugins/hook_spec.rb114
1 files changed, 98 insertions, 16 deletions
diff --git a/spec/plugins/hook_spec.rb b/spec/plugins/hook_spec.rb
index 8bdf61a8ab..53062095e2 100644
--- a/spec/plugins/hook_spec.rb
+++ b/spec/plugins/hook_spec.rb
@@ -1,27 +1,109 @@
# frozen_string_literal: true
RSpec.describe "hook plugins" do
- before do
- build_repo2 do
- build_plugin "before-install-plugin" do |s|
- s.write "plugins.rb", <<-RUBY
- Bundler::Plugin::API.hook "before-install-all" do |deps|
- puts "gems to be installed \#{deps.map(&:name).join(", ")}"
- end
- RUBY
+ context "before-install-all hook" do
+ before do
+ build_repo2 do
+ build_plugin "before-install-all-plugin" do |s|
+ s.write "plugins.rb", <<-RUBY
+ Bundler::Plugin::API.hook Bundler::Plugin::Events::GEM_BEFORE_INSTALL_ALL do |deps|
+ puts "gems to be installed \#{deps.map(&:name).join(", ")}"
+ end
+ RUBY
+ end
end
+
+ bundle "plugin install before-install-all-plugin --source file://#{gem_repo2}"
+ end
+
+ it "runs before all rubygems are installed" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rake"
+ gem "rack"
+ G
+
+ expect(out).to include "gems to be installed rake, rack"
+ end
+ end
+
+ context "before-install hook" do
+ before do
+ build_repo2 do
+ build_plugin "before-install-plugin" do |s|
+ s.write "plugins.rb", <<-RUBY
+ Bundler::Plugin::API.hook Bundler::Plugin::Events::GEM_BEFORE_INSTALL do |spec_install|
+ puts "installing gem \#{spec_install.name}"
+ end
+ RUBY
+ end
+ end
+
+ bundle "plugin install before-install-plugin --source file://#{gem_repo2}"
+ end
+
+ it "runs before each rubygem is installed" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rake"
+ gem "rack"
+ G
+
+ expect(out).to include "installing gem rake"
+ expect(out).to include "installing gem rack"
end
+ end
+
+ context "after-install-all hook" do
+ before do
+ build_repo2 do
+ build_plugin "after-install-all-plugin" do |s|
+ s.write "plugins.rb", <<-RUBY
+ Bundler::Plugin::API.hook Bundler::Plugin::Events::GEM_AFTER_INSTALL_ALL do |deps|
+ puts "installed gems \#{deps.map(&:name).join(", ")}"
+ end
+ RUBY
+ end
+ end
+
+ bundle "plugin install after-install-all-plugin --source file://#{gem_repo2}"
+ end
+
+ it "runs after each rubygem is installed" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rake"
+ gem "rack"
+ G
- bundle "plugin install before-install-plugin --source file://#{gem_repo2}"
+ expect(out).to include "installed gems rake, rack"
+ end
end
- it "runs after a rubygem is installed" do
- install_gemfile <<-G
- source "file://#{gem_repo1}"
- gem "rake"
- gem "rack"
- G
+ context "after-install hook" do
+ before do
+ build_repo2 do
+ build_plugin "after-install-plugin" do |s|
+ s.write "plugins.rb", <<-RUBY
+ Bundler::Plugin::API.hook Bundler::Plugin::Events::GEM_AFTER_INSTALL do |spec_install|
+ puts "installed gem \#{spec_install.name} : \#{spec_install.state}"
+ end
+ RUBY
+ end
+ end
+
+ bundle "plugin install after-install-plugin --source file://#{gem_repo2}"
+ end
+
+ it "runs after each rubygem is installed" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rake"
+ gem "rack"
+ G
- expect(out).to include "gems to be installed rake, rack"
+ expect(out).to include "installed gem rake : installed"
+ expect(out).to include "installed gem rack : installed"
+ end
end
end