Class: Mongoid::Matchers::BeStoredIn

Inherits:
Object
  • Object
show all
Defined in:
lib/matchers/be_stored_in.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ BeStoredIn

Returns a new instance of BeStoredIn.



8
9
10
# File 'lib/matchers/be_stored_in.rb', line 8

def initialize(expected)
  @expected_options = expected.transform_values { |v| v.to_sym rescue v }.symbolize_keys
end

Instance Method Details

#descriptionObject



17
18
19
# File 'lib/matchers/be_stored_in.rb', line 17

def description
  "be stored in #{@expected_options.inspect}"
end

#failure_messageObject



21
22
23
# File 'lib/matchers/be_stored_in.rb', line 21

def failure_message
  "Expected #{@model.inspect} to #{description}, got #{actual_options.inspect}"
end

#failure_message_when_negatedObject



25
26
27
# File 'lib/matchers/be_stored_in.rb', line 25

def failure_message_when_negated
  "Expected #{@model.inspect} not to #{description}, got #{actual_options.inspect}"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
# File 'lib/matchers/be_stored_in.rb', line 12

def matches?(actual)
  @model = actual.is_a?(Class) ? actual : actual.class
  actual_options == @expected_options
end