Parent

Class Index [+]

Quicksearch

RSpec::Matchers::BuiltIn::YieldWithArgs

Public Class Methods

new(*args) click to toggle source
     # File lib/rspec/matchers/built_in/yield.rb, line 112
112:         def initialize(*args)
113:           @expected = args
114:         end

Public Instance Methods

description() click to toggle source
     # File lib/rspec/matchers/built_in/yield.rb, line 130
130:         def description
131:           desc = "yield with args"
132:           desc << "(" + @expected.map { |e| e.inspect }.join(", ") + ")" if @expected.any?
133:           desc
134:         end
failure_message_for_should() click to toggle source
     # File lib/rspec/matchers/built_in/yield.rb, line 122
122:         def failure_message_for_should
123:           "expected given block to yield with arguments, but #{positive_failure_reason}"
124:         end
failure_message_for_should_not() click to toggle source
     # File lib/rspec/matchers/built_in/yield.rb, line 126
126:         def failure_message_for_should_not
127:           "expected given block not to yield with arguments, but #{negative_failure_reason}"
128:         end
matches?(block) click to toggle source
     # File lib/rspec/matchers/built_in/yield.rb, line 116
116:         def matches?(block)
117:           @probe = YieldProbe.probe(block)
118:           @actual = @probe.single_yield_args
119:           @probe.yielded_once?(:yield_with_args) && args_match?
120:         end

Private Instance Methods

all_args_match?() click to toggle source
     # File lib/rspec/matchers/built_in/yield.rb, line 171
171:         def all_args_match?
172:           return false if @expected.size != @actual.size
173: 
174:           @expected.zip(@actual).all? do |expected, actual|
175:             expected === actual || actual == expected
176:           end
177:         end
args_match?() click to toggle source
     # File lib/rspec/matchers/built_in/yield.rb, line 156
156:         def args_match?
157:           if @expected.none? # expect {...}.to yield_with_args
158:             @positive_args_failure = "yielded with no arguments" if @actual.none?
159:             return @actual.any?
160:           end
161: 
162:           unless match = all_args_match?
163:             @positive_args_failure = "yielded with unexpected arguments" +
164:               "\nexpected: #{@expected.inspect}" +
165:               "\n     got: #{@actual.inspect} (compared using === and ==)"
166:           end
167: 
168:           match
169:         end
negative_failure_reason() click to toggle source
     # File lib/rspec/matchers/built_in/yield.rb, line 146
146:         def negative_failure_reason
147:           if all_args_match?
148:             "yielded with expected arguments" +
149:               "\nexpected not: #{@expected.inspect}" +
150:               "\n         got: #{@actual.inspect} (compared using === and ==)"
151:           else
152:             "did"
153:           end
154:         end
positive_failure_reason() click to toggle source
     # File lib/rspec/matchers/built_in/yield.rb, line 138
138:         def positive_failure_reason
139:           if @probe.num_yields.zero?
140:             "did not yield"
141:           else
142:             @positive_args_failure
143:           end
144:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.