Skip to content

Commit

Permalink
Fixed the specs to work for deferred rake task initializer blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
soulcutter committed Oct 18, 2012
1 parent 6b0e0d1 commit 662758d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
11 changes: 4 additions & 7 deletions lib/rspec/core/rake_task.rb
Expand Up @@ -150,13 +150,14 @@ def has_files?
def run_task(verbose)
files = has_files?
if files
command = spec_command
begin
puts spec_command if verbose
success = system(spec_command)
puts command if verbose
success = system(command)
rescue
puts failure_message if failure_message
end
raise("#{spec_command} failed") if fail_on_error unless success
raise("#{command} failed") if fail_on_error unless success
end
end

Expand All @@ -171,10 +172,6 @@ def files_to_run
end

def spec_command
@spec_command ||= default_spec_command
end

def default_spec_command
cmd_parts = []
cmd_parts << RUBY
cmd_parts << ruby_opts
Expand Down
14 changes: 6 additions & 8 deletions spec/rspec/core/rake_task_spec.rb
Expand Up @@ -28,15 +28,13 @@ def spec_command
end

context "with args passed to the rake task" do
let(:task) do
RakeTask.new(:task_name, :files) do |t, args|
it "correctly passes along task arguments" do
task = RakeTask.new(:rake_task_args, :files) do |t, args|
args[:files].should == "first_spec.rb"
end
end

it "correctly passes along task arguments" do
task.should_receive(:run_task) { true }
Rake.application.invoke_task("task_name[first_spec.rb]").should be_true
Rake.application.invoke_task("rake_task_args[first_spec.rb]").should be_true
end
end

Expand Down Expand Up @@ -102,6 +100,8 @@ def spec_command
end

def specify_consistent_ordering_of_files_to_run(pattern, task)
task.stub(:run_task) { true }
Rake.application.invoke_task(task.name)
orderings = [
%w[ a/1.rb a/2.rb a/3.rb ],
%w[ a/2.rb a/1.rb a/3.rb ],
Expand Down Expand Up @@ -138,9 +138,7 @@ def specify_consistent_ordering_of_files_to_run(pattern, task)

context "with paths with quotes" do
it "escapes the quotes" do
task = RakeTask.new do |t|
t.pattern = File.join(Dir.tmpdir, "*spec.rb")
end
task.pattern = File.join(Dir.tmpdir, "*spec.rb")
["first_spec.rb", "second_\"spec.rb", "third_\'spec.rb"].each do |file_name|
FileUtils.touch(File.join(Dir.tmpdir, file_name))
end
Expand Down

0 comments on commit 662758d

Please sign in to comment.