Skip to content

Instantly share code, notes, and snippets.

@skrat
Created October 23, 2008 22:18
Show Gist options
  • Save skrat/19233 to your computer and use it in GitHub Desktop.
Save skrat/19233 to your computer and use it in GitHub Desktop.
require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb')
given "logged in" do
login
end
describe Posts do
describe "index action" do
it "should respond correctly" do
dispatch_to(Posts, :index).should respond_successfully
end
it "should fetch all posts" do
Post.should_receive(:all)
dispatch_to(Posts, :index) do |controller|
controller.stub!(:display)
end
end
context "with user logged in", :given => "logged in" do
it "should set new post" do
Post.should_receive(:new)
dispatch_to(Posts, :index).should respond_successfully
end
User.all.destroy!
end
end
end
def login
u = User.new(chucks_attributes)
u.save
rack = request(:login, :method => "POST",
:params => {:login => chucks_attributes[:login], :password => chucks_attributes[:password]})
end
alias logging_in login
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment