Class: Shoulda::ActiveRecord::Matchers::HaveNamedScopeMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/shoulda/active_record/matchers/have_named_scope_matcher.rb

Overview

:nodoc:

Instance Method Summary collapse

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

#descriptionObject



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_messageObject



70
71
72
# File 'lib/shoulda/active_record/matchers/have_named_scope_matcher.rb', line 70

def failure_message
  "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

Returns:

  • (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_messageObject



74
75
76
# File 'lib/shoulda/active_record/matchers/have_named_scope_matcher.rb', line 74

def negative_failure_message
  "Didn't expect a named scope for #{@scope_call}"
end