File: call_record.rb

package info (click to toggle)
ruby-flexmock 3.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 836 kB
  • sloc: ruby: 7,572; makefile: 6
file content (35 lines) | stat: -rw-r--r-- 859 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env ruby

#---
# Copyright 2003-2013 by Jim Weirich (jim.weirich@gmail.com).
# All rights reserved.
#
# Permission is granted for use, copying, modification, distribution,
# and distribution of modified versions of this work as long as the
# above copyright notice is included.
#+++

class FlexMock

  CallRecord = Struct.new(:method_name, :args, :kw, :block, :expectation) do
    def matches?(sym, expected_args, expected_kw, options)
      method_name == sym &&
        ArgumentMatching.all_match_args?(expected_args, args) &&
        ArgumentMatching.all_match_kw?(expected_kw, kw) &&
        matches_block?(options[:with_block])
    end

    private

    def matches_block?(block_option)
      block_option.nil? ||
        (block_option && block) ||
        (!block_option && !block)
    end

    def block_given
      block
    end
  end

end