Created
December 6, 2012 00:57
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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