cucumber 0.3.11 → 0.3.90
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +101 -0
- data/Manifest.txt +14 -5
- data/config/hoe.rb +1 -2
- data/cucumber.yml +1 -0
- data/examples/i18n/ar/Rakefile +1 -1
- data/examples/i18n/ar/features/addition.feature +1 -0
- data/examples/i18n/bg/Rakefile +1 -1
- data/examples/i18n/bg/features/addition.feature +1 -0
- data/examples/i18n/bg/features/consecutive_calculations.feature +1 -0
- data/examples/i18n/bg/features/division.feature +1 -0
- data/examples/i18n/cat/Rakefile +1 -1
- data/examples/i18n/cat/features/suma.feature +1 -0
- data/examples/i18n/da/Rakefile +1 -1
- data/examples/i18n/da/features/summering.feature +1 -0
- data/examples/i18n/de/Rakefile +1 -1
- data/examples/i18n/de/features/addition.feature +1 -0
- data/examples/i18n/de/features/division.feature +1 -0
- data/examples/i18n/en-lol/features/stuffing.feature +1 -1
- data/examples/i18n/en/Rakefile +1 -1
- data/examples/i18n/en/features/addition.feature +1 -0
- data/examples/i18n/en/features/division.feature +1 -0
- data/examples/i18n/es/Rakefile +1 -1
- data/examples/i18n/es/features/adicion.feature +1 -0
- data/examples/i18n/et/Rakefile +1 -1
- data/examples/i18n/et/features/jagamine.feature +1 -0
- data/examples/i18n/et/features/liitmine.feature +1 -0
- data/examples/i18n/fi/Rakefile +1 -1
- data/examples/i18n/fi/features/jakolasku.feature +1 -0
- data/examples/i18n/fr/Rakefile +1 -1
- data/examples/i18n/fr/features/addition.feature +2 -1
- data/examples/i18n/he/Rakefile +1 -1
- data/examples/i18n/he/features/addition.feature +1 -0
- data/examples/i18n/he/features/division.feature +1 -0
- data/examples/i18n/hu/Rakefile +1 -1
- data/examples/i18n/hu/features/addition.feature +1 -0
- data/examples/i18n/hu/features/division.feature +1 -0
- data/examples/i18n/id/Rakefile +1 -1
- data/examples/i18n/id/features/addition.feature +1 -0
- data/examples/i18n/id/features/division.feature +1 -0
- data/examples/i18n/it/Rakefile +1 -1
- data/examples/i18n/it/features/somma.feature +1 -0
- data/examples/i18n/ja/Rakefile +1 -1
- data/examples/i18n/ja/features/addition.feature +1 -0
- data/examples/i18n/ja/features/division.feature +1 -0
- data/examples/i18n/ko/Rakefile +1 -1
- data/examples/i18n/ko/features/addition.feature +6 -5
- data/examples/i18n/ko/features/division.feature +1 -0
- data/examples/i18n/ko/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/lt/Rakefile +1 -1
- data/examples/i18n/lt/features/addition.feature +1 -0
- data/examples/i18n/lt/features/division.feature +1 -0
- data/examples/i18n/lv/Rakefile +1 -1
- data/examples/i18n/lv/features/addition.feature +1 -0
- data/examples/i18n/lv/features/division.feature +1 -0
- data/examples/i18n/no/Rakefile +1 -1
- data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +1 -1
- data/examples/i18n/no/features/summering.feature +1 -0
- data/examples/i18n/pl/Rakefile +1 -1
- data/examples/i18n/pl/features/addition.feature +1 -0
- data/examples/i18n/pl/features/division.feature +1 -0
- data/examples/i18n/pt/Rakefile +1 -1
- data/examples/i18n/pt/features/adicao.feature +1 -0
- data/examples/i18n/ro/Rakefile +1 -1
- data/examples/i18n/ro/features/suma.feature +1 -0
- data/examples/i18n/ru/Rakefile +1 -1
- data/examples/i18n/ru/features/addition.feature +1 -0
- data/examples/i18n/ru/features/consecutive_calculations.feature +1 -0
- data/examples/i18n/ru/features/division.feature +1 -0
- data/examples/i18n/se/Rakefile +1 -1
- data/examples/i18n/se/features/summering.feature +1 -0
- data/examples/i18n/sk/Rakefile +1 -1
- data/examples/i18n/sk/features/addition.feature +1 -0
- data/examples/i18n/sk/features/division.feature +1 -0
- data/examples/i18n/zh-CN/features/addition.feature +1 -0
- data/examples/i18n/zh-TW/features/addition.feature +1 -0
- data/examples/i18n/zh-TW/features/division.feature +1 -0
- data/examples/self_test/features/support/env.rb +2 -1
- data/examples/sinatra/features/step_definitions/add_steps.rb +1 -1
- data/examples/sinatra/features/support/env.rb +13 -5
- data/examples/steps_library/features/step_definitions/steps_lib1.rb +8 -0
- data/examples/steps_library/features/step_definitions/steps_lib2.rb +8 -0
- data/examples/tickets/features/step_definitons/tickets_steps.rb +15 -0
- data/examples/tickets/features/table_diffing.feature +13 -0
- data/features/after_block_exceptions.feature +4 -1
- data/features/after_step_block_exceptions.feature +4 -1
- data/features/background.feature +6 -0
- data/features/bug_371.feature +32 -0
- data/features/cucumber_cli.feature +11 -1
- data/features/cucumber_cli_diff_disabled.feature +9 -2
- data/features/drb_server_integration.feature +28 -5
- data/features/expand.feature +2 -1
- data/features/html_formatter/a.html +129 -1614
- data/features/junit_formatter.feature +4 -4
- data/features/language_from_header.feature +30 -0
- data/features/rake_task.feature +28 -0
- data/features/step_definitions/cucumber_steps.rb +2 -2
- data/features/steps_formatter.feature +25 -0
- data/features/support/env.rb +13 -5
- data/features/table_diffing.feature +45 -0
- data/features/unicode_table.feature +35 -0
- data/features/work_in_progress.feature +3 -0
- data/gem_tasks/sass.rake +4 -0
- data/lib/cucumber.rb +0 -57
- data/lib/cucumber/ast/comment.rb +1 -1
- data/lib/cucumber/ast/feature.rb +2 -2
- data/lib/cucumber/ast/feature_element.rb +4 -0
- data/lib/cucumber/ast/outline_table.rb +2 -1
- data/lib/cucumber/ast/py_string.rb +0 -1
- data/lib/cucumber/ast/scenario.rb +5 -3
- data/lib/cucumber/ast/scenario_outline.rb +6 -1
- data/lib/cucumber/ast/step.rb +8 -1
- data/lib/cucumber/ast/step_invocation.rb +6 -1
- data/lib/cucumber/ast/table.rb +287 -49
- data/lib/cucumber/ast/visitor.rb +2 -1
- data/lib/cucumber/cli/configuration.rb +45 -28
- data/lib/cucumber/cli/drb_client.rb +8 -9
- data/lib/cucumber/cli/language_help_formatter.rb +9 -7
- data/lib/cucumber/cli/main.rb +8 -9
- data/lib/cucumber/feature_file.rb +53 -0
- data/lib/cucumber/filter.rb +50 -0
- data/lib/cucumber/formatter/console.rb +12 -0
- data/lib/cucumber/formatter/cucumber.css +106 -48
- data/lib/cucumber/formatter/cucumber.sass +121 -31
- data/lib/cucumber/formatter/html.rb +6 -5
- data/lib/cucumber/formatter/junit.rb +3 -6
- data/lib/cucumber/formatter/pretty.rb +22 -9
- data/lib/cucumber/formatter/profile.rb +1 -1
- data/lib/cucumber/formatter/progress.rb +1 -1
- data/lib/cucumber/formatter/steps.rb +49 -0
- data/lib/cucumber/languages.yml +3 -3
- data/lib/cucumber/parser.rb +1 -33
- data/lib/cucumber/parser/feature.rb +39 -16
- data/lib/cucumber/parser/feature.tt +1 -3
- data/lib/cucumber/parser/i18n.tt +30 -23
- data/lib/cucumber/parser/i18n/language.rb +83 -0
- data/lib/cucumber/parser/treetop_ext.rb +12 -83
- data/lib/cucumber/platform.rb +6 -0
- data/lib/cucumber/rake/task.rb +6 -0
- data/lib/cucumber/step_definition.rb +6 -0
- data/lib/cucumber/step_match.rb +1 -1
- data/lib/cucumber/step_mother.rb +3 -3
- data/lib/cucumber/version.rb +1 -1
- data/lib/cucumber/webrat/table_locator.rb +66 -0
- data/rails_generators/cucumber/templates/cucumber.rake +4 -0
- data/rails_generators/cucumber/templates/env.rb +1 -0
- data/rails_generators/cucumber/templates/spork_env.rb +1 -1
- data/rails_generators/cucumber/templates/webrat_steps.rb +17 -0
- data/rails_generators/feature/templates/feature.erb +1 -1
- data/rails_generators/feature/templates/steps.erb +2 -8
- data/spec/cucumber/ast/step_collection_spec.rb +5 -4
- data/spec/cucumber/ast/table_spec.rb +145 -0
- data/spec/cucumber/cli/configuration_spec.rb +55 -9
- data/spec/cucumber/cli/drb_client_spec.rb +5 -4
- data/spec/cucumber/cli/main_spec.rb +9 -12
- data/spec/cucumber/formatter/progress_spec.rb +2 -2
- data/spec/cucumber/parser/feature_parser_spec.rb +11 -9
- data/spec/cucumber/parser/table_parser_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -1
- metadata +21 -20
- data/spec/cucumber/formatter/html/cucumber.css +0 -37
- data/spec/cucumber/formatter/html/cucumber.js +0 -13
- data/spec/cucumber/formatter/html/index.html +0 -45
- data/spec/cucumber/formatter/html/jquery-1.3.min.js +0 -19
- data/spec/cucumber/formatter/html/jquery.uitableedit.js +0 -100
data/lib/cucumber/parser/i18n.tt
CHANGED
@@ -1,35 +1,42 @@
|
|
1
1
|
module Cucumber
|
2
2
|
module Parser
|
3
|
-
|
3
|
+
module I18n
|
4
|
+
grammar <%= keywords('grammar_name', true) %>
|
5
|
+
include Feature
|
6
|
+
include Table
|
4
7
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
+
rule feature
|
9
|
+
feature_sub
|
10
|
+
end
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
+
rule background_keyword
|
13
|
+
(<%= keywords('background') %>) ':'
|
14
|
+
end
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
+
rule scenario_keyword
|
17
|
+
(<%= keywords('scenario') %>) ':'
|
18
|
+
end
|
16
19
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
(<%= keywords('then') %>) /
|
21
|
-
(<%= keywords('and') %>) /
|
22
|
-
(<%= keywords('but') %>)
|
23
|
-
end
|
20
|
+
rule scenario_outline_keyword
|
21
|
+
(<%= keywords('scenario_outline') %>) ':'
|
22
|
+
end
|
24
23
|
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
rule step_keyword
|
25
|
+
(<%= keywords('given') %>) /
|
26
|
+
(<%= keywords('when') %>) /
|
27
|
+
(<%= keywords('then') %>) /
|
28
|
+
(<%= keywords('and') %>) /
|
29
|
+
(<%= keywords('but') %>)
|
30
|
+
end
|
28
31
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
+
rule keyword_space
|
33
|
+
<%= keywords('space_after_keyword', true) ? 'space+' : 'space*' %>
|
34
|
+
end
|
32
35
|
|
36
|
+
rule examples_keyword
|
37
|
+
(<%= keywords('examples') %>) ':'?
|
38
|
+
end
|
39
|
+
end
|
33
40
|
end
|
34
41
|
end
|
35
42
|
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module Parser
|
3
|
+
module I18n
|
4
|
+
class Language
|
5
|
+
KEYWORD_KEYS = %w{name native encoding feature background scenario scenario_outline examples given when then but}
|
6
|
+
|
7
|
+
class << self
|
8
|
+
LANGUAGES = Hash.new{|h,k| h[k] = Language.new(k)}
|
9
|
+
|
10
|
+
def [](key)
|
11
|
+
LANGUAGES[key]
|
12
|
+
end
|
13
|
+
|
14
|
+
def alias_step_definitions(keywords) #:nodoc:
|
15
|
+
all_keywords = %w{given when then and but}.map{|keyword| keywords[keyword].split('|')}.flatten
|
16
|
+
alias_steps(all_keywords)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Sets up additional method aliases for Given, When and Then.
|
20
|
+
# This does *not* affect how feature files are parsed. If you
|
21
|
+
# want to create aliases in the parser, you have to do this in
|
22
|
+
# languages.yml. For example:
|
23
|
+
#
|
24
|
+
# and: And|With
|
25
|
+
def alias_steps(keywords)
|
26
|
+
keywords.each do |adverb|
|
27
|
+
StepMother.alias_adverb(adverb)
|
28
|
+
World.alias_adverb(adverb)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
alias_step_definitions(Cucumber::LANGUAGES['en'])
|
34
|
+
|
35
|
+
def initialize(lang)
|
36
|
+
@keywords = Cucumber::LANGUAGES[lang]
|
37
|
+
raise "Language not supported: #{lang.inspect}" if @keywords.nil?
|
38
|
+
@keywords['grammar_name'] = @keywords['name'].gsub(/\s/, '')
|
39
|
+
end
|
40
|
+
|
41
|
+
def parser
|
42
|
+
return @parser if @parser
|
43
|
+
i18n_tt = File.expand_path(File.dirname(__FILE__) + '/../i18n.tt')
|
44
|
+
template = File.open(i18n_tt, Cucumber.file_mode('r')).read
|
45
|
+
erb = ERB.new(template)
|
46
|
+
grammar = erb.result(binding)
|
47
|
+
Treetop.load_from_string(grammar)
|
48
|
+
self.class.alias_step_definitions(@keywords)
|
49
|
+
@parser = Parser::I18n.const_get("#{@keywords['grammar_name']}Parser").new
|
50
|
+
end
|
51
|
+
|
52
|
+
def parse(source, path, filter)
|
53
|
+
feature = parser.parse_or_fail(source, path, filter)
|
54
|
+
feature.language = self if feature
|
55
|
+
feature
|
56
|
+
end
|
57
|
+
|
58
|
+
def keywords(key, raw=false)
|
59
|
+
return @keywords[key] if raw
|
60
|
+
return nil unless @keywords[key]
|
61
|
+
values = @keywords[key].split('|')
|
62
|
+
values.map{|value| "'#{value}'"}.join(" / ")
|
63
|
+
end
|
64
|
+
|
65
|
+
def incomplete?
|
66
|
+
KEYWORD_KEYS.detect{|key| @keywords[key].nil?}
|
67
|
+
end
|
68
|
+
|
69
|
+
def scenario_keyword
|
70
|
+
@keywords['scenario'].split('|')[0] + ':'
|
71
|
+
end
|
72
|
+
|
73
|
+
def but_keywords
|
74
|
+
@keywords['but'].split('|')
|
75
|
+
end
|
76
|
+
|
77
|
+
def and_keywords
|
78
|
+
@keywords['and'].split('|')
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -12,80 +12,19 @@ end
|
|
12
12
|
|
13
13
|
module Cucumber
|
14
14
|
module Parser
|
15
|
-
class
|
16
|
-
def initialize(
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
def accept?(syntax_node)
|
24
|
-
at_line?(syntax_node) &&
|
25
|
-
matches_tags?(syntax_node) &&
|
26
|
-
matches_names?(syntax_node)
|
27
|
-
end
|
28
|
-
|
29
|
-
def accept_example?(syntax_node, outline)
|
30
|
-
(at_line?(syntax_node) || outline_at_line?(outline)) &&
|
31
|
-
(matches_names?(syntax_node) || outline_matches_names?(outline))
|
32
|
-
end
|
33
|
-
|
34
|
-
def at_line?(syntax_node)
|
35
|
-
@lines.nil? || @lines.empty? || @lines.detect{|line| syntax_node.at_line?(line)}
|
36
|
-
end
|
37
|
-
|
38
|
-
def outline_at_line?(syntax_node)
|
39
|
-
@lines.nil? || @lines.empty? || @lines.detect{|line| syntax_node.outline_at_line?(line)}
|
40
|
-
end
|
41
|
-
|
42
|
-
def matches_tags?(syntax_node)
|
43
|
-
!excluded_by_tags?(syntax_node) &&
|
44
|
-
included_by_tags?(syntax_node)
|
45
|
-
end
|
46
|
-
|
47
|
-
def included_by_tags?(syntax_node)
|
48
|
-
@include_tags.empty? || syntax_node.has_tags?(@include_tags)
|
49
|
-
end
|
50
|
-
|
51
|
-
def excluded_by_tags?(syntax_node)
|
52
|
-
@exclude_tags.any? && syntax_node.has_tags?(@exclude_tags)
|
53
|
-
end
|
54
|
-
|
55
|
-
def outline_matches_names?(syntax_node)
|
56
|
-
@name_regexps.nil? || @name_regexps.empty? || @name_regexps.detect{|name_regexp| syntax_node.outline_matches_name?(name_regexp)}
|
57
|
-
end
|
58
|
-
|
59
|
-
def matches_names?(syntax_node)
|
60
|
-
@name_regexps.nil? || @name_regexps.empty? || @name_regexps.detect{|name_regexp| syntax_node.matches_name?(name_regexp)}
|
15
|
+
class SyntaxError < StandardError
|
16
|
+
def initialize(parser, file, line_offset)
|
17
|
+
tf = parser.terminal_failures
|
18
|
+
expected = tf.size == 1 ? tf[0].expected_string.inspect : "one of #{tf.map{|f| f.expected_string.inspect}.uniq*', '}"
|
19
|
+
line = parser.failure_line + line_offset
|
20
|
+
message = "#{file}:#{line}:#{parser.failure_column}: Parse error, expected #{expected}."
|
21
|
+
super(message)
|
61
22
|
end
|
62
23
|
end
|
63
|
-
|
64
|
-
module TreetopExt
|
65
|
-
|
66
|
-
|
67
|
-
# Parses a file and returns a Cucumber::Ast
|
68
|
-
def parse_file(file, options)
|
69
|
-
_, path, lines = *FILE_COLON_LINE_PATTERN.match(file)
|
70
|
-
if path
|
71
|
-
lines = lines.split(':').map { |line| line.to_i }
|
72
|
-
else
|
73
|
-
path = file
|
74
|
-
end
|
75
|
-
filter = Filter.new(lines, options)
|
76
|
-
|
77
|
-
loader = lambda { |io| parse_or_fail(io.read, filter, path) }
|
78
|
-
feature = if path =~ /^http/
|
79
|
-
require 'open-uri'
|
80
|
-
open(path, &loader)
|
81
|
-
else
|
82
|
-
File.open(path, Cucumber.file_mode('r'), &loader)
|
83
|
-
end
|
84
|
-
feature
|
85
|
-
end
|
86
|
-
|
87
|
-
def parse_or_fail(string, filter=nil, file=nil, line_offset=0)
|
88
|
-
parse_tree = parse(string)
|
24
|
+
|
25
|
+
module TreetopExt
|
26
|
+
def parse_or_fail(source, file=nil, filter=nil, line_offset=0)
|
27
|
+
parse_tree = parse(source)
|
89
28
|
if parse_tree.nil?
|
90
29
|
raise Cucumber::Parser::SyntaxError.new(self, file, line_offset)
|
91
30
|
else
|
@@ -95,16 +34,6 @@ module Cucumber
|
|
95
34
|
end
|
96
35
|
end
|
97
36
|
end
|
98
|
-
|
99
|
-
class SyntaxError < StandardError
|
100
|
-
def initialize(parser, file, line_offset)
|
101
|
-
tf = parser.terminal_failures
|
102
|
-
expected = tf.size == 1 ? tf[0].expected_string.inspect : "one of #{tf.map{|f| f.expected_string.inspect}.uniq*', '}"
|
103
|
-
line = parser.failure_line + line_offset
|
104
|
-
message = "#{file}:#{line}:#{parser.failure_column}: Parse error, expected #{expected}."
|
105
|
-
super(message)
|
106
|
-
end
|
107
|
-
end
|
108
37
|
end
|
109
38
|
end
|
110
39
|
|
@@ -115,7 +44,7 @@ module Treetop
|
|
115
44
|
input.line_of(interval.first)
|
116
45
|
end
|
117
46
|
end
|
118
|
-
|
47
|
+
|
119
48
|
class CompiledParser
|
120
49
|
include Cucumber::Parser::TreetopExt
|
121
50
|
end
|
data/lib/cucumber/platform.rb
CHANGED
@@ -4,9 +4,11 @@ require 'rbconfig'
|
|
4
4
|
require 'yaml'
|
5
5
|
|
6
6
|
module Cucumber
|
7
|
+
# TODO: Move these constants and the file to Language. Update wiki
|
7
8
|
LANGUAGE_FILE = File.expand_path(File.dirname(__FILE__) + '/languages.yml')
|
8
9
|
LANGUAGES = YAML.load_file(LANGUAGE_FILE)
|
9
10
|
BINARY = File.expand_path(File.dirname(__FILE__) + '/../../bin/cucumber')
|
11
|
+
LIBDIR = File.expand_path(File.dirname(__FILE__) + '/../../lib')
|
10
12
|
JRUBY = defined?(JRUBY_VERSION)
|
11
13
|
IRONRUBY = Config::CONFIG['sitedir'] =~ /IronRuby/
|
12
14
|
WINDOWS = Config::CONFIG['host_os'] =~ /mswin|mingw/
|
@@ -14,4 +16,8 @@ module Cucumber
|
|
14
16
|
RAILS = defined?(Rails)
|
15
17
|
RUBY_BINARY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
|
16
18
|
RUBY_1_9 = RUBY_VERSION =~ /^1\.9/
|
19
|
+
|
20
|
+
def self.file_mode(m)
|
21
|
+
RUBY_1_9 ? "#{m}:UTF-8" : m
|
22
|
+
end
|
17
23
|
end
|
data/lib/cucumber/rake/task.rb
CHANGED
@@ -194,6 +194,7 @@ module Cucumber
|
|
194
194
|
result = []
|
195
195
|
result += feature_list.to_a if feature_list
|
196
196
|
result += FileList[feature_pattern].to_a if feature_pattern
|
197
|
+
result = make_command_line_safe(result)
|
197
198
|
FileList[result]
|
198
199
|
end
|
199
200
|
end
|
@@ -208,6 +209,11 @@ module Cucumber
|
|
208
209
|
FileList[result]
|
209
210
|
end
|
210
211
|
end
|
212
|
+
|
213
|
+
private
|
214
|
+
def make_command_line_safe(list)
|
215
|
+
list.map{|string| string.gsub(' ', '\ ')}
|
216
|
+
end
|
211
217
|
end
|
212
218
|
|
213
219
|
class FeatureTask < Task
|
@@ -86,6 +86,8 @@ module Cucumber
|
|
86
86
|
|
87
87
|
include StepDefinitionMethods
|
88
88
|
|
89
|
+
attr_reader :regexp, :proc
|
90
|
+
|
89
91
|
def initialize(pattern, &proc)
|
90
92
|
raise MissingProc if proc.nil?
|
91
93
|
if String === pattern
|
@@ -112,5 +114,9 @@ module Cucumber
|
|
112
114
|
def file_colon_line
|
113
115
|
@proc.file_colon_line
|
114
116
|
end
|
117
|
+
|
118
|
+
def file
|
119
|
+
@file ||= file_colon_line.split(':')[0]
|
120
|
+
end
|
115
121
|
end
|
116
122
|
end
|
data/lib/cucumber/step_match.rb
CHANGED
data/lib/cucumber/step_mother.rb
CHANGED
@@ -254,12 +254,12 @@ module Cucumber
|
|
254
254
|
@snippet_generator.snippet_text(step_keyword, step_name, multiline_arg_class)
|
255
255
|
end
|
256
256
|
|
257
|
-
def before_and_after(scenario,
|
258
|
-
before(scenario) unless
|
257
|
+
def before_and_after(scenario, skip_hooks=false)
|
258
|
+
before(scenario) unless skip_hooks
|
259
259
|
@current_scenario = scenario
|
260
260
|
yield scenario
|
261
261
|
@current_scenario = nil
|
262
|
-
after(scenario) unless
|
262
|
+
after(scenario) unless skip_hooks
|
263
263
|
scenario_visited(scenario)
|
264
264
|
end
|
265
265
|
|
data/lib/cucumber/version.rb
CHANGED
@@ -0,0 +1,66 @@
|
|
1
|
+
module Webrat
|
2
|
+
class Table < Element
|
3
|
+
def self.xpath_search
|
4
|
+
".//table"
|
5
|
+
end
|
6
|
+
|
7
|
+
# Converts this Table element into a 2-dimensional array of String where each cell
|
8
|
+
# represents the inner_html of the <td> and <th> elements. The number of columns is
|
9
|
+
# determined by the number of cells in the first row.
|
10
|
+
def to_a
|
11
|
+
col_count = nil
|
12
|
+
Webrat::XML.css_search(@element, 'tr').map do |row|
|
13
|
+
cols = Webrat::XML.css_search(row, 'th,td')
|
14
|
+
col_count ||= cols.length
|
15
|
+
cols[0...col_count].map do |col|
|
16
|
+
col.inner_html
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module Locators
|
23
|
+
class TableLocator < Locator
|
24
|
+
def locate
|
25
|
+
Table.load(@session, table_element)
|
26
|
+
end
|
27
|
+
|
28
|
+
def table_element
|
29
|
+
table_elements.detect do |table_element|
|
30
|
+
matches_id?(table_element) ||
|
31
|
+
matches_css_selector?(table_element)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def matches_id?(table_element)
|
36
|
+
Webrat::XML.attribute(table_element, "id") == @value.to_s
|
37
|
+
end
|
38
|
+
|
39
|
+
def matches_css_selector?(table_element)
|
40
|
+
Webrat::XML.css_at(@dom, @value)
|
41
|
+
end
|
42
|
+
|
43
|
+
def table_elements
|
44
|
+
Webrat::XML.xpath_search(@dom, *Table.xpath_search)
|
45
|
+
end
|
46
|
+
|
47
|
+
def error_message
|
48
|
+
"Could not find table matching '#{@value}'"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Returns a Table element located by +id_or_selector+, which can
|
53
|
+
# be a DOM id or a CSS selector.
|
54
|
+
def table_at(id_or_selector)
|
55
|
+
TableLocator.new(@session, dom, id_or_selector).locate!
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
module Methods
|
60
|
+
delegate_to_session :table_at
|
61
|
+
end
|
62
|
+
|
63
|
+
class Session
|
64
|
+
def_delegators :current_scope, :table_at
|
65
|
+
end
|
66
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
$LOAD_PATH.unshift(RAILS_ROOT + '/vendor/plugins/cucumber/lib') if File.directory?(RAILS_ROOT + '/vendor/plugins/cucumber/lib')
|
2
2
|
|
3
|
+
unless ARGV.any? {|a| a =~ /^gems/}
|
4
|
+
|
3
5
|
begin
|
4
6
|
require 'cucumber/rake/task'
|
5
7
|
|
@@ -14,3 +16,5 @@ rescue LoadError
|
|
14
16
|
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
15
17
|
end
|
16
18
|
end
|
19
|
+
|
20
|
+
end
|