square-cucumber 0.3.12.2 → 0.3.93.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/History.txt +117 -4
  2. data/Manifest.txt +11 -0
  3. data/Rakefile +1 -1
  4. data/config/hoe.rb +3 -2
  5. data/cucumber.yml +2 -2
  6. data/examples/i18n/ko/features/addition.feature +5 -5
  7. data/examples/i18n/ko/features/step_definitons/calculator_steps.rb +1 -1
  8. data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +1 -1
  9. data/examples/i18n/pt/features/adicao.feature +4 -4
  10. data/examples/self_test/features/support/env.rb +2 -1
  11. data/examples/sinatra/features/support/env.rb +7 -1
  12. data/examples/steps_library/features/step_definitions/steps_lib1.rb +8 -0
  13. data/examples/steps_library/features/step_definitions/steps_lib2.rb +8 -0
  14. data/examples/tickets/features/step_definitons/tickets_steps.rb +15 -0
  15. data/examples/tickets/features/table_diffing.feature +13 -0
  16. data/examples/watir/features/step_definitons/search_steps.rb +5 -1
  17. data/features/cucumber_cli_diff_disabled.feature +2 -1
  18. data/features/html_formatter/a.html +5 -7
  19. data/features/junit_formatter.feature +21 -14
  20. data/features/profiles.feature +99 -0
  21. data/features/rake_task.feature +28 -0
  22. data/features/step_definitions/cucumber_steps.rb +28 -15
  23. data/features/steps_formatter.feature +25 -0
  24. data/features/support/env.rb +9 -5
  25. data/features/table_diffing.feature +45 -0
  26. data/features/unicode_table.feature +35 -0
  27. data/features/work_in_progress.feature +1 -0
  28. data/gem_tasks/contributors.rake +4 -0
  29. data/lib/cucumber/ast/background.rb +1 -0
  30. data/lib/cucumber/ast/comment.rb +1 -0
  31. data/lib/cucumber/ast/examples.rb +1 -0
  32. data/lib/cucumber/ast/feature.rb +10 -0
  33. data/lib/cucumber/ast/features.rb +6 -1
  34. data/lib/cucumber/ast/outline_table.rb +4 -1
  35. data/lib/cucumber/ast/py_string.rb +1 -1
  36. data/lib/cucumber/ast/scenario.rb +1 -0
  37. data/lib/cucumber/ast/scenario_outline.rb +2 -0
  38. data/lib/cucumber/ast/step.rb +5 -1
  39. data/lib/cucumber/ast/step_collection.rb +1 -0
  40. data/lib/cucumber/ast/step_invocation.rb +1 -0
  41. data/lib/cucumber/ast/table.rb +306 -52
  42. data/lib/cucumber/ast/tags.rb +1 -0
  43. data/lib/cucumber/ast/visitor.rb +2 -1
  44. data/lib/cucumber/cli/configuration.rb +28 -278
  45. data/lib/cucumber/cli/drb_client.rb +3 -1
  46. data/lib/cucumber/cli/language_help_formatter.rb +9 -7
  47. data/lib/cucumber/cli/main.rb +16 -2
  48. data/lib/cucumber/cli/options.rb +370 -0
  49. data/lib/cucumber/cli/profile_loader.rb +65 -0
  50. data/lib/cucumber/core_ext/instance_exec.rb +8 -5
  51. data/lib/cucumber/feature_file.rb +7 -1
  52. data/lib/cucumber/filter.rb +2 -2
  53. data/lib/cucumber/formatter/ansicolor.rb +42 -9
  54. data/lib/cucumber/formatter/console.rb +1 -1
  55. data/lib/cucumber/formatter/html.rb +12 -10
  56. data/lib/cucumber/formatter/junit.rb +63 -26
  57. data/lib/cucumber/formatter/pretty.rb +20 -5
  58. data/lib/cucumber/formatter/progress.rb +1 -1
  59. data/lib/cucumber/formatter/steps.rb +49 -0
  60. data/lib/cucumber/languages.yml +6 -6
  61. data/lib/cucumber/parser/feature.rb +90 -63
  62. data/lib/cucumber/parser/feature.tt +28 -1
  63. data/lib/cucumber/parser/i18n/language.rb +12 -5
  64. data/lib/cucumber/parser/table.rb +25 -25
  65. data/lib/cucumber/rake/task.rb +9 -3
  66. data/lib/cucumber/step_definition.rb +1 -1
  67. data/lib/cucumber/step_match.rb +1 -1
  68. data/lib/cucumber/step_mother.rb +3 -1
  69. data/lib/cucumber/version.rb +2 -2
  70. data/lib/cucumber/webrat/table_locator.rb +66 -0
  71. data/rails_generators/cucumber/cucumber_generator.rb +5 -1
  72. data/rails_generators/cucumber/templates/cucumber +3 -2
  73. data/rails_generators/cucumber/templates/cucumber.rake +18 -6
  74. data/rails_generators/cucumber/templates/cucumber_environment.rb +7 -4
  75. data/rails_generators/cucumber/templates/env.rb +1 -0
  76. data/rails_generators/cucumber/templates/spork_env.rb +1 -0
  77. data/rails_generators/cucumber/templates/webrat_steps.rb +22 -0
  78. data/rails_generators/feature/templates/feature.erb +1 -1
  79. data/rails_generators/feature/templates/steps.erb +2 -8
  80. data/spec/cucumber/ast/table_spec.rb +169 -0
  81. data/spec/cucumber/cli/configuration_spec.rb +144 -101
  82. data/spec/cucumber/cli/main_spec.rb +14 -5
  83. data/spec/cucumber/cli/options_spec.rb +311 -0
  84. data/spec/cucumber/cli/profile_loader_spec.rb +10 -0
  85. data/spec/cucumber/core_ext/proc_spec.rb +16 -2
  86. data/spec/cucumber/formatter/html_spec.rb +18 -0
  87. data/spec/cucumber/formatter/progress_spec.rb +2 -2
  88. data/spec/cucumber/parser/table_parser_spec.rb +1 -1
  89. data/spec/spec.opts +3 -1
  90. metadata +18 -4
  91. data/lib/cucumber/webrat/mechanize_world.rb +0 -82
@@ -6,42 +6,49 @@ Feature: JUnit output formatter
6
6
  Given I am in junit
7
7
  And the tmp directory is empty
8
8
 
9
- @mri186 @diffxml
9
+ @mri186
10
10
  Scenario: one feature, one passing scenario, one failing scenario
11
11
  When I run cucumber --format junit --out tmp/ features/one_passing_one_failing.feature
12
12
  Then it should fail with
13
13
  """
14
14
 
15
15
  """
16
- And "examples/junit/tmp/TEST-one_passing_one_failing.xml" should contain XML
16
+ And "examples/junit/tmp/TEST-one_passing_one_failing.xml" with junit duration "0.005" should contain
17
17
  """
18
- <?xml version="1.0" encoding="UTF-8"?>
19
- <testsuite errors="0" tests="2" name="One passing scenario, one failing scenario" failures="1">
20
- <testcase name="Given a passing scenario" classname="One passing scenario, one failing scenario.Passing">
18
+ <?xml encoding="UTF-8" version="1.0"?>
19
+ <testsuite errors="0" failures="1" name="One passing scenario, one failing scenario" tests="2" time="0.005">
20
+ <testcase classname="One passing scenario, one failing scenario.Passing" name="Passing" time="0.005">
21
21
  </testcase>
22
- <testcase name="Given a failing scenario" classname="One passing scenario, one failing scenario.Failing">
23
- <failure message="Given a failing scenario">
22
+ <testcase classname="One passing scenario, one failing scenario.Failing" name="Failing" time="0.005">
23
+ <failure message="failed Failing" type="failed">
24
+ Scenario: Failing
25
+
26
+ Given a failing scenario
27
+
28
+ Message:
24
29
  (RuntimeError)
25
30
  ./features/step_definitions/steps.rb:6:in `/a failing scenario/'
26
31
  features/one_passing_one_failing.feature:7:in `Given a failing scenario' </failure>
27
32
  </testcase>
28
33
  </testsuite>
29
-
34
+
30
35
  """
31
36
 
32
- @mri186 @diffxml
37
+ @mri186
33
38
  Scenario: pending step
34
39
  When I run cucumber --format junit --out tmp/ features/pending.feature
35
40
  Then it should pass with
36
41
  """
37
42
 
38
43
  """
39
- And "examples/junit/tmp/TEST-pending.xml" should contain XML
44
+ And "examples/junit/tmp/TEST-pending.xml" with junit duration "0.009" should contain
40
45
  """
41
- <?xml version="1.0" encoding="UTF-8"?>
42
- <testsuite errors="0" tests="1" name="Pending step" failures="1">
43
- <testcase name="Given a pending step" classname="Pending step.Pending">
44
- <failure message="Given a pending step">
46
+ <?xml encoding="UTF-8" version="1.0"?>
47
+ <testsuite errors="0" failures="1" name="Pending step" tests="1" time="0.009">
48
+ <testcase classname="Pending step.Pending" name="Pending" time="0.009">
49
+ <failure message="pending Pending" type="pending">
50
+ Scenario: Pending
51
+
45
52
  TODO (Cucumber::Pending)
46
53
  ./features/step_definitions/steps.rb:10:in `/a pending step/'
47
54
  features/pending.feature:4:in `Given a pending step' </failure>
@@ -0,0 +1,99 @@
1
+ Feature: Profiles
2
+ In order to save time and prevent carpal tunnel syndrome
3
+ Cucumber users can save and reuse commonly used cucumber flags in a 'cucumber.yml' file.
4
+ These named arguments are called profiles and the yml file should be in the root of your project.
5
+ Any cucumber argument is valid in a profile. To see all the available flags type 'cucumber --help'
6
+ For more information about profiles please see the wiki:
7
+ http://wiki.github.com/aslakhellesoy/cucumber/cucumberyml
8
+
9
+ Background: Basic App
10
+ Given a standard Cucumber project directory structure
11
+ And a file named "features/sample.feature" with:
12
+ """
13
+ Feature: Sample
14
+ Scenario: this is a test
15
+ Given I am just testing stuff
16
+ """
17
+ And a file named "features/support/env.rb"
18
+ And a file named "features/support/super_env.rb"
19
+ And the following profiles are defined:
20
+ """
21
+ default: features/sample.feature --require features/support/env.rb -v
22
+ super: features/sample.feature --require features/support/super_env.rb -v
23
+ """
24
+
25
+ Scenario: Explicitly defining a profile to run
26
+ When I run cucumber features/sample.feature --profile super
27
+ Then the output should contain
28
+ """
29
+ Using the super profile...
30
+ """
31
+ And exactly these files should be loaded: features/support/super_env.rb
32
+
33
+ Scenario: Defining multiple profiles to run
34
+ When I run cucumber features/sample.feature --profile default --profile super
35
+ Then the output should contain
36
+ """
37
+ Using the default and super profiles...
38
+ """
39
+ And exactly these files should be loaded: features/support/env.rb, features/support/super_env.rb
40
+
41
+ Scenario: Arguments passed in but no profile specified
42
+ When I run cucumber -v
43
+ Then the default profile should be used
44
+ And exactly these files should be loaded: features/support/env.rb
45
+
46
+ Scenario: Trying to use a missing profile
47
+ When I run cucumber -p foo
48
+ Then STDERR should be
49
+ """
50
+ Could not find profile: 'foo'
51
+
52
+ Defined profiles in cucumber.yml:
53
+ * default
54
+ * super
55
+
56
+ """
57
+
58
+ Scenario Outline: Disabling the default profile
59
+ When I run cucumber -v features/ <Flag>
60
+ Then the output should contain
61
+ """
62
+ Disabling profiles...
63
+ """
64
+ And exactly these files should be loaded: features/support/env.rb, features/support/super_env.rb
65
+
66
+ Examples:
67
+ | Flag |
68
+ | -P |
69
+ | --no-profile |
70
+
71
+
72
+ Scenario: Overriding the profile's features to run
73
+ Given a file named "features/another.feature" with:
74
+ """
75
+ Feature: Just this one should be ran
76
+ """
77
+ When I run cucumber -p default features/another.feature
78
+ Then exactly these features should be ran: features/another.feature
79
+
80
+ Scenario: Overriding the profile's formatter
81
+ You will most likely want to define a formatter in your default formatter.
82
+ However, you often want to run your features with a different formatter
83
+ yet still use the other the other arguments in the profile. Cucumber will
84
+ allow you to do this by giving precedence to the formatter specified on the
85
+ command line and override the one in the profile.
86
+
87
+ Given the following profiles are defined:
88
+ """
89
+ default: features/sample.feature --require features/support/env.rb -v --format profile
90
+ """
91
+ When I run cucumber features --format pretty
92
+ And the output should contain
93
+ """
94
+ Feature: Sample
95
+ """
96
+
97
+
98
+
99
+
@@ -148,3 +148,31 @@ Feature: Rake task
148
148
  """
149
149
  * features/support/dont_require_me.rb
150
150
  """
151
+
152
+ Scenario: feature files with spaces
153
+ Given a file named "features/spaces are nasty.feature" with:
154
+ """
155
+ Feature: The futures green
156
+
157
+ Scenario: Orange
158
+ Given this is missing
159
+ """
160
+ And a file named "Rakefile" with:
161
+ """
162
+ $LOAD_PATH.unshift(CUCUMBER_LIB)
163
+ require 'cucumber/rake/task'
164
+
165
+ Cucumber::Rake::Task.new(:features) do |t|
166
+ t.cucumber_opts = %w{--quiet --no-color}
167
+ end
168
+ """
169
+ When I run rake features
170
+ Then it should pass
171
+ And the output should contain
172
+ """
173
+ Feature: The futures green
174
+
175
+ Scenario: Orange
176
+ Given this is missing
177
+
178
+ """
@@ -39,7 +39,6 @@ Given /^I am not running (?:.*) in the background$/ do
39
39
  # no-op
40
40
  end
41
41
 
42
-
43
42
  When /^I run cucumber (.*)$/ do |cucumber_opts|
44
43
  run "#{Cucumber::RUBY_BINARY} #{Cucumber::BINARY} --no-color #{cucumber_opts}"
45
44
  end
@@ -75,23 +74,17 @@ Then /^the output should be$/ do |text|
75
74
  last_stdout.should == text
76
75
  end
77
76
 
78
- Then /^"(.*)" should contain XML$/ do |file, xml|
79
- t = Tempfile.new('cucumber-junit')
80
- t.write(xml)
81
- t.flush
82
- t.close
83
- cmd = "diffxml #{t.path} #{file}"
84
- diff = `#{cmd}`
85
- if diff =~ /<delta>/m
86
- raise diff + "\nXML WAS:\n" + IO.read(file)
87
- end
77
+ Then /^"([^\"]*)" should contain$/ do |file, text|
78
+ strip_duration(IO.read(file)).should == text
88
79
  end
89
80
 
90
- Then /^"(.*)" should contain$/ do |file, text|
91
- strip_duration(IO.read(file)).should == text
81
+ Then /^"([^\"]*)" with junit duration "([^\"]*)" should contain$/ do |actual_file, duration_replacement, text|
82
+ actual = IO.read(actual_file)
83
+ actual = replace_junit_duration(actual, duration_replacement)
84
+ actual.should == text
92
85
  end
93
86
 
94
- Then /^"(.*)" should match$/ do |file, text|
87
+ Then /^"([^\"]*)" should match$/ do |file, text|
95
88
  IO.read(file).should =~ Regexp.new(text)
96
89
  end
97
90
 
@@ -111,11 +104,15 @@ Then /^STDERR should not match$/ do |text|
111
104
  last_stderr.should_not =~ /#{text}/
112
105
  end
113
106
 
107
+ Then /^STDERR should be$/ do |text|
108
+ last_stderr.should == text
109
+ end
110
+
114
111
  Then /^STDERR should be empty$/ do
115
112
  last_stderr.should == ""
116
113
  end
117
114
 
118
- Then /^"(.*)" should exist$/ do |file|
115
+ Then /^"([^\"]*)" should exist$/ do |file|
119
116
  File.exists?(file).should be_true
120
117
  FileUtils.rm(file)
121
118
  end
@@ -128,3 +125,19 @@ Then /^"([^\"]*)" should be required$/ do |file_name|
128
125
  last_stdout.should include("* #{file_name}")
129
126
  end
130
127
 
128
+ Then /^exactly these files should be loaded:\s*(.*)$/ do |files|
129
+ last_stdout.scan(/^ \* (.*\.rb)$/).flatten.should == files.split(/,\s+/)
130
+ end
131
+
132
+ Then /^exactly these features should be ran:\s*(.*)$/ do |files|
133
+ last_stdout.scan(/^ \* (.*\.feature)$/).flatten.should == files.split(/,\s+/)
134
+ end
135
+
136
+ Then /^the (.*) profile should be used$/ do |profile|
137
+ last_stdout.should =~ /Using the #{profile} profile/
138
+ end
139
+
140
+ Then /^print output$/ do
141
+ puts last_stdout
142
+ end
143
+
@@ -0,0 +1,25 @@
1
+ Feature: --formatter steps option - Steps Formatter
2
+ In order to easily see which steps are already defined,
3
+ specially when using 3rd party steps libraries,
4
+ Cucumber should show the available steps in a user-friendly format
5
+
6
+ Background:
7
+ Given I am in steps_library
8
+
9
+ Scenario: Printing steps
10
+ When I run cucumber -f steps features
11
+ Then it should pass with
12
+ """
13
+ features/step_definitions/steps_lib1.rb
14
+ /^I defined a first step$/ # features/step_definitions/steps_lib1.rb:1
15
+ /^I define a second step$/ # features/step_definitions/steps_lib1.rb:4
16
+ /^I should also have a third step$/ # features/step_definitions/steps_lib1.rb:7
17
+
18
+ features/step_definitions/steps_lib2.rb
19
+ /^I defined a step 4$/ # features/step_definitions/steps_lib2.rb:1
20
+ /^I create a step 5$/ # features/step_definitions/steps_lib2.rb:4
21
+ /^I should be too tired for step 6$/ # features/step_definitions/steps_lib2.rb:7
22
+
23
+ 6 step definition(s) in 2 source file(s).
24
+
25
+ """
@@ -50,6 +50,10 @@ class CucumberWorld
50
50
  s.gsub(/\d+m\d+\.\d+s/m, replacement)
51
51
  end
52
52
 
53
+ def replace_junit_duration(s, replacement)
54
+ s.gsub(/\d+\.\d\d+/m, replacement)
55
+ end
56
+
53
57
  def create_file(file_name, file_content)
54
58
  file_content.gsub!("CUCUMBER_LIB", "'#{cucumber_lib_dir}'") # Some files, such as Rakefiles need to use the lib dir
55
59
  in_current_dir do
@@ -70,6 +74,11 @@ class CucumberWorld
70
74
  stderr_file.close
71
75
  in_current_dir do
72
76
  @last_stdout = `#{command} 2> #{stderr_file.path}`
77
+ mode = Cucumber::RUBY_1_9 ? {:external_encoding=>"UTF-8"} : 'r'
78
+ IO.popen("#{command} 2> #{stderr_file.path}", mode) do |io|
79
+ @last_stdout = io.read
80
+ end
81
+
73
82
  @last_exit_status = $?.exitstatus
74
83
  end
75
84
  @last_stderr = IO.read(stderr_file.path)
@@ -113,8 +122,3 @@ end
113
122
  After do
114
123
  terminate_background_jobs
115
124
  end
116
-
117
- Before('@diffxml') do
118
- `diffxml --version`
119
- raise "Please install diffxml from http://diffxml.sourceforge.net/" if $? != 0
120
- end
@@ -0,0 +1,45 @@
1
+ Feature: Table diffing
2
+ In order to more easily compare data in tables
3
+ step definition writers should be able to diff
4
+ a table with expected data and see the diff inline
5
+
6
+ Scenario: Extra row
7
+ Given a standard Cucumber project directory structure
8
+ And a file named "features/tables.feature" with:
9
+ """
10
+ Feature: Tables
11
+ Scenario: Extra row
12
+ Then the table should be:
13
+ | x | y |
14
+ | a | b |
15
+ """
16
+ And a file named "features/step_definitions/table_steps.rb" with:
17
+ """
18
+ Then /the table should be:/ do |expected|
19
+ expected.diff!(table(%{
20
+ | x | y |
21
+ | a | c |
22
+ }))
23
+ end
24
+ """
25
+ When I run cucumber -i features/tables.feature
26
+ Then it should fail with
27
+ """
28
+ Feature: Tables
29
+
30
+ Scenario: Extra row # features/tables.feature:2
31
+ Then the table should be: # features/step_definitions/table_steps.rb:1
32
+ | x | y |
33
+ | a | b |
34
+ | a | c |
35
+ Tables were not identical (RuntimeError)
36
+ ./features/step_definitions/table_steps.rb:2:in `/the table should be:/'
37
+ features/tables.feature:3:in `Then the table should be:'
38
+
39
+ Failing Scenarios:
40
+ cucumber features/tables.feature:2 # Scenario: Extra row
41
+
42
+ 1 scenario (1 failed)
43
+ 1 step (1 failed)
44
+
45
+ """
@@ -0,0 +1,35 @@
1
+ Feature: Unicode in tables
2
+ In order to please the whole world,
3
+ unicode characters in tables should be
4
+ properly aligned
5
+
6
+ Scenario: All sorts of weird stuff
7
+ Given a standard Cucumber project directory structure
8
+ And a file named "features/unicode.feature" with:
9
+ """
10
+ Feature: Featuring unicode
11
+
12
+ Scenario: So what, whatever
13
+ Given passing
14
+ | Brüno | abc |
15
+ | Bruno | æøå |
16
+ """
17
+ And a file named "features/env.rb" with:
18
+ """
19
+ $KCODE='u'
20
+ """
21
+ When I run cucumber -q --dry-run features/unicode.feature
22
+ Then it should pass with
23
+ """
24
+ Feature: Featuring unicode
25
+
26
+ Scenario: So what, whatever
27
+ Given passing
28
+ | Brüno | abc |
29
+ | Bruno | æøå |
30
+
31
+ 1 scenario (1 undefined)
32
+ 1 step (1 undefined)
33
+
34
+ """
35
+
@@ -52,6 +52,7 @@ Feature: Cucumber --work-in-progress switch
52
52
  @mri186
53
53
  Scenario: Pass with Failing Scenarios
54
54
  When I run cucumber -q -w -t @failing features/wip.feature
55
+ Then STDERR should be empty
55
56
  Then it should pass with
56
57
  """
57
58
  Feature: WIP
@@ -0,0 +1,4 @@
1
+ task :contributors do
2
+ contributors = `git log --pretty=short --no-merges | git shortlog -ne | egrep -ve '^ +' | egrep -ve '^$'`
3
+ puts contributors.split("\n").length
4
+ end
@@ -23,6 +23,7 @@ module Cucumber
23
23
  end
24
24
 
25
25
  def accept(visitor)
26
+ return if $cucumber_interrupted
26
27
  visitor.visit_comment(@comment) unless @comment.empty?
27
28
  visitor.visit_background_name(@keyword, @name, file_colon_line(@line), source_indent(first_line_length))
28
29
  visitor.step_mother.before(hook_context)
@@ -17,6 +17,7 @@ module Cucumber
17
17
  end
18
18
 
19
19
  def accept(visitor)
20
+ return if $cucumber_interrupted
20
21
  @value.strip.split("\n").each do |line|
21
22
  visitor.visit_comment_line(line.strip)
22
23
  end