protobuf 3.0.4 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/lib/protobuf/field/base_field.rb +5 -1
- data/lib/protobuf/field/float_field.rb +4 -0
- data/lib/protobuf/rpc/connectors/zmq.rb +31 -20
- data/lib/protobuf/rpc/servers/zmq/broker.rb +1 -1
- data/lib/protobuf/version.rb +1 -1
- data/protobuf.gemspec +1 -1
- data/spec/encoding/all_types_spec.rb +1 -1
- data/spec/encoding/extreme_values_spec.rb +0 -0
- data/spec/functional/socket_server_spec.rb +5 -4
- data/spec/functional/zmq_server_spec.rb +7 -7
- data/spec/lib/protobuf/cli_spec.rb +39 -39
- data/spec/lib/protobuf/code_generator_spec.rb +4 -4
- data/spec/lib/protobuf/enum_spec.rb +23 -23
- data/spec/lib/protobuf/field/float_field_spec.rb +55 -0
- data/spec/lib/protobuf/field/string_field_spec.rb +4 -4
- data/spec/lib/protobuf/generators/base_spec.rb +4 -7
- data/spec/lib/protobuf/generators/enum_generator_spec.rb +3 -3
- data/spec/lib/protobuf/generators/extension_generator_spec.rb +4 -4
- data/spec/lib/protobuf/generators/field_generator_spec.rb +11 -11
- data/spec/lib/protobuf/generators/file_generator_spec.rb +3 -3
- data/spec/lib/protobuf/generators/service_generator_spec.rb +2 -2
- data/spec/lib/protobuf/lifecycle_spec.rb +16 -16
- data/spec/lib/protobuf/logger_spec.rb +27 -27
- data/spec/lib/protobuf/message_spec.rb +42 -42
- data/spec/lib/protobuf/optionable_spec.rb +1 -1
- data/spec/lib/protobuf/rpc/client_spec.rb +13 -13
- data/spec/lib/protobuf/rpc/connector_spec.rb +4 -4
- data/spec/lib/protobuf/rpc/connectors/base_spec.rb +7 -7
- data/spec/lib/protobuf/rpc/connectors/common_spec.rb +31 -33
- data/spec/lib/protobuf/rpc/connectors/socket_spec.rb +8 -8
- data/spec/lib/protobuf/rpc/connectors/zmq_spec.rb +24 -35
- data/spec/lib/protobuf/rpc/middleware/exception_handler_spec.rb +8 -8
- data/spec/lib/protobuf/rpc/middleware/logger_spec.rb +2 -2
- data/spec/lib/protobuf/rpc/middleware/request_decoder_spec.rb +10 -10
- data/spec/lib/protobuf/rpc/middleware/response_encoder_spec.rb +6 -6
- data/spec/lib/protobuf/rpc/servers/socket_server_spec.rb +3 -3
- data/spec/lib/protobuf/rpc/servers/zmq/server_spec.rb +3 -3
- data/spec/lib/protobuf/rpc/servers/zmq/util_spec.rb +2 -2
- data/spec/lib/protobuf/rpc/servers/zmq/worker_spec.rb +5 -5
- data/spec/lib/protobuf/rpc/service_directory_spec.rb +26 -27
- data/spec/lib/protobuf/rpc/service_dispatcher_spec.rb +4 -4
- data/spec/lib/protobuf/rpc/service_filters_spec.rb +39 -39
- data/spec/lib/protobuf/rpc/service_spec.rb +27 -27
- data/spec/lib/protobuf/rpc/stat_spec.rb +4 -4
- data/spec/lib/protobuf_spec.rb +7 -7
- data/spec/spec_helper.rb +1 -0
- data/spec/support/packed_field.rb +1 -1
- metadata +6 -76
@@ -27,13 +27,13 @@ describe ::Protobuf::CodeGenerator do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
before do
|
30
|
-
::Protobuf::Generators::FileGenerator.
|
31
|
-
::Protobuf::Generators::FileGenerator.
|
30
|
+
expect(::Protobuf::Generators::FileGenerator).to receive(:new).with(input_file1).and_return(file_generator1)
|
31
|
+
expect(::Protobuf::Generators::FileGenerator).to receive(:new).with(input_file2).and_return(file_generator2)
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'returns the serialized CodeGeneratorResponse which contains the generated file contents' do
|
35
35
|
generator = described_class.new(request_bytes)
|
36
|
-
generator.response_bytes.
|
36
|
+
expect(generator.response_bytes).to eq expected_response_bytes
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -51,7 +51,7 @@ describe ::Protobuf::CodeGenerator do
|
|
51
51
|
|
52
52
|
describe '.warn' do
|
53
53
|
it 'prints a warning to stderr' do
|
54
|
-
STDERR.
|
54
|
+
expect(STDERR).to receive(:puts).with("[WARN] a warning")
|
55
55
|
described_class.warn("a warning")
|
56
56
|
end
|
57
57
|
end
|
@@ -22,7 +22,7 @@ describe Protobuf::Enum do
|
|
22
22
|
|
23
23
|
describe '.aliases_allowed?' do
|
24
24
|
it 'is false when the option is not set' do
|
25
|
-
expect(Test::EnumTestType.aliases_allowed?).to
|
25
|
+
expect(Test::EnumTestType.aliases_allowed?).to be_falsey
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -155,15 +155,15 @@ describe Protobuf::Enum do
|
|
155
155
|
|
156
156
|
describe '.valid_tag?' do
|
157
157
|
context 'when tag is defined' do
|
158
|
-
specify { expect(Test::EnumTestType.valid_tag?(tag)).to
|
158
|
+
specify { expect(Test::EnumTestType.valid_tag?(tag)).to be_truthy }
|
159
159
|
end
|
160
160
|
|
161
161
|
context 'when tag is not defined' do
|
162
|
-
specify { expect(Test::EnumTestType.valid_tag?(300)).to
|
162
|
+
specify { expect(Test::EnumTestType.valid_tag?(300)).to be_falsey }
|
163
163
|
end
|
164
164
|
|
165
165
|
context 'is true for aliased enums' do
|
166
|
-
specify { expect(EnumAliasTest.valid_tag?(1)).to
|
166
|
+
specify { expect(EnumAliasTest.valid_tag?(1)).to be_truthy }
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
@@ -201,31 +201,31 @@ describe Protobuf::Enum do
|
|
201
201
|
end
|
202
202
|
|
203
203
|
subject { Test::EnumTestType::ONE }
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
specify { subject.to_s(:tag).
|
213
|
-
specify { subject.to_s(:name).
|
204
|
+
specify { expect(subject.class).to eq(Fixnum) }
|
205
|
+
specify { expect(subject.parent_class).to eq(Test::EnumTestType) }
|
206
|
+
specify { expect(subject.name).to eq(:ONE) }
|
207
|
+
specify { expect(subject.tag).to eq(1) }
|
208
|
+
specify { expect(subject.value).to eq(1) }
|
209
|
+
specify { expect(subject.to_hash_value).to eq(1) }
|
210
|
+
specify { expect(subject.to_s).to eq("1") }
|
211
|
+
specify { expect(subject.inspect).to eq('#<Protobuf::Enum(Test::EnumTestType)::ONE=1>') }
|
212
|
+
specify { expect(subject.to_s(:tag)).to eq("1") }
|
213
|
+
specify { expect(subject.to_s(:name)).to eq("ONE") }
|
214
214
|
|
215
215
|
it "can be used as the index to an array" do
|
216
216
|
array = [0, 1, 2, 3]
|
217
|
-
array[::Test::EnumTestType::ONE].
|
217
|
+
expect(array[::Test::EnumTestType::ONE]).to eq(1)
|
218
218
|
end
|
219
219
|
|
220
220
|
describe '#try' do
|
221
|
-
specify { subject.try(:parent_class).
|
222
|
-
specify { subject.try(:class).
|
223
|
-
specify { subject.try(:name).
|
224
|
-
specify { subject.try(:tag).
|
225
|
-
specify { subject.try(:value).
|
226
|
-
specify { subject.try(:to_i).
|
227
|
-
specify { subject.try(:to_int).
|
228
|
-
specify { subject.try { |yielded| yielded.
|
221
|
+
specify { expect(subject.try(:parent_class)).to eq(subject.parent_class) }
|
222
|
+
specify { expect(subject.try(:class)).to eq(subject.class) }
|
223
|
+
specify { expect(subject.try(:name)).to eq(subject.name) }
|
224
|
+
specify { expect(subject.try(:tag)).to eq(subject.tag) }
|
225
|
+
specify { expect(subject.try(:value)).to eq(subject.value) }
|
226
|
+
specify { expect(subject.try(:to_i)).to eq(subject.to_i) }
|
227
|
+
specify { expect(subject.try(:to_int)).to eq(subject.to_int) }
|
228
|
+
specify { subject.try { |yielded| expect(yielded).to eq(subject) } }
|
229
229
|
end
|
230
230
|
|
231
231
|
context 'when coercing from enum' do
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Protobuf::Field::FloatField do
|
4
|
+
|
5
|
+
class SomeFloatMessage < ::Protobuf::Message
|
6
|
+
optional :float, :some_float, 1
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:instance) { SomeFloatMessage.new }
|
10
|
+
|
11
|
+
describe '#define_setter' do
|
12
|
+
subject { instance.some_float = value; instance.some_float }
|
13
|
+
|
14
|
+
context 'when set with an int' do
|
15
|
+
let(:value) { 100 }
|
16
|
+
|
17
|
+
it 'is readable as a float' do
|
18
|
+
expect(subject).to eq(100.0)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when set with a float' do
|
23
|
+
let(:value) { 100.1 }
|
24
|
+
|
25
|
+
it 'is readable as a float' do
|
26
|
+
expect(subject).to eq(100.1)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when set with a string of a float' do
|
31
|
+
let(:value) { "101.1" }
|
32
|
+
|
33
|
+
it 'is readable as a float' do
|
34
|
+
expect(subject).to eq(101.1)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when set with a non-numeric string' do
|
39
|
+
let(:value) { "aaaa" }
|
40
|
+
|
41
|
+
it 'throws an error' do
|
42
|
+
expect { subject }.to raise_error(ArgumentError)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when set with something that is not a float' do
|
47
|
+
let(:value) { [ 1, 2, 3 ] }
|
48
|
+
|
49
|
+
it 'throws an error' do
|
50
|
+
expect { subject }.to raise_error(TypeError)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -27,18 +27,18 @@ describe ::Protobuf::Field::StringField do
|
|
27
27
|
source_string = "foo"
|
28
28
|
proto = ::Test::Resource.new(:name => source_string)
|
29
29
|
proto.encode
|
30
|
-
proto.name.
|
30
|
+
expect(proto.name).to eq source_string
|
31
31
|
proto.encode
|
32
|
-
proto.name.
|
32
|
+
expect(proto.name).to eq source_string
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'does not alter unicode string values after encoding multiple times' do
|
36
36
|
source_string = "¢"
|
37
37
|
proto = ::Test::Resource.new(:name => source_string)
|
38
38
|
proto.encode
|
39
|
-
proto.name.
|
39
|
+
expect(proto.name).to eq source_string
|
40
40
|
proto.encode
|
41
|
-
proto.name.
|
41
|
+
expect(proto.name).to eq source_string
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -10,8 +10,8 @@ describe ::Protobuf::Generators::Base do
|
|
10
10
|
context 'namespaces' do
|
11
11
|
let(:descriptor) { double(:name => 'Baz') }
|
12
12
|
subject { described_class.new(descriptor, 0, :namespace => [ :foo, :bar ]) }
|
13
|
-
|
14
|
-
|
13
|
+
specify { expect(subject.type_namespace).to eq([ :foo, :bar, 'Baz' ]) }
|
14
|
+
specify { expect(subject.fully_qualified_type_namespace).to eq('.foo.bar.Baz') }
|
15
15
|
end
|
16
16
|
|
17
17
|
describe '#run_once' do
|
@@ -67,17 +67,14 @@ describe ::Protobuf::Generators::Base do
|
|
67
67
|
describe '#validate_tags' do
|
68
68
|
context 'when tags are duplicated' do
|
69
69
|
it 'fails with a GeneratorFatalError' do
|
70
|
-
::Protobuf::CodeGenerator.
|
71
|
-
.with(/FooBar object has duplicate tags\. Expected 3 tags, but got 4/)
|
72
|
-
|
70
|
+
expect(::Protobuf::CodeGenerator).to receive(:fatal).with(/FooBar object has duplicate tags\. Expected 3 tags, but got 4/)
|
73
71
|
described_class.validate_tags("FooBar", [1,2,2,3])
|
74
72
|
end
|
75
73
|
end
|
76
74
|
|
77
75
|
context 'when tags are missing in the range' do
|
78
76
|
it 'prints a warning' do
|
79
|
-
::Protobuf::CodeGenerator.
|
80
|
-
.with(/FooBar object should have 5 tags \(1\.\.5\), but found 4 tags/)
|
77
|
+
expect(::Protobuf::CodeGenerator).to receive(:warn).with(/FooBar object should have 5 tags \(1\.\.5\), but found 4 tags/)
|
81
78
|
described_class.validate_tags("FooBar", [1,2,4,5])
|
82
79
|
end
|
83
80
|
end
|
@@ -33,7 +33,7 @@ end
|
|
33
33
|
|
34
34
|
it 'compiles the enum and it\'s field values' do
|
35
35
|
subject.compile
|
36
|
-
subject.to_s.
|
36
|
+
expect(subject.to_s).to eq(compiled)
|
37
37
|
end
|
38
38
|
|
39
39
|
context 'when allow_alias option is set' do
|
@@ -53,14 +53,14 @@ end
|
|
53
53
|
|
54
54
|
it 'sets the allow_alias option' do
|
55
55
|
subject.compile
|
56
|
-
subject.to_s.
|
56
|
+
expect(subject.to_s).to eq(compiled)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
61
|
describe '#build_value' do
|
62
62
|
it 'returns a string identifying the given enum value' do
|
63
|
-
subject.build_value(enum.value.first).
|
63
|
+
expect(subject.build_value(enum.value.first)).to eq("define :FOO, 1")
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -15,9 +15,9 @@ describe ::Protobuf::Generators::ExtensionGenerator do
|
|
15
15
|
let(:message_type) { 'FooBar' }
|
16
16
|
|
17
17
|
before do
|
18
|
-
::Protobuf::Generators::FieldGenerator.
|
19
|
-
::Protobuf::Generators::FieldGenerator.
|
20
|
-
::Protobuf::Generators::FieldGenerator.
|
18
|
+
expect(::Protobuf::Generators::FieldGenerator).to receive(:new).with(field_descriptors[0], 1).and_return(field_descriptors[0])
|
19
|
+
expect(::Protobuf::Generators::FieldGenerator).to receive(:new).with(field_descriptors[1], 1).and_return(field_descriptors[1])
|
20
|
+
expect(::Protobuf::Generators::FieldGenerator).to receive(:new).with(field_descriptors[2], 1).and_return(field_descriptors[2])
|
21
21
|
end
|
22
22
|
|
23
23
|
subject { described_class.new(message_type, field_descriptors, 0) }
|
@@ -35,7 +35,7 @@ end
|
|
35
35
|
|
36
36
|
it 'compiles the a class with the extension fields' do
|
37
37
|
subject.compile
|
38
|
-
subject.to_s.
|
38
|
+
expect(subject.to_s).to eq(compiled)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -27,33 +27,33 @@ describe ::Protobuf::Generators::FieldGenerator do
|
|
27
27
|
describe '#compile' do
|
28
28
|
subject { described_class.new(field).to_s }
|
29
29
|
|
30
|
-
|
30
|
+
specify { expect(subject).to eq "optional :string, :foo_bar, 3\n" }
|
31
31
|
|
32
32
|
context 'when the type is another message' do
|
33
33
|
let(:type_enum) { :TYPE_MESSAGE }
|
34
34
|
let(:type_name) { '.foo.bar.Baz' }
|
35
35
|
|
36
|
-
|
36
|
+
specify { expect(subject).to eq "optional ::Foo::Bar::Baz, :foo_bar, 3\n" }
|
37
37
|
end
|
38
38
|
|
39
39
|
context 'when a default value is used' do
|
40
40
|
let(:type_enum) { :TYPE_INT32 }
|
41
41
|
let(:default_value) { '42' }
|
42
|
-
|
42
|
+
specify { expect(subject).to eq "optional :int32, :foo_bar, 3, :default => 42\n" }
|
43
43
|
|
44
44
|
context 'when type is an enum' do
|
45
45
|
let(:type_enum) { :TYPE_ENUM }
|
46
46
|
let(:type_name) { '.foo.bar.Baz' }
|
47
47
|
let(:default_value) { 'QUUX' }
|
48
48
|
|
49
|
-
|
49
|
+
specify { expect(subject).to eq "optional ::Foo::Bar::Baz, :foo_bar, 3, :default => ::Foo::Bar::Baz::QUUX\n" }
|
50
50
|
end
|
51
51
|
|
52
52
|
context 'when the type is a string' do
|
53
53
|
let(:type_enum) { :TYPE_STRING }
|
54
54
|
let(:default_value) { "a default \"string\"" }
|
55
55
|
|
56
|
-
|
56
|
+
specify { expect(subject).to eq %Q{optional :string, :foo_bar, 3, :default => "a default \"string\""\n} }
|
57
57
|
end
|
58
58
|
|
59
59
|
context 'when float or double field type' do
|
@@ -61,17 +61,17 @@ describe ::Protobuf::Generators::FieldGenerator do
|
|
61
61
|
|
62
62
|
context 'when the default value is "nan"' do
|
63
63
|
let(:default_value) { 'nan' }
|
64
|
-
|
64
|
+
specify { expect(subject).to match(/::Float::NAN/) }
|
65
65
|
end
|
66
66
|
|
67
67
|
context 'when the default value is "inf"' do
|
68
68
|
let(:default_value) { 'inf' }
|
69
|
-
|
69
|
+
specify { expect(subject).to match(/::Float::INFINITY/) }
|
70
70
|
end
|
71
71
|
|
72
72
|
context 'when the default value is "-inf"' do
|
73
73
|
let(:default_value) { '-inf' }
|
74
|
-
|
74
|
+
specify { expect(subject).to match(/-::Float::INFINITY/) }
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
@@ -79,19 +79,19 @@ describe ::Protobuf::Generators::FieldGenerator do
|
|
79
79
|
context 'when the field is an extension' do
|
80
80
|
let(:extendee) { 'foo.bar.Baz' }
|
81
81
|
|
82
|
-
|
82
|
+
specify { expect(subject).to eq "optional :string, :foo_bar, 3, :extension => true\n" }
|
83
83
|
end
|
84
84
|
|
85
85
|
context 'when field is packed' do
|
86
86
|
let(:field_options) { { :packed => true } }
|
87
87
|
|
88
|
-
|
88
|
+
specify { expect(subject).to eq "optional :string, :foo_bar, 3, :packed => true\n" }
|
89
89
|
end
|
90
90
|
|
91
91
|
context 'when field is deprecated' do
|
92
92
|
let(:field_options) { { :deprecated => true } }
|
93
93
|
|
94
|
-
|
94
|
+
specify { expect(subject).to eq "optional :string, :foo_bar, 3, :deprecated => true\n" }
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
@@ -9,7 +9,7 @@ describe ::Protobuf::Generators::FileGenerator do
|
|
9
9
|
let(:file_descriptor) { ::Google::Protobuf::FileDescriptorProto.new(descriptor_fields) }
|
10
10
|
|
11
11
|
subject { described_class.new(file_descriptor) }
|
12
|
-
|
12
|
+
specify { expect(subject.file_name).to eq('test/foo.pb.rb') }
|
13
13
|
|
14
14
|
describe '#print_import_requires' do
|
15
15
|
let(:descriptor_fields) do
|
@@ -18,8 +18,8 @@ describe ::Protobuf::Generators::FileGenerator do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'prints a ruby require for each dependency' do
|
21
|
-
subject.
|
22
|
-
subject.
|
21
|
+
expect(subject).to receive(:print_require).with('test/bar.pb')
|
22
|
+
expect(subject).to receive(:print_require).with('test/baz.pb')
|
23
23
|
subject.print_import_requires
|
24
24
|
end
|
25
25
|
|
@@ -29,13 +29,13 @@ end
|
|
29
29
|
|
30
30
|
it 'compiles the service and it\'s rpc methods' do
|
31
31
|
subject.compile
|
32
|
-
subject.to_s.
|
32
|
+
expect(subject.to_s).to eq(compiled)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
describe '#build_method' do
|
37
37
|
it 'returns a string identifying the given method descriptor' do
|
38
|
-
subject.build_method(service.method.first).
|
38
|
+
expect(subject.build_method(service.method.first)).to eq("rpc :search, FooRequest, FooResponse")
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -9,8 +9,8 @@ describe ::Protobuf::Lifecycle do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
it "registers a string as the event_name" do
|
12
|
-
::ActiveSupport::Notifications.
|
13
|
-
|
12
|
+
expect(::ActiveSupport::Notifications).to receive(:subscribe).with("something")
|
13
|
+
subject.register("something") { true }
|
14
14
|
end
|
15
15
|
|
16
16
|
it "only registers blocks for event callbacks" do
|
@@ -26,8 +26,8 @@ describe ::Protobuf::Lifecycle do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
subject.trigger("this")
|
29
|
-
this.
|
30
|
-
this.
|
29
|
+
expect(this).to_not be_nil
|
30
|
+
expect(this).to eq("not nil")
|
31
31
|
end
|
32
32
|
|
33
33
|
it "calls multiple registered blocks when triggered" do
|
@@ -43,10 +43,10 @@ describe ::Protobuf::Lifecycle do
|
|
43
43
|
end
|
44
44
|
|
45
45
|
subject.trigger("this")
|
46
|
-
this.
|
47
|
-
this.
|
48
|
-
that.
|
49
|
-
that.
|
46
|
+
expect(this).to_not be_nil
|
47
|
+
expect(this).to eq("not nil")
|
48
|
+
expect(that).to_not be_nil
|
49
|
+
expect(that).to eq("not nil")
|
50
50
|
end
|
51
51
|
|
52
52
|
context 'when the registered block has arity' do
|
@@ -55,12 +55,12 @@ describe ::Protobuf::Lifecycle do
|
|
55
55
|
outer_bar = nil
|
56
56
|
|
57
57
|
subject.register('foo') do |bar|
|
58
|
-
bar.
|
58
|
+
expect(bar).to be_nil
|
59
59
|
outer_bar = 'triggered'
|
60
60
|
end
|
61
61
|
|
62
62
|
subject.trigger('foo')
|
63
|
-
outer_bar.
|
63
|
+
expect(outer_bar).to eq 'triggered'
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -69,21 +69,21 @@ describe ::Protobuf::Lifecycle do
|
|
69
69
|
outer_bar = nil
|
70
70
|
|
71
71
|
subject.register('foo') do |bar|
|
72
|
-
bar.
|
72
|
+
expect(bar).to_not be_nil
|
73
73
|
outer_bar = bar
|
74
74
|
end
|
75
75
|
|
76
76
|
subject.trigger('foo', 'baz')
|
77
|
-
outer_bar.
|
77
|
+
expect(outer_bar).to eq 'baz'
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
82
|
context "normalized event names" do
|
83
|
-
specify { subject.normalized_event_name(:derp).
|
84
|
-
specify { subject.normalized_event_name(:Derp).
|
85
|
-
specify { subject.normalized_event_name("DERP").
|
86
|
-
specify { subject.normalized_event_name("derp").
|
83
|
+
specify { expect(subject.normalized_event_name(:derp)).to eq("derp") }
|
84
|
+
specify { expect(subject.normalized_event_name(:Derp)).to eq("derp") }
|
85
|
+
specify { expect(subject.normalized_event_name("DERP")).to eq("derp") }
|
86
|
+
specify { expect(subject.normalized_event_name("derp")).to eq("derp") }
|
87
87
|
end
|
88
88
|
|
89
89
|
end
|