Bundle automatically if --dev or --edge is given as option.
This commit is contained in:
parent
c905fce35f
commit
5252f5c1c9
|
@ -168,12 +168,14 @@ module Rails::Generators
|
||||||
raise Error, "The template [#{rails_template}] could not be loaded. Error: #{e}"
|
raise Error, "The template [#{rails_template}] could not be loaded. Error: #{e}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def bundle_if_dev_or_edge
|
||||||
|
run "gem bundle" if dev_or_edge?
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
attr_accessor :rails_template
|
attr_accessor :rails_template
|
||||||
|
|
||||||
def set_default_accessors!
|
def set_default_accessors!
|
||||||
app_name # Cache app name
|
|
||||||
|
|
||||||
self.rails_template = case options[:template]
|
self.rails_template = case options[:template]
|
||||||
when /^http:\/\//
|
when /^http:\/\//
|
||||||
options[:template]
|
options[:template]
|
||||||
|
|
|
@ -144,7 +144,7 @@ class AppGeneratorTest < GeneratorsTestCase
|
||||||
template = %{ say "It works!" }
|
template = %{ say "It works!" }
|
||||||
template.instance_eval "def read; self; end" # Make the string respond to read
|
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 }
|
assert_match /It works!/, silence(:stdout){ generator.invoke }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -168,14 +168,16 @@ class AppGeneratorTest < GeneratorsTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_dev_option
|
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)
|
rails_path = File.expand_path('../../..', Rails.root)
|
||||||
dev_gem = %(directory #{rails_path.inspect}, :glob => "{*/,}*.gemspec")
|
dev_gem = %(directory #{rails_path.inspect}, :glob => "{*/,}*.gemspec")
|
||||||
assert_file 'Gemfile', /^#{Regexp.escape(dev_gem)}$/
|
assert_file 'Gemfile', /^#{Regexp.escape(dev_gem)}$/
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_edge_option
|
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")
|
edge_gem = %(gem "rails", :git => "git://github.com/rails/rails.git")
|
||||||
assert_file 'Gemfile', /^#{Regexp.escape(edge_gem)}$/
|
assert_file 'Gemfile', /^#{Regexp.escape(edge_gem)}$/
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue