Created
April 22, 2009 10:55
-
-
Save tomtt/99718 to your computer and use it in GitHub Desktop.
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
| module Foo | |
| class Bar | |
| include ActionController::UrlWriter | |
| def self.some_path | |
| puts root_path | |
| end | |
| end | |
| end | |
| require File.expand_path(File.dirname(__FILE__) + '/../spec/spec_helper') | |
| describe Foo::Bar do | |
| it "should be able to use url writer" do | |
| Foo::Bar.some_path.should == '/' | |
| end | |
| end | |
| ## Running spec from command line: | |
| >: spec lib/test.rb | |
| F | |
| 1) | |
| NameError in 'Foo::Bar should be able to use url writer' | |
| undefined local variable or method `root_path' for Foo::Bar:Class | |
| ./lib/test.rb:6:in `some_path' | |
| ./lib/test.rb:14: | |
| script/spec:10: | |
| Finished in 0.083218 seconds | |
| 1 example, 1 failure | |
| ## Running in the console: | |
| >: ./script/console | |
| Loading development environment (Rails 2.3.2) | |
| >> module Foo | |
| >> class Bar | |
| >> include ActionController::UrlWriter | |
| >> | |
| ?> def self.some_path | |
| >> puts root_path | |
| >> end | |
| >> end | |
| >> end | |
| => nil | |
| >> Foo::Bar.some_path | |
| NameError: undefined local variable or method `root_path' for Foo::Bar:Class | |
| from (irb):6:in `some_path' | |
| from (irb):10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment