class RSpec::ActiveJob::Matchers::GlobalID
Public Class Methods
new(expected)
click to toggle source
# File lib/rspec/active_job/global_id.rb, line 7 def initialize(expected) unless valid_expected?(expected) raise "expected argument must implement to_global_id" end @expected = expected end
Public Instance Methods
===(other)
click to toggle source
# File lib/rspec/active_job/global_id.rb, line 15 def ===(other) other.is_a?(Hash) && other.keys == ['_aj_globalid'] && global_id_matches?(other['_aj_globalid']) end
description()
click to toggle source
# File lib/rspec/active_job/global_id.rb, line 21 def description "serialized global ID of #{@expected}" unless @expected.is_a?(Class) "serialized global ID of #{@expected.name}" end
Private Instance Methods
correct_class?(other)
click to toggle source
# File lib/rspec/active_job/global_id.rb, line 40 def correct_class?(other) other.app == ::GlobalID.app && other.model_class == @expected end
global_id_matches?(other)
click to toggle source
# File lib/rspec/active_job/global_id.rb, line 33 def global_id_matches?(other) parsed = ::GlobalID.parse(other) return false unless parsed return correct_class?(parsed) if @expected.is_a?(Class) other == @expected.to_global_id.to_s end
valid_expected?(expected)
click to toggle source
# File lib/rspec/active_job/global_id.rb, line 28 def valid_expected?(expected) return expected.instance_method(:to_global_id) if expected.is_a?(Class) expected.respond_to?(:to_global_id) end