Sha256: 8cb4fbe3c4687a60a43c8100edda126372682bb9849591983d0e906f79d998e0
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 KB
Contents
require 'spec_helper' require 'pact/consumer_contract/active_support_support' module Pact describe ActiveSupportSupport do include ActiveSupportSupport describe "fix_regexp" do let(:regexp) { /moose/ } subject { fix_regexp regexp } it "returns the original regexp" do expect(subject).to be(regexp) end it "fixes the as_json method for Regexp that ActiveSupport tramples beneath its destructive hooves of destruction" do expect(subject.to_json).to eq("{\"json_class\":\"Regexp\",\"o\":0,\"s\":\"moose\"}") end end describe "fix_all_the_things" do let(:hash) do { 'body' => Pact::Term.new(matcher: /a*b/, generate: 'abba'), array: [/blah/], thing: /alligator/ } end subject { fix_all_the_things(hash) } it "returns the original object" do expect(subject).to be(hash) end it "finds all the Regexp objects in hashes or Pact class attributes and fixes the as_json method" do json = subject.to_json expect(json).to include("{\"json_class\":\"Regexp\",\"o\":0,\"s\":\"a*b\"}") expect(json).to include("{\"json_class\":\"Regexp\",\"o\":0,\"s\":\"blah\"}") expect(json).to include("{\"json_class\":\"Regexp\",\"o\":0,\"s\":\"alligator\"}") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pact-1.0.19 | spec/lib/pact/consumer_contract/active_support_support_spec.rb |
pact-1.0.18 | spec/lib/pact/consumer_contract/active_support_support_spec.rb |