From 0e244f21c56cd711a7c5a3e80a125ce77d28b017 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Sun, 25 Oct 2009 20:13:28 -0700 Subject: [PATCH] Oh look, there's the ruby call I was looking for (exit!) --- features/env.rb | 35 ---------------- .../step_definitions/command_line_steps.rb | 4 +- test/rails_helper.rb | 40 +++++++++++++++++++ 3 files changed, 42 insertions(+), 37 deletions(-) delete mode 100644 features/env.rb create mode 100644 test/rails_helper.rb diff --git a/features/env.rb b/features/env.rb deleted file mode 100644 index 70f553de..00000000 --- a/features/env.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'cucumber/ast/step_invocation' - -module Cucumber - module Ast - class StepInvocation #:nodoc: - def invoke(step_mother, options) - find_step_match!(step_mother) - unless @skip_invoke || options[:dry_run] || @exception || @step_collection.exception - @skip_invoke = true - begin - @step_match.invoke(@multiline_arg) - step_mother.after_step - status!(:passed) - rescue Pending => e - failed(options, e, false) - status!(:pending) - rescue Undefined => e - failed(options, e, false) - status!(:undefined) - rescue Cucumber::Ast::Table::Different => e - @different_table = e.table - failed(options, e, false) - status!(:failed) - rescue SystemExit => e - raise - rescue Exception => e - failed(options, e, false) - status!(:failed) - end - end - end - end - end -end - diff --git a/features/step_definitions/command_line_steps.rb b/features/step_definitions/command_line_steps.rb index c319e510..71101160 100644 --- a/features/step_definitions/command_line_steps.rb +++ b/features/step_definitions/command_line_steps.rb @@ -53,14 +53,14 @@ When /^I run in a separate process: compass ([^\s]+) ?(.+)?$/ do |command, args| open('/tmp/last_error.compass_test.txt', 'w') do |file| file.puts @stderr.string end - exit # This doesn't exit + exit! end # this command will run forever # we kill it with a HUP signal from the parent process. args = (args || '').split args << { :wait => 5 } compass command, *args - exit + exit! end end diff --git a/test/rails_helper.rb b/test/rails_helper.rb new file mode 100644 index 00000000..789365b9 --- /dev/null +++ b/test/rails_helper.rb @@ -0,0 +1,40 @@ +module Compass + module RailsHelper + def generate_rails_app_directories(name) + Dir.mkdir name + Dir.mkdir File.join(name, "config") + Dir.mkdir File.join(name, "config", "initializers") + end + + # Generate a rails application without polluting our current set of requires + # with the rails libraries. This will allow testing against multiple versions of rails + # by manipulating the load path. + def generate_rails_app(name) + if pid = fork + Process.wait(pid) + if $?.exitstatus == 2 + raise LoadError, "Couldn't load rails" + elsif $?.exitstatus != 0 + raise "Failed to generate rails application." + end + else + begin + require 'rails/version' + require 'rails_generator' + require 'rails_generator/scripts/generate' + Rails::Generator::Base.use_application_sources! + capture_output do + Rails::Generator::Base.logger = Rails::Generator::SimpleLogger.new $stdout + Rails::Generator::Scripts::Generate.new.run([name], :generator => 'app') + end + rescue LoadError + Kernel.exit(2) + rescue => e + $stderr.puts e + Kernel.exit!(1) + end + Kernel.exit!(0) + end + end + end +end