lib/rspec/iso8601.rb in rspec-iso8601-0.1.0 vs lib/rspec/iso8601.rb in rspec-iso8601-0.2.0

- old
+ new

@@ -10,18 +10,24 @@ return false unless actual.is_a?(String) matches = actual.match(RSpec::ISO8601::REGEXP) precision ||= @precision - matches && (precision.nil? || (matches[:usec]&.length || 0) == precision) + matches && + (precision.nil? || (matches[:usec]&.length || 0) == precision) && + (@utc != true || matches[:offset] == "Z") end description do - "be an ISO8601 string#{" with precision #{precision}" unless precision.nil?}" + "be an ISO8601#{" UTC" if @utc} string#{" with precision #{precision}" unless precision.nil?}" end chain :with_precision do |digits| @precision = digits + end + + chain :in_utc do + @utc = true end end RSpec::Matchers.alias_matcher :an_iso8601_string, :be_an_iso8601_string