cucumber 2.3.1 → 2.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +4 -4
- data/cucumber.gemspec +0 -1
- data/features/docs/defining_steps/skip_scenario.feature +1 -1
- data/lib/cucumber/configuration.rb +1 -4
- data/lib/cucumber/events/bus.rb +86 -0
- data/lib/cucumber/version +1 -1
- data/spec/cucumber/events/bus_spec.rb +94 -0
- metadata +6 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ea4c325d27aa0512732b572a494fccee6e4dff0
|
4
|
+
data.tar.gz: 1defb0bb6842a9995ec302dcc7b2864d9a0e4498
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bc0298eda9a2055a26b030a32149a16ecf96d05ee5623538f0055c3c7515439298aff445cc8fb2341550ddb2f036618e29a742900f5cd056775e1838abf6299
|
7
|
+
data.tar.gz: 47b7a3f1f9cb191af39730bac8506264231df606fa7a63ac13017a01628ef43b74e11f7b5322ea64ee69e28af7251a78435584ce9d1e5a302db3fadab8a9e8ac
|
data/History.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
## [In Git](https://github.com/cucumber/cucumber-ruby/compare/v2.3.1...master)
|
2
2
|
|
3
|
-
|
3
|
+
... your change here?
|
4
4
|
|
5
|
-
|
5
|
+
## [v2.3.2](https://github.com/cucumber/cucumber-ruby/compare/v2.3.1...v2.3.2)
|
6
6
|
|
7
|
-
|
7
|
+
Brought the event bus code back into Cucumber to avoid https://github.com/fedux-org/event-bus/issues/6
|
8
8
|
|
9
|
-
## [
|
9
|
+
## [v2.3.1](https://github.com/cucumber/cucumber-ruby/compare/v2.3.0...v2.3.1)
|
10
10
|
|
11
11
|
Better deprecation warnings to help fix https://github.com/cucumber/cucumber-ruby/issues/942
|
12
12
|
|
data/cucumber.gemspec
CHANGED
@@ -18,7 +18,6 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.add_dependency 'multi_json', '>= 1.7.5', '< 2.0'
|
19
19
|
s.add_dependency 'multi_test', '>= 0.1.2'
|
20
20
|
s.add_dependency 'cucumber-wire', '~> 0.0.1'
|
21
|
-
s.add_dependency 'event-bus', '~> 0.1.0'
|
22
21
|
|
23
22
|
s.add_development_dependency 'aruba', '~> 0.6.1'
|
24
23
|
s.add_development_dependency 'json', '~> 1.7'
|
@@ -3,9 +3,6 @@ require 'cucumber/cli/rerun_file'
|
|
3
3
|
require 'cucumber/events'
|
4
4
|
require 'forwardable'
|
5
5
|
require 'cucumber/core/gherkin/tag_expression'
|
6
|
-
require 'cucumber'
|
7
|
-
require 'event/bus'
|
8
|
-
require 'event/name_resolver'
|
9
6
|
|
10
7
|
module Cucumber
|
11
8
|
# The base class for configuring settings for a Cucumber run.
|
@@ -234,7 +231,7 @@ module Cucumber
|
|
234
231
|
:snippets => true,
|
235
232
|
:source => true,
|
236
233
|
:duration => true,
|
237
|
-
:event_bus =>
|
234
|
+
:event_bus => Events::Bus.new(Cucumber::Events)
|
238
235
|
}
|
239
236
|
end
|
240
237
|
|
@@ -0,0 +1,86 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module Events
|
3
|
+
|
4
|
+
# Event bus
|
5
|
+
#
|
6
|
+
# Implements and in-process pub-sub events broadcaster allowing multiple observers
|
7
|
+
# to subscribe to different events that fire as your tests are executed.
|
8
|
+
#
|
9
|
+
# @private
|
10
|
+
class Bus
|
11
|
+
|
12
|
+
def initialize(default_namespace)
|
13
|
+
@default_namespace = default_namespace.to_s
|
14
|
+
@handlers = {}
|
15
|
+
end
|
16
|
+
|
17
|
+
# Register for an event
|
18
|
+
def register(event_id, handler_object = nil, &handler_proc)
|
19
|
+
handler = handler_proc || handler_object
|
20
|
+
raise ArgumentError.new("Please pass either an object or a handler block") unless handler
|
21
|
+
event_class = parse_event_id(event_id)
|
22
|
+
handlers_for(event_class) << handler
|
23
|
+
end
|
24
|
+
|
25
|
+
# Broadcast an event
|
26
|
+
def notify(event)
|
27
|
+
handlers_for(event.class).each { |handler| handler.call(event) }
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def handlers_for(event_class)
|
33
|
+
@handlers[event_class.to_s] ||= []
|
34
|
+
end
|
35
|
+
|
36
|
+
def parse_event_id(event_id)
|
37
|
+
case event_id
|
38
|
+
when Class
|
39
|
+
return event_id
|
40
|
+
when String
|
41
|
+
constantize(event_id)
|
42
|
+
else
|
43
|
+
constantize("#{@default_namespace}::#{camel_case(event_id)}")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def camel_case(underscored_name)
|
48
|
+
underscored_name.to_s.split("_").map { |word| word.upcase[0] + word[1..-1] }.join
|
49
|
+
end
|
50
|
+
|
51
|
+
# Thanks ActiveSupport
|
52
|
+
# (Only needed to support Ruby 1.9.3 and JRuby)
|
53
|
+
def constantize(camel_cased_word)
|
54
|
+
names = camel_cased_word.split('::')
|
55
|
+
|
56
|
+
# Trigger a built-in NameError exception including the ill-formed constant in the message.
|
57
|
+
Object.const_get(camel_cased_word) if names.empty?
|
58
|
+
|
59
|
+
# Remove the first blank element in case of '::ClassName' notation.
|
60
|
+
names.shift if names.size > 1 && names.first.empty?
|
61
|
+
|
62
|
+
names.inject(Object) do |constant, name|
|
63
|
+
if constant == Object
|
64
|
+
constant.const_get(name)
|
65
|
+
else
|
66
|
+
candidate = constant.const_get(name)
|
67
|
+
next candidate if constant.const_defined?(name, false)
|
68
|
+
next candidate unless Object.const_defined?(name)
|
69
|
+
|
70
|
+
# Go down the ancestors to check if it is owned directly. The check
|
71
|
+
# stops when we reach Object or the end of ancestors tree.
|
72
|
+
constant = constant.ancestors.inject do |const, ancestor|
|
73
|
+
break const if ancestor == Object
|
74
|
+
break ancestor if ancestor.const_defined?(name, false)
|
75
|
+
const
|
76
|
+
end
|
77
|
+
|
78
|
+
# owner is in Object, so raise
|
79
|
+
constant.const_get(name, false)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
data/lib/cucumber/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.2
|
@@ -0,0 +1,94 @@
|
|
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
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aslak Hellesøy
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-01-
|
13
|
+
date: 2016-01-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: cucumber-core
|
@@ -116,20 +116,6 @@ dependencies:
|
|
116
116
|
- - "~>"
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: 0.0.1
|
119
|
-
- !ruby/object:Gem::Dependency
|
120
|
-
name: event-bus
|
121
|
-
requirement: !ruby/object:Gem::Requirement
|
122
|
-
requirements:
|
123
|
-
- - "~>"
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: 0.1.0
|
126
|
-
type: :runtime
|
127
|
-
prerelease: false
|
128
|
-
version_requirements: !ruby/object:Gem::Requirement
|
129
|
-
requirements:
|
130
|
-
- - "~>"
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
version: 0.1.0
|
133
119
|
- !ruby/object:Gem::Dependency
|
134
120
|
name: aruba
|
135
121
|
requirement: !ruby/object:Gem::Requirement
|
@@ -705,6 +691,7 @@ files:
|
|
705
691
|
- lib/cucumber/events/after_test_step.rb
|
706
692
|
- lib/cucumber/events/before_test_case.rb
|
707
693
|
- lib/cucumber/events/before_test_step.rb
|
694
|
+
- lib/cucumber/events/bus.rb
|
708
695
|
- lib/cucumber/events/step_match.rb
|
709
696
|
- lib/cucumber/file_specs.rb
|
710
697
|
- lib/cucumber/filters.rb
|
@@ -799,6 +786,7 @@ files:
|
|
799
786
|
- spec/cucumber/configuration_spec.rb
|
800
787
|
- spec/cucumber/constantize_spec.rb
|
801
788
|
- spec/cucumber/core_ext/instance_exec_spec.rb
|
789
|
+
- spec/cucumber/events/bus_spec.rb
|
802
790
|
- spec/cucumber/file_specs_spec.rb
|
803
791
|
- spec/cucumber/filters/activate_steps_spec.rb
|
804
792
|
- spec/cucumber/filters/gated_receiver_spec.rb
|
@@ -864,7 +852,7 @@ rubyforge_project:
|
|
864
852
|
rubygems_version: 2.2.2
|
865
853
|
signing_key:
|
866
854
|
specification_version: 4
|
867
|
-
summary: cucumber-2.3.
|
855
|
+
summary: cucumber-2.3.2
|
868
856
|
test_files:
|
869
857
|
- features/docs/api/list_step_defs_as_json.feature
|
870
858
|
- features/docs/api/listen_for_events.feature
|
@@ -951,6 +939,7 @@ test_files:
|
|
951
939
|
- spec/cucumber/configuration_spec.rb
|
952
940
|
- spec/cucumber/constantize_spec.rb
|
953
941
|
- spec/cucumber/core_ext/instance_exec_spec.rb
|
942
|
+
- spec/cucumber/events/bus_spec.rb
|
954
943
|
- spec/cucumber/file_specs_spec.rb
|
955
944
|
- spec/cucumber/filters/activate_steps_spec.rb
|
956
945
|
- spec/cucumber/filters/gated_receiver_spec.rb
|