Skip to content

Instantly share code, notes, and snippets.

@pumpchaser
Created October 19, 2012 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pumpchaser/3919350 to your computer and use it in GitHub Desktop.
Save pumpchaser/3919350 to your computer and use it in GitHub Desktop.
rspec
def new
begin
@slug = params[:slug_text]
@place = Slug.where(name: @slug).first.sluggable
@klass = @place.class
rescue Exception => e
redirect_to :root
end
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