RSpec Post/Get and Sessions in a Story

I've got an RSpec story that reads like:

Ben Men wrote:

1. Can I do get/post within a story, and if so, how? I've seen examples of get/posts in stories, but everything I've tried comes back with "get" or "post as an undefined method.

Are get/post methods defined inside your controller or are you thinking of the httpd verbs here? These are two very different things. Your default controller actions are:

  def index   def show   def new   def edit   def create   def update   def destroy

2. Is there any way to get to the session directly within an RSpec story?

Your session is accessible via the params hash. The question is: what form of login authentication are you using and how is it represented in parans?

The params thing should do it for the session variable. All that's happening to check whether a user is logged in or not is to see if the session['username'] has a value. Currently it's doing authentication via our Windows domain.

Are get/post methods defined inside your controller or are you thinking of the httpd verbs here? These are two very different things. Your default controller actions are:

I'm not testing the controller directly in this situation - I've done that within an RSpec spec. What I'm attempting to do is request a page from our RSpec story. According to http://tomtenthij.co.uk/2008/1/25/rspec-plain-text-story-runner-on-a-fresh-rails-app , I should be able to call "post" within our story without specifying the method in a controller context. That being said, I have absolutely no idea what object post or get is being called on within the example I've linked to.

Are you aware of another way to request a page? For example, my first instinct is to call "get '/posts/1/'" when considering the story line "When I visit the post details page", and this does not work.

Ben Men wrote:

The params thing should do it for the session variable. All that's happening to check whether a user is logged in or not is to see if the session['username'] has a value. Currently it's doing authentication via our Windows domain.

Are get/post methods defined inside your controller or are you thinking of the httpd verbs here? These are two very different things. Your default controller actions are:

I'm not testing the controller directly in this situation - I've done that within an RSpec spec. What I'm attempting to do is request a page from our RSpec story. According to http://tomtenthij.co.uk/2008/1/25/rspec-plain-text-story-runner-on-a-fresh-rails-app , I should be able to call "post" within our story without specifying the method in a controller context. That being said, I have absolutely no idea what object post or get is being called on within the example I've linked to.

Are you aware of another way to request a page? For example, my first instinct is to call "get '/posts/1/'" when considering the story line "When I visit the post details page", and this does not work.

I've solved this by doing a complete overview of the differences between the example code in that article and my code. It seems I missed defining the type of story to run. In the story itself, it needs to have:

with_steps_for(:login) do   run_local_story "login_story", :type => RailsStory end

This RailsStory thing isn't in much of the sample RSpec code I've run across, but by defining the type, you gain access to some Rails commands like get and post.

Yes, and keep in mind that RailsStory stories use the integration testing support from Rails, which is slightly different from the functional testing support used in controller specs, so you want to post/get.. a path rather than an action.

You might also want to consider the rspec specific mailing list http://rubyforge.org/mailman/listinfo/rspec-users