Created
November 28, 2011 02:26
-
-
Save rhysforyou/1398829 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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