From 322248963b31ffbef2fa612d9f7280decbf244f8 Mon Sep 17 00:00:00 2001 From: Reinier Balt Date: Mon, 19 Mar 2012 19:59:04 +0100 Subject: [PATCH] fix the conflict between aruba and unit/functional tests by backporting a fix from newer versions of aruba gemspec changes to comment out dep on cucumber lib/aruba.rb emptied We need to move forward to recent versions of rails/cucumber/etc --- Gemfile | 2 +- Gemfile.lock | 8 +- vendor/gems/aruba-0.2.2/.bundle/config | 2 + vendor/gems/aruba-0.2.2/.document | 5 + vendor/gems/aruba-0.2.2/.gitignore | 23 ++ vendor/gems/aruba-0.2.2/Gemfile | 5 + vendor/gems/aruba-0.2.2/History.txt | 84 +++++++ vendor/gems/aruba-0.2.2/LICENSE | 20 ++ vendor/gems/aruba-0.2.2/README.rdoc | 41 ++++ vendor/gems/aruba-0.2.2/Rakefile | 13 ++ vendor/gems/aruba-0.2.2/aruba.gemspec | 24 ++ vendor/gems/aruba-0.2.2/config/.gitignore | 1 + .../features/exit_statuses.feature | 21 ++ .../features/file_system_commands.feature | 84 +++++++ .../gems/aruba-0.2.2/features/output.feature | 96 ++++++++ .../step_definitions/aruba_dev_steps.rb | 24 ++ .../gems/aruba-0.2.2/features/support/env.rb | 15 ++ vendor/gems/aruba-0.2.2/lib/aruba.rb | 0 vendor/gems/aruba-0.2.2/lib/aruba/api.rb | 220 ++++++++++++++++++ vendor/gems/aruba-0.2.2/lib/aruba/cucumber.rb | 188 +++++++++++++++ 20 files changed, 873 insertions(+), 3 deletions(-) create mode 100644 vendor/gems/aruba-0.2.2/.bundle/config create mode 100644 vendor/gems/aruba-0.2.2/.document create mode 100644 vendor/gems/aruba-0.2.2/.gitignore create mode 100644 vendor/gems/aruba-0.2.2/Gemfile create mode 100644 vendor/gems/aruba-0.2.2/History.txt create mode 100644 vendor/gems/aruba-0.2.2/LICENSE create mode 100644 vendor/gems/aruba-0.2.2/README.rdoc create mode 100644 vendor/gems/aruba-0.2.2/Rakefile create mode 100644 vendor/gems/aruba-0.2.2/aruba.gemspec create mode 100644 vendor/gems/aruba-0.2.2/config/.gitignore create mode 100644 vendor/gems/aruba-0.2.2/features/exit_statuses.feature create mode 100644 vendor/gems/aruba-0.2.2/features/file_system_commands.feature create mode 100644 vendor/gems/aruba-0.2.2/features/output.feature create mode 100644 vendor/gems/aruba-0.2.2/features/step_definitions/aruba_dev_steps.rb create mode 100644 vendor/gems/aruba-0.2.2/features/support/env.rb create mode 100644 vendor/gems/aruba-0.2.2/lib/aruba.rb create mode 100644 vendor/gems/aruba-0.2.2/lib/aruba/api.rb create mode 100644 vendor/gems/aruba-0.2.2/lib/aruba/cucumber.rb diff --git a/Gemfile b/Gemfile index 2dc4858e..dc3af876 100644 --- a/Gemfile +++ b/Gemfile @@ -54,7 +54,7 @@ group :test do gem "selenium-webdriver" # Note that > 2.14 has problems: https://code.google.com/p/selenium/issues/detail?id=3075 gem "database_cleaner", ">=0.5.0" gem "cucumber-rails", "~>0.3.2" - gem "aruba" + gem "aruba", "0.2.2", :path => "vendor/gems/aruba-0.2.2" # uncomment to use the webkit option. This depends on Qt to be installed #gem "capybara-webkit" diff --git a/Gemfile.lock b/Gemfile.lock index b8410960..34569fc6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,8 @@ +PATH + remote: vendor/gems/aruba-0.2.2 + specs: + aruba (0.2.2) + GEM remote: http://rubygems.org/ remote: http://gems.github.com/ @@ -16,7 +21,6 @@ GEM activesupport (= 2.3.14) activesupport (2.3.14) acts_as_list (0.1.4) - aruba (0.2.2) bcrypt-ruby (2.1.4) builder (3.0.0) capybara (1.1.2) @@ -133,7 +137,7 @@ DEPENDENCIES ZenTest (>= 4.0.0) aasm (~> 2.2.0) acts_as_list (~> 0.1.4) - aruba + aruba (= 0.2.2)! bcrypt-ruby (~> 2.1.4) capybara (>= 0.3.5) cucumber-rails (~> 0.3.2) diff --git a/vendor/gems/aruba-0.2.2/.bundle/config b/vendor/gems/aruba-0.2.2/.bundle/config new file mode 100644 index 00000000..8ebbe30e --- /dev/null +++ b/vendor/gems/aruba-0.2.2/.bundle/config @@ -0,0 +1,2 @@ +--- +BUNDLE_DISABLE_SHARED_GEMS: "1" diff --git a/vendor/gems/aruba-0.2.2/.document b/vendor/gems/aruba-0.2.2/.document new file mode 100644 index 00000000..ecf36731 --- /dev/null +++ b/vendor/gems/aruba-0.2.2/.document @@ -0,0 +1,5 @@ +README.rdoc +lib/**/*.rb +bin/* +features/**/*.feature +LICENSE diff --git a/vendor/gems/aruba-0.2.2/.gitignore b/vendor/gems/aruba-0.2.2/.gitignore new file mode 100644 index 00000000..b13347cc --- /dev/null +++ b/vendor/gems/aruba-0.2.2/.gitignore @@ -0,0 +1,23 @@ +## MAC OS +.DS_Store + +## TEXTMATE +*.tmproj +tmtags + +## EMACS +*~ +\#* +.\#* + +## VIM +*.swp + +## PROJECT::GENERAL +coverage +rdoc +pkg + +## PROJECT::SPECIFIC +tmp +Gemfile.lock \ No newline at end of file diff --git a/vendor/gems/aruba-0.2.2/Gemfile b/vendor/gems/aruba-0.2.2/Gemfile new file mode 100644 index 00000000..e826fba0 --- /dev/null +++ b/vendor/gems/aruba-0.2.2/Gemfile @@ -0,0 +1,5 @@ +source "http://rubygems.org" +gemspec + +gem 'cucumber', :path => '../cucumber' if File.directory?(File.dirname(__FILE__) + '/../cucumber') +gem 'gherkin', :path => '../gherkin' if File.directory?(File.dirname(__FILE__) + '/../gherkin') \ No newline at end of file diff --git a/vendor/gems/aruba-0.2.2/History.txt b/vendor/gems/aruba-0.2.2/History.txt new file mode 100644 index 00000000..44e2a887 --- /dev/null +++ b/vendor/gems/aruba-0.2.2/History.txt @@ -0,0 +1,84 @@ +== 0.2.2 + +=== New Features +* Added a @bin tag that sets up './bin' first on the path (Aslak Hellesøy) +* Richer API making aruba easier to use from Ruby code. (Mark Nijhof, Aslak Hellesøy) + +=== Removed Features +* No more support for RVM. Use rvm 1.9.2,1.8.7 exec cucumber .... instead. (Mark Nijhof, Aslak Hellesøy) + +== 0.2.1 + +=== Bugfixes +* Always compare with RSpec should =~ instead of should match. This gives a diff when there is no match. (Aslak Hellesøy) + +== 0.2.0 + +=== New Features +* Added aruba.gemspec. (David Chelimsky) + +=== Changed features +* Several step definitions regarding output have changed. (#1 Aslak Hellesøy) + + - /^I should see "([^\"]*)"$/ + + /^the output should contain "([^"]*)"$/ + + - /^I should not see "([^\"]*)"$/ + + /^the output should not contain "([^"]*)"$/ + + - /^I should see:$/ + + /^the output should contain:$/ + + - /^I should not see:$/ + + /^the output should not contain:$/ + + - /^I should see exactly "([^\"]*)"$/ + + /^the output should contain exactly "([^"]*)"$/ + + - /^I should see exactly:$/ + + /^the output should contain exactly:$/ + + - /^I should see matching \/([^\/]*)\/$/ + + /^the output should match \/([^\/]*)\/$/ + + - /^I should see matching:$/ + + /^the output should match:$/ + +== 0.1.9 +* If the GOTGEMS environment variable is set, bundler won't run (faster). (Aslak Hellesøy) + +== 0.1.8 +* Use // instead of "" for "I should see matching" step. (Aslak Hellesøy) +* Replace rvm gemset character '%' with '@' for rvm 0.1.24 (#5 Ashley Moran) +* Support gem bundler, making it easier to specify gems. (Aslak Hellesøy) + +== 0.1.7 +* New @announce-stderr tag (Robert Wahler) +* New "I should see matching" steps using Regexp (Robert Wahler) + +== 0.1.6 +* When /^I successfully run "(.*)"$/ now prints the combined output if exit status is not 0. (Aslak Hellesøy) +* Add bundle to list of common ruby scripts. (Aslak Hellesøy) + +== 0.1.5 +* Added ability to map rvm versions to a specific version with config/aruba-rvm.yml. (Aslak Hellesøy) +* Check for presence of files. (Aslak Hellesøy) +* Allow specification of rvm gemsets. (Aslak Hellesøy) +* Detect ruby commands and use current ruby when rvm is not explicitly used. (Aslak Hellesøy) +* Added support for rvm, making it possible to choose Ruby interpreter. (Aslak Hellesøy) +* Added @announce-cmd, @announce-stdout and @announce tags, useful for seeing what's executed and outputted. (Aslak Hellesøy) + +== 0.1.4 +* New step definition for appending to a file (Aslak Hellesøy) + +== 0.1.3 +* New step definition for cd (change directory) (Aslak Hellesøy) + +== 0.1.2 +* Separated API from Cucumber step definitions, makes this usable without Cucumber. (Aslak Hellesøy) + +== 0.1.1 +* Better Regexp escaping (David Chelimsky) + +== 0.1.0 +* First release (David Chelimsky and Aslak Hellesøy) \ No newline at end of file diff --git a/vendor/gems/aruba-0.2.2/LICENSE b/vendor/gems/aruba-0.2.2/LICENSE new file mode 100644 index 00000000..546f731b --- /dev/null +++ b/vendor/gems/aruba-0.2.2/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2010 Aslak Hellesøy, David Chelimsky + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/gems/aruba-0.2.2/README.rdoc b/vendor/gems/aruba-0.2.2/README.rdoc new file mode 100644 index 00000000..2a7781c4 --- /dev/null +++ b/vendor/gems/aruba-0.2.2/README.rdoc @@ -0,0 +1,41 @@ += aruba + +Cucumber steps for driving out command line applications. The command line application can be anything, +a compiled C program, a Java program, a Perl script - anything. There is also special support for various +Ruby versions (see below). + +== Usage + + gem install aruba + +Then, just require the library in one of your ruby files under features/support + + require 'aruba' + +You now have a bunch of step definitions that you can use in your features. Look at aruba/cucumber.rb +to see all the step definitions. Look at features/*.feature for examples (which are also testing Aruba +itself). + +== Getting more output with tags. + +Aruba has several tags you can use to see what command actually gets run (useful if you're using the RVM steps), +STDOUT or STDERR. You can put these tags on individual scenarios, or on a feature. The tags are: + +* @announce-cmd +* @announce-stdout +* @announce-stderr +* @announce (does all of the above) + +== Note on Patches/Pull Requests + +* Fork the project. +* Make your feature addition or bug fix. +* Add tests for it. This is important so I don't break it in a + future version unintentionally. +* Commit, do not mess with rakefile, version, or history. + (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull) +* Send me a pull request. Bonus points for topic branches. + +== Copyright + +Copyright (c) 2010 Aslak Hellesøy and David Chelimsky. See LICENSE for details. diff --git a/vendor/gems/aruba-0.2.2/Rakefile b/vendor/gems/aruba-0.2.2/Rakefile new file mode 100644 index 00000000..e4491c79 --- /dev/null +++ b/vendor/gems/aruba-0.2.2/Rakefile @@ -0,0 +1,13 @@ +# encoding: utf-8 +require 'rubygems' +require 'bundler' +Bundler.setup +Bundler::GemHelper.install_tasks + +require 'cucumber/rake/task' + +Cucumber::Rake::Task.new do |t| + t.cucumber_opts = %w{--tags ~@jruby} unless defined?(JRUBY_VERSION) +end + +task :default => :cucumber diff --git a/vendor/gems/aruba-0.2.2/aruba.gemspec b/vendor/gems/aruba-0.2.2/aruba.gemspec new file mode 100644 index 00000000..73432581 --- /dev/null +++ b/vendor/gems/aruba-0.2.2/aruba.gemspec @@ -0,0 +1,24 @@ +# -*- encoding: utf-8 -*- +$LOAD_PATH.unshift File.expand_path("../lib", __FILE__) + +Gem::Specification.new do |s| + s.name = 'aruba' + s.version = "0.2.2" + s.authors = ["Aslak Hellesøy", "David Chelimsky"] + s.description = 'CLI Steps for Cucumber, hand-crafted for you in Aruba' + s.summary = "aruba-#{s.version}" + s.email = 'cukes@googlegroups.com' + s.homepage = 'http://github.com/aslakhellesoy/aruba' + + # s.add_dependency 'cucumber', '~> 0.9.0' unless File.directory?(File.dirname(__FILE__) + '/../cucumber') + s.add_development_dependency('rspec', "~> 2.0.0.beta.22") + + s.rubygems_version = "1.3.7" + s.files = `git ls-files`.split("\n") + s.test_files = `git ls-files -- {spec,features}/*`.split("\n") + s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } + s.extra_rdoc_files = ["LICENSE", "README.rdoc", "History.txt"] + s.rdoc_options = ["--charset=UTF-8"] + s.require_path = "lib" +end + diff --git a/vendor/gems/aruba-0.2.2/config/.gitignore b/vendor/gems/aruba-0.2.2/config/.gitignore new file mode 100644 index 00000000..53c4367d --- /dev/null +++ b/vendor/gems/aruba-0.2.2/config/.gitignore @@ -0,0 +1 @@ +aruba-rvm.yml \ No newline at end of file diff --git a/vendor/gems/aruba-0.2.2/features/exit_statuses.feature b/vendor/gems/aruba-0.2.2/features/exit_statuses.feature new file mode 100644 index 00000000..dab0701b --- /dev/null +++ b/vendor/gems/aruba-0.2.2/features/exit_statuses.feature @@ -0,0 +1,21 @@ +Feature: exit statuses + + In order to specify expected exit statuses + As a developer using Cucumber + I want to use the "the exit status should be" step + + Scenario: exit status of 0 + When I run "ruby -h" + Then the exit status should be 0 + + Scenario: non-zero exit status + When I run "ruby -e 'exit 56'" + Then the exit status should be 56 + And the exit status should not be 0 + + Scenario: Successfully run something + When I successfully run "ruby -e 'exit 0'" + + Scenario: Unsuccessfully run something + When I do aruba I successfully run "ruby -e 'exit 10'" + Then aruba should fail with "Exit status was 10" diff --git a/vendor/gems/aruba-0.2.2/features/file_system_commands.feature b/vendor/gems/aruba-0.2.2/features/file_system_commands.feature new file mode 100644 index 00000000..044a520f --- /dev/null +++ b/vendor/gems/aruba-0.2.2/features/file_system_commands.feature @@ -0,0 +1,84 @@ +Feature: file system commands + + In order to specify commands that load files + As a developer using Cucumber + I want to create temporary files + + Scenario: create a dir + Given a directory named "foo/bar" + When I run "ruby -e \"puts test ?d, 'foo'\"" + Then the stdout should contain "true" + + Scenario: create a file + Given a file named "foo/bar/example.rb" with: + """ + puts "hello world" + """ + When I run "ruby foo/bar/example.rb" + Then the output should contain "hello world" + + Scenario: append to a file + Given a file named "foo/bar/example.rb" with: + """ + puts "hello world" + """ + When I append to "foo/bar/example.rb" with: + """ + puts "this was appended" + """ + When I run "ruby foo/bar/example.rb" + Then the output should contain "hello world" + And the output should contain "this was appended" + + Scenario: clean up files generated in previous scenario + When I run "ruby foo/bar/example.rb" + Then the exit status should be 1 + And the output should contain "No such file or directory -- foo/bar/example.rb" + + Scenario: change to a subdir + Given a file named "foo/bar/example.rb" with: + """ + puts "hello world" + """ + When I cd to "foo/bar" + And I run "ruby example.rb" + Then the output should contain "hello world" + + Scenario: Reset current directory from previous scenario + When I run "ruby example.rb" + Then the exit status should be 1 + + Scenario: Holler if cd to bad dir + Given a file named "foo/bar/example.rb" with: + """ + puts "hello world" + """ + When I do aruba I cd to "foo/nonexistant" + Then aruba should fail with "tmp/aruba/foo/nonexistant is not a directory" + + Scenario: Check for presence of a subset of files + Given an empty file named "lorem/ipsum/dolor" + Given an empty file named "lorem/ipsum/sit" + Given an empty file named "lorem/ipsum/amet" + Then the following files should exist: + | lorem/ipsum/dolor | + | lorem/ipsum/amet | + + Scenario: Check for absence of files + Then the following files should not exist: + | lorem/ipsum/dolor | + + Scenario: Check for presence of a subset of directories + Given a directory named "foo/bar" + Given a directory named "foo/bla" + Then the following directories should exist: + | foo/bar | + | foo/bla | + + Scenario: Check file contents + Given a file named "foo" with: + """ + hello world + """ + Then the file "foo" should contain "hello world" + And the file "foo" should not contain "HELLO WORLD" diff --git a/vendor/gems/aruba-0.2.2/features/output.feature b/vendor/gems/aruba-0.2.2/features/output.feature new file mode 100644 index 00000000..82262f9c --- /dev/null +++ b/vendor/gems/aruba-0.2.2/features/output.feature @@ -0,0 +1,96 @@ +Feature: Output + + In order to specify expected output + As a developer using Cucumber + I want to use the "the output should contain" step + + Scenario: Run unknown command + When I run "neverever gonna work" + Then the output should contain: + """ + sh: neverever: command not found + """ + + Scenario: Detect subset of one-line output + When I run "ruby -e 'puts \"hello world\"'" + Then the output should contain "hello world" + + Scenario: Detect subset of one-line output + When I run "echo 'hello world'" + Then the output should contain "hello world" + + Scenario: Detect absence of one-line output + When I run "ruby -e 'puts \"hello world\"'" + Then the output should not contain "good-bye" + + Scenario: Detect subset of multiline output + When I run "ruby -e 'puts \"hello\\nworld\"'" + Then the output should contain: + """ + hello + """ + + Scenario: Detect subset of multiline output + When I run "ruby -e 'puts \"hello\\nworld\"'" + Then the output should not contain: + """ + good-bye + """ + + Scenario: Detect exact one-line output + When I run "ruby -e 'puts \"hello world\"'" + Then the output should contain exactly "hello world\n" + + Scenario: Detect exact multiline output + When I run "ruby -e 'puts \"hello\\nworld\"'" + Then the output should contain exactly: + """ + hello + world + + """ + + @announce + Scenario: Detect subset of one-line output with regex + When I run "ruby --version" + Then the output should contain "ruby" + And the output should match /ruby ([\d]+\.[\d]+\.[\d]+)(p\d+)? \(.*$/ + + @announce + Scenario: Detect subset of multiline output with regex + When I run "ruby -e 'puts \"hello\\nworld\\nextra line1\\nextra line2\\nimportant line\"'" + Then the output should match: + """ + he..o + wor.d + .* + important line + """ + + @announce + Scenario: Match passing exit status and partial output + When I run "ruby -e 'puts \"hello\\nworld\"'" + Then it should pass with: + """ + hello + """ + + @announce-stdout + Scenario: Match failing exit status and partial output + When I run "ruby -e 'puts \"hello\\nworld\";exit 99'" + Then it should fail with: + """ + hello + """ + + @announce-cmd + Scenario: Match output in stdout + When I run "ruby -e 'puts \"hello\\nworld\"'" + Then the stdout should contain "hello" + Then the stderr should not contain "hello" + + @announce-stderr + Scenario: Match output in stderr + When I run "ruby -e 'STDERR.puts \"hello\\nworld\";exit 99'" + Then the stderr should contain "hello" + Then the stdout should not contain "hello" diff --git a/vendor/gems/aruba-0.2.2/features/step_definitions/aruba_dev_steps.rb b/vendor/gems/aruba-0.2.2/features/step_definitions/aruba_dev_steps.rb new file mode 100644 index 00000000..d46a4c09 --- /dev/null +++ b/vendor/gems/aruba-0.2.2/features/step_definitions/aruba_dev_steps.rb @@ -0,0 +1,24 @@ +Given /^I have a local file named "([^"]*)" with:$/ do |filename, content| + File.open(filename, 'w') {|io| io.write(content)} +end + +When /^I do aruba (.*)$/ do |aruba_step| + begin + When(aruba_step) + rescue => e + @aruba_exception = e + end +end + +Then /^the output should contain the JRuby version$/ do + pending "This must be manually run in JRuby" unless defined?(JRUBY_VERSION) + Then %{the output should contain "#{JRUBY_VERSION}"} +end + +Then /^the output should contain the current Ruby version$/ do + Then %{the output should contain "#{RUBY_VERSION}"} +end + +Then /^aruba should fail with "([^"]*)"$/ do |error_message| + @aruba_exception.message.should =~ compile_and_escape(error_message) +end diff --git a/vendor/gems/aruba-0.2.2/features/support/env.rb b/vendor/gems/aruba-0.2.2/features/support/env.rb new file mode 100644 index 00000000..7031bf51 --- /dev/null +++ b/vendor/gems/aruba-0.2.2/features/support/env.rb @@ -0,0 +1,15 @@ +$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib') +require 'aruba' +require 'fileutils' + +begin + # rspec-2 + require 'rspec/expectations' +rescue LoadError + # rspec-1 + require 'spec/expectations' +end + +Before do + FileUtils.rm(Dir['config/*.yml']) +end \ No newline at end of file diff --git a/vendor/gems/aruba-0.2.2/lib/aruba.rb b/vendor/gems/aruba-0.2.2/lib/aruba.rb new file mode 100644 index 00000000..e69de29b diff --git a/vendor/gems/aruba-0.2.2/lib/aruba/api.rb b/vendor/gems/aruba-0.2.2/lib/aruba/api.rb new file mode 100644 index 00000000..4f059b55 --- /dev/null +++ b/vendor/gems/aruba-0.2.2/lib/aruba/api.rb @@ -0,0 +1,220 @@ +require 'tempfile' +require 'rbconfig' + +module Aruba + module Api + def in_current_dir(&block) + _mkdir(current_dir) + Dir.chdir(current_dir, &block) + end + + def current_dir + File.join(*dirs) + end + + def cd(dir) + dirs << dir + raise "#{current_dir} is not a directory." unless File.directory?(current_dir) + end + + def dirs + @dirs ||= ['tmp/aruba'] + end + + def create_file(file_name, file_content, check_presence = false) + in_current_dir do + raise "expected #{file_name} to be present" if check_presence && !File.file?(file_name) + _mkdir(File.dirname(file_name)) + File.open(file_name, 'w') { |f| f << file_content } + end + end + + def append_to_file(file_name, file_content) + in_current_dir do + File.open(file_name, 'a') { |f| f << file_content } + end + end + + def create_dir(dir_name) + in_current_dir do + _mkdir(dir_name) + end + end + + def check_file_presence(paths, expect_presence) + in_current_dir do + paths.each do |path| + if expect_presence + File.should be_file(path) + else + File.should_not be_file(path) + end + end + end + end + + def check_file_content(file, partial_content, expect_match) + regexp = compile_and_escape(partial_content) + in_current_dir do + content = IO.read(file) + if expect_match + content.should =~ regexp + else + content.should_not =~ regexp + end + end + end + + def check_exact_file_content(file, exact_content) + in_current_dir do + IO.read(file).should == exact_content + end + end + + def check_directory_presence(paths, expect_presence) + in_current_dir do + paths.each do |path| + if expect_presence + File.should be_directory(path) + else + File.should_not be_directory(path) + end + end + end + end + + def _mkdir(dir_name) + FileUtils.mkdir_p(dir_name) unless File.directory?(dir_name) + end + + def unescape(string) + eval(%{"#{string}"}) + end + + def compile_and_escape(string) + Regexp.compile(Regexp.escape(string)) + end + + def combined_output + @last_stdout + (@last_stderr == '' ? '' : "\n#{'-'*70}\n#{@last_stderr}") + end + + def assert_partial_output(partial_output) + combined_output.should =~ compile_and_escape(partial_output) + end + + def assert_passing_with(partial_output) + assert_exit_status_and_partial_output(true, partial_output) + end + + def assert_failing_with(partial_output) + assert_exit_status_and_partial_output(false, partial_output) + end + + def assert_exit_status_and_partial_output(expect_to_pass, partial_output) + assert_partial_output(partial_output) + if expect_to_pass + @last_exit_status.should == 0 + else + @last_exit_status.should_not == 0 + end + end + + def install_gems(gemfile) + create_file("Gemfile", gemfile) + if ENV['GOTGEMS'].nil? + run("gem install bundler") + run("bundle --no-color install") + end + end + + def run(cmd, fail_on_error=true) + cmd = detect_ruby(cmd) + + stderr_file = Tempfile.new('cucumber') + stderr_file.close + in_current_dir do + announce_or_puts("$ cd #{Dir.pwd}") if @announce_dir + announce_or_puts("$ #{cmd}") if @announce_cmd + + mode = RUBY_VERSION =~ /^1\.9/ ? {:external_encoding=>"UTF-8"} : 'r' + + IO.popen("#{cmd} 2> #{stderr_file.path}", mode) do |io| + @last_stdout = io.read + announce_or_puts(@last_stdout) if @announce_stdout + end + + @last_exit_status = $?.exitstatus + end + @last_stderr = IO.read(stderr_file.path) + + announce_or_puts(@last_stderr) if @announce_stderr + + if(@last_exit_status != 0 && fail_on_error) + fail("Exit status was #{@last_exit_status}. Output:\n#{combined_output}") + end + + @last_stderr + end + + def announce_or_puts(msg) + if(@puts) + puts(msg) + else + announce(msg) + end + end + + def detect_ruby(cmd) + if cmd =~ /^ruby\s/ + cmd.gsub(/^ruby\s/, "#{current_ruby} ") + else + cmd + end + end + + def current_ruby + File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']) + end + + def use_clean_gemset(gemset) + run(%{rvm gemset create "#{gemset}"}, true) + if @last_stdout =~ /'#{gemset}' gemset created \((.*)\)\./ + gem_home = $1 + set_env('GEM_HOME', gem_home) + set_env('GEM_PATH', gem_home) + set_env('BUNDLE_PATH', gem_home) + + paths = (ENV['PATH'] || "").split(File::PATH_SEPARATOR) + paths.unshift(File.join(gem_home, 'bin')) + set_env('PATH', paths.uniq.join(File::PATH_SEPARATOR)) + + run("gem install bundler", true) + else + raise "I didn't understand rvm's output: #{@last_stdout}" + end + end + + def unset_bundler_env_vars + %w[RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE].each do |key| + set_env(key, nil) + end + end + + def set_env(key, value) + announce_or_puts(%{$ export #{key}="#{value}"}) if @announce_env + original_env[key] = ENV.delete(key) + ENV[key] = value + end + + def restore_env + original_env.each do |key, value| + ENV[key] = value + end + end + + def original_env + @original_env ||= {} + end + end +end diff --git a/vendor/gems/aruba-0.2.2/lib/aruba/cucumber.rb b/vendor/gems/aruba-0.2.2/lib/aruba/cucumber.rb new file mode 100644 index 00000000..081727fd --- /dev/null +++ b/vendor/gems/aruba-0.2.2/lib/aruba/cucumber.rb @@ -0,0 +1,188 @@ +require 'aruba/api' + +World(Aruba::Api) + +Before('@disable-bundler') do + unset_bundler_env_vars +end + +Before('@bin') do + @__aruba_original_paths = (ENV['PATH'] || '').split(File::PATH_SEPARATOR) + ENV['PATH'] = ([File.expand_path('bin')] + @__aruba_original_paths).join(File::PATH_SEPARATOR) +end + +After('@bin') do + ENV['PATH'] = @__aruba_original_paths.join(File::PATH_SEPARATOR) +end + +Before do + FileUtils.rm_rf(current_dir) +end + +Before('@puts') do + @puts = true +end + +Before('@announce-cmd') do + @announce_cmd = true +end + +Before('@announce-stdout') do + @announce_stdout = true +end + +Before('@announce-stderr') do + @announce_stderr = true +end + +Before('@announce-dir') do + @announce_dir = true +end + +Before('@announce-env') do + @announce_env = true +end + +Before('@announce') do + @announce_stdout = true + @announce_stderr = true + @announce_cmd = true + @announce_dir = true + @announce_env = true +end + +After do + restore_env +end + +Given /^I'm using a clean gemset "([^"]*)"$/ do |gemset| + use_clean_gemset(gemset) +end + +Given /^a directory named "([^"]*)"$/ do |dir_name| + create_dir(dir_name) +end + +Given /^a file named "([^"]*)" with:$/ do |file_name, file_content| + create_file(file_name, file_content) +end + +Given /^an empty file named "([^"]*)"$/ do |file_name| + create_file(file_name, "") +end + +When /^I write to "([^"]*)" with:$/ do |file_name, file_content| + create_file(file_name, file_content, false) +end + +When /^I overwrite "([^"]*)" with:$/ do |file_name, file_content| + create_file(file_name, file_content, true) +end + +When /^I append to "([^"]*)" with:$/ do |file_name, file_content| + append_to_file(file_name, file_content) +end + +When /^I cd to "([^"]*)"$/ do |dir| + cd(dir) +end + +When /^I run "(.*)"$/ do |cmd| + run(unescape(cmd), false) +end + +When /^I successfully run "(.*)"$/ do |cmd| + run(unescape(cmd)) +end + +Then /^the output should contain "([^"]*)"$/ do |partial_output| + assert_partial_output(partial_output) +end + +Then /^the output should not contain "([^"]*)"$/ do |partial_output| + combined_output.should_not =~ compile_and_escape(partial_output) +end + +Then /^the output should contain:$/ do |partial_output| + combined_output.should =~ compile_and_escape(partial_output) +end + +Then /^the output should not contain:$/ do |partial_output| + combined_output.should_not =~ compile_and_escape(partial_output) +end + +Then /^the output should contain exactly "([^"]*)"$/ do |exact_output| + combined_output.should == unescape(exact_output) +end + +Then /^the output should contain exactly:$/ do |exact_output| + combined_output.should == exact_output +end + +# "the output should match" allows regex in the partial_output, if +# you don't need regex, use "the output should contain" instead since +# that way, you don't have to escape regex characters that +# appear naturally in the output +Then /^the output should match \/([^\/]*)\/$/ do |partial_output| + combined_output.should =~ /#{partial_output}/ +end + +Then /^the output should match:$/ do |partial_output| + combined_output.should =~ /#{partial_output}/m +end + +Then /^the exit status should be (\d+)$/ do |exit_status| + @last_exit_status.should == exit_status.to_i +end + +Then /^the exit status should not be (\d+)$/ do |exit_status| + @last_exit_status.should_not == exit_status.to_i +end + +Then /^it should (pass|fail) with:$/ do |pass_fail, partial_output| + self.__send__("assert_#{pass_fail}ing_with", partial_output) +end + +Then /^the stderr should contain "([^"]*)"$/ do |partial_output| + @last_stderr.should =~ compile_and_escape(partial_output) +end + +Then /^the stdout should contain "([^"]*)"$/ do |partial_output| + @last_stdout.should =~ compile_and_escape(partial_output) +end + +Then /^the stderr should not contain "([^"]*)"$/ do |partial_output| + @last_stderr.should_not =~ compile_and_escape(partial_output) +end + +Then /^the stdout should not contain "([^"]*)"$/ do |partial_output| + @last_stdout.should_not =~ compile_and_escape(partial_output) +end + +Then /^the following files should exist:$/ do |files| + check_file_presence(files.raw.map{|file_row| file_row[0]}, true) +end + +Then /^the following files should not exist:$/ do |files| + check_file_presence(files.raw.map{|file_row| file_row[0]}, false) +end + +Then /^the following directories should exist:$/ do |directories| + check_directory_presence(directories.raw.map{|directory_row| directory_row[0]}, true) +end + +Then /^the following directories should not exist:$/ do |directories| + check_file_presence(directories.raw.map{|directory_row| directory_row[0]}, false) +end + +Then /^the file "([^"]*)" should contain "([^"]*)"$/ do |file, partial_content| + check_file_content(file, partial_content, true) +end + +Then /^the file "([^"]*)" should not contain "([^"]*)"$/ do |file, partial_content| + check_file_content(file, partial_content, false) +end + +Then /^the file "([^"]*)" should contain exactly:$/ do |file, exact_content| + check_exact_file_content(file, exact_content) +end