Sha256: 43193aea64fb36a91702b7905ff4626182b0e12798287471082177d924697914
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
Contents
module RSpec::RubyContentMatchers class HaveCalls < RSpec::RubyContentMatcher attr_reader :calls, :method, :args def initialize(calls) @calls = calls end def matches?(content) super calls.each_pair do |method, args| @method = method.to_s @args = args return false if (content =~ /#{method}\s+#{args_expr}/m) == nil end true end def failure_message super return "Expected there to be a call to #{method} with args #{args}, but there wasn't" if args "Expected there to be a call to #{method}, but there wasn't" end def negative_failure_message super return "Did not expect there to be a call to #{method} with args #{args}, but there was" if args "Did not expect there to be a call to #{method}, but there was" end protected def args_expr args ? "(\()?\s*#{args}\s*(\))?" : '' end end def have_calls(calls) HaveCalls.new(calls) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
generator-spec-0.4.5 | lib/generator_spec/matchers/content/have_calls.rb |
generator-spec-0.4.4 | lib/generator_spec/matchers/content/have_calls.rb |