Created
May 13, 2010 17:03
-
-
Save rogerleite/400069 to your computer and use it in GitHub Desktop.
Sample sources for post: http://wp.me/piFiH-an
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
require 'cucumber/rake/task' | |
Cucumber::Rake::Task.new(:cucumber) do |t| | |
t.cucumber_opts = "features --format pretty" | |
end | |
namespace :cucumber do | |
Cucumber::Rake::Task.new(:wip) do |t| | |
t.cucumber_opts = "features --format pretty -t @wip --wip" | |
end | |
end | |
rescue LoadError | |
desc 'cucumber rake task not available (cucumber not installed)' | |
task :cucumber do | |
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem.' | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "fileutils" | |
OUTPUT = 'tmp/output.log' | |
SHOW_OUTPUT = !!ENV["show_output"] | |
#rake cucumber show_output=true #to show output | |
Before do | |
FileUtils.rm_f OUTPUT | |
FileUtils.mkdir_p File.dirname(OUTPUT) | |
end | |
#execute system command, redirecting output | |
def execute(command) | |
#2>&1 Redirect standard error to standard output | |
system("#{command} > #{OUTPUT} 2>&1") | |
puts File.read(OUTPUT) if SHOW_OUTPUT | |
end | |
#read output | |
def output | |
File.read(OUTPUT) | |
end | |
#Change some commands if necessary | |
def gsub_command(system_command) | |
command = system_command | |
if system_command =~ /^gem/ | |
command << " --config-file=features/resources/gem-cucumber.yml" | |
end | |
command | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When /^I run "([^\"]*)"$/ do |syscommand| | |
command = gsub_command(syscommand) | |
execute(command) | |
end | |
Then /^I should see "([^\"]*)"$/ do |data| | |
output.should match(Regexp.new(Regexp.escape(data))) | |
end | |
Then /^I should not see "([^\"]*)"$/ do |data| | |
output.should_not match(Regexp.new(Regexp.escape(data))) | |
end | |
Then /^I should see file "([^\"]*)" content like$/ do |filename, content| | |
File.read(filename).should == content | |
end | |
Given /^I have a file "([^\"]*)" with content$/ do |filename, content| | |
File.open(filename, "w+") { |file| file.puts content } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment