Skip to content

Instantly share code, notes, and snippets.

@matenia
Created November 5, 2012 23:42
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/4021169 to your computer and use it in GitHub Desktop.
Save matenia/4021169 to your computer and use it in GitHub Desktop.
Failing helper spec calling route helper
# app/helpers/application_helper.rb
module ApplicationHelper
def go_to_page(resource)
polymorphic_path([resource.company, resource])
end
end
# spec/helpers/application_helper_spec.rb
require 'spec_helper'
require 'uri'
describe ApplicationHelper do
it "builds a non-secure page url" do
# make new product with valid associated company
res = Product.make!
uri = helper.go_to_page(res)
uri.scheme.should == 'http'
end
end
# error
1) ApplicationHelper builds a non-secure page url
Failure/Error: uri = helper.go_to_page(res)
NoMethodError:
undefined method `company_product_path' for #<#<Class:0x007fddac62ac78>:0x007fddb0acd470>
## notes:
# company_product_path exists in routes and the view that uses this helper works as expected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment