Created
March 4, 2011 19:23
-
-
Save JakubOboza/855526 to your computer and use it in GitHub Desktop.
first some tests....
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 CatsController do | |
describe "#index" do | |
it "should display cats" do | |
get :index | |
response.status.should eql(200) | |
end | |
end | |
describe "#create" do | |
it "should create new cat" do | |
lambda do | |
post :create, :cat => {:name => "test-hitler-looking-cat", :url => "http://lolcat.com/test.png"} | |
response.status.should eql(302) | |
end.should change(Cat, :count).by(1) | |
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
# new route in config/routes.rb | |
resources :cats |
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
# some controller code | |
class CatsController < ApplicationController | |
def index | |
@cats = Cat.all | |
end | |
def create | |
@cat = Cat.new(params[:cat]) | |
if @cat.save | |
redirect_to cats_path | |
else | |
render :action => :index | |
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
Pending: | |
Application should earn loads of money | |
# Not Yet Implemented | |
# ./spec/application_spec.rb:6 | |
Finished in 0.10377 seconds | |
5 examples, 0 failures, 1 pending |
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
Failures: | |
1) CatsController#index should display cats | |
Failure/Error: get :index | |
ActionController::RoutingError: | |
No route matches {:controller=>"cats"} | |
# ./spec/controllers/cats_controller_spec.rb:7 | |
2) CatsController#create should create new cat | |
Failure/Error: post :create, :cat => {:name => "test-hitler-looking-cat", :url => "http://lolcat.com/test.png"} | |
ActionController::RoutingError: | |
No route matches {:cat=>{:url=>"http://lolcat.com/test.png", :name=>"test-hitler-looking-cat"}, :action=>"create", :controller=>"cats"} | |
# ./spec/controllers/cats_controller_spec.rb:15 | |
# ./spec/controllers/cats_controller_spec.rb:14 | |
Finished in 0.11783 seconds | |
6 examples, 2 failures, 2 pending |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment