Class Index [+]

Quicksearch

Spec::Matchers::BePredicate

Public Class Methods

new(*args, &block) click to toggle source
     # File lib/spec/matchers/be.rb, line 121
121:       def initialize(*args, &block)
122:         @expected = parse_expected(args.shift)
123:         @args = args
124:         @block = block
125:       end

Public Instance Methods

description() click to toggle source
     # File lib/spec/matchers/be.rb, line 150
150:       def description
151:         "#{prefix_to_sentence}#{expected_to_sentence}#{args_to_sentence}"
152:       end
failure_message_for_should() click to toggle source
     # File lib/spec/matchers/be.rb, line 142
142:       def failure_message_for_should
143:         "expected #{predicate}#{args_to_s} to return true, got #{@result.inspect}"
144:       end
failure_message_for_should_not() click to toggle source
     # File lib/spec/matchers/be.rb, line 146
146:       def failure_message_for_should_not
147:         "expected #{predicate}#{args_to_s} to return false, got #{@result.inspect}"
148:       end
matches?(actual) click to toggle source
     # File lib/spec/matchers/be.rb, line 127
127:       def matches?(actual)
128:         @actual = actual
129:         begin
130:           return @result = actual.__send__(predicate, *@args, &@block)
131:         rescue NameError => predicate_missing_error
132:           "this needs to be here or rcov will not count this branch even though it's executed in a code example"
133:         end
134: 
135:         begin
136:           return @result = actual.__send__(present_tense_predicate, *@args, &@block)
137:         rescue NameError
138:           raise predicate_missing_error
139:         end
140:       end

Private Instance Methods

parse_expected(expected) click to toggle source
     # File lib/spec/matchers/be.rb, line 164
164:       def parse_expected(expected)
165:         @prefix, expected = prefix_and_expected(expected)
166:         expected
167:       end
predicate() click to toggle source
     # File lib/spec/matchers/be.rb, line 156
156:       def predicate
157:         "#{@expected}?".to_sym
158:       end
prefix_and_expected(symbol) click to toggle source
     # File lib/spec/matchers/be.rb, line 169
169:       def prefix_and_expected(symbol)
170:         symbol.to_s =~ /^(be_(an?_)?)(.*)/
171:         return $1, $3
172:       end
prefix_to_sentence() click to toggle source
     # File lib/spec/matchers/be.rb, line 174
174:       def prefix_to_sentence
175:         split_words(@prefix)
176:       end
present_tense_predicate() click to toggle source
     # File lib/spec/matchers/be.rb, line 160
160:       def present_tense_predicate
161:         "#{@expected}s?".to_sym
162:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.