Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: rspec/rspec-core
base: v2.11.0
...
head fork: rspec/rspec-core
compare: bundler-raketask
Checking mergeability… Don't worry, you can still create the pull request.
  • 1 commit
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Commits on Sep 09, 2011
@dchelimsky dchelimsky Deprecate skip_bundler and gemfile options on rake task. Check for
presence of BUNDLE_GEMFILE instead.

- #454.
f90b9f5
Showing with 51 additions and 45 deletions.
  1. +17 −8 lib/rspec/core/rake_task.rb
  2. +34 −37 spec/rspec/core/rake_task_spec.rb
View
25 lib/rspec/core/rake_task.rb
@@ -20,19 +20,29 @@ class RakeTask < ::Rake::TaskLib
# 'spec/**/*_spec.rb'
attr_accessor :pattern
+ # Deprecated and has no effect. The rake task now checks
+ # ENV['BUNDLE_GEMFILE'] instead.
+ #
# By default, if there is a Gemfile, the generated command will include
# 'bundle exec'. Set this to true to ignore the presence of a Gemfile, and
# not add 'bundle exec' to the command.
#
# default:
# false
- attr_accessor :skip_bundler
+ def skip_bundler=(*)
+ RSpec.deprecate("RSpec::Core::RakeTask#skip_bundler=", 'ENV["BUNDLE_GEMFILE"]')
+ end
- # Name of Gemfile to use
+ # Deprecated and has no effect. The rake task now checks
+ # ENV['BUNDLE_GEMFILE'] instead.
+ #
+ # Name of Gemfile to use.
#
# default:
# Gemfile
- attr_accessor :gemfile
+ def gemfile=(*)
+ RSpec.deprecate("RSpec::Core::RakeTask#gemfile=", 'ENV["BUNDLE_GEMFILE"]')
+ end
# Deprecated. Use ruby_opts="-w" instead.
#
@@ -114,9 +124,8 @@ def spec_opts=(opts)
def initialize(*args)
@name = args.shift || :spec
@pattern, @rcov_path, @rcov_opts, @ruby_opts, @rspec_opts = nil, nil, nil, nil, nil
- @warning, @rcov, @skip_bundler = false, false, false
+ @warning, @rcov = false, false
@verbose, @fail_on_error = true, true
- @gemfile = 'Gemfile'
yield self if block_given?
@@ -156,7 +165,7 @@ def files_to_run # :nodoc:
def spec_command
@spec_command ||= begin
cmd_parts = []
- cmd_parts << "bundle exec" if gemfile? unless skip_bundler
+ cmd_parts << "bundle exec" if bundler?
cmd_parts << RUBY
cmd_parts << ruby_opts
cmd_parts << "-w" if warning?
@@ -189,8 +198,8 @@ def blank
lambda {|s| s == ""}
end
- def gemfile?
- File.exist?(gemfile)
+ def bundler?
+ ENV["BUNDLE_GEMFILE"] if ENV["BUNDLE_GEMFILE"] unless ENV["BUNDLE_GEMFILE"] == ""
end
end
View
71 spec/rspec/core/rake_task_spec.rb
@@ -9,14 +9,20 @@ def ruby
FileUtils::RUBY
end
- before do
- File.stub(:exist?) { false }
+ def with_bundle_gemfile(val)
+ begin
+ orig = ENV['BUNDLE_GEMFILE']
+ ENV['BUNDLE_GEMFILE'] = val
+ yield
+ ensure
+ ENV['BUNDLE_GEMFILE'] = orig
+ end
end
- def with_bundler
- task.skip_bundler = false
- File.stub(:exist?) { true }
- yield
+ def without_bundler
+ with_bundle_gemfile nil do
+ yield
+ end
end
def with_rcov
@@ -28,50 +34,39 @@ def spec_command
task.__send__(:spec_command)
end
- context "default" do
+ context "default (BUNDLE_GEMFILE nil)" do
it "renders rspec" do
- spec_command.should =~ /^#{ruby} -S rspec/
- end
- end
-
- context "with bundler" do
- context "with Gemfile" do
- it "renders bundle exec rspec" do
- File.stub(:exist?) { true }
- task.skip_bundler = false
- spec_command.should match(/bundle exec/)
+ with_bundle_gemfile nil do
+ spec_command.should =~ /^#{ruby} -S rspec/
end
end
+ end
- context "with non-standard Gemfile" do
- it "renders bundle exec rspec" do
- File.stub(:exist?) {|f| f =~ /AltGemfile/}
- task.gemfile = 'AltGemfile'
- task.skip_bundler = false
- spec_command.should match(/bundle exec/)
+ context "default (BUNDLE_GEMFILE '')" do
+ it "renders rspec" do
+ with_bundle_gemfile '' do
+ spec_command.should =~ /^#{ruby} -S rspec/
end
end
+ end
- context "without Gemfile" do
- it "renders bundle exec rspec" do
- File.stub(:exist?) { false }
- task.skip_bundler = false
- spec_command.should_not match(/bundle exec/)
- end
+ context "with bundler (BUNDLE_GEMFILE non-blank)" do
+ it "renders bundle exec rspec" do
+ spec_command.should match(/bundle exec/)
end
end
context "with rcov" do
it "renders rcov" do
- with_rcov do
- spec_command.should =~ /^#{ruby} -S rcov/
+ without_bundler do
+ with_rcov do
+ spec_command.should =~ /^#{ruby} -S rcov/
+ end
end
end
- end
- context "with bundler and rcov" do
- it "renders bundle exec rcov" do
- with_bundler do
+ context "with bundler" do
+ it "renders bundle exec rcov" do
with_rcov do
spec_command.should =~ /^bundle exec #{ruby} -S rcov/
end
@@ -81,8 +76,10 @@ def spec_command
context "with ruby options" do
it "renders them before -S" do
- task.ruby_opts = "-w"
- spec_command.should =~ /^#{ruby} -w -S rspec/
+ without_bundler do
+ task.ruby_opts = "-w"
+ spec_command.should =~ /^#{ruby} -w -S rspec/
+ end
end
end

No commit comments for this range

Something went wrong with that request. Please try again.