cucumber 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +10 -0
  3. data/Gemfile +3 -1
  4. data/History.md +18 -2
  5. data/README.md +5 -1
  6. data/cucumber.gemspec +3 -4
  7. data/cucumber.yml +2 -2
  8. data/features/docs/api/run_cli_main_with_existing_runtime.feature +4 -7
  9. data/features/docs/defining_steps/skip_scenario.feature +6 -2
  10. data/features/docs/formatters/api_methods.feature +36 -0
  11. data/features/docs/profiles.feature +2 -2
  12. data/features/lib/step_definitions/profile_steps.rb +1 -1
  13. data/lib/cucumber.rb +11 -4
  14. data/lib/cucumber/cli/configuration.rb +2 -2
  15. data/lib/cucumber/cli/options.rb +2 -2
  16. data/lib/cucumber/configuration.rb +25 -3
  17. data/lib/cucumber/deprecate.rb +29 -0
  18. data/lib/cucumber/filters/activate_steps.rb +39 -5
  19. data/lib/cucumber/formatter/console.rb +4 -4
  20. data/lib/cucumber/formatter/io.rb +1 -1
  21. data/lib/cucumber/formatter/legacy_api/adapter.rb +30 -30
  22. data/lib/cucumber/formatter/legacy_api/runtime_facade.rb +4 -9
  23. data/lib/cucumber/platform.rb +2 -7
  24. data/lib/cucumber/rb_support/rb_language.rb +72 -26
  25. data/lib/cucumber/rb_support/rb_step_definition.rb +2 -2
  26. data/lib/cucumber/rb_support/rb_world.rb +6 -1
  27. data/lib/cucumber/rb_support/snippet.rb +21 -0
  28. data/lib/cucumber/running_test_case.rb +5 -1
  29. data/lib/cucumber/runtime.rb +11 -15
  30. data/lib/cucumber/runtime/support_code.rb +20 -128
  31. data/lib/cucumber/step_argument.rb +25 -0
  32. data/lib/cucumber/step_match.rb +6 -12
  33. data/lib/cucumber/step_match_search.rb +67 -0
  34. data/lib/cucumber/version +1 -0
  35. data/spec/cucumber/configuration_spec.rb +3 -2
  36. data/spec/cucumber/filters/activate_steps_spec.rb +95 -3
  37. data/spec/cucumber/formatter/html_spec.rb +1 -1
  38. data/spec/cucumber/formatter/legacy_api/adapter_spec.rb +55 -28
  39. data/spec/cucumber/formatter/pretty_spec.rb +2 -2
  40. data/spec/cucumber/formatter/spec_helper.rb +22 -12
  41. data/spec/cucumber/rb_support/rb_language_spec.rb +9 -45
  42. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +2 -2
  43. data/spec/cucumber/rb_support/rb_world_spec.rb +47 -0
  44. data/spec/cucumber/runtime/for_programming_languages_spec.rb +1 -1
  45. data/spec/cucumber/runtime/support_code_spec.rb +4 -111
  46. data/spec/cucumber/step_argument_spec.rb +18 -0
  47. data/spec/cucumber/step_match_search_spec.rb +122 -0
  48. data/spec/cucumber/step_match_spec.rb +8 -2
  49. data/spec/cucumber/world/pending_spec.rb +2 -1
  50. data/spec/cucumber_spec.rb +39 -0
  51. metadata +45 -50
  52. data/features/docs/wire_protocol/erb_configuration.feature +0 -56
  53. data/features/docs/wire_protocol/handle_unexpected_response.feature +0 -30
  54. data/features/docs/wire_protocol/invoke_message.feature +0 -216
  55. data/features/docs/wire_protocol/readme.md +0 -26
  56. data/features/docs/wire_protocol/snippets_message.feature +0 -51
  57. data/features/docs/wire_protocol/step_matches_message.feature +0 -81
  58. data/features/docs/wire_protocol/table_diffing.feature +0 -126
  59. data/features/docs/wire_protocol/tags.feature +0 -87
  60. data/features/docs/wire_protocol/timeouts.feature +0 -64
  61. data/lib/cucumber/events/bus.rb +0 -86
  62. data/lib/cucumber/gherkin/formatter/argument.rb +0 -17
  63. data/lib/cucumber/gherkin/formatter/hashable.rb +0 -27
  64. data/lib/cucumber/language_support.rb +0 -30
  65. data/lib/cucumber/language_support/language_methods.rb +0 -72
  66. data/lib/cucumber/rb_support/regexp_argument_matcher.rb +0 -21
  67. data/lib/cucumber/wire_support/configuration.rb +0 -38
  68. data/lib/cucumber/wire_support/connection.rb +0 -61
  69. data/lib/cucumber/wire_support/request_handler.rb +0 -32
  70. data/lib/cucumber/wire_support/wire_exception.rb +0 -32
  71. data/lib/cucumber/wire_support/wire_language.rb +0 -68
  72. data/lib/cucumber/wire_support/wire_packet.rb +0 -34
  73. data/lib/cucumber/wire_support/wire_protocol.rb +0 -43
  74. data/lib/cucumber/wire_support/wire_protocol/requests.rb +0 -133
  75. data/lib/cucumber/wire_support/wire_step_definition.rb +0 -21
  76. data/spec/cucumber/events/bus_spec.rb +0 -94
  77. data/spec/cucumber/rb_support/regexp_argument_matcher_spec.rb +0 -22
  78. data/spec/cucumber/wire_support/configuration_spec.rb +0 -64
  79. data/spec/cucumber/wire_support/connection_spec.rb +0 -64
  80. data/spec/cucumber/wire_support/wire_exception_spec.rb +0 -50
  81. data/spec/cucumber/wire_support/wire_language_spec.rb +0 -46
  82. data/spec/cucumber/wire_support/wire_packet_spec.rb +0 -44
@@ -1,21 +0,0 @@
1
- require 'cucumber/core/ast/location'
2
-
3
- module Cucumber
4
- module WireSupport
5
- class WireStepDefinition
6
- attr_reader :regexp_source, :location
7
-
8
- def initialize(connection, data)
9
- @connection = connection
10
- @id = data['id']
11
- @regexp_source = data['regexp'] || "Unknown"
12
- @location = data['source'] ? Cucumber::Core::Ast::Location.from_file_colon_line(data['source']) : Cucumber::Core::Ast::Location.new("Unknown")
13
- end
14
-
15
- def invoke(args)
16
- @connection.invoke(@id, args)
17
- end
18
-
19
- end
20
- end
21
- end
@@ -1,94 +0,0 @@
1
- require "cucumber/events/bus"
2
-
3
- module Cucumber
4
- module Events
5
- class TestEvent
6
- end
7
-
8
- class AnotherTestEvent
9
- end
10
-
11
- describe Bus do
12
- let(:bus) { Bus.new(Cucumber::Events) }
13
- let(:test_event) { TestEvent.new }
14
- let(:another_test_event) { AnotherTestEvent.new }
15
-
16
- it "calls subscriber with event payload" do
17
- received_payload = nil
18
- bus.register(TestEvent) do |event|
19
- received_payload = event
20
- end
21
-
22
- bus.notify test_event
23
-
24
- expect(received_payload).to eq(test_event)
25
- end
26
-
27
- it "does not call subscribers for other events" do
28
- handler_called = false
29
- bus.register(TestEvent) do |event|
30
- handler_called = true
31
- end
32
-
33
- bus.notify another_test_event
34
-
35
- expect(handler_called).to eq(false)
36
- end
37
-
38
- it "broadcasts to multiple subscribers" do
39
- received_events = []
40
- bus.register(TestEvent) do |event|
41
- received_events << event
42
- end
43
- bus.register(TestEvent) do |event|
44
- received_events << event
45
- end
46
-
47
- bus.notify test_event
48
-
49
- expect(received_events.length).to eq 2
50
- expect(received_events).to all eq test_event
51
- end
52
-
53
- it "allows subscription by string" do
54
- received_payload = nil
55
- bus.register('Cucumber::Events::TestEvent') do |event|
56
- received_payload = event
57
- end
58
-
59
- bus.notify test_event
60
-
61
- expect(received_payload).to eq(test_event)
62
- end
63
-
64
- it "allows subscription by symbol (for events in the Cucumber::Events namespace)" do
65
- received_payload = nil
66
- bus.register(:test_event) do |event|
67
- received_payload = event
68
- end
69
-
70
- bus.notify test_event
71
-
72
- expect(received_payload).to eq(test_event)
73
- end
74
-
75
- it "allows handlers that are objects with a `call` method" do
76
- class MyHandler
77
- attr_reader :received_payload
78
-
79
- def call(event)
80
- @received_payload = event
81
- end
82
- end
83
-
84
- handler = MyHandler.new
85
- bus.register(TestEvent, handler)
86
-
87
- bus.notify test_event
88
-
89
- expect(handler.received_payload).to eq test_event
90
- end
91
-
92
- end
93
- end
94
- end
@@ -1,22 +0,0 @@
1
- require 'spec_helper'
2
- require 'cucumber/rb_support/regexp_argument_matcher'
3
-
4
- module Cucumber
5
- module RbSupport
6
- describe RegexpArgumentMatcher do
7
- include RSpec::WorkInProgress
8
-
9
- it "creates 2 arguments" do
10
- arguments = RegexpArgumentMatcher.arguments_from(/I (\w+) (\w+)/, "I like fish")
11
-
12
- expect(arguments.map{|argument| [argument.val, argument.offset]}).to eq [["like", 2], ["fish", 7]]
13
- end
14
-
15
- it "creates 2 arguments when first group is optional" do
16
- arguments = RegexpArgumentMatcher.arguments_from(/should( not)? be flashed '([^']*?)'$/, "I should be flashed 'Login failed.'")
17
-
18
- expect(arguments.map{|argument| [argument.val, argument.offset]}).to eq [[nil, nil], ["Login failed.", 21]]
19
- end
20
- end
21
- end
22
- end
@@ -1,64 +0,0 @@
1
- require 'spec_helper'
2
- require 'cucumber/wire_support/wire_language'
3
- require 'tempfile'
4
-
5
- module Cucumber
6
- module WireSupport
7
- describe Configuration do
8
- let(:wire_file) { Tempfile.new('wire') }
9
- let(:config) { Configuration.from_file(wire_file.path) }
10
-
11
- def write_wire_file(contents)
12
- wire_file << contents
13
- wire_file.close
14
- end
15
-
16
- it "reads the hostname / port from the file" do
17
- write_wire_file %q{
18
- host: localhost
19
- port: 54321
20
- }
21
-
22
- expect(config.host).to eq 'localhost'
23
- expect(config.port).to eq 54321
24
- end
25
-
26
- it "reads the timeout for a specific message" do
27
- write_wire_file %q{
28
- host: localhost
29
- port: 54321
30
- timeout:
31
- invoke: 99
32
- }
33
-
34
- expect(config.timeout('invoke')).to eq 99
35
- end
36
-
37
- it "reads the timeout for a connect message" do
38
- write_wire_file %q{
39
- host: localhost
40
- port: 54321
41
- timeout:
42
- connect: 99
43
- }
44
-
45
- expect(config.timeout('connect')).to eq 99
46
- end
47
-
48
- describe "a wire file with no timeouts specified" do
49
- before(:each) do
50
- write_wire_file %q{
51
- host: localhost
52
- port: 54321
53
- }
54
- end
55
-
56
- %w(invoke begin_scenario end_scenario).each do |message|
57
- it "sets the default timeout for '#{message}' to 120 seconds" do
58
- expect(config.timeout(message)).to eq 120
59
- end
60
- end
61
- end
62
- end
63
- end
64
- end
@@ -1,64 +0,0 @@
1
- require 'spec_helper'
2
- require 'cucumber/wire_support/wire_language'
3
-
4
- module Cucumber
5
- module WireSupport
6
- describe Connection do
7
- class TestConnection < Connection
8
- attr_accessor :socket
9
- end
10
-
11
- class TestConfiguration
12
- attr_reader :custom_timeout
13
-
14
- def initialize
15
- @custom_timeout = {}
16
- end
17
-
18
- def timeout(message = nil)
19
- return :default_timeout if message.nil?
20
- @custom_timeout[message] || Configuration::DEFAULT_TIMEOUTS.fetch(message)
21
- end
22
-
23
- def host
24
- 'localhost'
25
- end
26
-
27
- def port
28
- '3902'
29
- end
30
- end
31
-
32
- before(:each) do
33
- @config = TestConfiguration.new
34
- @connection = TestConnection.new(@config)
35
- @connection.socket = @socket = double('socket').as_null_object
36
- @response = %q{["response"]}
37
- end
38
-
39
- it "re-raises a timeout error" do
40
- allow(Timeout).to receive(:timeout).and_raise(Timeout::Error.new(''))
41
- expect(-> { @connection.call_remote(nil, :foo, []) }).to raise_error(Timeout::Error)
42
- end
43
-
44
- it "ignores timeout errors when configured to do so" do
45
- @config.custom_timeout[:foo] = :never
46
-
47
- allow(@socket).to receive(:gets) { @response }
48
-
49
- handler = double(:handle_response => :response)
50
-
51
- expect(@connection.call_remote(handler, :foo, [])).to eq :response
52
- end
53
-
54
- it "raises an exception on remote connection closed" do
55
- @config.custom_timeout[:foo] = :never
56
-
57
- allow(@socket).to receive(:gets)
58
- expect(-> {
59
- @connection.call_remote(nil, :foo, [])
60
- }).to raise_error(WireException, 'Remote Socket with localhost:3902 closed.')
61
- end
62
- end
63
- end
64
- end
@@ -1,50 +0,0 @@
1
- require 'spec_helper'
2
- require 'cucumber/wire_support/wire_language'
3
-
4
- module Cucumber
5
- module WireSupport
6
- describe WireException do
7
- before(:each) do
8
- @config = Configuration.new('host' => 'localhost', 'port' => 54321)
9
- end
10
-
11
- def exception
12
- WireException.new(@data, @config)
13
- end
14
-
15
- describe "with just a message" do
16
- before(:each) do
17
- @data = {'message' => 'foo'}
18
- end
19
-
20
- it "#to_s as expecteds" do
21
- expect(exception.to_s).to eq "foo"
22
- end
23
- end
24
-
25
- describe "with a message and an exception" do
26
- before(:each) do
27
- @data = {'message' => 'foo', 'exception' => 'Bar'}
28
- end
29
-
30
- it "#to_s as expecteds" do
31
- expect(exception.to_s).to eq "foo"
32
- end
33
-
34
- it "#class.to_s returns the name of the exception" do
35
- expect(exception.class.to_s).to eq 'Bar from localhost:54321'
36
- end
37
- end
38
-
39
- describe "with a custom backtrace" do
40
- before(:each) do
41
- @data = {'message' => 'foo', 'backtrace' => ['foo', 'bar', 'baz']}
42
- end
43
-
44
- it "#backrace returns the custom backtrace" do
45
- expect(exception.backtrace).to eq ['foo', 'bar', 'baz']
46
- end
47
- end
48
- end
49
- end
50
- end
@@ -1,46 +0,0 @@
1
- require 'spec_helper'
2
- require 'cucumber/wire_support/wire_language'
3
-
4
- module Cucumber
5
- module WireSupport
6
- describe WireLanguage do
7
- def stub_wire_file!(filename, config)
8
- allow(Configuration).to receive(:from_file).with(filename) { config }
9
- end
10
-
11
- describe "#load_code_file" do
12
- before(:each) do
13
- stub_wire_file! 'foo.wire', :config
14
- end
15
-
16
- it "creates a RemoteSteps object" do
17
- expect(Connection).to receive(:new).with(:config)
18
-
19
- WireLanguage.new.load_code_file('foo.wire')
20
- end
21
- end
22
-
23
- describe "#step_matches" do
24
- def stub_remote_steps!(config, attributes)
25
- expect(Connection).to receive(:new).with(config) { double('remote_steps', attributes) }
26
- end
27
-
28
- before(:each) do
29
- stub_wire_file! 'one.wire', :config_one
30
- stub_wire_file! 'two.wire', :config_two
31
- end
32
-
33
- it "returns the matches from each of the RemoteSteps" do
34
- stub_remote_steps! :config_one, :step_matches => [:a, :b]
35
- stub_remote_steps! :config_two, :step_matches => [:c]
36
-
37
- wire_language = WireLanguage.new
38
- wire_language.load_code_file('one.wire')
39
- wire_language.load_code_file('two.wire')
40
-
41
- expect(wire_language.step_matches('','')).to eq [:a, :b, :c]
42
- end
43
- end
44
- end
45
- end
46
- end
@@ -1,44 +0,0 @@
1
- require 'spec_helper'
2
- require 'cucumber/wire_support/wire_language'
3
-
4
- module Cucumber
5
- module WireSupport
6
- describe WirePacket do
7
- describe "#to_json" do
8
- it "converts params to a JSON hash" do
9
- packet = WirePacket.new('test_message', :foo => :bar)
10
-
11
- expect(packet.to_json).to eq "[\"test_message\",{\"foo\":\"bar\"}]"
12
- end
13
-
14
- it "does not pass blank params" do
15
- packet = WirePacket.new('test_message')
16
-
17
- expect(packet.to_json).to eq "[\"test_message\"]"
18
- end
19
- end
20
-
21
- describe ".parse" do
22
- it "understands a raw packet containing null parameters" do
23
- packet = WirePacket.parse("[\"test_message\",null]")
24
-
25
- expect(packet.message).to eq 'test_message'
26
- expect(packet.params).to be_nil
27
- end
28
-
29
- it "understands a raw packet containing no parameters" do
30
- packet = WirePacket.parse("[\"test_message\"]")
31
-
32
- expect(packet.message).to eq 'test_message'
33
- expect(packet.params).to be_nil
34
- end
35
-
36
- it "understands a raw packet containging parameters data" do
37
- packet = WirePacket.parse("[\"test_message\",{\"foo\":\"bar\"}]")
38
-
39
- expect(packet.params['foo']).to eq 'bar'
40
- end
41
- end
42
- end
43
- end
44
- end