class Shoulda::ActionController::Matchers::AssignToMatcher

:nodoc:

def assigned_value

def assigned_value
  assigns[@variable]
end

def assigned_value?

def assigned_value?
  if assigned_value.nil?
    @failure_message =
      "Expected action to assign a value for @#{@variable}"
    false
  else
    @negative_failure_message = 
      "Didn't expect action to assign a value for @#{@variable}, " <<
      "but it was assigned to #{assigned_value.inspect}"
    true
  end
end

def assigns

def assigns
  @controller.response.template.assigns 
end

def description

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

def equal_to_expected_value?

def equal_to_expected_value?
  return true unless @expected_value
  if @expected_value == assigned_value
    @negative_failure_message =
      "Didn't expect action to assign #{@expected_value.inspect} " <<
      "for #{@variable}, but got it anyway"
    true
  else
    @failure_message =
      "Expected action to assign #{@expected_value.inspect} " <<
      "for #{@variable}, but got #{assigned_value.inspect}"
    false
  end
end

def initialize(variable)

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

def kind_of_expected_class?

def kind_of_expected_class?
  return true unless @expected_class
  if assigned_value.kind_of?(@expected_class)
    @negative_failure_message =
      "Didn't expect action to assign a kind of #{@expected_class} " <<
      "for #{@variable}, but got one anyway"
    true
  else
    @failure_message =
      "Expected action to assign a kind of #{@expected_class} " <<
      "for #{@variable}, but got #{@variable.inspect} " <<
      "(#{@variable.class.name})"
    false
  end
end

def matches?(controller)

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

def with(expected_value)

def with(expected_value)
  @expected_value = expected_value
  self
end

def with_kind_of(expected_class)

def with_kind_of(expected_class)
  @expected_class = expected_class
  self
end