Class: RSpec::Matchers::BuiltIn::Has
- Inherits:
-
Object
- Object
- RSpec::Matchers::BuiltIn::Has
- Includes:
- MatchAliases
- Defined in:
- lib/rspec/matchers/built_in/has.rb
Instance Method Summary (collapse)
- - (Object) description
- - (Object) failure_message_for_should
- - (Object) failure_message_for_should_not
-
- (Has) initialize(expected, *args)
constructor
A new instance of Has.
- - (Boolean) is_private_on?(actual)
- - (Boolean) matches?(actual)
Methods included from MatchAliases
Constructor Details
- (Has) initialize(expected, *args)
A new instance of Has
7 8 9 |
# File 'lib/rspec/matchers/built_in/has.rb', line 7 def initialize(expected, *args) @expected, @args = expected, args end |
Instance Method Details
- (Object) description
32 33 34 |
# File 'lib/rspec/matchers/built_in/has.rb', line 32 def description [method_description(@expected), args_description].compact.join(' ') end |
- (Object) failure_message_for_should
24 25 26 |
# File 'lib/rspec/matchers/built_in/has.rb', line 24 def "expected ##{predicate}#{} to return true, got false" end |
- (Object) failure_message_for_should_not
28 29 30 |
# File 'lib/rspec/matchers/built_in/has.rb', line 28 def "expected ##{predicate}#{} to return false, got true" end |
- (Boolean) is_private_on?(actual)
45 46 47 |
# File 'lib/rspec/matchers/built_in/has.rb', line 45 def is_private_on? actual actual.private_methods.include? predicate.to_s end |
- (Boolean) matches?(actual)
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rspec/matchers/built_in/has.rb', line 11 def matches?(actual) method = predicate if is_private_on?(actual) RSpec.deprecate "matching with #{@expected} on private method #{predicate}", :replacement => "`expect(object.send(#{predicate.inspect})).to be_true` or change the method's visibility to public" end result = actual.__send__(method, *@args) check_respond_to(actual, method) result end |