diff --git a/Rakefile b/Rakefile index d19b8a0..00e60ee 100644 --- a/Rakefile +++ b/Rakefile @@ -1,8 +1,6 @@ -require 'bundler/gem_tasks' - require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) do |t| t.pattern = 'spec/cypress_on_rails/*_spec.rb' end -task default: %w[spec build] +task default: :spec \ No newline at end of file diff --git a/rakelib/release.rake b/rakelib/release.rake index 84fa92b..d935cd3 100644 --- a/rakelib/release.rake +++ b/rakelib/release.rake @@ -15,7 +15,7 @@ desc("Releases the gem using the given version. IMPORTANT: the gem version must be in valid rubygem format (no dashes). -This task depends on the gem-release ruby gem which is installed via `bundle install` +This task depends on the gem-release (ruby gem) which is installed via `bundle install` 1st argument: The new version in rubygem format (no dashes). Pass no argument to automatically perform a patch version bump. @@ -23,7 +23,7 @@ This task depends on the gem-release ruby gem which is installed via `bundle ins Note, accept defaults for rubygems options. Script will pause to get 2FA tokens. -Example: `rake release[1.19.0,false]`") +Example: `rake release[2.1.0,false]`") task :release, %i[gem_version dry_run] do |_t, args| include CypressOnRails::TaskHelpers @@ -40,7 +40,7 @@ task :release, %i[gem_version dry_run] do |_t, args| # See https://github.com/svenfuchs/gem-release sh_in_dir(gem_root, "git pull --rebase") - sh_in_dir(gem_root, "gem bump --no-commit #{gem_version.strip.empty? ? '' : %(-v #{gem_version})}") + sh_in_dir(gem_root, "gem bump --no-commit --file lib/cypress_on_rails/version.rb #{gem_version.strip.empty? ? '' : %(-v #{gem_version})}") # Release the new gem version puts "Carefully add your OTP for Rubygems. If you get an error, run 'gem release' again." diff --git a/rakelib/task_helpers.rb b/rakelib/task_helpers.rb index b6d6771..360706c 100644 --- a/rakelib/task_helpers.rb +++ b/rakelib/task_helpers.rb @@ -9,7 +9,15 @@ def gem_root # Executes a string or an array of strings in a shell in the given directory def sh_in_dir(dir, *shell_commands) - shell_commands.flatten.each { |shell_command| sh %(cd #{dir} && #{shell_command.strip}) } + Dir.chdir(dir) do + # Without `with_unbundled_env`, running bundle in the child directories won't correctly + # update the Gemfile.lock + Bundler.with_unbundled_env do + shell_commands.flatten.each do |shell_command| + sh(shell_command.strip) + end + end + end end end -end +end \ No newline at end of file