Permalink
Browse files

Bundle automatically if --dev or --edge is given as option.

  • Loading branch information...
1 parent c905fce commit 5252f5c1c96001795d3e723ad8e48117e34c045b @josevalim josevalim committed Jan 15, 2010
@@ -168,12 +168,14 @@ def apply_rails_template
raise Error, "The template [#{rails_template}] could not be loaded. Error: #{e}"
end
+ def bundle_if_dev_or_edge
+ run "gem bundle" if dev_or_edge?
+ end
+
protected
attr_accessor :rails_template
def set_default_accessors!
- app_name # Cache app name
-
self.rails_template = case options[:template]
when /^http:\/\//
options[:template]
@@ -144,7 +144,7 @@ def test_template_is_executed_when_supplied
template = %{ say "It works!" }
template.instance_eval "def read; self; end" # Make the string respond to read
- generator([destination_root], :template => path, :database => "sqlite3").expects(:open).with(path).returns(template)
+ generator([destination_root], :template => path).expects(:open).with(path).returns(template)
assert_match /It works!/, silence(:stdout){ generator.invoke }
end
@@ -168,14 +168,16 @@ def test_file_is_added_for_backwards_compatibility
end
def test_dev_option
- run_generator [destination_root, "--dev"]
+ generator([destination_root], :dev => true).expects(:run).with("gem bundle")
+ silence(:stdout){ generator.invoke }
rails_path = File.expand_path('../../..', Rails.root)
dev_gem = %(directory #{rails_path.inspect}, :glob => "{*/,}*.gemspec")
assert_file 'Gemfile', /^#{Regexp.escape(dev_gem)}$/
end
def test_edge_option
- run_generator [destination_root, "--edge"]
+ generator([destination_root], :edge => true).expects(:run).with("gem bundle")
+ silence(:stdout){ generator.invoke }
edge_gem = %(gem "rails", :git => "git://github.com/rails/rails.git")
assert_file 'Gemfile', /^#{Regexp.escape(edge_gem)}$/
end

2 comments on commit 5252f5c

@KieranP

This assumes gem bundler is installed though..... if it isn't......

@KieranP

(otherwise, nice commit, really shortens the setup process for my rails 3 generator script - http://gist.github.com/225330)

Please sign in to comment.