Skip to content

Instantly share code, notes, and snippets.

@jakcharlton
Created April 25, 2012 09:32
Show Gist options
  • Save jakcharlton/2488506 to your computer and use it in GitHub Desktop.
Save jakcharlton/2488506 to your computer and use it in GitHub Desktop.
More complete rspec controller test
before(:each) do
@organisation = create(:organisation, owner: subject.current_user)
@request.host = @organisation.subdomain + ".example.com"
subject.current_user.stub(:organisations).and_return([@organisation])
subject.current_user.stub_chain(:organisations, :find_by_id).and_return(@organisation)
end
describe "GET index" do
it "assigns all organisations as @organisations" do
get :index, {}, valid_session
assigns(:organisations).should eq([@organisation])
end
end
describe "GET show" do
it "assigns the requested organisation as @organisation" do
get :show, {:id => @organisation.to_param}, valid_session
assigns(:organisation).should eq(@organisation)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment