Skip to content

Commit

Permalink
Fix init command when a Rakefile is already present.
Browse files Browse the repository at this point in the history
Spec used to miss the bug because rake was required by an earlier test, so I split this spec in a separate file.
  • Loading branch information
Arnaud Meuret authored and ragaskar committed Jun 25, 2011
1 parent 1b20a6f commit d44bb8c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/jasmine/command_line_tool.rb
Expand Up @@ -44,13 +44,13 @@ def process(argv)
copy_unless_exists('spec/javascripts/support/jasmine-rails.yml', 'spec/javascripts/support/jasmine.yml')
else
copy_unless_exists('spec/javascripts/support/jasmine.yml')
require 'rake'
write_mode = 'w'
if File.exist?(dest_path('Rakefile'))
load dest_path('Rakefile')
write_mode = 'a'
end

require 'rake'
unless Rake::Task.task_defined?('jasmine')
File.open(dest_path('Rakefile'), write_mode) do |f|
f.write("\n" + File.read(template_path('lib/tasks/jasmine.rake')))
Expand Down
4 changes: 4 additions & 0 deletions spec/fixture/Rakefile
@@ -0,0 +1,4 @@
desc "A flunk task that does not want to be trampled"
task :jasmine_flunk do
nil
end
20 changes: 20 additions & 0 deletions spec/jasmine_command_line_tool_rakeless_spec.rb
@@ -0,0 +1,20 @@
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))

describe "Jasmine command line tool" do
context "when rake has not been required yet" do
before :each do
temp_dir_before
Dir::chdir @tmp
end

after :each do
temp_dir_after
end

it "should append to an existing Rakefile" do
FileUtils.cp("#{@old_dir}/spec/fixture/Rakefile", @tmp)
output = capture_stdout { Jasmine::CommandLineTool.new.process ["init"] }
output.should =~ /Jasmine has been installed with example specs./
end
end
end

0 comments on commit d44bb8c

Please sign in to comment.