Class: Shoulda::ActionController::Matchers::AssignToMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/shoulda/action_controller/matchers/assign_to_matcher.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(variable) ⇒ AssignToMatcher

Returns a new instance of AssignToMatcher.



24
25
26
# File 'lib/shoulda/action_controller/matchers/assign_to_matcher.rb', line 24

def initialize(variable)
  @variable = variable.to_s
end

Instance Attribute Details

#failure_messageObject (readonly)

Returns the value of attribute failure_message.



43
44
45
# File 'lib/shoulda/action_controller/matchers/assign_to_matcher.rb', line 43

def failure_message
  @failure_message
end

#negative_failure_messageObject (readonly)

Returns the value of attribute negative_failure_message.



43
44
45
# File 'lib/shoulda/action_controller/matchers/assign_to_matcher.rb', line 43

def negative_failure_message
  @negative_failure_message
end

Instance Method Details

#descriptionObject



45
46
47
48
49
# File 'lib/shoulda/action_controller/matchers/assign_to_matcher.rb', line 45

def description
  description = "assign @#{@variable}"
  description << " with a kind of #{@expected_class}" if @expected_class
  description
end

#matches?(controller) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
41
# File 'lib/shoulda/action_controller/matchers/assign_to_matcher.rb', line 38

def matches?(controller)
  @controller = controller
  assigned_value? && kind_of_expected_class? && equal_to_expected_value?
end

#with(expected_value) ⇒ Object



33
34
35
36
# File 'lib/shoulda/action_controller/matchers/assign_to_matcher.rb', line 33

def with(expected_value)
  @expected_value = expected_value
  self
end

#with_kind_of(expected_class) ⇒ Object



28
29
30
31
# File 'lib/shoulda/action_controller/matchers/assign_to_matcher.rb', line 28

def with_kind_of(expected_class)
  @expected_class = expected_class
  self
end