Skip to content

Instantly share code, notes, and snippets.

@KensoDev
Forked from pumpchaser/controller
Created October 19, 2012 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KensoDev/3919455 to your computer and use it in GitHub Desktop.
Save KensoDev/3919455 to your computer and use it in GitHub Desktop.
rspec
def new
slug = Slug.where(name: params[:slug_text]).first
return redirect_to :root unless slug
@place = slug.sluggable
return redirect_to :root unless @place
end
describe ModerationController do
describe "#new" do
it "sends the query to the correct class" do
place=stub(:place)
Slug.should_receive(:where).with(name: "Paris").and_return(place)
get :new, slug_text: "Paris"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment