Guest User

Untitled

a guest
Jun 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. require File.dirname(__FILE__) + '/../spec_helper'
  2.  
  3. describe PostsController do
  4. fixtures :posts, :users, :categories
  5.  
  6. it "should map { :controller => 'posts', :action => 'index' } to /posts" do
  7. route_for(:controller => "posts", :action => "index").should == "/posts"
  8. end
  9.  
  10. it "should map { :controller => 'posts', :action => 'show' } to /posts/:id" do
  11. post = create_post
  12. route_for(:controller => "posts", :action => "show", :id => post.id).should == "/posts/#{:id}"
  13. end
  14.  
  15. it "should map { :controller => 'posts', :action => 'edit } to /posts/:id/edit" do
  16. post = create_post
  17. route_for(:controller => "posts", :action => "edit", :id => posts(:first_post).id).should == "/posts/#{:id}/edit"
  18. end
  19.  
  20. def create_post(options = {})
  21. Post.create({:title => "new post", :body => "This is the body", :user => users(:quentin), :category => categories(:news)}.merge(options))
  22. end
  23. end
Add Comment
Please, Sign In to add comment