cucumber 0.8.5 → 0.8.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -1
- data/LICENSE +1 -1
- data/Rakefile +5 -51
- data/bin/cucumber +7 -1
- data/cucumber.gemspec +463 -679
- data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/he/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +4 -7
- data/examples/i18n/ru/features/division.feature +2 -2
- data/examples/i18n/tr/features/step_definitons/hesap_makinesi_adimlari.rb +3 -3
- data/examples/sinatra/features/support/env.rb +2 -5
- data/examples/v8/features/fibonacci.feature +1 -1
- data/examples/watir/features/step_definitions/search_steps.rb +1 -1
- data/features/background.feature +284 -95
- data/features/custom_formatter.feature +3 -73
- data/features/json_formatter.feature +160 -245
- data/features/step_definitions/cucumber_steps.rb +7 -153
- data/features/support/env.rb +18 -140
- data/fixtures/junit/features/pending.feature +3 -1
- data/fixtures/self_test/features/support/env.rb +8 -0
- data/fixtures/tickets/features.html +1 -1
- data/gem_tasks/examples.rake +1 -1
- data/lib/cucumber.rb +12 -0
- data/lib/cucumber/ast.rb +1 -1
- data/lib/cucumber/ast/background.rb +21 -5
- data/lib/cucumber/ast/examples.rb +12 -4
- data/lib/cucumber/ast/feature.rb +13 -5
- data/lib/cucumber/ast/feature_element.rb +9 -4
- data/lib/cucumber/ast/outline_table.rb +4 -4
- data/lib/cucumber/ast/scenario.rb +7 -5
- data/lib/cucumber/ast/scenario_outline.rb +23 -15
- data/lib/cucumber/ast/step.rb +5 -0
- data/lib/cucumber/ast/step_invocation.rb +21 -15
- data/lib/cucumber/ast/table.rb +14 -8
- data/lib/cucumber/ast/tree_walker.rb +10 -48
- data/lib/cucumber/cli/configuration.rb +33 -8
- data/lib/cucumber/cli/main.rb +20 -35
- data/lib/cucumber/cli/options.rb +8 -7
- data/lib/cucumber/cli/profile_loader.rb +2 -0
- data/lib/cucumber/core_ext/proc.rb +2 -1
- data/lib/cucumber/feature_file.rb +47 -15
- data/lib/cucumber/formatter/ansicolor.rb +3 -5
- data/lib/cucumber/formatter/console.rb +27 -23
- data/lib/cucumber/formatter/cucumber.css +34 -17
- data/lib/cucumber/formatter/cucumber.sass +173 -182
- data/lib/cucumber/formatter/html.rb +46 -11
- data/lib/cucumber/formatter/io.rb +2 -4
- data/lib/cucumber/formatter/json.rb +15 -152
- data/lib/cucumber/formatter/json_pretty.rb +5 -6
- data/lib/cucumber/formatter/junit.rb +28 -22
- data/lib/cucumber/formatter/pdf.rb +6 -6
- data/lib/cucumber/formatter/pretty.rb +5 -5
- data/lib/cucumber/formatter/rerun.rb +22 -11
- data/lib/cucumber/formatter/unicode.rb +41 -20
- data/lib/cucumber/js_support/js_dsl.js +4 -4
- data/lib/cucumber/js_support/js_language.rb +9 -5
- data/lib/cucumber/js_support/js_snippets.rb +2 -2
- data/lib/cucumber/language_support.rb +2 -2
- data/lib/cucumber/parser/gherkin_builder.rb +35 -30
- data/lib/cucumber/platform.rb +8 -8
- data/lib/cucumber/py_support/py_language.rb +2 -2
- data/lib/cucumber/rake/task.rb +80 -31
- data/lib/cucumber/rb_support/rb_dsl.rb +1 -0
- data/lib/cucumber/rb_support/rb_language.rb +10 -8
- data/lib/cucumber/rb_support/rb_step_definition.rb +8 -0
- data/lib/cucumber/rb_support/rb_transform.rb +17 -0
- data/lib/cucumber/rb_support/rb_world.rb +26 -18
- data/lib/cucumber/rspec/doubles.rb +3 -3
- data/lib/cucumber/step_match.rb +6 -2
- data/lib/cucumber/step_mother.rb +6 -427
- data/lib/cucumber/wire_support/configuration.rb +4 -1
- data/lib/cucumber/wire_support/wire_language.rb +3 -10
- data/spec/cucumber/ast/background_spec.rb +68 -6
- data/spec/cucumber/ast/feature_factory.rb +5 -4
- data/spec/cucumber/ast/feature_spec.rb +4 -4
- data/spec/cucumber/ast/outline_table_spec.rb +1 -1
- data/spec/cucumber/ast/scenario_outline_spec.rb +15 -11
- data/spec/cucumber/ast/scenario_spec.rb +4 -4
- data/spec/cucumber/ast/step_spec.rb +3 -3
- data/spec/cucumber/ast/table_spec.rb +38 -2
- data/spec/cucumber/ast/tree_walker_spec.rb +2 -2
- data/spec/cucumber/broadcaster_spec.rb +1 -1
- data/spec/cucumber/cli/configuration_spec.rb +32 -6
- data/spec/cucumber/cli/drb_client_spec.rb +2 -3
- data/spec/cucumber/cli/main_spec.rb +43 -43
- data/spec/cucumber/cli/options_spec.rb +28 -1
- data/spec/cucumber/cli/profile_loader_spec.rb +1 -1
- data/spec/cucumber/core_ext/proc_spec.rb +1 -1
- data/spec/cucumber/formatter/ansicolor_spec.rb +1 -1
- data/spec/cucumber/formatter/duration_spec.rb +1 -1
- data/spec/cucumber/formatter/html_spec.rb +3 -5
- data/spec/cucumber/formatter/junit_spec.rb +16 -2
- data/spec/cucumber/formatter/progress_spec.rb +1 -1
- data/spec/cucumber/formatter/spec_helper.rb +11 -12
- data/spec/cucumber/rb_support/rb_language_spec.rb +241 -28
- data/spec/cucumber/rb_support/rb_step_definition_spec.rb +33 -28
- data/spec/cucumber/rb_support/regexp_argument_matcher_spec.rb +1 -1
- data/spec/cucumber/step_match_spec.rb +11 -9
- data/spec/cucumber/wire_support/configuration_spec.rb +1 -1
- data/spec/cucumber/wire_support/connection_spec.rb +1 -1
- data/spec/cucumber/wire_support/wire_exception_spec.rb +1 -1
- data/spec/cucumber/wire_support/wire_language_spec.rb +1 -1
- data/spec/cucumber/wire_support/wire_packet_spec.rb +1 -1
- data/spec/cucumber/wire_support/wire_step_definition_spec.rb +1 -1
- data/spec/cucumber/world/pending_spec.rb +2 -2
- data/spec/spec_helper.rb +13 -20
- metadata +11 -222
- data/.gitignore +0 -20
- data/Caliper.yml +0 -4
- data/History.txt +0 -1552
- data/README.rdoc +0 -26
- data/VERSION.yml +0 -5
- data/examples/i18n/ro/features/suma.feature +0 -11
- data/features/announce.feature +0 -164
- data/features/around_hooks.feature +0 -232
- data/features/bug_371.feature +0 -32
- data/features/bug_464.feature +0 -16
- data/features/bug_475.feature +0 -42
- data/features/bug_585_tab_indentation.feature +0 -22
- data/features/bug_600.feature +0 -67
- data/features/call_steps_from_stepdefs.feature +0 -154
- data/features/cucumber_cli.feature +0 -591
- data/features/cucumber_cli_outlines.feature +0 -117
- data/features/default_snippets.feature +0 -42
- data/features/diffing.feature +0 -25
- data/features/drb_server_integration.feature +0 -174
- data/features/exception_in_after_block.feature +0 -127
- data/features/exception_in_after_step_block.feature +0 -104
- data/features/exception_in_before_block.feature +0 -98
- data/features/exclude_files.feature +0 -20
- data/features/expand.feature +0 -60
- data/features/html_formatter.feature +0 -8
- data/features/html_formatter/a.html +0 -582
- data/features/junit_formatter.feature +0 -88
- data/features/language_from_header.feature +0 -30
- data/features/language_help.feature +0 -78
- data/features/listener_debugger_formatter.feature +0 -42
- data/features/multiline_names.feature +0 -44
- data/features/negative_tagged_hooks.feature +0 -60
- data/features/post_configuration_hook.feature +0 -37
- data/features/profiles.feature +0 -126
- data/features/rake_task.feature +0 -152
- data/features/report_called_undefined_steps.feature +0 -34
- data/features/rerun_formatter.feature +0 -45
- data/features/simplest.feature +0 -11
- data/features/snippet.feature +0 -23
- data/features/snippets_when_using_star_keyword.feature +0 -36
- data/features/step_definitions/extra_steps.rb +0 -2
- data/features/step_definitions/simplest_steps.rb +0 -3
- data/features/step_definitions/wire_steps.rb +0 -32
- data/features/support/env.rb.simplest +0 -7
- data/features/support/fake_wire_server.rb +0 -77
- data/features/table_diffing.feature +0 -45
- data/features/table_mapping.feature +0 -34
- data/features/tag_logic.feature +0 -258
- data/features/transform.feature +0 -245
- data/features/unicode_table.feature +0 -35
- data/features/usage_and_stepdefs_formatter.feature +0 -169
- data/features/wire_protocol.feature +0 -332
- data/features/wire_protocol_table_diffing.feature +0 -119
- data/features/wire_protocol_tags.feature +0 -87
- data/features/wire_protocol_timeouts.feature +0 -63
- data/features/work_in_progress.feature +0 -156
- data/fixtures/json/features/pystring.feature +0 -8
- data/fixtures/self_test/features/background/background_tagged_before_on_outline.feature +0 -12
- data/fixtures/self_test/features/background/background_with_name.feature +0 -7
- data/fixtures/self_test/features/background/failing_background.feature +0 -12
- data/fixtures/self_test/features/background/failing_background_after_success.feature +0 -11
- data/fixtures/self_test/features/background/multiline_args_background.feature +0 -32
- data/fixtures/self_test/features/background/passing_background.feature +0 -10
- data/fixtures/self_test/features/background/pending_background.feature +0 -10
- data/fixtures/self_test/features/background/scenario_outline_failing_background.feature +0 -16
- data/fixtures/self_test/features/background/scenario_outline_passing_background.feature +0 -16
- data/gem_tasks/features.rake +0 -14
- data/gem_tasks/sdoc.rake +0 -12
- data/lib/cucumber/ast/py_string.rb +0 -80
- data/lib/cucumber/formatter/color_io.rb +0 -23
- data/lib/cucumber/formatter/tag_cloud.rb +0 -35
- data/spec/cucumber/ast/py_string_spec.rb +0 -40
- data/spec/cucumber/formatter/color_io_spec.rb +0 -29
- data/spec/cucumber/step_mother_spec.rb +0 -302
data/features/rake_task.feature
DELETED
@@ -1,152 +0,0 @@
|
|
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
|
-
"""
|
@@ -1,34 +0,0 @@
|
|
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
|
-
|
@@ -1,45 +0,0 @@
|
|
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
|
-
"""
|
data/features/simplest.feature
DELETED
data/features/snippet.feature
DELETED
@@ -1,23 +0,0 @@
|
|
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
|
-
"""
|
@@ -1,36 +0,0 @@
|
|
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,32 +0,0 @@
|
|
1
|
-
Given /^there is a wire server (running |)on port (\d+) which understands the following protocol:$/ do |running, port, table|
|
2
|
-
protocol = table.hashes
|
3
|
-
@server = FakeWireServer.new(port.to_i, protocol)
|
4
|
-
start_wire_server if running.strip == "running"
|
5
|
-
end
|
6
|
-
|
7
|
-
Given /^the wire server takes (.*) seconds to respond to the invoke message$/ do |timeout|
|
8
|
-
@server.delay_response(:invoke, timeout.to_f)
|
9
|
-
start_wire_server
|
10
|
-
end
|
11
|
-
|
12
|
-
module WireHelper
|
13
|
-
def start_wire_server
|
14
|
-
@wire_pid = fork do
|
15
|
-
@server.run
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def stop_wire_server
|
20
|
-
return unless @wire_pid
|
21
|
-
Process.kill('KILL', @wire_pid)
|
22
|
-
Process.wait
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
Before('@wire') do
|
27
|
-
extend(WireHelper)
|
28
|
-
end
|
29
|
-
|
30
|
-
After('@wire') do
|
31
|
-
stop_wire_server
|
32
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'socket'
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
class FakeWireServer
|
5
|
-
def initialize(port, protocol_table)
|
6
|
-
@port, @protocol_table = port, protocol_table
|
7
|
-
@delays = {}
|
8
|
-
end
|
9
|
-
|
10
|
-
def run
|
11
|
-
@server = TCPServer.open(@port)
|
12
|
-
loop { handle_connections }
|
13
|
-
end
|
14
|
-
|
15
|
-
def delay_response(message, delay)
|
16
|
-
@delays[message] = delay
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def handle_connections
|
22
|
-
Thread.start(@server.accept) { |socket| open_session_on socket }
|
23
|
-
end
|
24
|
-
|
25
|
-
def open_session_on(socket)
|
26
|
-
begin
|
27
|
-
SocketSession.new(socket, @protocol_table, @delays).start
|
28
|
-
rescue Exception => e
|
29
|
-
raise e
|
30
|
-
ensure
|
31
|
-
socket.close
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class SocketSession
|
36
|
-
def initialize(socket, protocol, delays)
|
37
|
-
@socket = socket
|
38
|
-
@protocol = protocol
|
39
|
-
@delays = delays
|
40
|
-
end
|
41
|
-
|
42
|
-
def start
|
43
|
-
while message = @socket.gets
|
44
|
-
handle(message)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
def handle(data)
|
51
|
-
if protocol_entry = response_to(data.strip)
|
52
|
-
sleep delay(data)
|
53
|
-
send_response(protocol_entry['response'])
|
54
|
-
else
|
55
|
-
serialized_exception = { :message => "Not understood: #{data}", :backtrace => [] }
|
56
|
-
send_response(['fail', serialized_exception ].to_json)
|
57
|
-
end
|
58
|
-
rescue => e
|
59
|
-
send_response(['fail', { :message => e.message, :backtrace => e.backtrace, :exception => e.class } ].to_json)
|
60
|
-
end
|
61
|
-
|
62
|
-
def response_to(data)
|
63
|
-
@protocol.detect do |entry|
|
64
|
-
JSON.parse(entry['request']) == JSON.parse(data)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def send_response(response)
|
69
|
-
@socket.puts response + "\n"
|
70
|
-
end
|
71
|
-
|
72
|
-
def delay(data)
|
73
|
-
message = JSON.parse(data.strip)[0]
|
74
|
-
@delays[message.to_sym] || 0
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,45 +0,0 @@
|
|
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| x=1
|
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 (Cucumber::Ast::Table::Different)
|
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
|
-
"""
|