busser 0.7.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ci.yml +32 -0
  3. data/.github/workflows/pr-title.yml +28 -0
  4. data/.github/workflows/publish.yml +45 -0
  5. data/.gitignore +0 -1
  6. data/.markdownlint.yaml +6 -0
  7. data/.release-please-manifest.json +3 -0
  8. data/.rubocop.yml +9 -0
  9. data/.yamllint +6 -0
  10. data/CHANGELOG.md +44 -0
  11. data/CONTRIBUTING.md +103 -0
  12. data/Gemfile +10 -6
  13. data/README.md +82 -21
  14. data/Rakefile +6 -23
  15. data/bin/busser +2 -4
  16. data/busser.gemspec +12 -15
  17. data/features/deserialize_command.feature +4 -1
  18. data/features/plugin_install_command.feature +1 -1
  19. data/features/support/env.rb +4 -16
  20. data/lib/busser/cli.rb +6 -7
  21. data/lib/busser/command/deserialize.rb +16 -11
  22. data/lib/busser/command/plugin.rb +4 -5
  23. data/lib/busser/command/plugin_create.rb +23 -24
  24. data/lib/busser/command/plugin_install.rb +21 -14
  25. data/lib/busser/command/plugin_list.rb +3 -4
  26. data/lib/busser/command/setup.rb +17 -18
  27. data/lib/busser/command/suite.rb +3 -4
  28. data/lib/busser/command/suite_cleanup.rb +3 -3
  29. data/lib/busser/command/suite_path.rb +2 -3
  30. data/lib/busser/command/test.rb +4 -4
  31. data/lib/busser/cucumber/hooks.rb +1 -9
  32. data/lib/busser/cucumber.rb +69 -49
  33. data/lib/busser/helpers.rb +4 -5
  34. data/lib/busser/plugin.rb +12 -6
  35. data/lib/busser/rubygems.rb +35 -39
  36. data/lib/busser/runner_plugin/dummy.rb +2 -3
  37. data/lib/busser/runner_plugin.rb +1 -2
  38. data/lib/busser/thor.rb +3 -4
  39. data/lib/busser/ui.rb +15 -5
  40. data/lib/busser/version.rb +1 -2
  41. data/lib/busser.rb +3 -4
  42. data/release-please-config.json +13 -0
  43. data/renovate.json +8 -0
  44. data/spec/busser/command/deserialize_spec.rb +110 -0
  45. data/spec/busser/helpers_spec.rb +11 -10
  46. data/spec/busser/plugin_spec.rb +133 -0
  47. data/spec/busser/ui_spec.rb +35 -29
  48. data/spec/spec_helper.rb +1 -7
  49. metadata +29 -89
  50. data/.cane +0 -0
  51. data/.simplecov +0 -10
  52. data/.travis.yml +0 -52
  53. data/Guardfile +0 -18
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -16,10 +15,12 @@
16
15
  # See the License for the specific language governing permissions and
17
16
  # limitations under the License.
18
17
 
19
- require 'base64'
20
- require 'digest'
18
+ require "base64" unless defined?(Base64)
19
+ require "fileutils" unless defined?(FileUtils)
20
+ require "digest/md5" unless defined?(Digest::MD5)
21
+ require "digest" unless defined?(Digest)
21
22
 
22
- require 'busser/thor'
23
+ require "busser/thor"
23
24
 
24
25
  module Busser
25
26
 
@@ -31,23 +32,27 @@ module Busser
31
32
  #
32
33
  class Deserialize < Busser::Thor::BaseGroup
33
34
 
34
- class_option :destination, :desc => "Destination file path"
35
+ class_option :destination, desc: "Destination file path"
35
36
 
36
- class_option :md5sum, :desc => "MD5 digest of original file"
37
+ class_option :md5sum, desc: "MD5 digest of original file"
37
38
 
38
- class_option :perms, :desc => "Unix permissions on destination file"
39
+ class_option :perms, desc: "Unix permissions on destination file"
39
40
 
40
41
  def perform
41
42
  file = File.expand_path(options[:destination])
42
43
  contents = Base64.decode64(STDIN.read)
43
44
 
44
- FileUtils.mkdir_p(File.dirname(file))
45
- File.open(file, "wb") { |f| f.write(contents) }
46
- FileUtils.chmod(Integer(options[:perms]), file)
47
-
45
+ # Verify before writing. Checking afterwards still failed the command,
46
+ # but only once the unverified content was already on disk with its
47
+ # requested permissions, so a truncated stream left an executable file
48
+ # behind for anything later to pick up.
48
49
  if Digest::MD5.hexdigest(contents) != options[:md5sum]
49
50
  abort "Streamed file #{file} does not match source file md5"
50
51
  end
52
+
53
+ FileUtils.mkdir_p(File.dirname(file))
54
+ File.open(file, "wb") { |f| f.write(contents) }
55
+ FileUtils.chmod(Integer(options[:perms]), file)
51
56
  end
52
57
  end
53
58
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -16,10 +15,10 @@
16
15
  # See the License for the specific language governing permissions and
17
16
  # limitations under the License.
18
17
 
19
- require 'busser/thor'
20
- require 'busser/command/plugin_create'
21
- require 'busser/command/plugin_install'
22
- require 'busser/command/plugin_list'
18
+ require "busser/thor"
19
+ require "busser/command/plugin_create"
20
+ require "busser/command/plugin_install"
21
+ require "busser/command/plugin_list"
23
22
 
24
23
  module Busser
25
24
 
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -16,8 +15,8 @@
16
15
  # See the License for the specific language governing permissions and
17
16
  # limitations under the License.
18
17
 
19
- require 'busser'
20
- require 'busser/thor'
18
+ require "busser"
19
+ require "busser/thor"
21
20
 
22
21
  module Busser
23
22
 
@@ -29,13 +28,13 @@ module Busser
29
28
  #
30
29
  class PluginCreate < Busser::Thor::BaseGroup
31
30
 
32
- argument :name, :type => :string
31
+ argument :name, type: :string
33
32
 
34
- class_option :type, :aliases => "-t", :type => :string,
35
- :default => 'runner', :desc => "Type of plugin (runner)"
33
+ class_option :type, aliases: "-t", type: :string,
34
+ default: "runner", desc: "Type of plugin (runner)"
36
35
 
37
- class_option :license, :aliases => "-l", :default => "apachev2",
38
- :desc => "License type for gem (apachev2, mit, lgplv3, reserved)"
36
+ class_option :license, aliases: "-l", default: "apachev2",
37
+ desc: "License type for gem (apachev2, mit, lgplv3, reserved)"
39
38
 
40
39
  def create
41
40
  self.class.source_root(Busser.source_root.join("templates", "plugin"))
@@ -118,29 +117,29 @@ module Busser
118
117
  type_klass_name = "#{::Thor::Util.camel_case(options[:type])}Plugin"
119
118
 
120
119
  {
121
- :name => name,
122
- :gem_name => "busser-#{name}",
123
- :gemspec => "busser-#{name}.gemspec",
124
- :klass_name => ::Thor::Util.camel_case(name),
125
- :type => options[:type],
126
- :type_klass_name => type_klass_name,
127
- :constant_name => ::Thor::Util.snake_case(name).upcase,
128
- :author => author,
129
- :email => email,
130
- :license => options[:license],
131
- :license_string => license_string,
132
- :year => Time.now.year,
120
+ name: name,
121
+ gem_name: "busser-#{name}",
122
+ gemspec: "busser-#{name}.gemspec",
123
+ klass_name: ::Thor::Util.camel_case(name),
124
+ type: options[:type],
125
+ type_klass_name: type_klass_name,
126
+ constant_name: ::Thor::Util.snake_case(name).upcase,
127
+ author: author,
128
+ email: email,
129
+ license: options[:license],
130
+ license_string: license_string,
131
+ year: Time.now.year,
133
132
  }
134
133
  end
135
134
  end
136
135
 
137
136
  def author
138
- git_user_name = %x{git config user.name}.chomp
137
+ git_user_name = `git config user.name`.chomp
139
138
  git_user_name.empty? ? "TODO: Write your name" : git_user_name
140
139
  end
141
140
 
142
141
  def email
143
- git_user_email = %x{git config user.email}.chomp
142
+ git_user_email = `git config user.email`.chomp
144
143
  git_user_email.empty? ? "TODO: Write your email" : git_user_email
145
144
  end
146
145
 
@@ -166,8 +165,8 @@ module Busser
166
165
  end
167
166
 
168
167
  def license_comment
169
- @license_comment ||= IO.read(File.join(target_dir, license_filename)).
170
- gsub(/^/, '# ').gsub(/\s+$/, '')
168
+ @license_comment ||= IO.read(File.join(target_dir, license_filename))
169
+ .gsub(/^/, "# ").gsub(/\s+$/, "")
171
170
  end
172
171
  end
173
172
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -16,10 +15,10 @@
16
15
  # See the License for the specific language governing permissions and
17
16
  # limitations under the License.
18
17
 
19
- require 'openssl'
18
+ require "openssl" unless defined?(OpenSSL)
20
19
 
21
- require 'busser/rubygems'
22
- require 'busser/thor'
20
+ require "busser/rubygems"
21
+ require "busser/thor"
23
22
 
24
23
  module Busser
25
24
 
@@ -33,12 +32,20 @@ module Busser
33
32
 
34
33
  include Busser::RubyGems
35
34
 
36
- argument :plugins, :type => :array
35
+ argument :plugins, type: :array
37
36
 
38
- class_option :force_postinstall, :type => :boolean, :default => false,
39
- :desc => "Run the plugin's postinstall if it is already installed"
37
+ class_option :force_postinstall, type: :boolean, default: false,
38
+ desc: "Run the plugin's postinstall if it is already installed"
39
+
40
+ class_option :verbose, type: :boolean, default: false,
41
+ desc: "Set a more verbose output"
40
42
 
41
43
  def install_all
44
+ if options[:verbose]
45
+ Gem.configuration.verbose = 2 if options[:verbose]
46
+ info("Using http_proxy=#{rbg_options[:http_proxy].inspect}")
47
+ end
48
+
42
49
  silence_gem_ui do
43
50
  plugins.each { |plugin| install(plugin) }
44
51
  end
@@ -48,7 +55,7 @@ module Busser
48
55
 
49
56
  def install(plugin)
50
57
  gem_name, version = plugin.split("@")
51
- name = gem_name.sub(/^busser-/, '')
58
+ name = gem_name.sub(/^busser-/, "")
52
59
 
53
60
  new_install = install_plugin_gem(gem_name, version, name)
54
61
 
@@ -61,11 +68,11 @@ module Busser
61
68
  def install_plugin_gem(gem, version, name)
62
69
  if internal_plugin?(name) || gem_installed?(gem, version)
63
70
  info "Plugin #{name} already installed"
64
- return false
71
+ false
65
72
  else
66
73
  spec = install_gem(gem, version)
67
74
  info "Plugin #{name} installed (version #{spec.version})"
68
- return true
75
+ true
69
76
  end
70
77
  end
71
78
 
@@ -95,11 +102,11 @@ module Busser
95
102
  #
96
103
  def drop_ssl_verify_peer
97
104
  before = OpenSSL::SSL::VERIFY_PEER
98
- OpenSSL::SSL.send(:remove_const, 'VERIFY_PEER')
99
- OpenSSL::SSL.const_set('VERIFY_PEER', OpenSSL::SSL::VERIFY_NONE)
105
+ OpenSSL::SSL.send(:remove_const, "VERIFY_PEER")
106
+ OpenSSL::SSL.const_set("VERIFY_PEER", OpenSSL::SSL::VERIFY_NONE)
100
107
  yield
101
- OpenSSL::SSL.send(:remove_const, 'VERIFY_PEER')
102
- OpenSSL::SSL.const_set('VERIFY_PEER', before)
108
+ OpenSSL::SSL.send(:remove_const, "VERIFY_PEER")
109
+ OpenSSL::SSL.const_set("VERIFY_PEER", before)
103
110
  end
104
111
  end
105
112
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -16,8 +15,8 @@
16
15
  # See the License for the specific language governing permissions and
17
16
  # limitations under the License.
18
17
 
19
- require 'busser/plugin'
20
- require 'busser/thor'
18
+ require "busser/plugin"
19
+ require "busser/thor"
21
20
 
22
21
  module Busser
23
22
 
@@ -33,7 +32,7 @@ module Busser
33
32
  if plugin_data.empty?
34
33
  say "No plugins installed yet"
35
34
  else
36
- print_table([["Plugin", "Version"]] + plugin_data)
35
+ print_table([%w{Plugin Version}] + plugin_data)
37
36
  end
38
37
  end
39
38
 
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -16,8 +15,8 @@
16
15
  # See the License for the specific language governing permissions and
17
16
  # limitations under the License.
18
17
 
19
- require 'busser/thor'
20
- require 'busser/plugin'
18
+ require "busser/thor"
19
+ require "busser/plugin"
21
20
 
22
21
  module Busser
23
22
 
@@ -30,8 +29,8 @@ module Busser
30
29
  class Setup < Busser::Thor::BaseGroup
31
30
 
32
31
  class_option :type,
33
- :desc => "Type of binstub file to create (bourne or bat)",
34
- :default => "bourne"
32
+ desc: "Type of binstub file to create (bourne or bat)",
33
+ default: "bourne"
35
34
 
36
35
  def perform
37
36
  banner "Setting up Busser"
@@ -43,7 +42,7 @@ module Busser
43
42
 
44
43
  def create_busser_root
45
44
  info "Creating BUSSER_ROOT in #{root_path}"
46
- empty_directory(root_path, :verbose => false)
45
+ empty_directory(root_path, verbose: false)
47
46
  end
48
47
 
49
48
  def generate_busser_binstub
@@ -60,9 +59,9 @@ module Busser
60
59
  binstub = root_path + "bin/busser.bat"
61
60
  busser_root = root_path.to_s.gsub("/", "\\")
62
61
 
63
- File.unlink(binstub) if File.exists?(binstub)
64
- create_file(binstub, :verbose => false) do
65
- <<-BUSSER_BINSTUB.gsub(/^ {12}/, '')
62
+ File.unlink(binstub) if File.exist?(binstub)
63
+ create_file(binstub, verbose: false) do
64
+ <<-BUSSER_BINSTUB.gsub(/^ {12}/, "")
66
65
  @ECHO OFF
67
66
  REM This file was generated by Busser.
68
67
  REM
@@ -99,9 +98,9 @@ module Busser
99
98
  def generate_busser_binstub_for_bourne
100
99
  binstub = root_path + "bin/busser"
101
100
 
102
- File.unlink(binstub) if File.exists?(binstub)
103
- create_file(binstub, :verbose => false) do
104
- <<-BUSSER_BINSTUB.gsub(/^ {12}/, '')
101
+ File.unlink(binstub) if File.exist?(binstub)
102
+ create_file(binstub, verbose: false) do
103
+ <<-BUSSER_BINSTUB.gsub(/^ {12}/, "")
105
104
  #!/usr/bin/env sh
106
105
  #
107
106
  # This file was generated by Busser.
@@ -128,15 +127,15 @@ module Busser
128
127
  exec "#{ruby_bin}" "#{gem_bindir}/busser" "$@"
129
128
  BUSSER_BINSTUB
130
129
  end
131
- chmod(binstub, 0755, :verbose => false)
130
+ chmod(binstub, 0755, verbose: false)
132
131
  end
133
132
 
134
133
  def ruby_bin
135
- result = if bindir = RbConfig::CONFIG["bindir"]
136
- File.join(bindir, "ruby")
137
- else
138
- "ruby"
139
- end
134
+ result = if (bindir = RbConfig::CONFIG["bindir"])
135
+ File.join(bindir, "ruby")
136
+ else
137
+ "ruby"
138
+ end
140
139
  result = result.gsub("/", "\\").concat(".exe") if bat?
141
140
  result
142
141
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -16,9 +15,9 @@
16
15
  # See the License for the specific language governing permissions and
17
16
  # limitations under the License.
18
17
 
19
- require 'busser/thor'
20
- require 'busser/command/suite_cleanup'
21
- require 'busser/command/suite_path'
18
+ require "busser/thor"
19
+ require "busser/command/suite_cleanup"
20
+ require "busser/command/suite_path"
22
21
 
23
22
  module Busser
24
23
 
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -16,7 +15,8 @@
16
15
  # See the License for the specific language governing permissions and
17
16
  # limitations under the License.
18
17
 
19
- require 'busser/thor'
18
+ require "fileutils" unless defined?(FileUtils) # Pathname#rmtree needs it
19
+ require "busser/thor"
20
20
 
21
21
  module Busser
22
22
 
@@ -32,7 +32,7 @@ module Busser
32
32
  if suite_path.directory?
33
33
  Pathname.glob(suite_path + "*").each do |dir|
34
34
  info "Removing #{dir}"
35
- dir.rmtree
35
+ FileUtils.rm_rf(dir)
36
36
  end
37
37
  else
38
38
  info "Suite path directory #{suite_path} does not exist, skipping."
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -16,7 +15,7 @@
16
15
  # See the License for the specific language governing permissions and
17
16
  # limitations under the License.
18
17
 
19
- require 'busser/thor'
18
+ require "busser/thor"
20
19
 
21
20
  module Busser
22
21
 
@@ -28,7 +27,7 @@ module Busser
28
27
  #
29
28
  class SuitePath < Busser::Thor::BaseGroup
30
29
 
31
- argument :suite_name, :required => false
30
+ argument :suite_name, required: false
32
31
 
33
32
  def path
34
33
  say suite_path(suite_name).to_s
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  #
3
2
  # Author:: Fletcher Nichol (<fnichol@nichol.ca>)
4
3
  #
@@ -16,8 +15,8 @@
16
15
  # See the License for the specific language governing permissions and
17
16
  # limitations under the License.
18
17
 
19
- require 'busser/thor'
20
- require 'busser/plugin'
18
+ require "busser/thor"
19
+ require "busser/plugin"
21
20
 
22
21
  module Busser
23
22
 
@@ -29,12 +28,13 @@ module Busser
29
28
  #
30
29
  class Test < Busser::Thor::BaseGroup
31
30
 
32
- argument :plugins, :type => :array, :required => false
31
+ argument :plugins, type: :array, required: false
33
32
 
34
33
  def perform
35
34
  Busser::Plugin.runner_plugins(plugins).each do |runner_path|
36
35
  runner = File.basename(runner_path)
37
36
  next if skip_runner?(runner)
37
+
38
38
  klass = ::Thor::Util.camel_case(runner)
39
39
 
40
40
  banner "Running #{runner} test suite"
@@ -10,7 +10,7 @@ end
10
10
  # been saved off
11
11
  After do
12
12
  ENV.keys.select { |key| key =~ /^_CUKE_/ }.each do |backup_key|
13
- ENV[backup_key.sub(/^_CUKE_/, '')] = ENV.delete(backup_key)
13
+ ENV[backup_key.sub(/^_CUKE_/, "")] = ENV.delete(backup_key)
14
14
  end
15
15
  end
16
16
 
@@ -21,11 +21,3 @@ end
21
21
  def restore_envvar(key)
22
22
  ENV[key] = ENV.delete("_CUKE_#{key}")
23
23
  end
24
-
25
- def unbundlerize
26
- keys = %w[BUNDLER_EDITOR BUNDLE_BIN_PATH BUNDLE_GEMFILE RUBYOPT]
27
-
28
- keys.each { |key| backup_envvar(key) ; ENV.delete(key) }
29
- yield
30
- keys.each { |key| restore_envvar(key) }
31
- end
@@ -1,123 +1,143 @@
1
1
  begin
2
- require 'aruba/cucumber'
2
+ require "aruba/cucumber"
3
3
  rescue LoadError
4
4
  abort "The aruba gem must be in your development dependencies"
5
5
  end
6
6
 
7
- require 'busser/cucumber/hooks'
7
+ require "busser/cucumber/hooks"
8
8
 
9
- require 'tmpdir'
10
- require 'pathname'
9
+ require "fileutils" unless defined?(FileUtils)
10
+ require "tmpdir" unless defined?(Dir.mktmpdir)
11
+ require "pathname" unless defined?(Pathname)
11
12
 
12
13
  Given(/^a BUSSER_ROOT of "(.*?)"$/) do |busser_root|
13
- backup_envvar('BUSSER_ROOT')
14
+ backup_envvar("BUSSER_ROOT")
14
15
 
15
- ENV['BUSSER_ROOT'] = busser_root
16
+ ENV["BUSSER_ROOT"] = busser_root
16
17
  end
17
18
 
18
19
  Given(/^a test BUSSER_ROOT directory named "(.*?)"$/) do |name|
19
- backup_envvar('BUSSER_ROOT')
20
+ backup_envvar("BUSSER_ROOT")
20
21
 
21
22
  busser_root = Pathname.new(Dir.mktmpdir(name))
22
23
  (busser_root + "suites").mkpath
23
- ENV['BUSSER_ROOT'] = busser_root.to_s
24
+ ENV["BUSSER_ROOT"] = busser_root.to_s
25
+ # aruba 2.x runs commands with its own environment, so set it there too
26
+ set_environment_variable("BUSSER_ROOT", busser_root.to_s)
24
27
  @busser_root_dirs << busser_root
25
28
  end
26
29
 
27
30
  Given(/^I delete the BUSSER_ROOT directory$/) do
28
- FileUtils.rm_rf(ENV['BUSSER_ROOT'])
31
+ FileUtils.rm_rf(ENV["BUSSER_ROOT"])
29
32
  end
30
33
 
31
34
  Given(/^a suite directory named "(.*?)"$/) do |name|
32
- FileUtils.mkdir_p(File.join(ENV['BUSSER_ROOT'], "suites", name))
35
+ FileUtils.mkdir_p(File.join(ENV["BUSSER_ROOT"], "suites", name))
33
36
  end
34
37
 
35
38
  Given(/^a file in suite "(.*?)" named "(.*?)" with:$/) do |suite, file, content|
36
- file_name = File.join(ENV['BUSSER_ROOT'], "suites", suite, file)
37
- write_file(file_name, content)
39
+ # BUSSER_ROOT is outside aruba's working directory, and aruba 1.0+ refuses
40
+ # absolute paths in its file helpers, so write it directly.
41
+ file_name = File.join(ENV["BUSSER_ROOT"], "suites", suite, file)
42
+ FileUtils.mkdir_p(File.dirname(file_name))
43
+ File.write(file_name, content)
38
44
  end
39
45
 
40
46
  Given(/^a sandboxed GEM_HOME directory named "(.*?)"$/) do |name|
41
- backup_envvar('GEM_HOME')
42
- backup_envvar('GEM_PATH')
47
+ backup_envvar("GEM_HOME")
48
+ backup_envvar("GEM_PATH")
43
49
 
44
50
  gem_home = Pathname.new(Dir.mktmpdir(name))
45
- ENV['GEM_HOME'] = gem_home.to_s
46
- ENV['GEM_PATH'] = [gem_home.to_s, ENV['GEM_PATH']].join(':')
51
+ ENV["GEM_HOME"] = gem_home.to_s
52
+ ENV["GEM_PATH"] = [gem_home.to_s, ENV["GEM_PATH"]].join(":")
53
+ set_environment_variable("GEM_HOME", ENV["GEM_HOME"])
54
+ set_environment_variable("GEM_PATH", ENV["GEM_PATH"])
47
55
  @busser_root_dirs << gem_home
48
56
  end
49
57
 
50
58
  Given(/^a non bundler environment$/) do
51
- %w[BUNDLER_EDITOR BUNDLE_BIN_PATH BUNDLE_GEMFILE RUBYOPT].each do |key|
59
+ # Where bundler is currently serving gems from: vendor/bundle/ruby/<abi>
60
+ # when the bundle is vendored, the system gem directory otherwise. Busser's
61
+ # own runtime dependencies live there, so the child still needs it on
62
+ # GEM_PATH once bundler is gone. Read it while RubyGems still points at it.
63
+ bundled_gem_dir = Gem.dir
64
+
65
+ # RubyGems auto-requires bundler/setup whenever BUNDLER_SETUP is set, so
66
+ # leaving that behind lets bundler re-activate inside the child, walk up to
67
+ # this repository's Gemfile and .bundle/config, and reset GEM_HOME to the
68
+ # bundle -- plugins would install there instead of the sandbox.
69
+ %w{
70
+ BUNDLER_EDITOR BUNDLER_SETUP BUNDLER_VERSION
71
+ BUNDLE_BIN_PATH BUNDLE_GEMFILE BUNDLE_LOCKFILE BUNDLE_PATH
72
+ RUBYLIB RUBYOPT
73
+ }.each do |key|
52
74
  backup_envvar(key)
53
75
  ENV.delete(key)
76
+ delete_environment_variable(key)
54
77
  end
78
+
79
+ ENV["GEM_PATH"] =
80
+ [ENV["GEM_PATH"], bundled_gem_dir].compact.reject(&:empty?).join(":")
81
+ set_environment_variable("GEM_PATH", ENV["GEM_PATH"])
55
82
  end
56
83
 
57
84
  Then(/^the suite directory named "(.*?)" should exist$/) do |name|
58
- directory = File.join(ENV['BUSSER_ROOT'], "suites", name)
59
- check_directory_presence([directory], true)
85
+ directory = File.join(ENV["BUSSER_ROOT"], "suites", name)
86
+ expect(Dir).to exist(directory)
60
87
  end
61
88
 
62
89
  Then(/^the suite directory named "(.*?)" should not exist$/) do |name|
63
- directory = File.join(ENV['BUSSER_ROOT'], "suites", name)
64
- check_directory_presence([directory], false)
90
+ directory = File.join(ENV["BUSSER_ROOT"], "suites", name)
91
+ expect(Dir).to_not exist(directory)
65
92
  end
66
93
 
67
94
  Then(/^the suite file "(.*?)" should contain exactly:$/) do |file, content|
68
- file_name = File.join(ENV['BUSSER_ROOT'], "suites", file)
69
- check_file_content(file_name, content)
95
+ file_name = File.join(ENV["BUSSER_ROOT"], "suites", file)
96
+ expect(File.read(file_name)).to eq(content)
70
97
  end
71
98
 
72
99
  Then(/^the vendor directory named "(.*?)" should exist$/) do |name|
73
- directory = File.join(ENV['BUSSER_ROOT'], "vendor", name)
74
- check_directory_presence([directory], true)
100
+ directory = File.join(ENV["BUSSER_ROOT"], "vendor", name)
101
+ expect(Dir).to exist(directory)
75
102
  end
76
103
 
77
104
  Then(/^the vendor directory named "(.*?)" should not exist$/) do |name|
78
- directory = File.join(ENV['BUSSER_ROOT'], "vendor", name)
79
- check_directory_presence([directory], false)
105
+ directory = File.join(ENV["BUSSER_ROOT"], "vendor", name)
106
+ expect(Dir).to_not exist(directory)
80
107
  end
81
108
 
82
109
  Then(/^the vendor file "(.*?)" should contain "(.*?)"$/) do |file, content|
83
- file_name = File.join(ENV['BUSSER_ROOT'], "vendor", file)
84
- check_file_content(file_name, content, true)
110
+ file_name = File.join(ENV["BUSSER_ROOT"], "vendor", file)
111
+ expect(File.read(file_name)).to include(content)
85
112
  end
86
113
 
114
+ # Check the sandboxed GEM_HOME directly. Shelling out to `gem list` depends on
115
+ # the child process inheriting the sandbox and a bundler-free environment,
116
+ # which aruba 2.x no longer arranges for us.
87
117
  Then(/^a gem named "(.*?)" is installed with version "(.*?)"$/) do |name, ver|
88
- unbundlerize do
89
- run_simple(unescape("gem list #{name} --version #{ver} -i"), true, nil)
90
- end
118
+ specs = Dir.glob(File.join(ENV["GEM_HOME"], "specifications", "#{name}-#{ver}.gemspec"))
119
+ expect(specs).to_not be_empty
91
120
  end
92
121
 
93
122
  Then(/^a gem named "(.*?)" is installed$/) do |name|
94
- unbundlerize do
95
- run_simple(unescape("gem list #{name} -i"), true, nil)
96
- end
123
+ specs = Dir.glob(File.join(ENV["GEM_HOME"], "specifications", "#{name}-*.gemspec"))
124
+ expect(specs).to_not be_empty
97
125
  end
98
126
 
99
127
  Then(/^the BUSSER_ROOT directory should exist$/) do
100
- check_directory_presence([ENV['BUSSER_ROOT']], true)
128
+ expect(Dir).to exist(ENV["BUSSER_ROOT"])
101
129
  end
102
130
 
103
131
  Then(/^a busser binstub file should contain:$/) do |partial_content|
104
- file = File.join(ENV['BUSSER_ROOT'], %w{bin busser})
105
- check_file_content(file, Regexp.new(Regexp.escape(partial_content)), true)
132
+ file = File.join(ENV["BUSSER_ROOT"], %w{bin busser})
133
+ expect(File.read(file)).to include(partial_content)
106
134
  end
107
135
 
108
136
  Then(/^a bat busser binstub file should contain:$/) do |partial_content|
109
- file = File.join(ENV['BUSSER_ROOT'], %w{bin busser.bat})
110
- check_file_content(file, Regexp.new(Regexp.escape(partial_content)), true)
111
- end
112
-
113
- Then(/^the file "(.*?)" should have permissions "(.*?)"$/) do |file, perms|
114
- in_current_dir do
115
- file_perms = sprintf("%o", File.stat(file).mode)
116
- file_perms = file_perms[2, 4]
117
- expect(file_perms).to eq(perms)
118
- end
137
+ file = File.join(ENV["BUSSER_ROOT"], %w{bin busser.bat})
138
+ expect(File.read(file)).to include(partial_content)
119
139
  end
120
140
 
121
141
  Then(/^pry me$/) do
122
- require 'pry' ; binding.pry
142
+ require "pry"; binding.pry # rubocop:disable Lint/Debugger
123
143
  end