diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-30 15:29:01 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-30 15:29:01 -0700 |
commit | 3060dfce5a45dac0d19ec3d73af3cdebdf0bb20e (patch) | |
tree | 0d0493d78519dae54cb633c7b8c2d279bf2475bd /railties/test | |
parent | 9696073b2db210745738c8328a6524ea6dc57fff (diff) | |
download | rails-3060dfce5a45dac0d19ec3d73af3cdebdf0bb20e.tar.gz rails-3060dfce5a45dac0d19ec3d73af3cdebdf0bb20e.tar.bz2 rails-3060dfce5a45dac0d19ec3d73af3cdebdf0bb20e.zip |
test some of the rc specification
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/generators/argv_scrubber_test.rb | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/railties/test/generators/argv_scrubber_test.rb b/railties/test/generators/argv_scrubber_test.rb index 9fd1112f18..5bf8442074 100644 --- a/railties/test/generators/argv_scrubber_test.rb +++ b/railties/test/generators/argv_scrubber_test.rb @@ -1,6 +1,7 @@ require 'active_support/test_case' require 'active_support/testing/autorun' require 'rails/generators/rails/app/app_generator' +require 'tempfile' module Rails module Generators @@ -14,7 +15,7 @@ module Rails define_method(:puts) { |str| output = str } define_method(:exit) { |code| exit_code = code } }) - scrubber.prepare + scrubber.prepare! assert_equal "Rails #{Rails::VERSION::STRING}", output assert_equal 0, exit_code end @@ -22,15 +23,54 @@ module Rails def test_prepare_returns_args scrubber = ARGVScrubber.new ['hi mom'] - args = scrubber.prepare + args = scrubber.prepare! assert_equal '--help', args.first end def test_no_mutations scrubber = ARGVScrubber.new ['hi mom'].freeze - args = scrubber.prepare + args = scrubber.prepare! assert_equal '--help', args.first end + + def test_new_command_no_rc + scrubber = Class.new(ARGVScrubber) { + def self.default_rc_file + File.join(Dir.tmpdir, 'whatever') + end + }.new ['new'] + args = scrubber.prepare! + assert_nil args.first + assert_equal [], args + end + + def test_new_homedir_rc + file = Tempfile.new 'myrcfile' + file.puts '--hello-world' + file.flush + + message = nil + scrubber = Class.new(ARGVScrubber) { + define_singleton_method(:default_rc_file) do + file.path + end + define_method(:puts) { |msg| message = msg } + }.new ['new'] + args = scrubber.prepare! + assert_nil args.first + assert_equal [nil, '--hello-world'], args + assert_match 'hello-world', message + assert_match file.path, message + ensure + file.close + file.unlink + end + + def test_no_rc + scrubber = ARGVScrubber.new ['new', '--no-rc'] + args = scrubber.prepare! + assert_equal [], args + end end end end |