On Sun, Jul 8, 2012 at 5:05 PM, Tsvetelina Borisova
<[email protected]> wrote:
> Hello, I have this situation: I have one controller - Notifier that puts
> message in session[:message] and I have other controller - SendQueues that
> uses this value in session[:message] and gives it to a method of a class.
> Now I don't know how to test that the controller - SendQueues gives to the
> class the value of the session[;message] and not other value. Can you give
> me an advice? Thanks in advance :)

The fact that NotfierController sets the message is not relevant to an
isolated example of the behavior of SendQueuesController. In a
controller spec, you have access to the session before the the action
is invoked, so:

describe SendQueuesController do
  describe "GET #some_action" do
    it "passes session[:message] to SomeClass" do
      session[:message] = "session message"
      SomeClass.should_receive(:some_message).with("session message")
      get :some_action
    end
  end
end

HTH,
David

PS - it's generally better to post code snippets than describe the
code. My response is filled with assumptions that may or may not be
correct, and working against a code snippet would reduce the amount of
guessing.

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rspec?hl=en.

Reply via email to