Sha256: eef63357bb10cbd3ea66902a54676f5c4c51bd2d137f98dadc1450a9bbd0f63e
Contents?: true
Size: 959 Bytes
Versions: 3
Compression:
Stored size: 959 Bytes
Contents
module Bogus class Interaction < Struct.new(:method, :args, :return_value, :error, :has_result) def initialize(method, args, &block) self.method = method self.args = args if block_given? evaluate_return_value(block) self.has_result = true end end def ==(other) method == other.method && same_args?(other) && same_result?(other) end def any_args? args == [AnyArgs] end private def same_args?(other) return true if any_args? || other.any_args? return false unless args.size == other.args.size args.zip(other.args).all?{|a1, a2| a1 == a2 || a2 == a1} end def same_result?(other) return true unless has_result && other.has_result return_value == other.return_value && error == other.error end def evaluate_return_value(block) self.return_value = block.call rescue => e self.error = e.class end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bogus-0.0.3 | lib/bogus/interaction.rb |
bogus-0.0.3.rc.2 | lib/bogus/interaction.rb |
bogus-0.0.3.rc.1 | lib/bogus/interaction.rb |