Skip to content

Instantly share code, notes, and snippets.

@burlesona
Created December 6, 2012 00:57
Show Gist options
  • Save burlesona/4220986 to your computer and use it in GitHub Desktop.
Save burlesona/4220986 to your computer and use it in GitHub Desktop.
Stubbing local scope methods from outside a module so you can test methods inside a module
require 'minitest_helper'
require 'helpers/application_helper'
describe ApplicationHelper do
before :all do
@helper = Struct.new(:request).new #Create an empty request method so it can be stubbed
@helper.extend(ApplicationHelper)
end
describe "nav links" do
before :all do
@request = MiniTest::Mock.new
@request.expect :path_info, '/'
end
it "should return a link to a path" do
@helper.stub :request, @request do
@helper.nav_link_to('test','/test').must_equal '<a href="/test">test</a>'
end
end
it "should return an anchor link to the current path with class 'current'" do
@helper.stub :request, @request do
@helper.nav_link_to('test','/').must_equal '<a href="/" class="current">test</a>'
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment