Re: [rspec-users] stubbed methods are not returning what I've stubbed them to return

2013-03-16 Thread Dan Brooking
Yes I realize that :) I actually need to stub this method out in some of my other methods... Since I'm still figuring out how stubbing works, I wanted to strip it down to it's most basic. So in essence, I guess I am testing my stub with this code. So now I know that if I throw this stub in my ot

Re: [rspec-users] stubbed methods are not returning what I've stubbed them to return

2013-03-16 Thread David Chelimsky
On Sat, Mar 16, 2013 at 9:11 AM, Dan Brooking wrote: > I got it... > > I called it using instance_eval. > > def app > Sinatra::Application > end > > describe "#random_string" do > it "returns a random string" do > app.should_receive(:random_string).with(6).and_return('abcdef') > str = app.instance

Re: [rspec-users] stubbed methods are not returning what I've stubbed them to return

2013-03-16 Thread Dan Brooking
I got it... I called it using instance_eval. def app Sinatra::Application end describe "#random_string" do it "returns a random string" do app.should_receive(:random_string).with(6).and_return('abcdef') str = app.instance_eval("random_string(6)") str.should == "abcdef" end end On Sat, Mar 1

Re: [rspec-users] stubbed methods are not returning what I've stubbed them to return

2013-03-16 Thread Dan Brooking
OK, so I think based on this, I'm doing it right and it's a Sinatra issue. I did as you suggested and made a call to Sinatra::Application.random_string and now my error is "private method `random_string' called for Sinatra::Application:Class". So, like I said, looks to me like a Sintra specific i

Re: [rspec-users] stubbed methods are not returning what I've stubbed them to return

2013-03-16 Thread David Chelimsky
On Sat, Mar 16, 2013 at 7:56 AM, Dan Brooking wrote: > I'm working on a small Sintra app and am having trouble getting my stub to > return what I want it to. I've been searching and found quite a few with > this question but no real answers. I also posted this to the sinatrarb > google group in