Skip to content

Instantly share code, notes, and snippets.

@rhysforyou
Created November 28, 2011 02:26
Show Gist options
  • Select an option

  • Save rhysforyou/1398829 to your computer and use it in GitHub Desktop.

Select an option

Save rhysforyou/1398829 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe BooksController do
before :each do
mock_model("Book")
end
describe "GET 'new'" do
before :each do
get :new
end
it "assigns a new Book to @book" do
assigns(:book).should_not be_nil
assigns(:book).class.should eq(Book)
end
end
describe "GET 'index" do
before :each do
get :index
end
it "assigns an array of Books called @books" do
assigns(:books).should_not be_nil
assigns(:books).class.should eq(Array)
assigns(:books)[0].class.should eq(Book)
end
end
end
class BooksController < ApplicationController
def new
@book = Book.new
end
def create
redirect_to books_path
end
def index
@books = Book.all
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment