[rspec-devel] [ rspec-Feature Requests-11834 ] Fake Controller Flash object

noreply at rubyforge.org noreply at rubyforge.org
Wed Jun 27 02:38:05 EDT 2007


Feature Requests item #11834, was opened at 2007-06-25 10:06
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3152&aid=11834&group_id=797

Category: rails plugin
Group: None
Status: Open
Priority: 3
Submitted By: Brian Takita (btakita)
Assigned to: Nobody (None)
Summary: Fake Controller Flash object

Initial Comment:
Currently it is difficult to test the values on Flash.now, because the Flash.sweep is called during the process action.

We made a Fake Flash Hash object that collects the flash content and does not sweep it when the request is processed.


----------------------------------------------------------------------

>Comment By: Brian Takita (btakita)
Date: 2007-06-26 23:38

Message:
Mainly, it was Nathan Wilmes who developed this. It is very
bare bones, and meant for primarily collecting value.

class MockFlashHash
  def initialize
    @hash = {}
    @now_hash = {}
  end

  def [](key)
    @hash[key]
  end

  def []=(key, obj)
    @hash[key] = obj
  end

  def discard(k = nil)
    initialize
  end

  def now
    @now_hash
  end

  def update(hash)
    @hash.update(hash)
  end

  def sweep
    # This is the key.  We don't really want flash.now's to
go away.
  end
end


----------------------------------------------------------------------

Comment By: Aslak Hellesøy (aslak_hellesoy)
Date: 2007-06-26 00:02

Message:
What does it look like?

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3152&aid=11834&group_id=797


More information about the rspec-devel mailing list