Class: Remarkable::ActiveRecord::Matchers::HaveNamedScope

Inherits:
Matcher::Base
  • Object
show all
Defined in:
lib/remarkable/active_record/macros/validations/have_named_scope_matcher.rb

Instance Method Summary collapse

Methods inherited from Matcher::Base

#negative, #spec

Methods included from Matcher::DSL

included

Constructor Details

#initialize(scope_call, *args) ⇒ HaveNamedScope

Returns a new instance of HaveNamedScope.



5
6
7
8
9
# File 'lib/remarkable/active_record/macros/validations/have_named_scope_matcher.rb', line 5

def initialize(scope_call, *args)
  @scope_opts = args.extract_options!
  @scope_call = scope_call.to_s
  @args       = args
end

Instance Method Details

#descriptionObject



20
21
22
# File 'lib/remarkable/active_record/macros/validations/have_named_scope_matcher.rb', line 20

def description
  "have to scope itself to #{@scope_opts.inspect} when #{@scope_call} is called"
end

#failure_messageObject



24
25
26
# File 'lib/remarkable/active_record/macros/validations/have_named_scope_matcher.rb', line 24

def failure_message
  "Expected #{expectation} (#{@missing})"
end

#matches?(subject) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
# File 'lib/remarkable/active_record/macros/validations/have_named_scope_matcher.rb', line 11

def matches?(subject)
  @subject = subject

  assert_matcher do
    @scope = eval("#{subject_class}.#{@scope_call}")
    return_scope_object? && scope_itself_to_options?
  end
end

#negative_failure_messageObject



28
29
30
# File 'lib/remarkable/active_record/macros/validations/have_named_scope_matcher.rb', line 28

def negative_failure_message
  "Did not expect #{expectation}"
end