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.



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

#descriptionObject



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_messageObject



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

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

Returns:

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



77
78
79
# File 'lib/shoulda/active_record/matchers/have_named_scope_matcher.rb', line 77

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