Permalink
Browse files

Make the aruba features the default ones.

  • Loading branch information...
1 parent c11e00f commit e610a024e027847f7a928f33b7fc34a55ed526e0 @aslakhellesoy aslakhellesoy committed Nov 30, 2010
Showing with 355 additions and 357 deletions.
  1. +0 −8 aruba_features/step_definitions/cucumber_steps.rb
  2. +0 −31 aruba_features/support/env.rb
  3. 0 {aruba_features → features}/background.feature
  4. 0 {aruba_features → features}/custom_formatter.feature
  5. 0 {aruba_features → features}/execute_with_tag_filter.feature
  6. 0 {aruba_features → features}/hooks.feature
  7. 0 {aruba_features → features}/json_formatter.feature
  8. 0 {aruba_features → features}/stats_formatters.feature
  9. +5 −163 features/step_definitions/cucumber_steps.rb
  10. +23 −149 features/support/env.rb
  11. 0 {aruba_features → features}/tagged_hooks.feature
  12. +4 −6 gem_tasks/{features.rake → cucumber.rake}
  13. 0 {features → legacy_features}/announce.feature
  14. 0 {features → legacy_features}/api/list_step_defs_as_json.feature
  15. 0 {features → legacy_features}/api/run_cli_main_with_existing_runtime.feature
  16. 0 {features → legacy_features}/around_hooks.feature
  17. 0 {features → legacy_features}/bug_371.feature
  18. 0 {features → legacy_features}/bug_464.feature
  19. 0 {features → legacy_features}/bug_475.feature
  20. 0 {features → legacy_features}/bug_585_tab_indentation.feature
  21. 0 {features → legacy_features}/bug_600.feature
  22. 0 {features → legacy_features}/call_steps_from_stepdefs.feature
  23. 0 {features → legacy_features}/cucumber_cli.feature
  24. 0 {features → legacy_features}/cucumber_cli_outlines.feature
  25. 0 {features → legacy_features}/default_snippets.feature
  26. 0 {features → legacy_features}/diffing.feature
  27. 0 {features → legacy_features}/drb_server_integration.feature
  28. 0 {features → legacy_features}/exception_in_after_block.feature
  29. 0 {features → legacy_features}/exception_in_after_step_block.feature
  30. 0 {features → legacy_features}/exception_in_before_block.feature
  31. 0 {features → legacy_features}/exclude_files.feature
  32. 0 {features → legacy_features}/expand.feature
  33. 0 {features → legacy_features}/html_formatter.feature
  34. 0 {features → legacy_features}/html_formatter/a.html
  35. 0 {features → legacy_features}/junit_formatter.feature
  36. 0 {features → legacy_features}/language_from_header.feature
  37. 0 {features → legacy_features}/language_help.feature
  38. 0 {features → legacy_features}/listener_debugger_formatter.feature
  39. 0 {features → legacy_features}/multiline_names.feature
  40. 0 {features → legacy_features}/post_configuration_hook.feature
  41. 0 {features → legacy_features}/profiles.feature
  42. 0 {features → legacy_features}/rake_task.feature
  43. 0 {features → legacy_features}/report_called_undefined_steps.feature
  44. 0 {features → legacy_features}/rerun_formatter.feature
  45. 0 {features → legacy_features}/simplest.feature
  46. 0 {features → legacy_features}/snippet.feature
  47. 0 {features → legacy_features}/snippets_when_using_star_keyword.feature
  48. +166 −0 legacy_features/step_definitions/cucumber_steps.rb
  49. 0 {features → legacy_features}/step_definitions/extra_steps.rb
  50. 0 {features → legacy_features}/step_definitions/simplest_steps.rb
  51. 0 {features → legacy_features}/step_definitions/wire_steps.rb
  52. +157 −0 legacy_features/support/env.rb
  53. 0 {features → legacy_features}/support/env.rb.simplest
  54. 0 {features → legacy_features}/support/fake_wire_server.rb
  55. 0 {features → legacy_features}/table_diffing.feature
  56. 0 {features → legacy_features}/table_mapping.feature
  57. 0 {features → legacy_features}/transform.feature
  58. 0 {features → legacy_features}/unicode_table.feature
  59. 0 {features → legacy_features}/wire_protocol.feature
  60. 0 {features → legacy_features}/wire_protocol_table_diffing.feature
  61. 0 {features → legacy_features}/wire_protocol_tags.feature
  62. 0 {features → legacy_features}/wire_protocol_timeouts.feature
  63. 0 {features → legacy_features}/work_in_progress.feature
@@ -1,8 +0,0 @@
-When /^I run cucumber "([^"]*)"$/ do |cmd|
- run_simple(unescape("cucumber #{cmd}"), false)
-end
-
-Then /^it should (pass|fail) with JSON:$/ do |pass_fail, json|
- JSON.pretty_generate(JSON.parse(all_stdout)).should == JSON.pretty_generate(JSON.parse(json))
- assert_exiting_with(pass_fail == 'pass')
-end
@@ -1,31 +0,0 @@
-require 'aruba/api'
-
-# Monkey patch aruba to filter out some stuff
-module Aruba::Api
- alias _all_stdout all_stdout
-
- def all_stdout
- out = _all_stdout
-
- # Remove absolute paths
- out.gsub!(/#{Dir.pwd}\/tmp\/aruba/, '.')
- # Make duration predictable
- out.gsub!(/^\d+m\d+\.\d+s$/, '0m0.012s')
- # Remove SimpleCov message
- out.gsub!(/Coverage report generated for Cucumber Features to #{Dir.pwd}\/coverage\n$/, '')
-
- out
- end
-end
-
-require 'aruba/cucumber'
-
-Before do |scenario|
- @scenario = scenario
-
- # Make sure bin/cucumber runs with SimpleCov enabled
- set_env('SIMPLECOV', 'true')
-
- # Set a longer timeout for aruba
- @aruba_timeout_seconds = 5
-end
File renamed without changes.
File renamed without changes.
@@ -1,166 +1,8 @@
-# encoding: utf-8
-require 'tempfile'
-
-Given /^I am in (.*)$/ do |example_dir_relative_path|
- @current_dir = fixtures_dir(example_dir_relative_path)
-end
-
-Given /^a standard Cucumber project directory structure$/ do
- @current_dir = working_dir
- in_current_dir do
- FileUtils.rm_rf 'features' if File.directory?('features')
- FileUtils.mkdir_p 'features/support'
- FileUtils.mkdir 'features/step_definitions'
- end
-end
-
-Given /^the (.*) directory is empty$/ do |directory|
- in_current_dir do
- FileUtils.remove_dir(directory) rescue nil
- FileUtils.mkdir 'tmp'
- end
-end
-
-Given /^a file named "([^"]*)"$/ do |file_name|
- create_file(file_name, '')
-end
-
-Given /^a file named "([^"]*)" with:$/ do |file_name, file_content|
- create_file(file_name, file_content)
-end
-
-Given /^the following profiles? (?:are|is) defined:$/ do |profiles|
- create_file('cucumber.yml', profiles)
-end
-
-Given /^I am running spork in the background$/ do
- run_spork_in_background
-end
-
-Given /^I am running spork in the background on port (\d+)$/ do |port|
- run_spork_in_background(port.to_i)
-end
-
-Given /^I am not running (?:.*) in the background$/ do
- # no-op
-end
-
-Given /^I have environment variable (\w+) set to "([^"]*)"$/ do |variable, value|
- set_env_var(variable, value)
-end
-
-When /^I run cucumber (.*)$/ do |cucumber_opts|
- run "#{Cucumber::RUBY_BINARY} -I rubygems #{cucumber_bin} --no-color #{cucumber_opts} CUCUMBER_OUTPUT_ENCODING=UTF-8"
-end
-
-When /^I run rake (.*)$/ do |rake_opts|
- run "rake #{rake_opts} --trace"
-end
-
-When /^I run the following Ruby code:$/ do |code|
- run %{#{Cucumber::RUBY_BINARY} -r rubygems -I #{cucumber_lib_dir} -e "#{code}"}
-end
-
-Then /^it should (fail|pass)$/ do |success|
- if success == 'fail'
- last_exit_status.should_not == 0
- else
- if last_exit_status != 0
- raise "Failed with exit status #{last_exit_status}\nSTDOUT:\n#{last_stdout}\nSTDERR:\n#{last_stderr}"
- end
- end
-end
-
-Then /^it should (fail|pass) with$/ do |success, output|
- combined_output.should =~ Regexp.compile(Regexp.escape(output))
- Then("it should #{success}")
-end
-
-Then /^the output should contain:?$/ do |text|
- last_stdout.should include(text)
-end
-
-Then /^the output should not contain$/ do |text|
- last_stdout.should_not include(text)
-end
-
-Then /^the output should be$/ do |text|
- last_stdout.should == text
-end
-
-Then /^it should (fail|pass) with JSON$/ do |success, text|
- JSON.parse(last_stdout).should == JSON.parse(text)
- Then("it should #{success}")
-end
-
-Then /^"([^"]*)" should contain$/ do |file, text|
- strip_duration(IO.read(file)).should == text
-end
-
-Then /^"([^"]*)" with junit duration "([^"]*)" should contain$/ do |actual_file, duration_replacement, text|
- actual = IO.read(actual_file)
- actual = replace_junit_duration(actual, duration_replacement)
- actual = strip_ruby186_extra_trace(actual)
- actual.should == text
-end
-
-Then /^"([^"]*)" should match "(.+?)"$/ do |file, text|
- File.open(file, Cucumber.file_mode('r')).read.should =~ Regexp.new(text)
-end
-
-Then /^"([^"]*)" should have the same contents as "([^"]*)"$/ do |actual_file, expected_file|
- actual = IO.read(actual_file)
- actual = replace_duration(actual, '0m30.005s')
- # Comment out to replace expected file. Use with care!
- # File.open(expected_file, "w") {|io| io.write(actual)}
- actual.should == IO.read(expected_file)
-end
-
-Then /^STDERR should match$/ do |text|
- last_stderr.should =~ /#{text}/
-end
-
-Then /^STDERR should not match$/ do |text|
- last_stderr.should_not =~ /#{text}/
-end
-
-Then /^STDERR should be$/ do |text|
- last_stderr.should == text
-end
-
-Then /^STDERR should be empty$/ do
- last_stderr.should == ""
-end
-
-Then /^"([^"]*)" should exist$/ do |file|
- File.exists?(file).should be_true
- FileUtils.rm(file)
-end
-
-Then /^"([^"]*)" should not be required$/ do |file_name|
- last_stdout.should_not include("* #{file_name}")
-end
-
-Then /^"([^"]*)" should be required$/ do |file_name|
- last_stdout.should include("* #{file_name}")
-end
-
-Then /^exactly these files should be loaded:\s*(.*)$/ do |files|
- last_stdout.scan(/^ \* (.*\.rb)$/).flatten.should == files.split(/,\s+/)
-end
-
-Then /^exactly these features should be ran:\s*(.*)$/ do |files|
- last_stdout.scan(/^ \* (.*\.feature)$/).flatten.should == files.split(/,\s+/)
-end
-
-Then /^the (.*) profile should be used$/ do |profile|
- last_stdout.should =~ /Using the #{profile} profile/
-end
-
-Then /^print output$/ do
- puts last_stdout
+When /^I run cucumber "([^"]*)"$/ do |cmd|
+ run_simple(unescape("cucumber #{cmd}"), false)
end
-Then /^the output should contain the following JSON:$/ do |json_string|
- JSON.parse(last_stdout).should == JSON.parse(json_string)
+Then /^it should (pass|fail) with JSON:$/ do |pass_fail, json|
+ JSON.pretty_generate(JSON.parse(all_stdout)).should == JSON.pretty_generate(JSON.parse(json))
+ assert_exiting_with(pass_fail == 'pass')
end
View
@@ -1,157 +1,31 @@
-require 'rubygems'
+require 'aruba/api'
-require 'tempfile'
-require 'rspec/expectations'
-require 'fileutils'
-require 'forwardable'
-require 'cucumber/formatter/unicode'
-# This is to force miniunit to be loaded on 1.9.2, and verify that we can still run with --profile. See:
-# * disable_mini_test_autorun.rb and
-# * http://groups.google.com/group/cukes/browse_thread/thread/5682d41436e235d7
-# * https://rspec.lighthouseapp.com/projects/16211/tickets/677-cucumber-093-prevents-testunit-from-running
-require 'test/unit'
-
-class CucumberWorld
- extend Forwardable
- def_delegators CucumberWorld, :fixtures_dir, :self_test_dir, :working_dir, :cucumber_lib_dir
-
- def self.fixtures_dir(subdir=nil)
- @fixtures_dir ||= File.expand_path(File.join(File.dirname(__FILE__), '../../fixtures'))
- subdir ? File.join(@fixtures_dir, subdir) : @fixtures_dir
- end
-
- def self.self_test_dir
- @self_test_dir ||= fixtures_dir('self_test')
- end
-
- def self.working_dir
- @working_dir ||= fixtures_dir('self_test/tmp')
- end
-
- def cucumber_lib_dir
- @cucumber_lib_dir ||= File.expand_path(File.join(File.dirname(__FILE__), '../../lib'))
- end
+# Monkey patch aruba to filter out some stuff
+module Aruba::Api
+ alias _all_stdout all_stdout
- # Don't use Cucumber::BINARY (which is the binary used to start the "outer" cucumber)
- # Instead we force the use of this codebase's cucumber bin script.
- # This allows us to run cucumber's cukes with an older, stable cucumber.
- def cucumber_bin
- File.expand_path(File.dirname(__FILE__) + '/../../bin/cucumber')
- end
-
- def initialize
- @current_dir = self_test_dir
- end
-
- private
- attr_reader :last_exit_status, :last_stderr
-
- # The last standard out, with the duration line taken out (unpredictable)
- def last_stdout
- strip_1_9_paths(strip_duration(@last_stdout))
- end
-
- def combined_output
- last_stdout + "\n" + last_stderr
- end
-
- def strip_duration(s)
- s.gsub(/^\d+m\d+\.\d+s\n/m, "")
- end
-
- def strip_1_9_paths(s)
- s.gsub(/#{Dir.pwd}\/fixtures\/self_test\/tmp/m, ".").gsub(/#{Dir.pwd}\/fixtures\/self_test/m, ".")
- end
-
- def replace_duration(s, replacement)
- s.gsub(/\d+m\d+\.\d+s/m, replacement)
- end
-
- def replace_junit_duration(s, replacement)
- s.gsub(/\d+\.\d\d+/m, replacement)
+ def all_stdout
+ out = _all_stdout
+
+ # Remove absolute paths
+ out.gsub!(/#{Dir.pwd}\/tmp\/aruba/, '.')
+ # Make duration predictable
+ out.gsub!(/^\d+m\d+\.\d+s$/, '0m0.012s')
+ # Remove SimpleCov message
+ out.gsub!(/Coverage report generated for Cucumber Features to #{Dir.pwd}\/coverage\n$/, '')
+
+ out
end
-
- def strip_ruby186_extra_trace(s)
- s.gsub(/^.*\.\/features\/step_definitions(.*)\n/, "")
- end
-
- def create_file(file_name, file_content)
- file_content.gsub!("CUCUMBER_LIB", "'#{cucumber_lib_dir}'") # Some files, such as Rakefiles need to use the lib dir
- in_current_dir do
- FileUtils.mkdir_p(File.dirname(file_name)) unless File.directory?(File.dirname(file_name))
- File.open(file_name, 'w') { |f| f << file_content }
- end
- end
-
- def set_env_var(variable, value)
- @original_env_vars ||= {}
- @original_env_vars[variable] = ENV[variable]
- ENV[variable] = value
- end
-
- def background_jobs
- @background_jobs ||= []
- end
-
- def in_current_dir(&block)
- Dir.chdir(@current_dir, &block)
- end
-
- def run(command)
- stderr_file = Tempfile.new('cucumber')
- stderr_file.close
- in_current_dir do
- mode = Cucumber::RUBY_1_9 ? {:external_encoding=>"UTF-8"} : 'r'
- IO.popen("#{command} 2> #{stderr_file.path}", mode) do |io|
- @last_stdout = io.read
- end
-
- @last_exit_status = $?.exitstatus
- end
- @last_stderr = IO.read(stderr_file.path)
- end
-
- def run_spork_in_background(port = nil)
- require 'spork'
-
- pid = fork
- in_current_dir do
- if pid
- background_jobs << pid
- else
- # STDOUT.close
- # STDERR.close
- port_arg = port ? "-p #{port}" : ''
- cmd = "#{Cucumber::RUBY_BINARY} -I #{Cucumber::LIBDIR} #{Spork::BINARY} cuc #{port_arg}"
- exec cmd
- end
- end
- sleep 1.0
- end
-
- def terminate_background_jobs
- background_jobs.each do |pid|
- Process.kill(Signal.list['TERM'], pid)
- end
- end
-
- def restore_original_env_vars
- @original_env_vars.each { |variable, value| ENV[variable] = value } if @original_env_vars
- end
-
end
-World do
- CucumberWorld.new
-end
+require 'aruba/cucumber'
-Before do
- FileUtils.rm_rf CucumberWorld.working_dir
- FileUtils.mkdir CucumberWorld.working_dir
-end
+Before do |scenario|
+ @scenario = scenario
-After do
- FileUtils.rm_rf CucumberWorld.working_dir unless ENV['KEEP_FILES']
- terminate_background_jobs
- restore_original_env_vars
+ # Make sure bin/cucumber runs with SimpleCov enabled
+ set_env('SIMPLECOV', 'true')
+
+ # Set a longer timeout for aruba
+ @aruba_timeout_seconds = 5
end
File renamed without changes.
Oops, something went wrong.

0 comments on commit e610a02

Please sign in to comment.