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.
51 52 53 |
# File 'lib/shoulda/active_record/matchers/have_named_scope_matcher.rb', line 51 def initialize(scope_call) @scope_call = scope_call.to_s end |
Instance Method Details
#description ⇒ Object
78 79 80 81 82 |
# File 'lib/shoulda/active_record/matchers/have_named_scope_matcher.rb', line 78 def description result = "have a named scope for #{@scope_call}" result << " finding #{@finding.inspect}" unless @finding.nil? result end |
#failure_message ⇒ Object
70 71 72 |
# File 'lib/shoulda/active_record/matchers/have_named_scope_matcher.rb', line 70 def "Expected #{@missing_expectation}" end |
#finding(finding) ⇒ Object
55 56 57 58 |
# File 'lib/shoulda/active_record/matchers/have_named_scope_matcher.rb', line 55 def finding(finding) @finding = finding self end |
#in_context(context) ⇒ Object
60 61 62 63 |
# File 'lib/shoulda/active_record/matchers/have_named_scope_matcher.rb', line 60 def in_context(context) @context = context self end |
#matches?(subject) ⇒ Boolean
65 66 67 68 |
# File 'lib/shoulda/active_record/matchers/have_named_scope_matcher.rb', line 65 def matches?(subject) @subject = subject call_succeeds? && returns_scope? && finds_correct_scope? end |
#negative_failure_message ⇒ Object
74 75 76 |
# File 'lib/shoulda/active_record/matchers/have_named_scope_matcher.rb', line 74 def "Didn't expect a named scope for #{@scope_call}" end |