aslakhellesoy-cucumber 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- metadata +14 -2
- data/History.txt +0 -4
- data/License.txt +0 -20
- data/Manifest.txt +0 -98
- data/README.txt +0 -42
- data/Rakefile +0 -4
- data/TODO.txt +0 -30
- data/bin/cucumber +0 -3
- data/config/hoe.rb +0 -69
- data/config/requirements.rb +0 -15
- data/examples/calculator/Rakefile +0 -6
- data/examples/calculator/features/addition.feature +0 -16
- data/examples/calculator/features/division.feature +0 -11
- data/examples/calculator/features/steps/calculator_steps.rb +0 -30
- data/examples/calculator/lib/calculator.rb +0 -16
- data/examples/calculator_ruby_features/Rakefile +0 -6
- data/examples/calculator_ruby_features/features/addition.rb +0 -23
- data/examples/calculator_ruby_features/features/steps/calculator_steps.rb +0 -43
- data/examples/java/README.textile +0 -22
- data/examples/java/Rakefile +0 -12
- data/examples/java/features/hello.feature +0 -11
- data/examples/java/features/steps/hello_steps.rb +0 -25
- data/examples/java/features/steps/tree_steps.rb +0 -14
- data/examples/java/features/tree.feature +0 -9
- data/examples/java/src/cucumber/demo/Hello.java +0 -15
- data/examples/norwegian_calculator/Rakefile +0 -6
- data/examples/norwegian_calculator/features/kalkulator_steps.rb +0 -31
- data/examples/norwegian_calculator/features/summering.feature +0 -13
- data/examples/watir/Rakefile +0 -6
- data/examples/watir/features/search.feature +0 -9
- data/examples/watir/features/steps/stories_steps.rb +0 -51
- data/gem_tasks/deployment.rake +0 -34
- data/gem_tasks/environment.rake +0 -7
- data/gem_tasks/fix_cr_lf.rake +0 -10
- data/gem_tasks/gemspec.rake +0 -6
- data/gem_tasks/rspec.rake +0 -21
- data/gem_tasks/treetop.rake +0 -27
- data/gem_tasks/website.rake +0 -17
- data/generators/cucumber/cucumber_generator.rb +0 -20
- data/generators/cucumber/templates/common_webrat.rb +0 -30
- data/generators/cucumber/templates/cucumber.rake +0 -7
- data/generators/cucumber/templates/env.rb +0 -6
- data/generators/feature/feature_generator.rb +0 -17
- data/generators/feature/templates/feature.erb +0 -27
- data/generators/feature/templates/steps.erb +0 -22
- data/lib/cucumber/cli.rb +0 -133
- data/lib/cucumber/core_ext/proc.rb +0 -43
- data/lib/cucumber/core_ext/string.rb +0 -17
- data/lib/cucumber/executor.rb +0 -79
- data/lib/cucumber/formatters/ansicolor.rb +0 -89
- data/lib/cucumber/formatters/html_formatter.rb +0 -272
- data/lib/cucumber/formatters/pretty_formatter.rb +0 -129
- data/lib/cucumber/formatters/progress_formatter.rb +0 -41
- data/lib/cucumber/formatters.rb +0 -1
- data/lib/cucumber/languages.yml +0 -31
- data/lib/cucumber/rails/rspec.rb +0 -12
- data/lib/cucumber/rails/world.rb +0 -71
- data/lib/cucumber/rake/task.rb +0 -75
- data/lib/cucumber/step_methods.rb +0 -41
- data/lib/cucumber/step_mother.rb +0 -38
- data/lib/cucumber/tree/feature.rb +0 -45
- data/lib/cucumber/tree/features.rb +0 -21
- data/lib/cucumber/tree/scenario.rb +0 -85
- data/lib/cucumber/tree/step.rb +0 -141
- data/lib/cucumber/tree/table.rb +0 -26
- data/lib/cucumber/tree/top_down_visitor.rb +0 -23
- data/lib/cucumber/tree.rb +0 -18
- data/lib/cucumber/treetop_parser/feature.treetop.erb +0 -102
- data/lib/cucumber/treetop_parser/feature_en.rb +0 -974
- data/lib/cucumber/treetop_parser/feature_fr.rb +0 -974
- data/lib/cucumber/treetop_parser/feature_no.rb +0 -974
- data/lib/cucumber/treetop_parser/feature_parser.rb +0 -32
- data/lib/cucumber/treetop_parser/feature_pt.rb +0 -974
- data/lib/cucumber/version.rb +0 -9
- data/lib/cucumber.rb +0 -32
- data/script/console +0 -10
- data/script/console.cmd +0 -1
- data/script/destroy +0 -14
- data/script/destroy.cmd +0 -1
- data/script/generate +0 -14
- data/script/generate.cmd +0 -1
- data/script/txt2html +0 -74
- data/script/txt2html.cmd +0 -1
- data/setup.rb +0 -1585
- data/spec/cucumber/core_ext/string_spec.rb +0 -20
- data/spec/cucumber/executor_spec.rb +0 -55
- data/spec/cucumber/formatters/ansicolor_spec.rb +0 -18
- data/spec/cucumber/formatters/features.html +0 -274
- data/spec/cucumber/formatters/html_formatter_spec.rb +0 -59
- data/spec/cucumber/sell_cucumbers.feature +0 -9
- data/spec/cucumber/treetop_parser/feature_parser_spec.rb +0 -40
- data/spec/cucumber/treetop_parser/spaces.feature +0 -10
- data/spec/spec.opts +0 -2
- data/spec/spec_helper.rb +0 -14
- data/website/index.html +0 -11
- data/website/index.txt +0 -39
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -138
- data/website/template.html.erb +0 -48
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'spec'
|
2
|
-
|
3
|
-
class Kalkulator
|
4
|
-
def push(n)
|
5
|
-
@args ||= []
|
6
|
-
@args << n
|
7
|
-
end
|
8
|
-
|
9
|
-
def add
|
10
|
-
@args.inject(0){|n,sum| sum+=n}
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
Before do
|
15
|
-
@calc = Kalkulator.new
|
16
|
-
end
|
17
|
-
|
18
|
-
After do
|
19
|
-
end
|
20
|
-
|
21
|
-
Given /at jeg har tastet inn (\d+)/ do |n|
|
22
|
-
@calc.push n.to_i
|
23
|
-
end
|
24
|
-
|
25
|
-
When 'jeg summerer' do
|
26
|
-
@result = @calc.add
|
27
|
-
end
|
28
|
-
|
29
|
-
Then /skal resultatet være (\d*)/ do |result|
|
30
|
-
@result.should == result.to_i
|
31
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
Egenskap: Summering
|
2
|
-
For å slippe å gjøre dumme feil
|
3
|
-
Som en regnskapsfører
|
4
|
-
Vil jeg kunne legge sammen
|
5
|
-
|
6
|
-
Scenario: to tall
|
7
|
-
Gitt at jeg har tastet inn 5
|
8
|
-
Og at jeg har tastet inn 7
|
9
|
-
Når jeg summerer
|
10
|
-
Så skal resultatet være 12
|
11
|
-
|
12
|
-
|a|b|s|
|
13
|
-
|2|3|5|
|
data/examples/watir/Rakefile
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
Feature: Search
|
2
|
-
In order to learn more
|
3
|
-
As an information seeker
|
4
|
-
I want to find more information
|
5
|
-
|
6
|
-
Scenario: Find what I'm looking for
|
7
|
-
Given I am on the Google search page
|
8
|
-
When I search for "rspec"
|
9
|
-
Then I should see a link to "RSpec-1.1.4: Overview":http://rspec.info/
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'spec'
|
2
|
-
|
3
|
-
case PLATFORM
|
4
|
-
when /darwin/
|
5
|
-
require 'safariwatir'
|
6
|
-
Watir::Browser = Watir::Safari
|
7
|
-
when /win32|mingw/
|
8
|
-
require 'watir'
|
9
|
-
Watir::Browser = Watir::IE
|
10
|
-
when /java/
|
11
|
-
require 'celerity'
|
12
|
-
Watir::Browser = Celerity::Browser
|
13
|
-
else
|
14
|
-
raise "This platform is not supported (#{PLATFORM})"
|
15
|
-
end
|
16
|
-
|
17
|
-
class GoogleSearch
|
18
|
-
def initialize(b)
|
19
|
-
@b = b
|
20
|
-
end
|
21
|
-
|
22
|
-
def goto
|
23
|
-
@b.goto 'http://www.google.com/'
|
24
|
-
end
|
25
|
-
|
26
|
-
def search(text)
|
27
|
-
@b.text_field(:name, 'q').set(text)
|
28
|
-
@b.button(:name, 'btnG').click
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
Before do
|
33
|
-
@b = Watir::Browser.new
|
34
|
-
end
|
35
|
-
|
36
|
-
After do
|
37
|
-
@b.close
|
38
|
-
end
|
39
|
-
|
40
|
-
Given 'I am on the Google search page' do
|
41
|
-
@page = GoogleSearch.new(@b)
|
42
|
-
@page.goto
|
43
|
-
end
|
44
|
-
|
45
|
-
When /I search for "(.*)"/ do |query|
|
46
|
-
@page.search(query)
|
47
|
-
end
|
48
|
-
|
49
|
-
Then /I should see a link to "(.*)":(.*)/ do |text, url|
|
50
|
-
@b.link(:url, url).text.should == text
|
51
|
-
end
|
data/gem_tasks/deployment.rake
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
desc 'Release the website and new gem version'
|
2
|
-
task :deploy => [:check_version, :website, :release] do
|
3
|
-
puts "Remember to create SVN tag:"
|
4
|
-
puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
|
5
|
-
"svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
|
6
|
-
puts "Suggested comment:"
|
7
|
-
puts "Tagging release #{CHANGES}"
|
8
|
-
end
|
9
|
-
|
10
|
-
desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
|
11
|
-
task :local_deploy => [:website_generate, :install_gem]
|
12
|
-
|
13
|
-
task :check_version do
|
14
|
-
unless ENV['VERSION']
|
15
|
-
puts 'Must pass a VERSION=x.y.z release version'
|
16
|
-
exit
|
17
|
-
end
|
18
|
-
unless ENV['VERSION'] == VERS
|
19
|
-
puts "Please update your version.rb to match the release version, currently #{VERS}"
|
20
|
-
exit
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
|
25
|
-
task :install_gem_no_doc => [:clean, :package] do
|
26
|
-
sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
|
27
|
-
end
|
28
|
-
|
29
|
-
namespace :manifest do
|
30
|
-
desc 'Recreate Manifest.txt to include ALL files'
|
31
|
-
task :refresh do
|
32
|
-
`rake check_manifest | patch -p0 > Manifest.txt`
|
33
|
-
end
|
34
|
-
end
|
data/gem_tasks/environment.rake
DELETED
data/gem_tasks/fix_cr_lf.rake
DELETED
data/gem_tasks/gemspec.rake
DELETED
data/gem_tasks/rspec.rake
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'spec'
|
3
|
-
rescue LoadError
|
4
|
-
require 'rubygems'
|
5
|
-
require 'spec'
|
6
|
-
end
|
7
|
-
begin
|
8
|
-
require 'spec/rake/spectask'
|
9
|
-
rescue LoadError
|
10
|
-
puts <<-EOS
|
11
|
-
To use rspec for testing you must install rspec gem:
|
12
|
-
gem install rspec
|
13
|
-
EOS
|
14
|
-
exit(0)
|
15
|
-
end
|
16
|
-
|
17
|
-
desc "Run the specs under spec/models"
|
18
|
-
Spec::Rake::SpecTask.new do |t|
|
19
|
-
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
-
end
|
data/gem_tasks/treetop.rake
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
class FeatureCompiler
|
2
|
-
def compile
|
3
|
-
require 'yaml'
|
4
|
-
require 'erb'
|
5
|
-
tt = PLATFORM =~ /win32/ ? 'tt.bat' : 'tt'
|
6
|
-
|
7
|
-
template = ERB.new(IO.read(File.dirname(__FILE__) + '/../lib/cucumber/treetop_parser/feature.treetop.erb'))
|
8
|
-
langs = YAML.load_file(File.dirname(__FILE__) + '/../lib/cucumber/languages.yml')
|
9
|
-
|
10
|
-
langs.each do |lang, words|
|
11
|
-
grammar_file = File.dirname(__FILE__) + "/../lib/cucumber/treetop_parser/feature_#{lang}.treetop"
|
12
|
-
grammar = template.result(binding)
|
13
|
-
File.open(grammar_file, "wb") do |io|
|
14
|
-
io.write(grammar)
|
15
|
-
end
|
16
|
-
sh "#{tt} #{grammar_file}"
|
17
|
-
FileUtils.rm(grammar_file)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
namespace :treetop do
|
23
|
-
desc 'Compile the grammar'
|
24
|
-
task :compile do
|
25
|
-
FeatureCompiler.new.compile
|
26
|
-
end
|
27
|
-
end
|
data/gem_tasks/website.rake
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
desc 'Generate website files'
|
2
|
-
task :website_generate => :ruby_env do
|
3
|
-
(Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
|
4
|
-
sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
desc 'Upload website files to rubyforge'
|
9
|
-
task :website_upload do
|
10
|
-
host = "#{rubyforge_username}@rubyforge.org"
|
11
|
-
remote_dir = "/var/www/gforge-projects/#{PATH}/"
|
12
|
-
local_dir = 'website'
|
13
|
-
sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
|
14
|
-
end
|
15
|
-
|
16
|
-
desc 'Generate and upload website files'
|
17
|
-
task :website => [:website_generate, :website_upload, :publish_docs]
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# This generator bootstraps a Rails project for use with Cucumber
|
2
|
-
class CucumberGenerator < Rails::Generator::Base
|
3
|
-
def manifest
|
4
|
-
record do |m|
|
5
|
-
m.directory 'features/steps'
|
6
|
-
m.file 'env.rb', 'features/steps/env.rb'
|
7
|
-
m.file 'common_webrat.rb', 'features/steps/common_webrat.rb'
|
8
|
-
|
9
|
-
m.directory 'lib/tasks'
|
10
|
-
m.file 'cucumber.rake', 'lib/tasks/cucumber.rake'
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
protected
|
15
|
-
|
16
|
-
def banner
|
17
|
-
"Usage: #{$0} cucumber"
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# Commonly used webrat steps
|
2
|
-
# http://github.com/brynary/webrat
|
3
|
-
|
4
|
-
When /I press "(.*)"/ do |button|
|
5
|
-
clicks_button(button)
|
6
|
-
end
|
7
|
-
|
8
|
-
When /I follow "(.*)"/ do |link|
|
9
|
-
clicks_link(link)
|
10
|
-
end
|
11
|
-
|
12
|
-
When /I fill in "(.*)" for "(.*)"/ do |value, field|
|
13
|
-
fills_in(field, :with => value)
|
14
|
-
end
|
15
|
-
|
16
|
-
When /I check "(.*)"/ do |field|
|
17
|
-
checks(field)
|
18
|
-
end
|
19
|
-
|
20
|
-
When /I go to "(.*)"/ do |path|
|
21
|
-
visits(path)
|
22
|
-
end
|
23
|
-
|
24
|
-
Then /I should see "(.*)"/ do |text|
|
25
|
-
response.body.should =~ /#{text}/m
|
26
|
-
end
|
27
|
-
|
28
|
-
Then /I should not see "(.*)"/ do |text|
|
29
|
-
response.body.should_not =~ /#{text}/m
|
30
|
-
end
|
@@ -1,6 +0,0 @@
|
|
1
|
-
# Sets up the Rails environment for Cucumber
|
2
|
-
ENV["RAILS_ENV"] = "test"
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
|
4
|
-
require 'cucumber/rails/world'
|
5
|
-
# Comment out the next line if you're not using RSpec's matchers (should / should_not) in your steps.
|
6
|
-
require 'cucumber/rails/rspec'
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# This generator bootstraps a Rails project for use with Cucumber
|
2
|
-
class FeatureGenerator < Rails::Generator::NamedBase
|
3
|
-
def manifest
|
4
|
-
record do |m|
|
5
|
-
m.directory 'features/steps'
|
6
|
-
m.template 'feature.erb', "features/manage_#{plural_name}.feature"
|
7
|
-
m.template 'steps.erb', "features/steps/#{singular_name}_steps.rb"
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
protected
|
12
|
-
|
13
|
-
def banner
|
14
|
-
"Usage: #{$0} cucumber"
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
Feature: Manage <%= plural_name %>
|
2
|
-
In order to keep track of <%= plural_name %>
|
3
|
-
A <%= singular_name %> mechanic
|
4
|
-
Should be able to manage several <%= plural_name %>
|
5
|
-
|
6
|
-
Scenario: Register new <%= singular_name %>
|
7
|
-
Given I am on the new <%= singular_name %> page
|
8
|
-
<% keyword = 'When' -%>
|
9
|
-
<% args.each do |arg| -%>
|
10
|
-
<%= keyword %> I fill in "My <%= singular_name %> <%= arg %>" for "<%= arg.humanize %>"
|
11
|
-
<% keyword = 'And' -%>
|
12
|
-
<% end -%>
|
13
|
-
And I press "Create"
|
14
|
-
<% keyword = 'Then' -%>
|
15
|
-
<% args.each do |arg| -%>
|
16
|
-
<%= keyword %> I should see "My <%= singular_name %> <%= arg %>"
|
17
|
-
<% keyword = 'And' -%>
|
18
|
-
<% end -%>
|
19
|
-
|
20
|
-
Scenario: Delete <%= singular_name %>
|
21
|
-
Given there are 4 <%= plural_name %>
|
22
|
-
When I delete the first <%= singular_name %>
|
23
|
-
Then there should be 3 <%= plural_name %> left
|
24
|
-
|
25
|
-
| initial | after |
|
26
|
-
| 100 | 99 |
|
27
|
-
| 1 | 0 |
|
@@ -1,22 +0,0 @@
|
|
1
|
-
Given /I am on the new <%= singular_name %> page/ do
|
2
|
-
visits "/<%= plural_name %>/new"
|
3
|
-
end
|
4
|
-
|
5
|
-
Given /there are (\d+) <%= plural_name %>/ do |n|
|
6
|
-
<%= class_name %>.transaction do
|
7
|
-
<%= class_name %>.destroy_all
|
8
|
-
n.to_i.times do |n|
|
9
|
-
<%= class_name %>.create! :name => "<%= class_name %> #{n}"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
When /I delete the first <%= singular_name %>/ do
|
15
|
-
visits <%= plural_name %>_url
|
16
|
-
clicks_link "Destroy"
|
17
|
-
end
|
18
|
-
|
19
|
-
Then /there should be (\d+) <%= plural_name %> left/ do |n|
|
20
|
-
<%= class_name %>.count.should == n.to_i
|
21
|
-
response.should have_tag("table tr", n.to_i + 1) # There is a header row too
|
22
|
-
end
|
data/lib/cucumber/cli.rb
DELETED
@@ -1,133 +0,0 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
require 'cucumber'
|
3
|
-
|
4
|
-
module Cucumber
|
5
|
-
class CLI
|
6
|
-
class << self
|
7
|
-
attr_writer :step_mother, :features
|
8
|
-
|
9
|
-
def execute
|
10
|
-
@execute_called = true
|
11
|
-
parse(ARGV).execute!(@step_mother, @features)
|
12
|
-
end
|
13
|
-
|
14
|
-
def execute_called?
|
15
|
-
@execute_called
|
16
|
-
end
|
17
|
-
|
18
|
-
def parse(args)
|
19
|
-
cli = new(args)
|
20
|
-
cli.parse_options!
|
21
|
-
cli
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
FORMATS = {
|
26
|
-
'progress' => Formatters::ProgressFormatter,
|
27
|
-
'html' => Formatters::HtmlFormatter,
|
28
|
-
'pretty' => Formatters::PrettyFormatter
|
29
|
-
}
|
30
|
-
|
31
|
-
def initialize(args)
|
32
|
-
@args = args.dup
|
33
|
-
@args.extend(OptionParser::Arguable)
|
34
|
-
end
|
35
|
-
|
36
|
-
def parse_options!
|
37
|
-
@options = { :require => nil, :lang => 'en', :format => 'pretty', :dry_run => false }
|
38
|
-
@args.options do |opts|
|
39
|
-
opts.banner = "Usage: cucumber [options] FILES|DIRS"
|
40
|
-
opts.on("-r LIBRARY|DIR", "--require LIBRARY|DIR", "Require files before executing the features.",
|
41
|
-
"If this option is not specified, all *.rb files that",
|
42
|
-
"are siblings or below the features will be autorequired") do |v|
|
43
|
-
@options[:require] ||= []
|
44
|
-
@options[:require] << v
|
45
|
-
end
|
46
|
-
opts.on("-l LINE", "--line LINE", "Only execute the scenario at the given line") do |v|
|
47
|
-
@options[:line] = v
|
48
|
-
end
|
49
|
-
opts.on("-a LANG", "--language LANG", "Specify language for features (Default: #{@options[:lang]})",
|
50
|
-
"Available languages: #{Cucumber.languages.join(", ")}") do |v|
|
51
|
-
@options[:lang] = v
|
52
|
-
end
|
53
|
-
opts.on("-f FORMAT", "--format FORMAT", "How to format features (Default: #{@options[:format]})",
|
54
|
-
"Available formats: #{FORMATS.keys.sort.join(", ")}") do |v|
|
55
|
-
@options[:format] = v
|
56
|
-
end
|
57
|
-
opts.on("-d", "--dry-run", "Invokes formatters without executing the steps.") do
|
58
|
-
@options[:dry_run] = true
|
59
|
-
end
|
60
|
-
opts.on_tail("--version", "Show version") do
|
61
|
-
puts VERSION::STRING
|
62
|
-
exit
|
63
|
-
end
|
64
|
-
opts.on_tail("--help", "You're looking at it") do
|
65
|
-
puts opts.help
|
66
|
-
exit
|
67
|
-
end
|
68
|
-
end.parse!
|
69
|
-
|
70
|
-
# Whatever is left after option parsing
|
71
|
-
@files = @args.map do |path|
|
72
|
-
path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
|
73
|
-
File.directory?(path) ? Dir["#{path}/**/*.feature"] : path
|
74
|
-
end.flatten
|
75
|
-
end
|
76
|
-
|
77
|
-
def execute!(step_mother, features)
|
78
|
-
Cucumber.load_language(@options[:lang])
|
79
|
-
$executor = Executor.new(formatter, step_mother)
|
80
|
-
require_files
|
81
|
-
load_plain_text_features(features)
|
82
|
-
$executor.line = @options[:line].to_i if @options[:line]
|
83
|
-
$executor.visit_features(features)
|
84
|
-
exit 1 if $executor.failed
|
85
|
-
end
|
86
|
-
|
87
|
-
private
|
88
|
-
|
89
|
-
# Requires files - typically step files and ruby feature files.
|
90
|
-
def require_files
|
91
|
-
ARGV.clear # Shut up RSpec
|
92
|
-
require "cucumber/treetop_parser/feature_#{@options[:lang]}"
|
93
|
-
require "cucumber/treetop_parser/feature_parser"
|
94
|
-
|
95
|
-
requires = @options[:require] || @args.map{|f| File.directory?(f) ? f : File.dirname(f)}.uniq
|
96
|
-
libs = requires.map do |path|
|
97
|
-
path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
|
98
|
-
File.directory?(path) ? Dir["#{path}/**/*.rb"] : path
|
99
|
-
end.flatten
|
100
|
-
libs.each do |lib|
|
101
|
-
begin
|
102
|
-
require lib
|
103
|
-
rescue LoadError => e
|
104
|
-
e.message << "\nFailed to load #{lib}"
|
105
|
-
raise e
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def load_plain_text_features(features)
|
111
|
-
parser = TreetopParser::FeatureParser.new
|
112
|
-
@files.each do |f|
|
113
|
-
features << parser.parse_feature(f)
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def formatter
|
118
|
-
klass = FORMATS[@options[:format]]
|
119
|
-
klass.new(STDOUT)
|
120
|
-
end
|
121
|
-
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
extend Cucumber::StepMethods
|
126
|
-
Cucumber::CLI.step_mother = step_mother
|
127
|
-
|
128
|
-
extend(Cucumber::Tree)
|
129
|
-
Cucumber::CLI.features = features
|
130
|
-
|
131
|
-
at_exit do
|
132
|
-
Cucumber::CLI.execute unless Cucumber::CLI.execute_called?
|
133
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
module Cucumber
|
2
|
-
class ArgCountError < StandardError
|
3
|
-
end
|
4
|
-
|
5
|
-
module CoreExt
|
6
|
-
# Proc extension that allows a proc to be called in the context of any object.
|
7
|
-
# Also makes it possible to tack a name onto a Proc.
|
8
|
-
module CallIn
|
9
|
-
attr_accessor :name
|
10
|
-
|
11
|
-
def call_in(obj, *args)
|
12
|
-
obj.extend(mod)
|
13
|
-
a = arity == -1 ? 0 : arity
|
14
|
-
if self != Tree::Step::PENDING && args.length != a
|
15
|
-
# We have to manually raise when the block has arity -1 (no pipes)
|
16
|
-
raise ArgCountError.new("wrong number of arguments (#{args.length} for 0)")
|
17
|
-
else
|
18
|
-
obj.__send__(meth, *args)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def arity2
|
23
|
-
arity == -1 ? 0 : arity
|
24
|
-
end
|
25
|
-
|
26
|
-
def backtrace_line
|
27
|
-
to_s.match(/[\d\w]+@(.*)>/)[1] + ":in `#{name}'"
|
28
|
-
end
|
29
|
-
|
30
|
-
def meth
|
31
|
-
@meth ||= "__cucumber_#{object_id}"
|
32
|
-
end
|
33
|
-
|
34
|
-
def mod
|
35
|
-
p = self
|
36
|
-
m = meth
|
37
|
-
@mod ||= Module.new do
|
38
|
-
define_method(m, &p)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class String
|
2
|
-
def gzub(pattern, format=nil, &proc)
|
3
|
-
s = dup
|
4
|
-
md = match(pattern)
|
5
|
-
pos = 0
|
6
|
-
md.captures.each_with_index do |m, n|
|
7
|
-
replacement = if block_given?
|
8
|
-
proc.call(m)
|
9
|
-
else
|
10
|
-
format % m
|
11
|
-
end
|
12
|
-
s[md.offset(n+1)[0] + pos, m.length] = replacement
|
13
|
-
pos += replacement.length - m.length
|
14
|
-
end
|
15
|
-
s
|
16
|
-
end
|
17
|
-
end
|
data/lib/cucumber/executor.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
require 'cucumber/core_ext/proc'
|
2
|
-
|
3
|
-
module Cucumber
|
4
|
-
class Pending < StandardError
|
5
|
-
end
|
6
|
-
|
7
|
-
class Executor
|
8
|
-
attr_reader :failed
|
9
|
-
|
10
|
-
def line=(line)
|
11
|
-
@line = line
|
12
|
-
end
|
13
|
-
|
14
|
-
def initialize(formatter, step_mother)
|
15
|
-
@formatter = formatter
|
16
|
-
@world_proc = lambda{ Object.new }
|
17
|
-
@before_procs = []
|
18
|
-
@after_procs = []
|
19
|
-
@step_mother = step_mother
|
20
|
-
end
|
21
|
-
|
22
|
-
def register_world_proc(&proc)
|
23
|
-
@world_proc = proc
|
24
|
-
end
|
25
|
-
|
26
|
-
def register_before_proc(&proc)
|
27
|
-
proc.extend(CoreExt::CallIn)
|
28
|
-
@before_procs << proc
|
29
|
-
end
|
30
|
-
|
31
|
-
def register_after_proc(&proc)
|
32
|
-
proc.extend(CoreExt::CallIn)
|
33
|
-
@after_procs << proc
|
34
|
-
end
|
35
|
-
|
36
|
-
def visit_features(features)
|
37
|
-
raise "Line number can only be specified when there is 1 feature. There were #{features.length}." if @line && features.length != 1
|
38
|
-
@step_mother.visit_features(features)
|
39
|
-
@formatter.visit_features(features) if @formatter.respond_to?(:visit_features)
|
40
|
-
features.accept(self)
|
41
|
-
@formatter.dump
|
42
|
-
end
|
43
|
-
|
44
|
-
def visit_feature(feature)
|
45
|
-
feature.accept(self)
|
46
|
-
end
|
47
|
-
|
48
|
-
def visit_header(header)
|
49
|
-
@formatter.header_executing(header) if @formatter.respond_to?(:header_executing)
|
50
|
-
end
|
51
|
-
|
52
|
-
def visit_scenario(scenario)
|
53
|
-
if @line.nil? || scenario.at_line?(@line)
|
54
|
-
@error = nil
|
55
|
-
@world = @world_proc.call
|
56
|
-
@formatter.scenario_executing(scenario) if @formatter.respond_to?(:scenario_executing)
|
57
|
-
@before_procs.each{|p| p.call_in(@world, *[])}
|
58
|
-
scenario.accept(self)
|
59
|
-
@after_procs.each{|p| p.call_in(@world, *[])}
|
60
|
-
@formatter.scenario_executed(scenario) if @formatter.respond_to?(:scenario_executed)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def visit_step(step)
|
65
|
-
if @error.nil?
|
66
|
-
begin
|
67
|
-
step.execute_in(@world)
|
68
|
-
rescue Pending => ignore
|
69
|
-
rescue => e
|
70
|
-
@failed = true
|
71
|
-
@error = e
|
72
|
-
end
|
73
|
-
@formatter.step_executed(step)
|
74
|
-
else
|
75
|
-
@formatter.step_skipped(step)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|