lib/acfs/stub.rb in acfs-0.23.2 vs lib/acfs/stub.rb in acfs-0.24.0.b210

- old
+ new

@@ -9,20 +9,23 @@ attr_reader :opts def initialize(opts) @opts = opts - @opts[:with].stringify_keys! if @opts[:with].respond_to? :stringify_keys + + @opts[:with].stringify_keys! if @opts[:with].is_a? Hash + @opts[:return].stringify_keys! if @opts[:return].is_a? Hash + @opts[:return].map! { |h| h.stringify_keys! if h.is_a? Hash } if @opts[:return].is_a? Array end def accept?(op) return opts[:with].call op if opts[:with].respond_to? :call params = op.full_params.stringify_keys data = op.data.stringify_keys - opts[:with] == params || data == opts[:with] + opts[:with] == params || data == opts[:with] || (opts[:with].nil? && params.empty? && data.empty?) end def calls @calls ||= [] end @@ -36,10 +39,10 @@ calls << op if (err = opts[:raise]) raise_error op, err, opts[:return] elsif (data = opts[:return]) - op.callback.call data + op.call data else raise ArgumentError, 'Unsupported stub.' end end