Method works in rails console, but rspec says method is undefined
In my rails 3 app, I have a lib folder:
/lib
/lib/abc/some_class.rb
/lib/abc/some_class/other.rb
some_class.rb:
module ABC
class SomeClass
end
end
other.rb
module ABC
class SomeClass::Other
def self.hello(a,b,c,)
false
end
end
end
If I fire up rails console I can do:
ABC::SomeClass::Other.hello(1,2,3)
and it outputs false
In my rspec test, I have the same line:
result = ABC::Som开发者_运维问答eClass::Other.hello(1,2,3)
And I get:
undefined method 'hello' for #<Class:0x.......>
Is this a namespace issue? folder issue?
What are the require's in the rspec file? It needs to be including some_class.rb and some_class\other.rb (you may need to modify the load path to include both)
精彩评论