protobuf_spec 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.rspec +1 -0
- data/.travis.yml +5 -0
- data/CONTRIBUTION_GUIDELINES.md +22 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +81 -0
- data/LICENSE.txt +14 -0
- data/README.md +165 -0
- data/Rakefile +35 -0
- data/VERSION +1 -0
- data/features/builder.feature +34 -0
- data/features/equivalence.feature +95 -0
- data/features/inclusion.feature +72 -0
- data/features/memory.feature +135 -0
- data/features/paths.feature +21 -0
- data/features/step_definitions/steps.rb +3 -0
- data/features/support/env.rb +9 -0
- data/features/support/sample.pb.rb +40 -0
- data/lib/protobuf_spec.rb +4 -0
- data/lib/protobuf_spec/builder.rb +46 -0
- data/lib/protobuf_spec/cucumber.rb +69 -0
- data/lib/protobuf_spec/extensions.rb +9 -0
- data/lib/protobuf_spec/matchers.rb +18 -0
- data/lib/protobuf_spec/matchers/be_protobuf_eql.rb +37 -0
- data/lib/protobuf_spec/matchers/have_protobuf_path.rb +27 -0
- data/protobuf_spec.gemspec +87 -0
- data/sample.proto +17 -0
- data/spec/protobuf_spec/matchers/be_protobuf_eql_spec.rb +21 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/support/sample.pb.rb +40 -0
- metadata +151 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
module ProtobufSpec
|
2
|
+
module Matchers
|
3
|
+
class HaveProtobufPath
|
4
|
+
attr_reader :path
|
5
|
+
def initialize path
|
6
|
+
@path = path
|
7
|
+
@json_matcher = JsonSpec::Matchers::HaveJsonPath.new path
|
8
|
+
end
|
9
|
+
|
10
|
+
def matches? proto
|
11
|
+
@json_matcher.matches? proto.to_json
|
12
|
+
end
|
13
|
+
|
14
|
+
def failure_message_for_should
|
15
|
+
%(Expected Protobuf path "#{@path}")
|
16
|
+
end
|
17
|
+
|
18
|
+
def failure_message_for_should_not
|
19
|
+
%(Expected no Protobuf path "#{@path}")
|
20
|
+
end
|
21
|
+
|
22
|
+
def description
|
23
|
+
%(have Protobuf path "#{@path}")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "protobuf_spec"
|
8
|
+
s.version = "0.3.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Chris Busbey"]
|
12
|
+
s.date = "2013-08-28"
|
13
|
+
s.description = "Leverages json_spec to test structured protocol buffers with json data modeling"
|
14
|
+
s.email = "info@connamara.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
".travis.yml",
|
23
|
+
"CONTRIBUTION_GUIDELINES.md",
|
24
|
+
"Gemfile",
|
25
|
+
"Gemfile.lock",
|
26
|
+
"LICENSE.txt",
|
27
|
+
"README.md",
|
28
|
+
"Rakefile",
|
29
|
+
"VERSION",
|
30
|
+
"features/builder.feature",
|
31
|
+
"features/equivalence.feature",
|
32
|
+
"features/inclusion.feature",
|
33
|
+
"features/memory.feature",
|
34
|
+
"features/paths.feature",
|
35
|
+
"features/step_definitions/steps.rb",
|
36
|
+
"features/support/env.rb",
|
37
|
+
"features/support/sample.pb.rb",
|
38
|
+
"lib/protobuf_spec.rb",
|
39
|
+
"lib/protobuf_spec/builder.rb",
|
40
|
+
"lib/protobuf_spec/cucumber.rb",
|
41
|
+
"lib/protobuf_spec/extensions.rb",
|
42
|
+
"lib/protobuf_spec/matchers.rb",
|
43
|
+
"lib/protobuf_spec/matchers/be_protobuf_eql.rb",
|
44
|
+
"lib/protobuf_spec/matchers/have_protobuf_path.rb",
|
45
|
+
"protobuf_spec.gemspec",
|
46
|
+
"sample.proto",
|
47
|
+
"spec/protobuf_spec/matchers/be_protobuf_eql_spec.rb",
|
48
|
+
"spec/spec_helper.rb",
|
49
|
+
"spec/support/sample.pb.rb"
|
50
|
+
]
|
51
|
+
s.homepage = "http://github.com/connamara/protobuf_spec"
|
52
|
+
s.licenses = ["GPL"]
|
53
|
+
s.require_paths = ["lib"]
|
54
|
+
s.rubygems_version = "2.0.7"
|
55
|
+
s.summary = "RSpec matchers and cucumber step defs for testing protocol buffers"
|
56
|
+
|
57
|
+
if s.respond_to? :specification_version then
|
58
|
+
s.specification_version = 4
|
59
|
+
|
60
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
61
|
+
s.add_runtime_dependency(%q<ruby_protobuf>, ["~> 0.4.11"])
|
62
|
+
s.add_runtime_dependency(%q<json_spec>, ["~> 1.1.1"])
|
63
|
+
s.add_runtime_dependency(%q<cuke_mem>, ["~> 0.1.1"])
|
64
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.14"])
|
65
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8"])
|
66
|
+
s.add_development_dependency(%q<cucumber>, ["~> 1.3"])
|
67
|
+
s.add_development_dependency(%q<rake>, ["~> 10.1"])
|
68
|
+
else
|
69
|
+
s.add_dependency(%q<ruby_protobuf>, ["~> 0.4.11"])
|
70
|
+
s.add_dependency(%q<json_spec>, ["~> 1.1.1"])
|
71
|
+
s.add_dependency(%q<cuke_mem>, ["~> 0.1.1"])
|
72
|
+
s.add_dependency(%q<rspec>, ["~> 2.14"])
|
73
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8"])
|
74
|
+
s.add_dependency(%q<cucumber>, ["~> 1.3"])
|
75
|
+
s.add_dependency(%q<rake>, ["~> 10.1"])
|
76
|
+
end
|
77
|
+
else
|
78
|
+
s.add_dependency(%q<ruby_protobuf>, ["~> 0.4.11"])
|
79
|
+
s.add_dependency(%q<json_spec>, ["~> 1.1.1"])
|
80
|
+
s.add_dependency(%q<cuke_mem>, ["~> 0.1.1"])
|
81
|
+
s.add_dependency(%q<rspec>, ["~> 2.14"])
|
82
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8"])
|
83
|
+
s.add_dependency(%q<cucumber>, ["~> 1.3"])
|
84
|
+
s.add_dependency(%q<rake>, ["~> 10.1"])
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
data/sample.proto
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
message Sample {
|
2
|
+
optional string string_field = 1;
|
3
|
+
optional int32 int_field = 2;
|
4
|
+
optional double double_field = 3;
|
5
|
+
|
6
|
+
optional string string_field_2 = 4;
|
7
|
+
optional int32 int_field_2 = 5;
|
8
|
+
optional double double_field_2 = 6;
|
9
|
+
|
10
|
+
optional string string_field_3 = 7;
|
11
|
+
optional int32 int_field_3 = 8;
|
12
|
+
optional double double_field_3 = 9;
|
13
|
+
|
14
|
+
optional bool bool_field=10;
|
15
|
+
optional bool bool_field_2=11;
|
16
|
+
optional bool bool_field_3=12;
|
17
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ProtobufSpec::Matchers::BeProtobufEql do
|
4
|
+
before(:each) do
|
5
|
+
@sample = Sample.new
|
6
|
+
@sample.string_field="foo"
|
7
|
+
end
|
8
|
+
|
9
|
+
it "matches identical JSON" do
|
10
|
+
@sample.should be_protobuf_eql(%({"string_field":"foo"}))
|
11
|
+
end
|
12
|
+
|
13
|
+
it "matches at a path" do
|
14
|
+
@sample.should be_protobuf_eql(%("foo")).at_path("string_field")
|
15
|
+
end
|
16
|
+
|
17
|
+
it "doesn't match at a path" do
|
18
|
+
@sample.should_not be_protobuf_eql(%("bar")).at_path("string_field")
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'protobuf_spec'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
### Generated by rprotoc. DO NOT EDIT!
|
2
|
+
### <proto file: sample.proto>
|
3
|
+
# message Sample {
|
4
|
+
# optional string string_field = 1;
|
5
|
+
# optional int32 int_field = 2;
|
6
|
+
# optional double double_field = 3;
|
7
|
+
#
|
8
|
+
# optional string string_field_2 = 4;
|
9
|
+
# optional int32 int_field_2 = 5;
|
10
|
+
# optional double double_field_2 = 6;
|
11
|
+
#
|
12
|
+
# optional string string_field_3 = 7;
|
13
|
+
# optional int32 int_field_3 = 8;
|
14
|
+
# optional double double_field_3 = 9;
|
15
|
+
#
|
16
|
+
# optional bool bool_field=10;
|
17
|
+
# optional bool bool_field_2=11;
|
18
|
+
# optional bool bool_field_3=12;
|
19
|
+
# }
|
20
|
+
|
21
|
+
require 'protobuf/message/message'
|
22
|
+
require 'protobuf/message/enum'
|
23
|
+
require 'protobuf/message/service'
|
24
|
+
require 'protobuf/message/extend'
|
25
|
+
|
26
|
+
class Sample < ::Protobuf::Message
|
27
|
+
defined_in __FILE__
|
28
|
+
optional :string, :string_field, 1
|
29
|
+
optional :int32, :int_field, 2
|
30
|
+
optional :double, :double_field, 3
|
31
|
+
optional :string, :string_field_2, 4
|
32
|
+
optional :int32, :int_field_2, 5
|
33
|
+
optional :double, :double_field_2, 6
|
34
|
+
optional :string, :string_field_3, 7
|
35
|
+
optional :int32, :int_field_3, 8
|
36
|
+
optional :double, :double_field_3, 9
|
37
|
+
optional :bool, :bool_field, 10
|
38
|
+
optional :bool, :bool_field_2, 11
|
39
|
+
optional :bool, :bool_field_3, 12
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: protobuf_spec
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Busbey
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2013-08-28 00:00:00 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: ruby_protobuf
|
16
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.4.11
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: *id001
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: json_spec
|
26
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 1.1.1
|
31
|
+
type: :runtime
|
32
|
+
prerelease: false
|
33
|
+
version_requirements: *id002
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: cuke_mem
|
36
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.1.1
|
41
|
+
type: :runtime
|
42
|
+
prerelease: false
|
43
|
+
version_requirements: *id003
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: rspec
|
46
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ~>
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: "2.14"
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: *id004
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: jeweler
|
56
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ~>
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: "1.8"
|
61
|
+
type: :development
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: *id005
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: cucumber
|
66
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ~>
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: "1.3"
|
71
|
+
type: :development
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: *id006
|
74
|
+
- !ruby/object:Gem::Dependency
|
75
|
+
name: rake
|
76
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ~>
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: "10.1"
|
81
|
+
type: :development
|
82
|
+
prerelease: false
|
83
|
+
version_requirements: *id007
|
84
|
+
description: Leverages json_spec to test structured protocol buffers with json data modeling
|
85
|
+
email: info@connamara.com
|
86
|
+
executables: []
|
87
|
+
|
88
|
+
extensions: []
|
89
|
+
|
90
|
+
extra_rdoc_files:
|
91
|
+
- LICENSE.txt
|
92
|
+
- README.md
|
93
|
+
files:
|
94
|
+
- .document
|
95
|
+
- .rspec
|
96
|
+
- .travis.yml
|
97
|
+
- CONTRIBUTION_GUIDELINES.md
|
98
|
+
- Gemfile
|
99
|
+
- Gemfile.lock
|
100
|
+
- LICENSE.txt
|
101
|
+
- README.md
|
102
|
+
- Rakefile
|
103
|
+
- VERSION
|
104
|
+
- features/builder.feature
|
105
|
+
- features/equivalence.feature
|
106
|
+
- features/inclusion.feature
|
107
|
+
- features/memory.feature
|
108
|
+
- features/paths.feature
|
109
|
+
- features/step_definitions/steps.rb
|
110
|
+
- features/support/env.rb
|
111
|
+
- features/support/sample.pb.rb
|
112
|
+
- lib/protobuf_spec.rb
|
113
|
+
- lib/protobuf_spec/builder.rb
|
114
|
+
- lib/protobuf_spec/cucumber.rb
|
115
|
+
- lib/protobuf_spec/extensions.rb
|
116
|
+
- lib/protobuf_spec/matchers.rb
|
117
|
+
- lib/protobuf_spec/matchers/be_protobuf_eql.rb
|
118
|
+
- lib/protobuf_spec/matchers/have_protobuf_path.rb
|
119
|
+
- protobuf_spec.gemspec
|
120
|
+
- sample.proto
|
121
|
+
- spec/protobuf_spec/matchers/be_protobuf_eql_spec.rb
|
122
|
+
- spec/spec_helper.rb
|
123
|
+
- spec/support/sample.pb.rb
|
124
|
+
homepage: http://github.com/connamara/protobuf_spec
|
125
|
+
licenses:
|
126
|
+
- GPL
|
127
|
+
metadata: {}
|
128
|
+
|
129
|
+
post_install_message:
|
130
|
+
rdoc_options: []
|
131
|
+
|
132
|
+
require_paths:
|
133
|
+
- lib
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- &id008
|
137
|
+
- ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: "0"
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- *id008
|
143
|
+
requirements: []
|
144
|
+
|
145
|
+
rubyforge_project:
|
146
|
+
rubygems_version: 2.0.7
|
147
|
+
signing_key:
|
148
|
+
specification_version: 4
|
149
|
+
summary: RSpec matchers and cucumber step defs for testing protocol buffers
|
150
|
+
test_files: []
|
151
|
+
|