Skip to content

Instantly share code, notes, and snippets.

@matenia
Created November 6, 2012 00:14
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 matenia/4021365 to your computer and use it in GitHub Desktop.
Save matenia/4021365 to your computer and use it in GitHub Desktop.
Failing helper spec calling route helper
### console output
### 1.9.3p172 :018 > app.root_path
### => "/"
# spec/helpers/applcation_helper.rb
require 'spec_helper'
require 'uri'
describe ApplicationHelper do
include Rails.application.routes.url_helpers
it "does stuff" do
helper.go_to_page.should == '/'
end
end
# app/helpers/application_helper.rb
module ApplicationHelper
include Rails.application.routes.url_helpers
def go_to_page
root_path
end
end
### spec output
1) ApplicationHelper does stuff
Failure/Error: helper.go_to_page.should == '/'
RuntimeError:
In order to use #url_for, you must include routing helpers explicitly. For instance, `include Rails.application.routes.url_helpers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment