Sha256: 260c158b681a47704091580580636b1b76a8722767165d8078042af76cec08eb
Contents?: true
Size: 1.45 KB
Versions: 1
Compression:
Stored size: 1.45 KB
Contents
require 'cuke_mem' module ProtobufSpec module Builder def self.protobuf @protobuf end def self.protobuf= protobuf @protobuf=protobuf end end end Given /^I create a (?:ProtoBuf|Protobuf|protobuf) of type "([^"]*)"$/ do |proto_type| ProtobufSpec::Builder.protobuf = eval("#{proto_type}.new") end Given /^I set the (?:ProtoBuf|Protobuf|protobuf) at "([^"]*)" to "([^"]*)"$/ do |field, val| ProtobufSpec::Builder.protobuf.send("#{field}=".to_sym, val) end Given /^I set the (?:ProtoBuf|Protobuf|protobuf) at "([^"]*)" to (-?\d+)$/ do |field, val| ProtobufSpec::Builder.protobuf.send("#{field}=".to_sym, val.to_i) end Given /^I set the (?:ProtoBuf|Protobuf|protobuf) at "([^"]*)" to (-?\d+\.\d+)$/ do |field, val| ProtobufSpec::Builder.protobuf.send("#{field}=".to_sym, val.to_f) end Given /^I create the following (?:ProtoBuf|Protobuf|protobuf) of type "([^"]*)":$/ do |proto_type, proto_as_json| steps %{Given I create a ProtoBuf of type "#{proto_type}"} json = JSON.parse proto_as_json ProtobufSpec::Builder.protobuf.fields.each_value do |field| field_name = field.name.to_s ProtobufSpec::Builder.protobuf[field_name] = json[field_name] if json.has_key? field_name end end When /^I deserialize a (?:ProtoBuf|Protobuf|protobuf) of type "([^"]*)" from "([^"]*)"$/ do |proto_type, serial| steps %{Given I create a ProtoBuf of type "#{proto_type}"} ProtobufSpec::Builder.protobuf.parse_from_string CukeMem.remember(serial) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
protobuf_spec-0.3.1 | lib/protobuf_spec/builder.rb |