lib/pact/json_warning.rb in pact-0.1.35 vs lib/pact/json_warning.rb in pact-0.1.37

- old
+ new

@@ -2,10 +2,11 @@ require 'json/add/regexp' module Pact module JsonWarning def check_for_active_support_json + @already_warned ||= false # Active support clobbers the as_json methods defined in the json/add directory of the json gem. # These methods are required to serialize and deserialize the Regexp and Symbol classes properly. # You can potentially fix this by making sure the json gem is required AFTER the active_support/json gem # OR if you don't use the json part of activesupport you could only require the parts of active support you really need # OR you can only use strings in your pacts. @@ -13,11 +14,14 @@ # If someone knows how to make sure the pact gem uses the json gem as_json methods when activesupport/json is used in the calling code, # without breaking the calling code, which may depend on activesupport/json... then please fix this. # Note: we can probably do this in Ruby 2.0 with refinements, but for now, we're all stuck on 1.9 :( - unless Regexp.new('').as_json.is_a?(Hash) - Logger.new($stderr).warn("It appears you are using ActiveSupport json in your project. You are now in rubygems hell. Please see Pact::JsonWarning for more info.") + unless @already_warned + unless Regexp.new('').as_json.is_a?(Hash) + Logger.new($stderr).warn("It appears you are using ActiveSupport json in your project. You are now in rubygems hell. Please see Pact::JsonWarning for more info.") + @already_warned = true + end end end end end \ No newline at end of file