aslakhellesoy-cucumber 0.2.3.3 → 0.2.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +9 -1
- data/Manifest.txt +11 -2
- data/examples/i18n/bg/Rakefile +6 -0
- data/examples/i18n/bg/features/addition.feature +11 -0
- data/examples/i18n/bg/features/consecutive_calculations.feature +18 -0
- data/examples/i18n/bg/features/division.feature +16 -0
- data/examples/i18n/bg/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/bg/features/support/env.rb +6 -0
- data/examples/i18n/bg/features/support/world.rb +8 -0
- data/examples/i18n/bg/lib/calculator.rb +24 -0
- data/examples/tickets/Rakefile +1 -1
- data/examples/tickets/features/279/py_string_indent.feature +25 -0
- data/examples/tickets/features/279/py_string_indent.steps.rb +11 -0
- data/examples/tickets/features/279/wrong.feature_ +11 -0
- data/features/cucumber_cli_outlines.feature +3 -0
- data/features/step_definitions/cucumber_steps.rb +9 -1
- data/lib/cucumber/ast/examples.rb +0 -8
- data/lib/cucumber/ast/feature.rb +1 -9
- data/lib/cucumber/ast/feature_element.rb +0 -4
- data/lib/cucumber/ast/features.rb +1 -1
- data/lib/cucumber/ast/outline_table.rb +1 -15
- data/lib/cucumber/ast/scenario.rb +0 -6
- data/lib/cucumber/ast/scenario_outline.rb +1 -11
- data/lib/cucumber/ast/tags.rb +0 -4
- data/lib/cucumber/ast/visitor.rb +0 -10
- data/lib/cucumber/cli/main.rb +6 -3
- data/lib/cucumber/formatter/ansicolor.rb +1 -1
- data/lib/cucumber/formatter/html.rb +1 -1
- data/lib/cucumber/languages.yml +19 -1
- data/lib/cucumber/parser/feature.rb +80 -28
- data/lib/cucumber/parser/feature.tt +57 -14
- data/lib/cucumber/parser/table.rb +1 -1
- data/lib/cucumber/parser/table.tt +1 -1
- data/lib/cucumber/parser/treetop_ext.rb +30 -9
- data/lib/cucumber/version.rb +1 -1
- data/rails_generators/cucumber/templates/webrat_steps.rb +16 -0
- data/spec/cucumber/cli/main_spec.rb +1 -1
- data/spec/cucumber/parser/feature_parser_spec.rb +2 -10
- metadata +13 -4
- data/examples/tickets/cucumber.yml +0 -3
- data/spec/cucumber/ast/tags_spec.rb +0 -19
data/History.txt
CHANGED
@@ -6,13 +6,17 @@ several times, passing a Proc and extending the world object of the previous one
|
|
6
6
|
The problem was that there was no nice way to ensure the order in which these procs were called, which
|
7
7
|
led to some unexpected situations. In this release you can only register a single World proc. If you
|
8
8
|
want to extend a world with certain modules, you simply call the #World method with the module(s)
|
9
|
-
you wish to extend the World with. The Sinatra example illustrates how to do this.
|
9
|
+
you wish to extend the World with. The Sinatra example illustrates how to do this. Also check out
|
10
|
+
the RDoc for Cucumber::StepMother#World.
|
10
11
|
|
11
12
|
The Visitor API (which is used for formatters) has also changed slightly. However, we have tried to
|
12
13
|
do this in a backwards compatible way, so if you have custom formatters for Cucumber 0.2 they should
|
13
14
|
still work.
|
14
15
|
|
15
16
|
=== New features
|
17
|
+
* Field value steps for Webrat (Jack Chen)
|
18
|
+
* Added translation for Bulgarian (Krasimir Angelov)
|
19
|
+
* Updated translation for Polish (#273 Grzegorz Marszałek)
|
16
20
|
* Only a single World proc can be registered. World extension now happens by calling #World with ruby modules.
|
17
21
|
* Portuguese uses Funcionalidade in stead of Característica and accented words are aliased with unaccented ones (Alexandre da Silva and Felipe Coury).
|
18
22
|
* The usage formatter also prints unused step definitions (Aslak Hellesøy)
|
@@ -22,6 +26,10 @@ still work.
|
|
22
26
|
* Support description string for Backgrounds (#271 Joseph Wilk)
|
23
27
|
|
24
28
|
=== Bugfixes
|
29
|
+
* Fixed dependency on internal files in rspec breaks cucumber w/ rspec-1.2.4 (#291 Aslak Hellesøy)
|
30
|
+
* Fix color use when using autotest on Linux. (Hans de Graaff)
|
31
|
+
* Fixed incorrect calculation of pystring indentation (#279 Eugene Naydanov)
|
32
|
+
* Fixed --format html leads to an error (#252 Aslak Hellesøy)
|
25
33
|
* Fixed Background runs twice (#255 Aslak Hellesøy)
|
26
34
|
* Fixed Background Transactions and :xx (#270 Aslak Hellesøy)
|
27
35
|
* Fixed Autospec failing with cucumber 0.2 (#254 Aslak Hellesøy)
|
data/Manifest.txt
CHANGED
@@ -21,6 +21,14 @@ examples/i18n/ar/Rakefile
|
|
21
21
|
examples/i18n/ar/features/addition.feature
|
22
22
|
examples/i18n/ar/features/step_definitons/calculator_steps.rb
|
23
23
|
examples/i18n/ar/lib/calculator.rb
|
24
|
+
examples/i18n/bg/Rakefile
|
25
|
+
examples/i18n/bg/features/addition.feature
|
26
|
+
examples/i18n/bg/features/consecutive_calculations.feature
|
27
|
+
examples/i18n/bg/features/division.feature
|
28
|
+
examples/i18n/bg/features/step_definitons/calculator_steps.rb
|
29
|
+
examples/i18n/bg/features/support/env.rb
|
30
|
+
examples/i18n/bg/features/support/world.rb
|
31
|
+
examples/i18n/bg/lib/calculator.rb
|
24
32
|
examples/i18n/da/Rakefile
|
25
33
|
examples/i18n/da/features/step_definitons/kalkulator_steps.rb
|
26
34
|
examples/i18n/da/features/summering.feature
|
@@ -169,7 +177,6 @@ examples/test_unit/Rakefile
|
|
169
177
|
examples/test_unit/features/step_definitions/test_unit_steps.rb
|
170
178
|
examples/test_unit/features/test_unit.feature
|
171
179
|
examples/tickets/Rakefile
|
172
|
-
examples/tickets/cucumber.yml
|
173
180
|
examples/tickets/features/172.feature
|
174
181
|
examples/tickets/features/177/1.feature
|
175
182
|
examples/tickets/features/177/2.feature
|
@@ -181,6 +188,9 @@ examples/tickets/features/246.feature
|
|
181
188
|
examples/tickets/features/248.feature
|
182
189
|
examples/tickets/features/270/back.feature
|
183
190
|
examples/tickets/features/270/back.steps.rb
|
191
|
+
examples/tickets/features/279/py_string_indent.feature
|
192
|
+
examples/tickets/features/279/py_string_indent.steps.rb
|
193
|
+
examples/tickets/features/279/wrong.feature_
|
184
194
|
examples/tickets/features/lib/eatting_machine.rb
|
185
195
|
examples/tickets/features/lib/pantry.rb
|
186
196
|
examples/tickets/features/scenario_outline.feature
|
@@ -296,7 +306,6 @@ spec/cucumber/ast/scenario_spec.rb
|
|
296
306
|
spec/cucumber/ast/step_collection_spec.rb
|
297
307
|
spec/cucumber/ast/step_spec.rb
|
298
308
|
spec/cucumber/ast/table_spec.rb
|
299
|
-
spec/cucumber/ast/tags_spec.rb
|
300
309
|
spec/cucumber/broadcaster_spec.rb
|
301
310
|
spec/cucumber/cli/configuration_spec.rb
|
302
311
|
spec/cucumber/cli/main_spec.rb
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Функционалност: Събиране на числа
|
2
|
+
За да не го правят наум
|
3
|
+
Потребителите
|
4
|
+
Трябва да могат да събират числа с калкулатора
|
5
|
+
|
6
|
+
Сценарий: Събиране на две цели числа
|
7
|
+
Дадено е че съм въвел 50
|
8
|
+
И съм въвел 70
|
9
|
+
Когато натисна "+"
|
10
|
+
То резултата трябва да е равен на 120
|
11
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Функционалост: Последователни изчисления
|
2
|
+
За да не го правят наум
|
3
|
+
Потребителите
|
4
|
+
Трябва да могат да извършват последователни изчисления с калкулатора
|
5
|
+
|
6
|
+
Предистория:
|
7
|
+
Дадено е че съм събрал 3 и 5
|
8
|
+
|
9
|
+
Сценарий: събиране с резултата от последната операция
|
10
|
+
Когато въведа 4
|
11
|
+
И натисна "+"
|
12
|
+
То резултата трябва да е равен на 12
|
13
|
+
|
14
|
+
Сценарий: делене с резултата от последната операция
|
15
|
+
Когато въведа 2
|
16
|
+
И натисна "/"
|
17
|
+
То резултата трябва да е равен на 4
|
18
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Фунцкционалност: Делене на числа
|
2
|
+
За да не го правят наум
|
3
|
+
Потребителите
|
4
|
+
Трябва да могат да разделят числа с калкулатора
|
5
|
+
|
6
|
+
Рамка на сценарий: Делене на цели числа
|
7
|
+
Дадено е че съм въвел <делимо>
|
8
|
+
И е че съм въвел <делител>
|
9
|
+
Когато натисна "/"
|
10
|
+
То резултата трябва да е равен на <частно>
|
11
|
+
|
12
|
+
Примери:
|
13
|
+
| делимо | делител | частно |
|
14
|
+
| 100 | 2 | 50 |
|
15
|
+
| 28 | 7 | 4 |
|
16
|
+
| 0 | 5 | 0 |
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
Дадено /въвел (\d+)/ do |x|
|
4
|
+
calc.push x.to_i
|
5
|
+
end
|
6
|
+
|
7
|
+
Когато /^въведа (\d+)/ do |x|
|
8
|
+
calc.push x.to_i
|
9
|
+
end
|
10
|
+
|
11
|
+
Когато /натисна "(.*)"/ do |op|
|
12
|
+
calc.send op
|
13
|
+
end
|
14
|
+
|
15
|
+
То /резултата трябва да е равен на (\d+)/ do |result|
|
16
|
+
calc.result.should == result.to_f
|
17
|
+
end
|
18
|
+
|
19
|
+
Дадено /събрал (\d+) и (\d+)/ do |x, y|
|
20
|
+
Дадено %{въвел #{x}}
|
21
|
+
Дадено %{въвел #{y}}
|
22
|
+
Дадено %{натисна "+"}
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class Calculator
|
4
|
+
def initialize
|
5
|
+
@stack = []
|
6
|
+
end
|
7
|
+
|
8
|
+
def push(arg)
|
9
|
+
@stack.push arg
|
10
|
+
end
|
11
|
+
|
12
|
+
def result
|
13
|
+
@stack.last
|
14
|
+
end
|
15
|
+
|
16
|
+
def +
|
17
|
+
@stack.push @stack.pop + @stack.pop
|
18
|
+
end
|
19
|
+
|
20
|
+
def /
|
21
|
+
divisor, dividend = [@stack.pop, @stack.pop] # Hm, @stack.pop(2) doesn't work
|
22
|
+
@stack.push dividend / divisor
|
23
|
+
end
|
24
|
+
end
|
data/examples/tickets/Rakefile
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
Feature: pystring indentaion testcase
|
2
|
+
|
3
|
+
Scenario: example of correct indentation
|
4
|
+
Given multiline string
|
5
|
+
"""
|
6
|
+
I'm a cucumber and I'm ok
|
7
|
+
I sleep all night and test all day
|
8
|
+
"""
|
9
|
+
Then string is
|
10
|
+
"""
|
11
|
+
I'm a cucumber and I'm ok
|
12
|
+
I sleep all night and test all day
|
13
|
+
"""
|
14
|
+
|
15
|
+
Scenario: example of wrong indentation
|
16
|
+
Given I am in tickets/features/279
|
17
|
+
When I run cucumber -q wrong.feature_
|
18
|
+
Then it should fail with
|
19
|
+
"""
|
20
|
+
|
21
|
+
"""
|
22
|
+
And STDERR should match
|
23
|
+
"""
|
24
|
+
wrong.feature_:8:10: Parse error
|
25
|
+
"""
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec/expectations'
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../../../../features/step_definitions/cucumber_steps.rb'
|
4
|
+
|
5
|
+
Given /^multiline string$/ do |string|
|
6
|
+
@string = string
|
7
|
+
end
|
8
|
+
|
9
|
+
Then /^string is$/ do |string|
|
10
|
+
@string.should == string
|
11
|
+
end
|
@@ -58,6 +58,9 @@ Feature: Cucumber command line
|
|
58
58
|
|
59
59
|
"""
|
60
60
|
|
61
|
+
# There are 10 characters in the progress, but only 8 reported steps. Needs investigation.
|
62
|
+
# Looks like we're outputting too many characters.
|
63
|
+
@buggy
|
61
64
|
Scenario: Run all with progress formatter
|
62
65
|
When I run cucumber -q --format progress features/outline_sample.feature
|
63
66
|
Then it should fail with
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
1
3
|
Given /^I am in (.*)$/ do |dir|
|
2
4
|
@dir = dir
|
3
5
|
end
|
@@ -5,8 +7,10 @@ end
|
|
5
7
|
When /^I run cucumber (.*)$/ do |cmd|
|
6
8
|
@dir ||= 'self_test'
|
7
9
|
full_dir ||= File.expand_path(File.dirname(__FILE__) + "/../../examples/#{@dir}")
|
10
|
+
@stderr = Tempfile.new('cucumber')
|
11
|
+
@stderr.close
|
8
12
|
Dir.chdir(full_dir) do
|
9
|
-
@full_cmd = "#{Cucumber::RUBY_BINARY} #{Cucumber::BINARY} --no-color #{cmd}"
|
13
|
+
@full_cmd = "#{Cucumber::RUBY_BINARY} #{Cucumber::BINARY} --no-color #{cmd} 2> #{@stderr.path}"
|
10
14
|
@out = `#{@full_cmd}`
|
11
15
|
@status = $?.exitstatus
|
12
16
|
end
|
@@ -32,3 +36,7 @@ end
|
|
32
36
|
Then /^"(.*)" should match$/ do |file, text|
|
33
37
|
IO.read(file).should =~ Regexp.new(text)
|
34
38
|
end
|
39
|
+
|
40
|
+
Then /^STDERR should match$/ do |text|
|
41
|
+
Then %{"#{@stderr.path}" should match}, text
|
42
|
+
end
|
@@ -10,18 +10,10 @@ module Cucumber
|
|
10
10
|
visitor.visit_outline_table(@outline_table)
|
11
11
|
end
|
12
12
|
|
13
|
-
def descend?(visitor)
|
14
|
-
@outline_table.descend?(visitor)
|
15
|
-
end
|
16
|
-
|
17
13
|
def skip_invoke!
|
18
14
|
@outline_table.skip_invoke!
|
19
15
|
end
|
20
16
|
|
21
|
-
def matches_scenario_names?(scenario_names)
|
22
|
-
scenario_names.detect{|name| name == @name}
|
23
|
-
end
|
24
|
-
|
25
17
|
def each_example_row(&proc)
|
26
18
|
@outline_table.cells_rows[1..-1].each(&proc)
|
27
19
|
end
|
data/lib/cucumber/ast/feature.rb
CHANGED
@@ -19,18 +19,10 @@ module Cucumber
|
|
19
19
|
visitor.visit_feature_name(@name)
|
20
20
|
visitor.visit_background(@background) if @background
|
21
21
|
@feature_elements.each do |feature_element|
|
22
|
-
visitor.visit_feature_element(feature_element)
|
22
|
+
visitor.visit_feature_element(feature_element)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
def descend?(visitor)
|
27
|
-
@feature_elements.detect{ |feature_element| feature_element.descend?(visitor) }
|
28
|
-
end
|
29
|
-
|
30
|
-
def has_tags?(tags)
|
31
|
-
@tags.has_tags?(tags)
|
32
|
-
end
|
33
|
-
|
34
26
|
def next_feature_element(feature_element, &proc)
|
35
27
|
index = @feature_elements.index(feature_element)
|
36
28
|
next_one = @feature_elements[index+1]
|
@@ -10,21 +10,11 @@ module Cucumber
|
|
10
10
|
|
11
11
|
def accept(visitor)
|
12
12
|
cells_rows.each_with_index do |row, n|
|
13
|
-
|
14
|
-
visitor.visit_table_row(row)
|
15
|
-
end
|
13
|
+
visitor.visit_table_row(row)
|
16
14
|
end
|
17
15
|
nil
|
18
16
|
end
|
19
17
|
|
20
|
-
def descend?(visitor)
|
21
|
-
cells_rows.detect{|cells_row| cells_row.descend?(visitor)}
|
22
|
-
end
|
23
|
-
|
24
|
-
def matches?(visitor, cells)
|
25
|
-
@scenario_outline.matches_tags_and_name?(visitor)
|
26
|
-
end
|
27
|
-
|
28
18
|
def skip_invoke!
|
29
19
|
example_rows.each do |cells|
|
30
20
|
cells.skip_invoke!
|
@@ -46,10 +36,6 @@ module Cucumber
|
|
46
36
|
@step_invocations = scenario_outline.step_invocations(self)
|
47
37
|
end
|
48
38
|
|
49
|
-
def descend?(visitor)
|
50
|
-
@table.matches?(visitor, self)
|
51
|
-
end
|
52
|
-
|
53
39
|
def skip_invoke!
|
54
40
|
@step_invocations.each do |step_invocation|
|
55
41
|
step_invocation.skip_invoke!
|
@@ -22,12 +22,6 @@ module Cucumber
|
|
22
22
|
@background.feature = feature if @background
|
23
23
|
end
|
24
24
|
|
25
|
-
def descend?(visitor)
|
26
|
-
visitor.included_by_tags?(self) &&
|
27
|
-
!visitor.excluded_by_tags?(self) &&
|
28
|
-
visitor.matches_scenario_names?(self)
|
29
|
-
end
|
30
|
-
|
31
25
|
def accept(visitor)
|
32
26
|
visitor.visit_comment(@comment)
|
33
27
|
visitor.visit_tags(@tags)
|
@@ -30,16 +30,6 @@ module Cucumber
|
|
30
30
|
@background.feature = feature if @background
|
31
31
|
end
|
32
32
|
|
33
|
-
def descend?(visitor)
|
34
|
-
@examples_array.detect { |examples| examples.descend?(visitor) }
|
35
|
-
end
|
36
|
-
|
37
|
-
def matches_tags_and_name?(visitor)
|
38
|
-
visitor.included_by_tags?(self) &&
|
39
|
-
!visitor.excluded_by_tags?(self) &&
|
40
|
-
visitor.matches_scenario_names?(self)
|
41
|
-
end
|
42
|
-
|
43
33
|
def accept(visitor)
|
44
34
|
visitor.visit_comment(@comment)
|
45
35
|
visitor.visit_tags(@tags)
|
@@ -48,7 +38,7 @@ module Cucumber
|
|
48
38
|
|
49
39
|
skip_invoke! if @background && @background.failed?
|
50
40
|
@examples_array.each do |examples|
|
51
|
-
visitor.visit_examples(examples)
|
41
|
+
visitor.visit_examples(examples)
|
52
42
|
end
|
53
43
|
end
|
54
44
|
|
data/lib/cucumber/ast/tags.rb
CHANGED
data/lib/cucumber/ast/visitor.rb
CHANGED
@@ -10,16 +10,6 @@ module Cucumber
|
|
10
10
|
@step_mother = step_mother
|
11
11
|
end
|
12
12
|
|
13
|
-
def included_by_tags?(node)
|
14
|
-
tags = options[:include_tags] || []
|
15
|
-
tags.empty? || node.has_tags?(tags)
|
16
|
-
end
|
17
|
-
|
18
|
-
def excluded_by_tags?(node)
|
19
|
-
tags = options[:exclude_tags] || []
|
20
|
-
tags.any? && node.has_tags?(tags)
|
21
|
-
end
|
22
|
-
|
23
13
|
def matches_scenario_names?(node)
|
24
14
|
scenario_names = options[:scenario_names] || []
|
25
15
|
scenario_names.empty? || node.matches_scenario_names?(scenario_names)
|
data/lib/cucumber/cli/main.rb
CHANGED
@@ -52,8 +52,11 @@ module Cucumber
|
|
52
52
|
|
53
53
|
verbose_log("Features:")
|
54
54
|
configuration.feature_files.each do |f|
|
55
|
-
|
56
|
-
|
55
|
+
feature = parser.parse_file(f, configuration.options)
|
56
|
+
if feature
|
57
|
+
features.add_feature(feature)
|
58
|
+
verbose_log(" * #{f}")
|
59
|
+
end
|
57
60
|
end
|
58
61
|
verbose_log("\n"*2)
|
59
62
|
features
|
@@ -89,7 +92,7 @@ module Cucumber
|
|
89
92
|
|
90
93
|
def enable_diffing
|
91
94
|
if configuration.diff_enabled? && defined?(::Spec)
|
92
|
-
require 'spec/
|
95
|
+
require 'spec/runner/differs/default'
|
93
96
|
options = OpenStruct.new(:diff_format => :unified, :context_lines => 3)
|
94
97
|
::Spec::Expectations.differ = ::Spec::Expectations::Differs::Default.new(options)
|
95
98
|
end
|
@@ -102,7 +102,7 @@ module Cucumber
|
|
102
102
|
def visit_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background)
|
103
103
|
@status = status
|
104
104
|
@builder.li(:id => @step_id, :class => status) do
|
105
|
-
super
|
105
|
+
super(keyword, step_match, multiline_arg, status, exception, source_indent, background)
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
data/lib/cucumber/languages.yml
CHANGED
@@ -299,8 +299,11 @@
|
|
299
299
|
native: polski
|
300
300
|
encoding: UTF-8
|
301
301
|
feature: Właściwość
|
302
|
+
background: Założenia
|
302
303
|
scenario: Scenariusz
|
303
|
-
|
304
|
+
scenario_outline: Szablon scenariusza
|
305
|
+
examples: Przykłady
|
306
|
+
given: Zakładając
|
304
307
|
when: Jeżeli
|
305
308
|
then: Wtedy
|
306
309
|
and: Oraz
|
@@ -435,3 +438,18 @@
|
|
435
438
|
and: 그리고
|
436
439
|
but: 하지만
|
437
440
|
space_after_keyword: false
|
441
|
+
"bg":
|
442
|
+
name: Bulgarian
|
443
|
+
native: български
|
444
|
+
encoding: UTF-8
|
445
|
+
feature: Функционалност
|
446
|
+
background: Предистория
|
447
|
+
scenario: Сценарий
|
448
|
+
scenario_outline: Рамка на сценарий
|
449
|
+
examples: Примери
|
450
|
+
given: Дадено
|
451
|
+
when: Когато
|
452
|
+
then: То
|
453
|
+
and: И
|
454
|
+
but: Но
|
455
|
+
space_after_keyword: true
|
@@ -56,15 +56,21 @@ module Cucumber
|
|
56
56
|
end
|
57
57
|
|
58
58
|
module Feature2
|
59
|
+
def has_tags?(tag_names)
|
60
|
+
tags.has_tags?(tag_names)
|
61
|
+
end
|
62
|
+
|
59
63
|
def build(filter)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
64
|
+
if(filter.nil? || feature_elements.accept?(filter))
|
65
|
+
background = bg.respond_to?(:build) ? bg.build : nil
|
66
|
+
Ast::Feature.new(
|
67
|
+
background,
|
68
|
+
comment.build,
|
69
|
+
tags.build,
|
70
|
+
header.text_value,
|
71
|
+
feature_elements.build(background, filter)
|
72
|
+
)
|
73
|
+
end
|
68
74
|
end
|
69
75
|
end
|
70
76
|
|
@@ -209,10 +215,17 @@ module Cucumber
|
|
209
215
|
ts.elements.detect{|e| e.tag.line == line}
|
210
216
|
end
|
211
217
|
|
218
|
+
def has_tags?(tags)
|
219
|
+
tag_names.detect{|tag_name| tags.index(tag_name)}
|
220
|
+
end
|
221
|
+
|
212
222
|
def build
|
213
|
-
tag_names = ts.elements.map{|e| e.tag.tag_name.text_value}
|
214
223
|
Ast::Tags.new(ts.line, tag_names)
|
215
224
|
end
|
225
|
+
|
226
|
+
def tag_names
|
227
|
+
ts.elements.map{|e| e.tag.tag_name.text_value}
|
228
|
+
end
|
216
229
|
end
|
217
230
|
|
218
231
|
def _nt_tags
|
@@ -569,6 +582,10 @@ module Cucumber
|
|
569
582
|
end
|
570
583
|
|
571
584
|
module FeatureElements0
|
585
|
+
def accept?(filter)
|
586
|
+
filter.nil? || elements.empty? || elements.detect{|feature_element| filter.accept?(feature_element)}
|
587
|
+
end
|
588
|
+
|
572
589
|
def build(background, filter)
|
573
590
|
elements.map do |feature_element|
|
574
591
|
if filter.nil? || filter.accept?(feature_element)
|
@@ -656,6 +673,15 @@ module Cucumber
|
|
656
673
|
tags.at_line?(line)
|
657
674
|
end
|
658
675
|
|
676
|
+
def has_tags?(tag_names)
|
677
|
+
feature_tags = self.parent.parent.tags
|
678
|
+
tags.has_tags?(tag_names) || feature_tags.has_tags?(tag_names)
|
679
|
+
end
|
680
|
+
|
681
|
+
def matches_name?(name_to_match)
|
682
|
+
name.text_value == name_to_match
|
683
|
+
end
|
684
|
+
|
659
685
|
def build(background, filter)
|
660
686
|
Ast::Scenario.new(
|
661
687
|
background,
|
@@ -785,6 +811,15 @@ module Cucumber
|
|
785
811
|
steps.at_line?(line)
|
786
812
|
end
|
787
813
|
|
814
|
+
def has_tags?(tag_names)
|
815
|
+
feature_tags = self.parent.parent.tags
|
816
|
+
tags.has_tags?(tag_names) || feature_tags.has_tags?(tag_names)
|
817
|
+
end
|
818
|
+
|
819
|
+
def matches_name?(name_to_match)
|
820
|
+
name.text_value == name_to_match
|
821
|
+
end
|
822
|
+
|
788
823
|
def build(background, filter)
|
789
824
|
Ast::ScenarioOutline.new(
|
790
825
|
background,
|
@@ -1044,7 +1079,7 @@ module Cucumber
|
|
1044
1079
|
end
|
1045
1080
|
|
1046
1081
|
def build(filter, scenario_outline)
|
1047
|
-
elements.map do |e|
|
1082
|
+
elements.map do |e|
|
1048
1083
|
if(filter.nil? || filter.accept?(e) || filter.outline_at_line?(scenario_outline))
|
1049
1084
|
e.build(filter, scenario_outline)
|
1050
1085
|
end
|
@@ -1105,6 +1140,14 @@ module Cucumber
|
|
1105
1140
|
table.at_line?(line)
|
1106
1141
|
end
|
1107
1142
|
|
1143
|
+
def has_tags?(tag_names)
|
1144
|
+
true
|
1145
|
+
end
|
1146
|
+
|
1147
|
+
def outline_at_line?(line)
|
1148
|
+
true
|
1149
|
+
end
|
1150
|
+
|
1108
1151
|
def build(filter, scenario_outline)
|
1109
1152
|
[examples_keyword.line, examples_keyword.text_value, name.text_value, table.raw(filter, scenario_outline)]
|
1110
1153
|
end
|
@@ -1358,7 +1401,7 @@ module Cucumber
|
|
1358
1401
|
end
|
1359
1402
|
|
1360
1403
|
module OpenPyString0
|
1361
|
-
def
|
1404
|
+
def indent
|
1362
1405
|
elements[0]
|
1363
1406
|
end
|
1364
1407
|
|
@@ -1369,11 +1412,11 @@ module Cucumber
|
|
1369
1412
|
|
1370
1413
|
module OpenPyString1
|
1371
1414
|
def indentation
|
1372
|
-
|
1415
|
+
indent.text_value.length
|
1373
1416
|
end
|
1374
1417
|
|
1375
1418
|
def line
|
1376
|
-
|
1419
|
+
indent.line
|
1377
1420
|
end
|
1378
1421
|
end
|
1379
1422
|
|
@@ -1386,32 +1429,41 @@ module Cucumber
|
|
1386
1429
|
end
|
1387
1430
|
|
1388
1431
|
i0, s0 = index, []
|
1389
|
-
|
1432
|
+
s1, i1 = [], index
|
1433
|
+
loop do
|
1434
|
+
r2 = _nt_space
|
1435
|
+
if r2
|
1436
|
+
s1 << r2
|
1437
|
+
else
|
1438
|
+
break
|
1439
|
+
end
|
1440
|
+
end
|
1441
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
1390
1442
|
s0 << r1
|
1391
1443
|
if r1
|
1392
1444
|
if input.index('"""', index) == index
|
1393
|
-
|
1445
|
+
r3 = instantiate_node(SyntaxNode,input, index...(index + 3))
|
1394
1446
|
@index += 3
|
1395
1447
|
else
|
1396
1448
|
terminal_parse_failure('"""')
|
1397
|
-
|
1449
|
+
r3 = nil
|
1398
1450
|
end
|
1399
|
-
s0 <<
|
1400
|
-
if
|
1401
|
-
|
1451
|
+
s0 << r3
|
1452
|
+
if r3
|
1453
|
+
s4, i4 = [], index
|
1402
1454
|
loop do
|
1403
|
-
|
1404
|
-
if
|
1405
|
-
|
1455
|
+
r5 = _nt_space
|
1456
|
+
if r5
|
1457
|
+
s4 << r5
|
1406
1458
|
else
|
1407
1459
|
break
|
1408
1460
|
end
|
1409
1461
|
end
|
1410
|
-
|
1411
|
-
s0 <<
|
1412
|
-
if
|
1413
|
-
|
1414
|
-
s0 <<
|
1462
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
1463
|
+
s0 << r4
|
1464
|
+
if r4
|
1465
|
+
r6 = _nt_eol
|
1466
|
+
s0 << r6
|
1415
1467
|
end
|
1416
1468
|
end
|
1417
1469
|
end
|
@@ -1544,4 +1596,4 @@ module Cucumber
|
|
1544
1596
|
end
|
1545
1597
|
|
1546
1598
|
end
|
1547
|
-
end
|
1599
|
+
end
|
@@ -20,15 +20,21 @@ module Cucumber
|
|
20
20
|
bg:background?
|
21
21
|
feature_elements
|
22
22
|
comment? {
|
23
|
+
def has_tags?(tag_names)
|
24
|
+
tags.has_tags?(tag_names)
|
25
|
+
end
|
26
|
+
|
23
27
|
def build(filter)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
if(filter.nil? || feature_elements.accept?(filter))
|
29
|
+
background = bg.respond_to?(:build) ? bg.build : nil
|
30
|
+
Ast::Feature.new(
|
31
|
+
background,
|
32
|
+
comment.build,
|
33
|
+
tags.build,
|
34
|
+
header.text_value,
|
35
|
+
feature_elements.build(background, filter)
|
36
|
+
)
|
37
|
+
end
|
32
38
|
end
|
33
39
|
}
|
34
40
|
end
|
@@ -39,10 +45,17 @@ module Cucumber
|
|
39
45
|
ts.elements.detect{|e| e.tag.line == line}
|
40
46
|
end
|
41
47
|
|
48
|
+
def has_tags?(tags)
|
49
|
+
tag_names.detect{|tag_name| tags.index(tag_name)}
|
50
|
+
end
|
51
|
+
|
42
52
|
def build
|
43
|
-
tag_names = ts.elements.map{|e| e.tag.tag_name.text_value}
|
44
53
|
Ast::Tags.new(ts.line, tag_names)
|
45
54
|
end
|
55
|
+
|
56
|
+
def tag_names
|
57
|
+
ts.elements.map{|e| e.tag.tag_name.text_value}
|
58
|
+
end
|
46
59
|
}
|
47
60
|
end
|
48
61
|
|
@@ -78,6 +91,10 @@ module Cucumber
|
|
78
91
|
|
79
92
|
rule feature_elements
|
80
93
|
(scenario / scenario_outline)* {
|
94
|
+
def accept?(filter)
|
95
|
+
filter.nil? || elements.empty? || elements.detect{|feature_element| filter.accept?(feature_element)}
|
96
|
+
end
|
97
|
+
|
81
98
|
def build(background, filter)
|
82
99
|
elements.map do |feature_element|
|
83
100
|
if filter.nil? || filter.accept?(feature_element)
|
@@ -96,6 +113,15 @@ module Cucumber
|
|
96
113
|
tags.at_line?(line)
|
97
114
|
end
|
98
115
|
|
116
|
+
def has_tags?(tag_names)
|
117
|
+
feature_tags = self.parent.parent.tags
|
118
|
+
tags.has_tags?(tag_names) || feature_tags.has_tags?(tag_names)
|
119
|
+
end
|
120
|
+
|
121
|
+
def matches_name?(name_to_match)
|
122
|
+
name.text_value == name_to_match
|
123
|
+
end
|
124
|
+
|
99
125
|
def build(background, filter)
|
100
126
|
Ast::Scenario.new(
|
101
127
|
background,
|
@@ -123,6 +149,15 @@ module Cucumber
|
|
123
149
|
steps.at_line?(line)
|
124
150
|
end
|
125
151
|
|
152
|
+
def has_tags?(tag_names)
|
153
|
+
feature_tags = self.parent.parent.tags
|
154
|
+
tags.has_tags?(tag_names) || feature_tags.has_tags?(tag_names)
|
155
|
+
end
|
156
|
+
|
157
|
+
def matches_name?(name_to_match)
|
158
|
+
name.text_value == name_to_match
|
159
|
+
end
|
160
|
+
|
126
161
|
def build(background, filter)
|
127
162
|
Ast::ScenarioOutline.new(
|
128
163
|
background,
|
@@ -174,7 +209,7 @@ module Cucumber
|
|
174
209
|
end
|
175
210
|
|
176
211
|
def build(filter, scenario_outline)
|
177
|
-
elements.map do |e|
|
212
|
+
elements.map do |e|
|
178
213
|
if(filter.nil? || filter.accept?(e) || filter.outline_at_line?(scenario_outline))
|
179
214
|
e.build(filter, scenario_outline)
|
180
215
|
end
|
@@ -190,6 +225,14 @@ module Cucumber
|
|
190
225
|
table.at_line?(line)
|
191
226
|
end
|
192
227
|
|
228
|
+
def has_tags?(tag_names)
|
229
|
+
true
|
230
|
+
end
|
231
|
+
|
232
|
+
def outline_at_line?(line)
|
233
|
+
true
|
234
|
+
end
|
235
|
+
|
193
236
|
def build(filter, scenario_outline)
|
194
237
|
[examples_keyword.line, examples_keyword.text_value, name.text_value, table.raw(filter, scenario_outline)]
|
195
238
|
end
|
@@ -217,13 +260,13 @@ module Cucumber
|
|
217
260
|
end
|
218
261
|
|
219
262
|
rule open_py_string
|
220
|
-
|
263
|
+
indent:space* '"""' space* eol {
|
221
264
|
def indentation
|
222
|
-
|
265
|
+
indent.text_value.length
|
223
266
|
end
|
224
267
|
|
225
268
|
def line
|
226
|
-
|
269
|
+
indent.line
|
227
270
|
end
|
228
271
|
}
|
229
272
|
end
|
@@ -242,4 +285,4 @@ module Cucumber
|
|
242
285
|
|
243
286
|
end
|
244
287
|
end
|
245
|
-
end
|
288
|
+
end
|
@@ -13,20 +13,42 @@ end
|
|
13
13
|
module Cucumber
|
14
14
|
module Parser
|
15
15
|
class Filter
|
16
|
-
def initialize(lines)
|
16
|
+
def initialize(lines, options)
|
17
17
|
@lines = lines
|
18
|
+
@include_tags = options[:include_tags] || []
|
19
|
+
@exclude_tags = options[:exclude_tags] || []
|
20
|
+
@names = options[:scenario_names] || []
|
18
21
|
end
|
19
22
|
|
20
23
|
def accept?(syntax_node)
|
21
|
-
at_line?(syntax_node)
|
24
|
+
at_line?(syntax_node) &&
|
25
|
+
matches_tags?(syntax_node) &&
|
26
|
+
matches_names?(syntax_node)
|
22
27
|
end
|
23
28
|
|
24
29
|
def at_line?(syntax_node)
|
25
|
-
@lines.detect{|line| syntax_node.at_line?(line)}
|
30
|
+
@lines.nil? || @lines.empty? || @lines.detect{|line| syntax_node.at_line?(line)}
|
26
31
|
end
|
27
32
|
|
28
33
|
def outline_at_line?(syntax_node)
|
29
|
-
|
34
|
+
@lines.nil? || @lines.empty? || @lines.detect{|line| syntax_node.outline_at_line?(line)}
|
35
|
+
end
|
36
|
+
|
37
|
+
def matches_tags?(syntax_node)
|
38
|
+
!excluded_by_tags?(syntax_node) &&
|
39
|
+
included_by_tags?(syntax_node)
|
40
|
+
end
|
41
|
+
|
42
|
+
def included_by_tags?(syntax_node)
|
43
|
+
@include_tags.empty? || syntax_node.has_tags?(@include_tags)
|
44
|
+
end
|
45
|
+
|
46
|
+
def excluded_by_tags?(syntax_node)
|
47
|
+
@exclude_tags.any? && syntax_node.has_tags?(@exclude_tags)
|
48
|
+
end
|
49
|
+
|
50
|
+
def matches_names?(syntax_node)
|
51
|
+
@names.nil? || @names.empty? || @names.detect{|name| syntax_node.matches_name?(name)}
|
30
52
|
end
|
31
53
|
end
|
32
54
|
|
@@ -34,15 +56,14 @@ module Cucumber
|
|
34
56
|
FILE_COLON_LINE_PATTERN = /^([\w\W]*?):([\d:]+)$/
|
35
57
|
|
36
58
|
# Parses a file and returns a Cucumber::Ast
|
37
|
-
def parse_file(file)
|
59
|
+
def parse_file(file, options)
|
38
60
|
_, path, lines = *FILE_COLON_LINE_PATTERN.match(file)
|
39
61
|
if path
|
40
62
|
lines = lines.split(':').map { |line| line.to_i }
|
41
|
-
filter = Filter.new(lines)
|
42
63
|
else
|
43
64
|
path = file
|
44
|
-
filter = nil
|
45
65
|
end
|
66
|
+
filter = Filter.new(lines, options)
|
46
67
|
|
47
68
|
loader = lambda { |io| parse_or_fail(io.read, filter, path) }
|
48
69
|
feature = if path =~ /^http/
|
@@ -59,8 +80,8 @@ module Cucumber
|
|
59
80
|
if parse_tree.nil?
|
60
81
|
raise Cucumber::Parser::SyntaxError.new(self, file, line_offset)
|
61
82
|
else
|
62
|
-
ast = parse_tree.build(filter)
|
63
|
-
ast.file = file
|
83
|
+
ast = parse_tree.build(filter) # may return nil if it doesn't match filter.
|
84
|
+
ast.file = file unless ast.nil?
|
64
85
|
ast
|
65
86
|
end
|
66
87
|
end
|
data/lib/cucumber/version.rb
CHANGED
@@ -106,6 +106,22 @@ Then /^I should not see "([^\"]*)"$/ do |text|
|
|
106
106
|
<% end -%>
|
107
107
|
end
|
108
108
|
|
109
|
+
Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
|
110
|
+
<% if framework == :rspec -%>
|
111
|
+
field_labeled(field).value.should =~ /#{value}/
|
112
|
+
<% else -%>
|
113
|
+
assert_match(/#{value}/, field_labeled(field).value)
|
114
|
+
<% end -%>
|
115
|
+
end
|
116
|
+
|
117
|
+
Then /^the "([^\"]*)" field should not contain "([^\"]*)"$/ do |field, value|
|
118
|
+
<% if framework == :rspec -%>
|
119
|
+
field_labeled(field).value.should_not =~ /#{value}/
|
120
|
+
<% else -%>
|
121
|
+
assert_no_match(/#{value}/, field_labeled(field).value)
|
122
|
+
<% end -%>
|
123
|
+
end
|
124
|
+
|
109
125
|
Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
|
110
126
|
<% if framework == :rspec -%>
|
111
127
|
field_labeled(label).should be_checked
|
@@ -13,19 +13,11 @@ module Cucumber
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def parse_file(file)
|
16
|
-
@parser.parse_file(File.dirname(__FILE__) + "/../treetop_parser/" + file)
|
16
|
+
@parser.parse_file(File.dirname(__FILE__) + "/../treetop_parser/" + file, {})
|
17
17
|
end
|
18
18
|
|
19
19
|
def parse_example_file(file)
|
20
|
-
@parser.parse_file(File.dirname(__FILE__) + "/../../../examples/" + file)
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "Header" do
|
24
|
-
it "should parse Feature with blurb" do
|
25
|
-
parse(%{Feature: hi
|
26
|
-
with blurb
|
27
|
-
})
|
28
|
-
end
|
20
|
+
@parser.parse_file(File.dirname(__FILE__) + "/../../../examples/" + file, {})
|
29
21
|
end
|
30
22
|
|
31
23
|
describe "Comments" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aslakhellesoy-cucumber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.3.
|
4
|
+
version: 0.2.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Aslak Helles\xC3\xB8y"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-04-
|
12
|
+
date: 2009-04-13 00:00:00 -07:00
|
13
13
|
default_executable: cucumber
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -108,6 +108,14 @@ files:
|
|
108
108
|
- examples/i18n/ar/features/addition.feature
|
109
109
|
- examples/i18n/ar/features/step_definitons/calculator_steps.rb
|
110
110
|
- examples/i18n/ar/lib/calculator.rb
|
111
|
+
- examples/i18n/bg/Rakefile
|
112
|
+
- examples/i18n/bg/features/addition.feature
|
113
|
+
- examples/i18n/bg/features/consecutive_calculations.feature
|
114
|
+
- examples/i18n/bg/features/division.feature
|
115
|
+
- examples/i18n/bg/features/step_definitons/calculator_steps.rb
|
116
|
+
- examples/i18n/bg/features/support/env.rb
|
117
|
+
- examples/i18n/bg/features/support/world.rb
|
118
|
+
- examples/i18n/bg/lib/calculator.rb
|
111
119
|
- examples/i18n/da/Rakefile
|
112
120
|
- examples/i18n/da/features/step_definitons/kalkulator_steps.rb
|
113
121
|
- examples/i18n/da/features/summering.feature
|
@@ -256,7 +264,6 @@ files:
|
|
256
264
|
- examples/test_unit/features/step_definitions/test_unit_steps.rb
|
257
265
|
- examples/test_unit/features/test_unit.feature
|
258
266
|
- examples/tickets/Rakefile
|
259
|
-
- examples/tickets/cucumber.yml
|
260
267
|
- examples/tickets/features/172.feature
|
261
268
|
- examples/tickets/features/177/1.feature
|
262
269
|
- examples/tickets/features/177/2.feature
|
@@ -268,6 +275,9 @@ files:
|
|
268
275
|
- examples/tickets/features/248.feature
|
269
276
|
- examples/tickets/features/270/back.feature
|
270
277
|
- examples/tickets/features/270/back.steps.rb
|
278
|
+
- examples/tickets/features/279/py_string_indent.feature
|
279
|
+
- examples/tickets/features/279/py_string_indent.steps.rb
|
280
|
+
- examples/tickets/features/279/wrong.feature_
|
271
281
|
- examples/tickets/features/lib/eatting_machine.rb
|
272
282
|
- examples/tickets/features/lib/pantry.rb
|
273
283
|
- examples/tickets/features/scenario_outline.feature
|
@@ -383,7 +393,6 @@ files:
|
|
383
393
|
- spec/cucumber/ast/step_collection_spec.rb
|
384
394
|
- spec/cucumber/ast/step_spec.rb
|
385
395
|
- spec/cucumber/ast/table_spec.rb
|
386
|
-
- spec/cucumber/ast/tags_spec.rb
|
387
396
|
- spec/cucumber/broadcaster_spec.rb
|
388
397
|
- spec/cucumber/cli/configuration_spec.rb
|
389
398
|
- spec/cucumber/cli/main_spec.rb
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
-
|
3
|
-
module Cucumber
|
4
|
-
module Ast
|
5
|
-
describe Tags do
|
6
|
-
before do
|
7
|
-
@tags = Tags.new(-1, %w{one two three})
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should be among other tags" do
|
11
|
-
@tags.should have_tags(%w{one})
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should not be among other tags with irrelevent tag" do
|
15
|
-
@tags.should_not have_tags(%w{bacon})
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|