Class: Shoulda::ActiveRecord::Matchers::HaveNamedScopeMatcher
- Inherits:
-
Object
- Object
- Shoulda::ActiveRecord::Matchers::HaveNamedScopeMatcher
- Defined in:
- lib/shoulda/active_record/matchers/have_named_scope_matcher.rb
Overview
:nodoc:
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #finding(finding) ⇒ Object
- #in_context(context) ⇒ Object
-
#initialize(scope_call) ⇒ HaveNamedScopeMatcher
constructor
A new instance of HaveNamedScopeMatcher.
- #matches?(subject) ⇒ Boolean
- #negative_failure_message ⇒ Object
Constructor Details
#initialize(scope_call) ⇒ HaveNamedScopeMatcher
Returns a new instance of HaveNamedScopeMatcher.
54 55 56 |
# File 'lib/shoulda/active_record/matchers/have_named_scope_matcher.rb', line 54 def initialize(scope_call) @scope_call = scope_call.to_s end |
Instance Method Details
#description ⇒ Object
81 82 83 84 85 |
# File 'lib/shoulda/active_record/matchers/have_named_scope_matcher.rb', line 81 def description result = "have a named scope for #{@scope_call}" result << " finding #{@finding.inspect}" unless @finding.nil? result end |
#failure_message ⇒ Object
73 74 75 |
# File 'lib/shoulda/active_record/matchers/have_named_scope_matcher.rb', line 73 def "Expected #{@missing_expectation}" end |
#finding(finding) ⇒ Object
58 59 60 61 |
# File 'lib/shoulda/active_record/matchers/have_named_scope_matcher.rb', line 58 def finding(finding) @finding = finding self end |
#in_context(context) ⇒ Object
63 64 65 66 |
# File 'lib/shoulda/active_record/matchers/have_named_scope_matcher.rb', line 63 def in_context(context) @context = context self end |
#matches?(subject) ⇒ Boolean
68 69 70 71 |
# File 'lib/shoulda/active_record/matchers/have_named_scope_matcher.rb', line 68 def matches?(subject) @subject = subject call_succeeds? && returns_scope? && finds_correct_scope? end |
#negative_failure_message ⇒ Object
77 78 79 |
# File 'lib/shoulda/active_record/matchers/have_named_scope_matcher.rb', line 77 def "Didn't expect a named scope for #{@scope_call}" end |