In all of my controller specs I have tests that look something like this.

it "should require login" do
  get :edit, :id => '7'
  response.should redirect_to(new_session_path)
end

I'd like to move this to a shared example, but the request call (get() or 
post()) varies with each example. Is there a good way to tell the shared 
example how to request the page?

I thought about doing something like this

describe "whatever" do
  def request_page
    get :edit, :id => '7'
  end

  # use shared example
end

then in the shared example I would call request_page() instead. Although this 
is slightly more DRY it isn't saving me any lines of code and it feels like 
there could be a better way. Another idea I had was to make a helper function 
that returns a Proc (basically I'm faking currying) and I could bind that Proc 
to something like @request_proc and then run the proc in the shared example. 

Anyone have any better ideas?

Jay




      
____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to