Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove --skip-bundler and post -- arg handling from rspec_autotest

Unfortunately, this breaks compatibility, but it is a much simpler and
more sane approach to including or excluding 'bundle exec' in the
autotest command.

- default: do not include it
- to include it, use the autotest bundler plugin
  • Loading branch information...
commit 49da08c55d3beeb363f987a1d1bc8b9b41bdcec6 1 parent 70acb98
@dchelimsky dchelimsky authored
Showing with 6 additions and 177 deletions.
  1. +2 −51 lib/autotest/rspec2.rb
  2. +4 −126 spec/autotest/rspec_spec.rb
View
53 lib/autotest/rspec2.rb
@@ -5,15 +5,10 @@ class RSpecCommandError < StandardError; end
class Autotest::Rspec2 < Autotest
- attr_reader :cl_args, :skip_bundler
- alias_method :skip_bundler?, :skip_bundler
-
SPEC_PROGRAM = File.expand_path('../../../bin/rspec', __FILE__)
def initialize
super()
- @cl_args = ARGV.dup << "--tty"
- @skip_bundler = @cl_args.delete("--skip-bundler")
clear_mappings
setup_rspec_project_mappings
@@ -46,9 +41,8 @@ def consolidate_failures(failed)
end
def make_test_cmd(files_to_test)
- warn_about_bundler if rspec_wants_bundler? && !autotest_wants_bundler?
files_to_test.empty? ? '' :
- "#{prefix}#{ruby}#{suffix} -S #{SPEC_PROGRAM} #{cl_args.join(' ')} #{normalize(files_to_test).keys.flatten.map { |f| "'#{f}'"}.join(' ')}"
+ "#{prefix}#{ruby}#{suffix} -S #{SPEC_PROGRAM} --tty #{normalize(files_to_test).keys.flatten.map { |f| "'#{f}'"}.join(' ')}"
end
def normalize(files_to_test)
@@ -58,55 +52,12 @@ def normalize(files_to_test)
end
end
- def warn_about_bundler
- RSpec.warn_deprecation <<-WARNING
-
-****************************************************************************
-DEPRECATION WARNING: you are using deprecated behaviour that will be removed
-from a future version of RSpec.
-
-RSpec's autotest extension is relying on the presence of a Gemfile in the
-project root directory to generate a command including 'bundle exec'.
-
-You have two options to suppress this message:
-
-If you want to include 'bundle exec' in the command, add a .autotest file to
-the project root with the following content:
-
- require 'autotest/bundler'
-
-If you want to _not_include 'bundle exec' in the command, pass --skip-bundler
-to autotest as an extra argument, like this:
-
- autotest -- --skip-bundler
-*****************************************************************
-WARNING
- end
-
- alias_method :autotest_prefix, :prefix
-
- def rspec_prefix
- (rspec_wants_bundler? && !autotest_wants_bundler?) ? "bundle exec " : ""
- end
-
- def prefix
- skip_bundler? ? "#{rspec_prefix}#{autotest_prefix}".gsub("bundle exec","") : "#{rspec_prefix}#{autotest_prefix}"
- end
-
- def autotest_wants_bundler?
- autotest_prefix =~ /bundle exec/
- end
-
def suffix
using_bundler? ? "" : defined?(:Gem) ? " -rrubygems" : ""
end
- def rspec_wants_bundler?
- gemfile? && !skip_bundler?
- end
-
def using_bundler?
- rspec_wants_bundler? || autotest_wants_bundler?
+ prefix =~ /bundle exec/
end
def gemfile?
View
130 spec/autotest/rspec_spec.rb
@@ -6,135 +6,13 @@
let(:ruby_cmd) { "ruby" }
before do
- RSpec.stub(:warn_deprecation)
File.stub(:exist?) { false }
- @orig_argv = ARGV.dup; ARGV.clear
end
- after { ARGV.clear; ARGV.concat(@orig_argv) }
-
- context "with ARGV" do
- it "passes ARGV to command" do
- ARGV.concat(%w[-c -f d])
- rspec_autotest.cl_args.should eq(%w[-c -f d --tty])
- end
-
- context "with --skip-bundler" do
- before do
- ARGV.concat(%w[--skip-bundler])
- end
- it "extracts --skip-bundler" do
- rspec_autotest.cl_args.should eq(%w[--tty])
- end
-
- it "sets skip_bundler? true" do
- rspec_autotest.skip_bundler?.should be_true
- end
- end
- end
-
- describe "handling bundler" do
- context "gemfile, no prefix" do
- before do
- File.stub(:exist?).with("./Gemfile") { true }
- end
-
- it "warns of deprecation of implicit inclusion of 'bundle exec'" do
- RSpec.should_receive(:warn_deprecation)
- rspec_autotest.make_test_cmd({})
- end
-
- it "includes bundle exec" do
- rspec_autotest.
- make_test_cmd({'a' => 'b'}).should match(/bundle exec/)
- end
- end
-
- context "gemfile, no prefix, --skip-bundler" do
- before do
- File.stub(:exist?).with("./Gemfile") { true }
- ARGV.concat(%w[--skip-bundler])
- end
-
- it "does not warn" do
- RSpec.should_not_receive(:warn_deprecation)
- rspec_autotest.make_test_cmd({})
- end
-
- it "does not include bundle exec" do
- rspec_autotest.
- make_test_cmd({'a' => 'b'}).should_not match(/bundle exec/)
- end
- end
-
- context "no gemfile, prefix" do
- before do
- File.stub(:exist?).with("./Gemfile") { false }
- end
-
- it "does not warn" do
- RSpec.should_not_receive(:warn_deprecation)
- rspec_autotest.make_test_cmd({'a' => 'b'})
- end
-
- it "includes bundle exec" do
- rspec_autotest.prefix = "bundle exec "
- rspec_autotest.
- make_test_cmd({'a' => 'b'}).should match(/bundle exec/)
- end
- end
-
- context "gemfile, prefix" do
- before do
- File.stub(:exist?).with("./Gemfile") { true }
- rspec_autotest.prefix = "bundle exec "
- end
-
- it "does not warn" do
- RSpec.should_not_receive(:warn_deprecation)
- rspec_autotest.make_test_cmd({'a' => 'b'})
- end
-
- it "includes bundle exec" do
- rspec_autotest.prefix = "bundle exec "
- rspec_autotest.
- make_test_cmd({'a' => 'b'}).should match(/bundle exec/)
- end
- end
-
- context "gemfile, prefix, --skip-bundler" do
- before do
- File.stub(:exist?).with("./Gemfile") { true }
- rspec_autotest.prefix = "bundle exec "
- rspec_autotest.stub(:skip_bundler?) { true }
- end
-
- it "does not warn" do
- RSpec.should_not_receive(:warn_deprecation)
- rspec_autotest.make_test_cmd({'a' => 'b'})
- end
-
- it "does not include bundle exec" do
- rspec_autotest.
- make_test_cmd({'a' => 'b'}).should_not match(/bundle exec/)
- end
- end
-
- context "no gemfile, no prefix" do
- before do
- File.stub(:exist?).with("./Gemfile") { false }
- end
-
- it "does not warn" do
- RSpec.should_not_receive(:warn_deprecation)
- rspec_autotest.make_test_cmd({'a' => 'b'})
- end
-
- it "does not include bundle exec" do
- rspec_autotest.
- make_test_cmd({'a' => 'b'}).should_not match(/bundle exec/)
- end
- end
+ it "uses autotest's prefix" do
+ rspec_autotest.prefix = "this is the prefix "
+ rspec_autotest.
+ make_test_cmd({'a' => 'b'}).should match(/this is the prefix/)
end
describe "commands" do

0 comments on commit 49da08c

Please sign in to comment.
Something went wrong with that request. Please try again.