Class Index [+]

Quicksearch

RSpec::Matchers::BuiltIn::BePredicate

Public Class Methods

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

Public Instance Methods

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

Private Instance Methods

parse_expected(expected) click to toggle source
     # File lib/rspec/matchers/built_in/be.rb, line 166
166:         def parse_expected(expected)
167:           @prefix, expected = prefix_and_expected(expected)
168:           expected
169:         end
predicate() click to toggle source
     # File lib/rspec/matchers/built_in/be.rb, line 158
158:         def predicate
159:           "#{@expected}?".to_sym
160:         end
prefix_and_expected(symbol) click to toggle source
     # File lib/rspec/matchers/built_in/be.rb, line 171
171:         def prefix_and_expected(symbol)
172:           symbol.to_s =~ /^(be_(an?_)?)(.*)/
173:           return $1, $3
174:         end
prefix_to_sentence() click to toggle source
     # File lib/rspec/matchers/built_in/be.rb, line 176
176:         def prefix_to_sentence
177:           split_words(@prefix)
178:         end
present_tense_predicate() click to toggle source
     # File lib/rspec/matchers/built_in/be.rb, line 162
162:         def present_tense_predicate
163:           "#{@expected}s?".to_sym
164:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.