protobuf_spec 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 66bbc89abe97ac54c85205b4dd0807626e5d674c
4
+ data.tar.gz: 8230b7bf3c4ed051b868ce5600fb96623c1da194
5
+ SHA512:
6
+ metadata.gz: 3fa242e56478eb0881c37abf269b709e967f0d23e1d502603bfb4d729271ad5539c16d808a25d9b04cb50ada9a2640d4b7cfbb38d529b2df75aba2c5b89261b9
7
+ data.tar.gz: 973b1c68787c23b251886f691b9a9801cee3245050636fb98b7ee3fc055493de40b6fcb12dbc46628be996ebb412eb906faaaad904acef60f742e209bd80da83
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - 2.0.0
@@ -0,0 +1,22 @@
1
+ If you come across any issues, please [tell us](https://github.com/connamara/protobuf_spec/issues).
2
+ Pull requests (with tests) are appreciated. No pull request is too small. Please help with:
3
+
4
+ * Reporting bugs
5
+ * Suggesting features
6
+ * Writing or improving documentation
7
+ * Fixing typos
8
+ * Cleaning whitespace
9
+ * Refactoring code
10
+ * Adding tests
11
+ * Closing [issues](https://github.com/connamara/protobuf_spec/issues)
12
+
13
+ Contributing to protobuf\_spec:
14
+
15
+ 1. Fork the [official repository](https://github.com/connamara/protobuf_spec/tree/master).
16
+ 2. Make your changes in a topic branch.
17
+ 3. Send a pull request.
18
+
19
+ Notes:
20
+ * If you report a bug and don't include a fix, please include a failing test.
21
+ * Contributions without tests won't be accepted.
22
+ * Please don't update the Gem version
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "ruby_protobuf", "~> 0.4.11"
4
+ gem "json_spec", "~> 1.1.1"
5
+ gem "cuke_mem", "~> 0.1.1"
6
+
7
+
8
+ group :development do
9
+ gem "rspec", "~> 2.14"
10
+ gem "jeweler", "~> 1.8"
11
+ gem "cucumber", "~> 1.3"
12
+ gem "rake", "~> 10.1"
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,81 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.3.5)
5
+ builder (3.2.2)
6
+ cucumber (1.3.6)
7
+ builder (>= 2.1.2)
8
+ diff-lcs (>= 1.1.3)
9
+ gherkin (~> 2.12.0)
10
+ multi_json (~> 1.7.5)
11
+ multi_test (>= 0.0.2)
12
+ cuke_mem (0.1.1)
13
+ cucumber (~> 1.3)
14
+ diff-lcs (1.2.4)
15
+ faraday (0.8.8)
16
+ multipart-post (~> 1.2.0)
17
+ gherkin (2.12.1)
18
+ multi_json (~> 1.3)
19
+ git (1.2.6)
20
+ github_api (0.10.1)
21
+ addressable
22
+ faraday (~> 0.8.1)
23
+ hashie (>= 1.2)
24
+ multi_json (~> 1.4)
25
+ nokogiri (~> 1.5.2)
26
+ oauth2
27
+ hashie (2.0.5)
28
+ highline (1.6.19)
29
+ httpauth (0.2.0)
30
+ jeweler (1.8.7)
31
+ builder
32
+ bundler (~> 1.0)
33
+ git (>= 1.2.5)
34
+ github_api (= 0.10.1)
35
+ highline (>= 1.6.15)
36
+ nokogiri (= 1.5.10)
37
+ rake
38
+ rdoc
39
+ json (1.8.0)
40
+ json_spec (1.1.1)
41
+ multi_json (~> 1.0)
42
+ rspec (~> 2.0)
43
+ jwt (0.1.8)
44
+ multi_json (>= 1.5)
45
+ multi_json (1.7.9)
46
+ multi_test (0.0.2)
47
+ multi_xml (0.5.5)
48
+ multipart-post (1.2.0)
49
+ nokogiri (1.5.10)
50
+ oauth2 (0.9.2)
51
+ faraday (~> 0.8)
52
+ httpauth (~> 0.2)
53
+ jwt (~> 0.1.4)
54
+ multi_json (~> 1.0)
55
+ multi_xml (~> 0.5)
56
+ rack (~> 1.2)
57
+ rack (1.5.2)
58
+ rake (10.1.0)
59
+ rdoc (4.0.1)
60
+ json (~> 1.4)
61
+ rspec (2.14.1)
62
+ rspec-core (~> 2.14.0)
63
+ rspec-expectations (~> 2.14.0)
64
+ rspec-mocks (~> 2.14.0)
65
+ rspec-core (2.14.5)
66
+ rspec-expectations (2.14.2)
67
+ diff-lcs (>= 1.1.3, < 2.0)
68
+ rspec-mocks (2.14.3)
69
+ ruby_protobuf (0.4.11)
70
+
71
+ PLATFORMS
72
+ ruby
73
+
74
+ DEPENDENCIES
75
+ cucumber (~> 1.3)
76
+ cuke_mem (~> 0.1.1)
77
+ jeweler (~> 1.8)
78
+ json_spec (~> 1.1.1)
79
+ rake (~> 10.1)
80
+ rspec (~> 2.14)
81
+ ruby_protobuf (~> 0.4.11)
data/LICENSE.txt ADDED
@@ -0,0 +1,14 @@
1
+ Copyright (C) 2013 Connamara Systems, llc
2
+
3
+ This program is free software: you can redistribute it and/or modify
4
+ it under the terms of the GNU General Public License as published by
5
+ the Free Software Foundation, either version 3 of the License, or
6
+ (at your option) any later version.
7
+
8
+ This program is distributed in the hope that it will be useful,
9
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ GNU General Public License for more details.
12
+
13
+ You should have received a copy of the GNU General Public License
14
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
data/README.md ADDED
@@ -0,0 +1,165 @@
1
+ protobuf\_spec [![Build Status](https://travis-ci.org/connamara/protobuf_spec.png)](https://travis-ci.org/connamara/protobuf_spec)
2
+ =============
3
+
4
+ RSpec matchers and Cucumber step definitions for testing Protocol Buffers using [json_spec](https://github.com/collectiveidea/json_spec)
5
+
6
+ Usage
7
+ -----
8
+
9
+ ### RSpec
10
+
11
+ protobuf\_spec currently defines two matchers:
12
+
13
+ * ```be_protobuf_eql```
14
+ * ```have_protobuf_path```
15
+
16
+ The matchers can be used as their counterparts are used in json\_spec
17
+
18
+
19
+ ### Cucumber
20
+
21
+ protobuf\_spec provides cucumber steps that use its RSpec matchers.
22
+
23
+ In order to use the Cucumber steps, in your ```env.rb``` you must:
24
+
25
+ ```ruby
26
+ require "protobuf_spec/cucumber"
27
+ ```
28
+
29
+ You will need to load the ruby_protobuf generated classes you intend to test. This can be done by generating the classes into the cucumber ```support/``` directory, or requiring them manually.
30
+
31
+ #### "Should" Assertions
32
+
33
+ In order to test the contents of a Protocol Buffer, you will need to define a ```last_protobuf``` method. This method should return the protocol buffer to be tested by a protobuf_spec Cucumber step.
34
+
35
+ For example, suppose a step that aquires a Protocol Buffer and assigns it to ```@my_protocol_buffer```. In your ```features/support/env.rb``` you could then have
36
+
37
+ ```ruby
38
+ def last_protobuf
39
+ @my_protocol_buffer
40
+ end
41
+ ```
42
+
43
+ See ```features/support/env.rb``` for a very simple implementation.
44
+
45
+ Now you can use proto_spec steps in your features:
46
+
47
+
48
+ ```cucumber
49
+ Feature: Weather API
50
+ Background:
51
+ Given the weather is 58 degrees and cloudy in Chicago
52
+ And the weather is 72 degrees and sunny in Portland
53
+
54
+ Scenario: I can request the weather for a city
55
+ When I request weather for Portland
56
+ Then I should receive a ProtoBuf of type com.weather.WeatherResponse
57
+ And the ProtoBuf at "condition" should be "sunny"
58
+ And the ProtoBuf at "temperature" should be 72
59
+
60
+ When I request weather for Chicago
61
+ Then I should receive a ProtoBuf of type com.weather.WeatherResponse
62
+ And the ProtoBuf should be:
63
+ """
64
+ {
65
+ "condition":"sunny",
66
+ "temperature":58
67
+ }
68
+ """
69
+
70
+ Scenario: I can check if I need an umbrella
71
+ When I request the forecast for Chicago
72
+ Then I should receive a ProtoBuf of type com.weather.ForecastResponse
73
+ And the ProtoBuf should have "bring_umbrella"
74
+ And the ProtoBuf at "bring_umbrella" should be true
75
+ ```
76
+
77
+ The background and request/receive steps above aren't provided by protobuf_spec. The remaining steps protobuf_spec provides. See [json_spec documentation](https://github.com/collectiveidea/json_spec) for more examples
78
+
79
+ #### Building Protobufs
80
+
81
+ In order to use the Cucumber steps for building protocol buffers, in your ```env.rb``` you must:
82
+
83
+ ```ruby
84
+ require "protobuf_spec/builder"
85
+ ```
86
+ Now you can use proto_spec builder steps in your features:
87
+
88
+ ```cucumber
89
+ Feature: Weather Request API
90
+ Background:
91
+ Given the weather is 58 degrees and cloudy in Chicago
92
+ And the weather is 72 degrees and sunny in Portland
93
+
94
+ Scenario: I can request the weather for a city by protocol buffer
95
+ Given I create a ProtoBuf of type "com::weather::WeatherRequest"
96
+ And I set the ProtoBuf at "city" to "Portland"
97
+ And I set the ProtoBuf at "zipcode" to 97211
98
+ When I send the request
99
+ Then I should receive a ProtoBuf of type com::weather::WeatherResponse
100
+ And the ProtoBuf at "condition" should be "sunny"
101
+ And the ProtoBuf at "temperature" should be 72
102
+
103
+ Given I create the following protobuf of type "com::weather::WeatherRequest":
104
+ """
105
+ {
106
+ "city": "Chicago",
107
+ "zipcode": 60606
108
+ }
109
+ """
110
+ When I send the request
111
+ Then I should receive a ProtoBuf of type com::weather::WeatherResponse
112
+ And the ProtoBuf at "condition" should not be "sunny"
113
+ And the ProtoBuf at "temperature" should be 58
114
+ ```
115
+
116
+ The built protocol buffer can be accessed through the ```protobuf``` function in the ```ProtobufSpec::Builder``` module.
117
+
118
+ ### More
119
+
120
+ Check out [specs](https://github.com/connamara/protobuf_spec/blob/master/spec) and [features](https://github.com/connamara/protobuf_spec/blob/master/features) to see all the ways you can use protobuf_spec.
121
+
122
+ Install
123
+ -------
124
+
125
+ ```shell
126
+ gem install protobuf_spec
127
+ ```
128
+
129
+ or add the following to Gemfile:
130
+ ```ruby
131
+ gem 'protobuf_spec'
132
+ ```
133
+ and run `bundle install` from your shell.
134
+
135
+ More Information
136
+ ----------------
137
+
138
+ * [Rubygems](https://rubygems.org/gems/protobuf_spec)
139
+ * [Issues](https://github.com/connamara/protobuf_spec/issues)
140
+ * [Connamara Systems](http://connamara.com)
141
+
142
+ Contributing
143
+ ------------
144
+
145
+ Please see the [contribution guidelines](https://github.com/connamara/protobuf_spec/blob/master/CONTRIBUTION_GUIDELINES.md).
146
+
147
+ Credits
148
+ -------
149
+
150
+ Contributers:
151
+
152
+ * Chris Busbey
153
+
154
+ ![Connamara Systems](http://www.connamara.com/images/home-connamara-logo-lg.png)
155
+
156
+ protobuf_spec is maintained and funded by [Connamara Systems, llc](http://connamara.com).
157
+
158
+ The names and logos for Connamara Systems are trademarks of Connamara Systems, llc.
159
+
160
+ Licensing
161
+ ---------
162
+
163
+ protobuf_spec is Copyright © 2013 Connamara Systems, llc.
164
+
165
+ This software is available under the GPL and a commercial license. Please see the [LICENSE](https://github.com/connamara/protobuf_spec/blob/master/LICENSE.txt) file for the terms specified by the GPL license. The commercial license offers more flexible licensing terms compared to the GPL, and includes support services. [Contact us](mailto:info@connamara.com) for more information on the Connamara commercial license, what it enables, and how you can start developing with it.
data/Rakefile ADDED
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+
6
+ begin
7
+ Bundler.setup(:default, :development)
8
+ rescue Bundler::BundlerError => e
9
+ $stderr.puts e.message
10
+ $stderr.puts "Run `bundle install` to install missing gems"
11
+ exit e.status_code
12
+ end
13
+
14
+ require 'rspec/core/rake_task'
15
+ require 'cucumber/rake/task'
16
+
17
+ RSpec::Core::RakeTask.new(:spec)
18
+ Cucumber::Rake::Task.new(:cucumber)
19
+
20
+ task :test => [:spec, :cucumber]
21
+ task :default => :test
22
+
23
+ require 'jeweler'
24
+ Jeweler::Tasks.new do |gem|
25
+ gem.name = "protobuf_spec"
26
+ gem.homepage = "http://github.com/connamara/protobuf_spec"
27
+ gem.license = "GPL"
28
+ gem.summary = %Q{RSpec matchers and cucumber step defs for testing protocol buffers}
29
+ gem.description = %Q{Leverages json_spec to test structured protocol buffers with json data modeling}
30
+ gem.email = "info@connamara.com"
31
+ gem.authors = ["Chris Busbey"]
32
+ # dependencies defined in Gemfile
33
+ end
34
+
35
+ Jeweler::RubygemsDotOrgTasks.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.3.1
@@ -0,0 +1,34 @@
1
+ Feature: Building ProtoBufs
2
+ Scenario: I can create a blank protocol buffer
3
+ Given I create a ProtoBuf of type "Sample"
4
+ When I get the ProtoBuf
5
+ Then the ProtoBuf should not have "string_field"
6
+ Then the ProtoBuf should not have "int_field"
7
+ Then the ProtoBuf should not have "double_field"
8
+
9
+ Scenario: I can set values of the protocol buffer
10
+ Given I create a ProtoBuf of type "Sample"
11
+ And I set the ProtoBuf at "string_field" to "hello"
12
+ And I set the ProtoBuf at "int_field" to -5
13
+ And I set the ProtoBuf at "double_field" to 123.45
14
+ When I get the ProtoBuf
15
+ Then the ProtoBuf at "string_field" should be "hello"
16
+ And the ProtoBuf at "int_field" should be -5
17
+ And the ProtoBuf at "double_field" should be 123.45
18
+
19
+ Scenario: I can create a protobuf with a json description
20
+ Given I create the following ProtoBuf of type "Sample":
21
+ """
22
+ {
23
+ "string_field": "foo",
24
+ "int_field": 5,
25
+ "double_field": 50.23,
26
+ "int_field_2": -9
27
+ }
28
+ """
29
+
30
+ When I get the ProtoBuf
31
+ Then the ProtoBuf at "string_field" should be "foo"
32
+ And the ProtoBuf at "int_field" should be 5
33
+ And the ProtoBuf at "double_field" should be 50.23
34
+ And the ProtoBuf at "int_field_2" should be -9
@@ -0,0 +1,95 @@
1
+ Feature: Equivalence
2
+ Background:
3
+ Given I create the following ProtoBuf of type "Sample":
4
+ """
5
+ {
6
+ "string_field": "foo",
7
+ "int_field": 5,
8
+ "double_field": 50.23,
9
+ "int_field_2": -9,
10
+ "bool_field": true,
11
+ "bool_field_2": false
12
+ }
13
+ """
14
+
15
+ Scenario: Identical Protobuf
16
+ When I get the ProtoBuf
17
+ Then the Protobuf should be:
18
+ """
19
+ {
20
+ "string_field": "foo",
21
+ "int_field": 5,
22
+ "double_field": 50.23,
23
+ "int_field_2": -9,
24
+ "bool_field": true,
25
+ "bool_field_2": false
26
+ }
27
+ """
28
+
29
+ Scenario: String
30
+ When I get the ProtoBuf
31
+ Then the ProtoBuf at "string_field" should be "foo"
32
+ Then the protobuf at "string_field" should be:
33
+ """
34
+ "foo"
35
+ """
36
+ Then the ProtoBuf at "string_field" should not be "bar"
37
+
38
+ Scenario: Integer
39
+ When I get the ProtoBuf
40
+ Then the ProtoBuf at "int_field" should be 5
41
+ Then the ProtoBuf at "int_field" should not be 15
42
+
43
+
44
+ Scenario: Negative Integer
45
+ When I get the ProtoBuf
46
+ Then the ProtoBuf at "int_field_2" should be -9
47
+ Then the ProtoBuf at "int_field_2" should not be -19
48
+
49
+ Scenario: Double
50
+ When I get the ProtoBuf
51
+ Then the ProtoBuf at "double_field" should be 50.23
52
+ And the ProtoBuf at "double_field" should be 50.23e0
53
+ And the ProtoBuf at "double_field" should be 50.23e+0
54
+ And the ProtoBuf at "double_field" should be 50.23e-0
55
+ And the ProtoBuf at "double_field" should be 50.23e0
56
+ And the ProtoBuf at "double_field" should be 50.23e+0
57
+ And the ProtoBuf at "double_field" should be 50.23e-0
58
+ And the ProtoBuf at "double_field" should be 5.023e1
59
+ And the ProtoBuf at "double_field" should be 5.023e+1
60
+ And the ProtoBuf at "double_field" should be 502.3e-1
61
+ And the ProtoBuf at "double_field" should be:
62
+ """
63
+ 50.23
64
+ """
65
+
66
+ Then the ProtoBuf at "double_field" should not be -15.45
67
+
68
+ Scenario: True
69
+ When I get the ProtoBuf
70
+ Then the protobuf at "bool_field" should be true
71
+ Then the protobuf at "bool_field" should be:
72
+ """
73
+ true
74
+ """
75
+ Then the protobuf at "bool_field" should not be false
76
+
77
+ Scenario: False
78
+ When I get the ProtoBuf
79
+ Then the protobuf at "bool_field_2" should be false
80
+ Then the protobuf at "bool_field_2" should be:
81
+ """
82
+ false
83
+ """
84
+ Then the protobuf at "bool_field_2" should not be true
85
+
86
+ Scenario: Table format
87
+ When I get the ProtoBuf
88
+ Then the protobuf should have the following:
89
+ | string_field | "foo" |
90
+ | int_field | 5 |
91
+ | double_field | 50.23 |
92
+ | int_field_2 | -9 |
93
+ | bool_field | true |
94
+ | bool_field_2 | false |
95
+