Testing a sessions decorator lib in ruby on rails with rspec -


I included this code in lib / user_session.rb

by one of its controllers UserSession has been

How can I test it? I've added tests to spec / lib / user_session.rb but this code is dependent on session which I'm not sure how to mock.

  View the module user session DR session [: viewed] | | = Array.new return session [seen] End DR view_add (id, name) is seen if. Selection {| B B [: id] == id}. Empty? Session [: Viewed] & lt; & Lt; {: Id = & gt; ID ,: name = & gt; Name} end return session [: watched] end def views_delete (id) id.nil? Session [: see] .delete_if {| B. B [: ID] == ID} returns session [: viewed] end and end  

< At P> session you need to duplicate or stumble the operator. For example, in your imagination, you can:

  session.stub! (: []). And_written "foo"  

or

  session.should_receive (: []). With ((seen))  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -