aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/generators/testing
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails/generators/testing')
-rw-r--r--railties/lib/rails/generators/testing/assertions.rb2
-rw-r--r--railties/lib/rails/generators/testing/behaviour.rb27
2 files changed, 19 insertions, 10 deletions
diff --git a/railties/lib/rails/generators/testing/assertions.rb b/railties/lib/rails/generators/testing/assertions.rb
index 2e877f8762..bd069e4bd0 100644
--- a/railties/lib/rails/generators/testing/assertions.rb
+++ b/railties/lib/rails/generators/testing/assertions.rb
@@ -1,3 +1,5 @@
+require 'shellwords'
+
module Rails
module Generators
module Testing
diff --git a/railties/lib/rails/generators/testing/behaviour.rb b/railties/lib/rails/generators/testing/behaviour.rb
index 8e9028a3fb..fd2ea274e1 100644
--- a/railties/lib/rails/generators/testing/behaviour.rb
+++ b/railties/lib/rails/generators/testing/behaviour.rb
@@ -50,7 +50,7 @@ module Rails
# class AppGeneratorTest < Rails::Generators::TestCase
# tests AppGenerator
# destination File.expand_path("../tmp", File.dirname(__FILE__))
- # teardown :cleanup_destination_root
+ # setup :prepare_destination
#
# test "database.yml is not created when skipping Active Record" do
# run_generator %w(myapp --skip-active-record)
@@ -61,11 +61,9 @@ module Rails
# You can provide a configuration hash as second argument. This method returns the output
# printed by the generator.
def run_generator(args=self.default_arguments, config={})
- without_thor_debug do
- capture(:stdout) do
- args += ['--skip-bundle'] unless args.include? '--dev'
- self.generator_class.start(args, config.reverse_merge(destination_root: destination_root))
- end
+ capture(:stdout) do
+ args += ['--skip-bundle'] unless args.include? '--dev'
+ self.generator_class.start(args, config.reverse_merge(destination_root: destination_root))
end
end
@@ -103,12 +101,21 @@ module Rails
Dir.glob("#{dirname}/[0-9]*_*.rb").grep(/\d+_#{file_name}.rb$/).first
end
- # TODO: remove this once Bundler 1.5.2 is released
- def without_thor_debug # :nodoc:
- thor_debug, ENV['THOR_DEBUG'] = ENV['THOR_DEBUG'], nil
+ def capture(stream)
+ stream = stream.to_s
+ captured_stream = Tempfile.new(stream)
+ stream_io = eval("$#{stream}")
+ origin_stream = stream_io.dup
+ stream_io.reopen(captured_stream)
+
yield
+
+ stream_io.rewind
+ return captured_stream.read
ensure
- ENV['THOR_DEBUG'] = thor_debug
+ captured_stream.close
+ captured_stream.unlink
+ stream_io.reopen(origin_stream)
end
end
end