cucumber 0.8.6 → 0.8.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. data/.rspec +1 -1
  2. data/Caliper.yml +4 -0
  3. data/History.txt +1557 -0
  4. data/LICENSE +1 -1
  5. data/README.rdoc +26 -0
  6. data/Rakefile +51 -5
  7. data/VERSION.yml +5 -0
  8. data/bin/cucumber +1 -7
  9. data/cucumber.gemspec +77 -3
  10. data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +1 -1
  11. data/examples/i18n/he/features/step_definitons/calculator_steps.rb +1 -1
  12. data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +7 -4
  13. data/examples/i18n/ro/features/suma.feature +11 -0
  14. data/examples/i18n/ru/features/division.feature +2 -2
  15. data/examples/i18n/tr/features/step_definitons/hesap_makinesi_adimlari.rb +3 -3
  16. data/examples/sinatra/features/support/env.rb +5 -2
  17. data/examples/v8/features/fibonacci.feature +1 -1
  18. data/examples/watir/features/step_definitions/search_steps.rb +1 -1
  19. data/features/announce.feature +164 -0
  20. data/features/around_hooks.feature +232 -0
  21. data/features/background.feature +95 -284
  22. data/features/bug_371.feature +32 -0
  23. data/features/bug_464.feature +16 -0
  24. data/features/bug_475.feature +42 -0
  25. data/features/bug_585_tab_indentation.feature +22 -0
  26. data/features/bug_600.feature +67 -0
  27. data/features/call_steps_from_stepdefs.feature +154 -0
  28. data/features/cucumber_cli.feature +591 -0
  29. data/features/cucumber_cli_outlines.feature +117 -0
  30. data/features/custom_formatter.feature +73 -3
  31. data/features/default_snippets.feature +42 -0
  32. data/features/diffing.feature +25 -0
  33. data/features/drb_server_integration.feature +174 -0
  34. data/features/exception_in_after_block.feature +127 -0
  35. data/features/exception_in_after_step_block.feature +104 -0
  36. data/features/exception_in_before_block.feature +98 -0
  37. data/features/exclude_files.feature +20 -0
  38. data/features/expand.feature +60 -0
  39. data/features/html_formatter.feature +8 -0
  40. data/features/html_formatter/a.html +582 -0
  41. data/features/json_formatter.feature +245 -160
  42. data/features/junit_formatter.feature +88 -0
  43. data/features/language_from_header.feature +30 -0
  44. data/features/language_help.feature +78 -0
  45. data/features/listener_debugger_formatter.feature +42 -0
  46. data/features/multiline_names.feature +44 -0
  47. data/features/negative_tagged_hooks.feature +60 -0
  48. data/features/post_configuration_hook.feature +37 -0
  49. data/features/profiles.feature +126 -0
  50. data/features/rake_task.feature +152 -0
  51. data/features/report_called_undefined_steps.feature +34 -0
  52. data/features/rerun_formatter.feature +45 -0
  53. data/features/simplest.feature +11 -0
  54. data/features/snippet.feature +23 -0
  55. data/features/snippets_when_using_star_keyword.feature +36 -0
  56. data/features/step_definitions/cucumber_steps.rb +153 -7
  57. data/features/step_definitions/extra_steps.rb +2 -0
  58. data/features/step_definitions/simplest_steps.rb +3 -0
  59. data/features/step_definitions/wire_steps.rb +32 -0
  60. data/features/support/env.rb +140 -18
  61. data/features/support/env.rb.simplest +7 -0
  62. data/features/support/fake_wire_server.rb +77 -0
  63. data/features/table_diffing.feature +45 -0
  64. data/features/table_mapping.feature +34 -0
  65. data/features/tag_logic.feature +258 -0
  66. data/features/transform.feature +245 -0
  67. data/features/unicode_table.feature +35 -0
  68. data/features/usage_and_stepdefs_formatter.feature +169 -0
  69. data/features/wire_protocol.feature +332 -0
  70. data/features/wire_protocol_table_diffing.feature +119 -0
  71. data/features/wire_protocol_tags.feature +87 -0
  72. data/features/wire_protocol_timeouts.feature +63 -0
  73. data/features/work_in_progress.feature +156 -0
  74. data/fixtures/json/features/pystring.feature +8 -0
  75. data/fixtures/junit/features/pending.feature +1 -3
  76. data/fixtures/self_test/features/background/background_tagged_before_on_outline.feature +12 -0
  77. data/fixtures/self_test/features/background/background_with_name.feature +7 -0
  78. data/fixtures/self_test/features/background/failing_background.feature +12 -0
  79. data/fixtures/self_test/features/background/failing_background_after_success.feature +11 -0
  80. data/fixtures/self_test/features/background/multiline_args_background.feature +32 -0
  81. data/fixtures/self_test/features/background/passing_background.feature +10 -0
  82. data/fixtures/self_test/features/background/pending_background.feature +10 -0
  83. data/fixtures/self_test/features/background/scenario_outline_failing_background.feature +16 -0
  84. data/fixtures/self_test/features/background/scenario_outline_passing_background.feature +16 -0
  85. data/fixtures/self_test/features/support/env.rb +0 -8
  86. data/fixtures/tickets/features.html +1 -1
  87. data/gem_tasks/examples.rake +1 -1
  88. data/gem_tasks/features.rake +14 -0
  89. data/gem_tasks/sdoc.rake +12 -0
  90. data/lib/cucumber.rb +0 -12
  91. data/lib/cucumber/ast.rb +1 -1
  92. data/lib/cucumber/ast/background.rb +5 -21
  93. data/lib/cucumber/ast/examples.rb +4 -12
  94. data/lib/cucumber/ast/feature.rb +5 -13
  95. data/lib/cucumber/ast/feature_element.rb +4 -9
  96. data/lib/cucumber/ast/outline_table.rb +4 -4
  97. data/lib/cucumber/ast/py_string.rb +80 -0
  98. data/lib/cucumber/ast/scenario.rb +5 -7
  99. data/lib/cucumber/ast/scenario_outline.rb +15 -23
  100. data/lib/cucumber/ast/step.rb +0 -5
  101. data/lib/cucumber/ast/step_invocation.rb +15 -21
  102. data/lib/cucumber/ast/table.rb +8 -14
  103. data/lib/cucumber/ast/tree_walker.rb +48 -10
  104. data/lib/cucumber/cli/configuration.rb +8 -33
  105. data/lib/cucumber/cli/main.rb +35 -20
  106. data/lib/cucumber/cli/options.rb +7 -8
  107. data/lib/cucumber/cli/profile_loader.rb +0 -2
  108. data/lib/cucumber/core_ext/proc.rb +1 -2
  109. data/lib/cucumber/feature_file.rb +15 -47
  110. data/lib/cucumber/formatter/ansicolor.rb +5 -3
  111. data/lib/cucumber/formatter/color_io.rb +23 -0
  112. data/lib/cucumber/formatter/console.rb +23 -27
  113. data/lib/cucumber/formatter/cucumber.css +17 -34
  114. data/lib/cucumber/formatter/cucumber.sass +182 -173
  115. data/lib/cucumber/formatter/html.rb +11 -46
  116. data/lib/cucumber/formatter/io.rb +4 -2
  117. data/lib/cucumber/formatter/json.rb +152 -15
  118. data/lib/cucumber/formatter/json_pretty.rb +6 -5
  119. data/lib/cucumber/formatter/junit.rb +22 -28
  120. data/lib/cucumber/formatter/pdf.rb +6 -6
  121. data/lib/cucumber/formatter/pretty.rb +5 -5
  122. data/lib/cucumber/formatter/rerun.rb +11 -22
  123. data/lib/cucumber/formatter/tag_cloud.rb +35 -0
  124. data/lib/cucumber/formatter/unicode.rb +20 -41
  125. data/lib/cucumber/js_support/js_dsl.js +4 -4
  126. data/lib/cucumber/js_support/js_language.rb +5 -9
  127. data/lib/cucumber/js_support/js_snippets.rb +2 -2
  128. data/lib/cucumber/language_support.rb +2 -2
  129. data/lib/cucumber/parser/gherkin_builder.rb +30 -35
  130. data/lib/cucumber/platform.rb +8 -8
  131. data/lib/cucumber/py_support/py_language.rb +2 -2
  132. data/lib/cucumber/rake/task.rb +31 -74
  133. data/lib/cucumber/rb_support/rb_dsl.rb +0 -1
  134. data/lib/cucumber/rb_support/rb_language.rb +8 -10
  135. data/lib/cucumber/rb_support/rb_step_definition.rb +0 -8
  136. data/lib/cucumber/rb_support/rb_transform.rb +0 -17
  137. data/lib/cucumber/rb_support/rb_world.rb +18 -26
  138. data/lib/cucumber/rspec/doubles.rb +3 -3
  139. data/lib/cucumber/step_match.rb +2 -6
  140. data/lib/cucumber/step_mother.rb +427 -6
  141. data/lib/cucumber/wire_support/configuration.rb +1 -4
  142. data/lib/cucumber/wire_support/wire_language.rb +10 -3
  143. data/spec/cucumber/ast/background_spec.rb +6 -68
  144. data/spec/cucumber/ast/feature_factory.rb +4 -5
  145. data/spec/cucumber/ast/feature_spec.rb +4 -4
  146. data/spec/cucumber/ast/outline_table_spec.rb +1 -1
  147. data/spec/cucumber/ast/py_string_spec.rb +40 -0
  148. data/spec/cucumber/ast/scenario_outline_spec.rb +11 -15
  149. data/spec/cucumber/ast/scenario_spec.rb +4 -4
  150. data/spec/cucumber/ast/step_spec.rb +3 -3
  151. data/spec/cucumber/ast/table_spec.rb +2 -38
  152. data/spec/cucumber/ast/tree_walker_spec.rb +2 -2
  153. data/spec/cucumber/broadcaster_spec.rb +1 -1
  154. data/spec/cucumber/cli/configuration_spec.rb +6 -32
  155. data/spec/cucumber/cli/drb_client_spec.rb +3 -2
  156. data/spec/cucumber/cli/main_spec.rb +43 -43
  157. data/spec/cucumber/cli/options_spec.rb +1 -28
  158. data/spec/cucumber/cli/profile_loader_spec.rb +1 -1
  159. data/spec/cucumber/core_ext/proc_spec.rb +1 -1
  160. data/spec/cucumber/formatter/ansicolor_spec.rb +1 -1
  161. data/spec/cucumber/formatter/color_io_spec.rb +29 -0
  162. data/spec/cucumber/formatter/duration_spec.rb +1 -1
  163. data/spec/cucumber/formatter/html_spec.rb +5 -3
  164. data/spec/cucumber/formatter/junit_spec.rb +2 -16
  165. data/spec/cucumber/formatter/progress_spec.rb +1 -1
  166. data/spec/cucumber/formatter/spec_helper.rb +12 -11
  167. data/spec/cucumber/rb_support/rb_language_spec.rb +28 -241
  168. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +28 -33
  169. data/spec/cucumber/rb_support/regexp_argument_matcher_spec.rb +1 -1
  170. data/spec/cucumber/step_match_spec.rb +9 -11
  171. data/spec/cucumber/step_mother_spec.rb +302 -0
  172. data/spec/cucumber/wire_support/configuration_spec.rb +1 -1
  173. data/spec/cucumber/wire_support/connection_spec.rb +1 -1
  174. data/spec/cucumber/wire_support/wire_exception_spec.rb +1 -1
  175. data/spec/cucumber/wire_support/wire_language_spec.rb +1 -1
  176. data/spec/cucumber/wire_support/wire_packet_spec.rb +1 -1
  177. data/spec/cucumber/wire_support/wire_step_definition_spec.rb +1 -1
  178. data/spec/cucumber/world/pending_spec.rb +2 -2
  179. data/spec/spec_helper.rb +20 -13
  180. metadata +78 -4
@@ -0,0 +1,152 @@
1
+ Feature: Rake task
2
+ In order to ease the development process
3
+ As a developer and CI server administrator
4
+ Cucumber features should be executable via Rake
5
+
6
+ Background:
7
+ Given a standard Cucumber project directory structure
8
+ And a file named "features/missing_step_definitions.feature" with:
9
+ """
10
+ Feature: Sample
11
+
12
+ Scenario: Wanted
13
+ Given I want to run this
14
+
15
+ Scenario: Unwanted
16
+ Given I don't want this ran
17
+ """
18
+
19
+
20
+ Scenario: rake task with a defined profile
21
+ Given the following profile is defined:
22
+ """
23
+ foo: --quiet --no-color features/missing_step_definitions.feature:3
24
+ """
25
+ And a file named "Rakefile" with:
26
+ """
27
+ $LOAD_PATH.unshift(CUCUMBER_LIB)
28
+ require 'cucumber/rake/task'
29
+
30
+ Cucumber::Rake::Task.new do |t|
31
+ t.profile = "foo"
32
+ end
33
+ """
34
+ When I run rake cucumber
35
+ Then it should pass
36
+ And the output should contain
37
+ """
38
+ Feature: Sample
39
+
40
+ Scenario: Wanted
41
+ Given I want to run this
42
+
43
+ 1 scenario (1 undefined)
44
+ 1 step (1 undefined)
45
+ """
46
+
47
+ Scenario: rake task without a profile
48
+ Given a file named "Rakefile" with:
49
+ """
50
+ $LOAD_PATH.unshift(CUCUMBER_LIB)
51
+ require 'cucumber/rake/task'
52
+
53
+ Cucumber::Rake::Task.new do |t|
54
+ t.cucumber_opts = %w{--quiet --no-color}
55
+ end
56
+ """
57
+ When I run rake cucumber
58
+ Then it should pass
59
+ And the output should contain
60
+ """
61
+ Feature: Sample
62
+
63
+ Scenario: Wanted
64
+ Given I want to run this
65
+
66
+ Scenario: Unwanted
67
+ Given I don't want this ran
68
+
69
+ 2 scenarios (2 undefined)
70
+ 2 steps (2 undefined)
71
+ """
72
+
73
+ Scenario: rake task with a defined profile and cucumber_opts
74
+ Given the following profile is defined:
75
+ """
76
+ bar: ['features/missing_step_definitions.feature:3']
77
+ """
78
+ And a file named "Rakefile" with:
79
+ """
80
+ $LOAD_PATH.unshift(CUCUMBER_LIB)
81
+ require 'cucumber/rake/task'
82
+
83
+ Cucumber::Rake::Task.new do |t|
84
+ t.profile = "bar"
85
+ t.cucumber_opts = %w{--quiet --no-color}
86
+ end
87
+ """
88
+ When I run rake cucumber
89
+ Then it should pass
90
+ And the output should contain
91
+ """
92
+ Feature: Sample
93
+
94
+ Scenario: Wanted
95
+ Given I want to run this
96
+
97
+ 1 scenario (1 undefined)
98
+ 1 step (1 undefined)
99
+ """
100
+
101
+ Scenario: respect requires
102
+ Given a file named "features/support/env.rb"
103
+ And a file named "features/support/dont_require_me.rb"
104
+ And the following profile is defined:
105
+ """
106
+ no_bomb: features/missing_step_definitions.feature:3 --require features/support/env.rb --verbose
107
+ """
108
+ And a file named "Rakefile" with:
109
+ """
110
+ $LOAD_PATH.unshift(CUCUMBER_LIB)
111
+ require 'cucumber/rake/task'
112
+
113
+ Cucumber::Rake::Task.new do |t|
114
+ t.profile = "no_bomb"
115
+ t.cucumber_opts = %w{--quiet --no-color}
116
+ end
117
+ """
118
+
119
+ When I run rake cucumber
120
+ Then it should pass
121
+ And the output should not contain
122
+ """
123
+ * features/support/dont_require_me.rb
124
+ """
125
+
126
+ Scenario: feature files with spaces
127
+ Given a file named "features/spaces are nasty.feature" with:
128
+ """
129
+ Feature: The futures green
130
+
131
+ Scenario: Orange
132
+ Given this is missing
133
+ """
134
+ And a file named "Rakefile" with:
135
+ """
136
+ $LOAD_PATH.unshift(CUCUMBER_LIB)
137
+ require 'cucumber/rake/task'
138
+
139
+ Cucumber::Rake::Task.new do |t|
140
+ t.cucumber_opts = %w{--quiet --no-color}
141
+ end
142
+ """
143
+ When I run rake cucumber
144
+ Then it should pass
145
+ And the output should contain
146
+ """
147
+ Feature: The futures green
148
+
149
+ Scenario: Orange
150
+ Given this is missing
151
+
152
+ """
@@ -0,0 +1,34 @@
1
+ Feature: Cucumber command line
2
+ In order to find out what step definitions need to be implemented
3
+ Developers should always see what step definition is missing
4
+
5
+ Scenario: Get info at arbitrary levels of nesting
6
+ When I run cucumber features/call_undefined_step_from_step_def.feature
7
+ Then it should pass with
8
+ """
9
+ Feature: Calling undefined step
10
+
11
+ Scenario: Call directly # features/call_undefined_step_from_step_def.feature:3
12
+ Given a step definition that calls an undefined step # features/step_definitions/sample_steps.rb:19
13
+ Undefined step: "this does not exist" (Cucumber::Undefined)
14
+ ./features/step_definitions/sample_steps.rb:19:in `/^a step definition that calls an undefined step$/'
15
+ features/call_undefined_step_from_step_def.feature:4:in `Given a step definition that calls an undefined step'
16
+
17
+ Scenario: Call via another # features/call_undefined_step_from_step_def.feature:6
18
+ Given call step "a step definition that calls an undefined step" # features/step_definitions/sample_steps.rb:23
19
+ Undefined step: "this does not exist" (Cucumber::Undefined)
20
+ ./features/step_definitions/sample_steps.rb:19:in `/^a step definition that calls an undefined step$/'
21
+ features/call_undefined_step_from_step_def.feature:7:in `Given call step "a step definition that calls an undefined step"'
22
+
23
+ 2 scenarios (2 undefined)
24
+ 2 steps (2 undefined)
25
+
26
+ You can implement step definitions for undefined steps with these snippets:
27
+
28
+ Given /^this does not exist$/ do
29
+ pending # express the regexp above with the code you wish you had
30
+ end
31
+
32
+
33
+ """
34
+
@@ -0,0 +1,45 @@
1
+ Feature: Rerun Debugger
2
+ In order to save time
3
+ I want to run *only* failed, pending and missing features from previous runs
4
+ (with the help of a smart cucumber.yml)
5
+
6
+ Background:
7
+ Given a standard Cucumber project directory structure
8
+
9
+ Scenario: title
10
+ Given a file named "features/sample.feature" with:
11
+ """
12
+ Feature: Rerun
13
+
14
+ Scenario: Failing
15
+ Given failing
16
+
17
+ Scenario: Missing
18
+ Given missing
19
+
20
+ Scenario: Pending
21
+ Given pending
22
+
23
+ Scenario: Passing
24
+ Given passing
25
+ """
26
+ And a file named "features/step_definitions/steps.rb" with:
27
+ """
28
+ Given /failing/ do
29
+ raise 'FAIL'
30
+ end
31
+
32
+ Given /pending/ do
33
+ pending
34
+ end
35
+
36
+ Given /passing/ do
37
+ end
38
+ """
39
+
40
+ When I run cucumber -f rerun features/sample.feature
41
+ Then it should fail with
42
+ """
43
+ features/sample.feature:3:6:9
44
+
45
+ """
@@ -0,0 +1,11 @@
1
+ Feature: Sample
2
+
3
+ Background:
4
+ Given this step works
5
+
6
+ Scenario: Run a good step
7
+ Given this step works
8
+
9
+
10
+
11
+
@@ -0,0 +1,23 @@
1
+ Feature: Snippets
2
+ In order to help speed up writing step definitions
3
+ As a feature editor
4
+ I want snippet suggestions for undefined step definitions
5
+
6
+ Scenario: Snippet for undefined step with a pystring
7
+ When I run cucumber features/undefined_multiline_args.feature:3 -s
8
+ Then the output should contain
9
+ """
10
+ Given /^a pystring$/ do |string|
11
+ pending # express the regexp above with the code you wish you had
12
+ end
13
+ """
14
+
15
+ Scenario: Snippet for undefined step with a step table
16
+ When I run cucumber features/undefined_multiline_args.feature:9 -s
17
+ Then the output should contain
18
+ """
19
+ Given /^a table$/ do |table|
20
+ # table is a Cucumber::Ast::Table
21
+ pending # express the regexp above with the code you wish you had
22
+ end
23
+ """
@@ -0,0 +1,36 @@
1
+ Feature: Use * keywords and still get snippets
2
+ In order to make it possible to use * instead of
3
+ Given/When/Then, I should not get an exception
4
+ when I have undefined steps
5
+
6
+ Scenario: Use some *
7
+ Given a standard Cucumber project directory structure
8
+ And a file named "features/f.feature" with:
9
+ """
10
+ Feature: F
11
+ Scenario: S
12
+ * I have some cukes
13
+ """
14
+ When I run cucumber features/f.feature
15
+ Then STDERR should be empty
16
+ And it should pass with
17
+ """
18
+ Feature: F
19
+
20
+ Scenario: S # features/f.feature:2
21
+ * I have some cukes # features/f.feature:3
22
+
23
+ 1 scenario (1 undefined)
24
+ 1 step (1 undefined)
25
+
26
+ You can implement step definitions for undefined steps with these snippets:
27
+
28
+ Given /^I have some cukes$/ do
29
+ pending # express the regexp above with the code you wish you had
30
+ end
31
+
32
+ If you want snippets in a different programming language, just make sure a file
33
+ with the appropriate file extension exists where cucumber looks for step definitions.
34
+
35
+
36
+ """
@@ -1,14 +1,160 @@
1
- When /^I run cucumber "(.+)"$/ do |cmd|
2
- run_simple(unescape("cucumber #{cmd}"), false)
3
- end
1
+ # encoding: utf-8
2
+ require 'tempfile'
4
3
 
5
- Then /^it should (pass|fail) with JSON:$/ do |pass_fail, json|
6
- JSON.parse(all_stdout).should == JSON.parse(json)
7
- assert_success(pass_fail == 'pass')
4
+ Given /^I am in (.*)$/ do |example_dir_relative_path|
5
+ @current_dir = fixtures_dir(example_dir_relative_path)
8
6
  end
9
7
 
10
- Given /^a directory without standard Cucumber project directory structure$/ do
8
+ Given /^a standard Cucumber project directory structure$/ do
9
+ @current_dir = working_dir
11
10
  in_current_dir do
12
11
  FileUtils.rm_rf 'features' if File.directory?('features')
12
+ FileUtils.mkdir_p 'features/support'
13
+ FileUtils.mkdir 'features/step_definitions'
14
+ end
15
+ end
16
+
17
+ Given /^the (.*) directory is empty$/ do |directory|
18
+ in_current_dir do
19
+ FileUtils.remove_dir(directory) rescue nil
20
+ FileUtils.mkdir 'tmp'
21
+ end
22
+ end
23
+
24
+ Given /^a file named "([^"]*)"$/ do |file_name|
25
+ create_file(file_name, '')
26
+ end
27
+
28
+ Given /^a file named "([^"]*)" with:$/ do |file_name, file_content|
29
+ create_file(file_name, file_content)
30
+ end
31
+
32
+ Given /^the following profiles? (?:are|is) defined:$/ do |profiles|
33
+ create_file('cucumber.yml', profiles)
34
+ end
35
+
36
+ Given /^I am running spork in the background$/ do
37
+ run_spork_in_background
38
+ end
39
+
40
+ Given /^I am running spork in the background on port (\d+)$/ do |port|
41
+ run_spork_in_background(port.to_i)
42
+ end
43
+
44
+ Given /^I am not running (?:.*) in the background$/ do
45
+ # no-op
46
+ end
47
+
48
+ Given /^I have environment variable (\w+) set to "([^"]*)"$/ do |variable, value|
49
+ set_env_var(variable, value)
50
+ end
51
+
52
+ When /^I run cucumber (.*)$/ do |cucumber_opts|
53
+ run "#{Cucumber::RUBY_BINARY} -r rubygems #{Cucumber::BINARY} --no-color #{cucumber_opts} CUCUMBER_OUTPUT_ENCODING=UTF-8"
54
+ end
55
+
56
+ When /^I run rake (.*)$/ do |rake_opts|
57
+ run "rake #{rake_opts} --trace"
58
+ end
59
+
60
+ Then /^it should (fail|pass)$/ do |success|
61
+ if success == 'fail'
62
+ last_exit_status.should_not == 0
63
+ else
64
+ if last_exit_status != 0
65
+ raise "Failed with exit status #{last_exit_status}\nSTDOUT:\n#{last_stdout}\nSTDERR:\n#{last_stderr}"
66
+ end
13
67
  end
14
68
  end
69
+
70
+ Then /^it should (fail|pass) with$/ do |success, output|
71
+ combined_output.should =~ Regexp.compile(Regexp.escape(output))
72
+ Then("it should #{success}")
73
+ end
74
+
75
+ Then /^the output should contain$/ do |text|
76
+ last_stdout.should include(text)
77
+ end
78
+
79
+ Then /^the output should not contain$/ do |text|
80
+ last_stdout.should_not include(text)
81
+ end
82
+
83
+ Then /^the output should be$/ do |text|
84
+ last_stdout.should == text
85
+ end
86
+
87
+ Then /^it should (fail|pass) with JSON$/ do |success, text|
88
+ JSON.parse(last_stdout).should == JSON.parse(text)
89
+ Then("it should #{success}")
90
+ end
91
+
92
+ Then /^"([^"]*)" should contain$/ do |file, text|
93
+ strip_duration(IO.read(file)).should == text
94
+ end
95
+
96
+ Then /^"([^"]*)" with junit duration "([^"]*)" should contain$/ do |actual_file, duration_replacement, text|
97
+ actual = IO.read(actual_file)
98
+ actual = replace_junit_duration(actual, duration_replacement)
99
+ actual = strip_ruby186_extra_trace(actual)
100
+ actual.should == text
101
+ end
102
+
103
+ Then /^"([^"]*)" should match "(.+?)"$/ do |file, text|
104
+ File.open(file, Cucumber.file_mode('r')).read.should =~ Regexp.new(text)
105
+ end
106
+
107
+ Then /^"([^"]*)" should have the same contents as "([^"]*)"$/ do |actual_file, expected_file|
108
+ actual = IO.read(actual_file)
109
+ actual = replace_duration(actual, '0m30.005s')
110
+ # Comment out to replace expected file. Use with care!
111
+ # File.open(expected_file, "w") {|io| io.write(actual)}
112
+ actual.should == IO.read(expected_file)
113
+ end
114
+
115
+ Then /^STDERR should match$/ do |text|
116
+ last_stderr.should =~ /#{text}/
117
+ end
118
+
119
+ Then /^STDERR should not match$/ do |text|
120
+ last_stderr.should_not =~ /#{text}/
121
+ end
122
+
123
+ Then /^STDERR should be$/ do |text|
124
+ last_stderr.should == text
125
+ end
126
+
127
+ Then /^STDERR should be empty$/ do
128
+ last_stderr.should == ""
129
+ end
130
+
131
+ Then /^"([^"]*)" should exist$/ do |file|
132
+ File.exists?(file).should be_true
133
+ FileUtils.rm(file)
134
+ end
135
+
136
+ Then /^"([^"]*)" should not be required$/ do |file_name|
137
+ last_stdout.should_not include("* #{file_name}")
138
+ end
139
+
140
+ Then /^"([^"]*)" should be required$/ do |file_name|
141
+ last_stdout.should include("* #{file_name}")
142
+ end
143
+
144
+ Then /^exactly these files should be loaded:\s*(.*)$/ do |files|
145
+ last_stdout.scan(/^ \* (.*\.rb)$/).flatten.should == files.split(/,\s+/)
146
+ end
147
+
148
+ Then /^exactly these features should be ran:\s*(.*)$/ do |files|
149
+ last_stdout.scan(/^ \* (.*\.feature)$/).flatten.should == files.split(/,\s+/)
150
+ end
151
+
152
+ Then /^the (.*) profile should be used$/ do |profile|
153
+ last_stdout.should =~ /Using the #{profile} profile/
154
+ end
155
+
156
+ Then /^print output$/ do
157
+ puts last_stdout
158
+ end
159
+
160
+