Re: [rspec-users] Failing to stub "test" in an object , because "test" is already defined in Kernel

2013-04-09 Thread Samer Masry
It's because :test was defined a private method and you're trying to access it publicly class Object private def test ... end end There are different approaches to testing private methods. http://blog.jayfields.com/2007/11/ruby-testing-private-methods.html -or- you can test the m

[rspec-users] Different description in custom RSpec::Matcher depending on output formater

2013-04-09 Thread Ervin Weber
Hello is it possible to make something like following: RSpec::Matchers.define :be_json do |expected| match do |actual| JSON.parse(actual) == expected end description do if html? # to html formatter output this "return JSON:\n#{JSON.pretty_generate(expected)}" else # for o

[rspec-users] Failing to stub "test" in an object , because "test" is already defined in Kernel

2013-04-09 Thread Constantin Gavrilescu
I'm trying to stub the method "test" on an object, and I cannot do it with rspec. Example with a simpler case: o = Object.new o.stub!(:test).and_return "lol" o.test.should == "lol" Error: Failure/Error: o.test.should == "lol" NoMethodError: private method `test' called for #