Re: [rspec-users] modules and stub

2009-05-24 Thread Sarah Allen
David Chelimsky wrote: > > Foo::Bar.stub(:do_something) hmm. that's pretty close to where I started. > If you stub, for example, do_something on this module, but it turns > out that do_something gets added to the module through some dynamic > means *after the stub declaration*, the stub declarati

Re: [rspec-users] spec_server errors when reloading fixture replacement pl

2009-05-24 Thread Ben Mabey
Scott Taylor wrote: Ben Mabey wrote: Scott Taylor wrote: Ben Johnson wrote: Did anyone ever figure out the factory_girl / machinist issues? I am having the same problems and can figure out how to fix it for the life of me. The first run works fine, then afterwards I get a bunch of these erro

Re: [rspec-users] modules and stub

2009-05-24 Thread David Chelimsky
On Mon, May 25, 2009 at 12:03 AM, Sarah Allen wrote: > David Chelimsky wrote: >> Stub methods on objects, not modules. The method can be one that >> *comes from* a module, but you need to stub it on the specific object >> that is at play in the example. > > That makes sense, except the code does t

Re: [rspec-users] Is stubbing a call to super possible?

2009-05-24 Thread David Chelimsky
On Sun, May 24, 2009 at 2:25 PM, Fernando Perez wrote: >> In the meantime I have used alias_method_chain to override the method >> in the super class. > I up this old post, but I was having the same problem mocking super() so > I had to alias_method_chain my method. You can't mock super because s

Re: [rspec-users] modules and stub

2009-05-24 Thread Sarah Allen
David Chelimsky wrote: > Stub methods on objects, not modules. The method can be one that > *comes from* a module, but you need to stub it on the specific object > that is at play in the example. That makes sense, except the code does this: Foo::Bar::do_something(path) I'm not an expert with mod

Re: [rspec-users] undefined method `assert_select'

2009-05-24 Thread David Chelimsky
On Sun, May 24, 2009 at 7:38 PM, Sarah Allen wrote: > David Chelimsky wrote: >> FYI - if you put this file in spec/helpers/swf_object_helper_spec.rb, >> then :type => :helper is implied, so you don't have to make it >> explicit. > > just curious... are there any other magic directories I should kn

Re: [rspec-users] modules and stub

2009-05-24 Thread David Chelimsky
On Sun, May 24, 2009 at 7:15 PM, Sarah Allen wrote: > If there is a method defined on a module, how do I stub it? > > Imagine I have a module like this: > > Module Foo >   Module Bar > >    def self.do_something(path) >  ... >    end > > >   end > end > > > Somewhere in the code, there is this cal

Re: [rspec-users] undefined method `assert_select'

2009-05-24 Thread Sarah Allen
David Chelimsky wrote: > FYI - if you put this file in spec/helpers/swf_object_helper_spec.rb, > then :type => :helper is implied, so you don't have to make it > explicit. just curious... are there any other magic directories I should know about? Thanks, Sarah -- Posted via http://www.ruby-for

[rspec-users] modules and stub

2009-05-24 Thread Sarah Allen
If there is a method defined on a module, how do I stub it? Imagine I have a module like this: Module Foo Module Bar def self.do_something(path) ... end end end Somewhere in the code, there is this call: Foo::Bar::do_something(path) In my test I want the above

Re: [rspec-users] undefined method `assert_select'

2009-05-24 Thread Sarah Allen
David Chelimsky wrote: > FYI - if you put this file in spec/helpers/swf_object_helper_spec.rb, > then :type => :helper is implied, so you don't have to make it > explicit. Nice. By the way, I've been enjoying The RSpec Book, but it looks like I had to figure out view helpers before that chapter

Re: [rspec-users] undefined method `assert_select'

2009-05-24 Thread David Chelimsky
On Sun, May 24, 2009 at 3:20 PM, Sarah Allen wrote: > Sarah Allen wrote: >> Sarah Allen wrote: >>> line 17 is: >>>       html.should have_tag('script', /swfobject.embedSWF/) >> >> I order to use have_tag, it appears I have to include: >> >> # just enough infrastructure to get 'assert_select' to wo

Re: [rspec-users] Class method not being stubbed

2009-05-24 Thread Mark Wilden
On Sun, May 24, 2009 at 9:25 AM, Nick Hoffman wrote: > > In KeywordListsController#create, I call the private method > #create_keywords_and_associate, which calls AdSenseHeavenParser#parse > . > > Thus, some of my specs set an expectation on AdSenseHeavenParser#parse > . However, that expectation

Re: [rspec-users] Class method not being stubbed

2009-05-24 Thread Nick Hoffman
On Sun, May 24, 2009 at 3:25 PM, Rick DeNatale wrote: >> However, that doesn't really matter. The call to #require shouldn't >> happen, because the method is supposed to be stubbed out. > > No that's what confused me. > > class KeywordListsController < ApplicationController > ... >   private > ...

Re: [rspec-users] Class method not being stubbed

2009-05-24 Thread Nick Hoffman
>> Hi Fernando. I'm not sure what you mean by "the code never gets out of >> this require statement". > I should have said 'the interpreter never ...' Ah, I understand what you mean now. >> However, that doesn't really matter. The call to #require shouldn't >> happen, because the method is suppos

Re: [rspec-users] undefined method `assert_select'

2009-05-24 Thread Sarah Allen
Sarah Allen wrote: > Sarah Allen wrote: >> line 17 is: >> html.should have_tag('script', /swfobject.embedSWF/) > > I order to use have_tag, it appears I have to include: > > # just enough infrastructure to get 'assert_select' to work > require 'action_controller' > require 'action_controlle

Re: [rspec-users] Class method not being stubbed

2009-05-24 Thread Rick DeNatale
On Sun, May 24, 2009 at 2:24 PM, Nick Hoffman wrote: > On Sun, May 24, 2009 at 2:13 PM, Fernando Perez wrote: >>> Hi Fernando. In this case, I don't think it's a matter of using the >>> debugger. >> >> I suspect a problem in: require 'lib/adsense_heaven_parser', the code >> maybe never gets out o

Re: [rspec-users] Class method not being stubbed

2009-05-24 Thread Fernando Perez
> Hi Fernando. I'm not sure what you mean by "the code never gets out of > this require statement". I should have said 'the interpreter never ...' > However, that doesn't really matter. The call to #require shouldn't > happen, because the method is supposed to be stubbed out. You are making a lot

Re: [rspec-users] Is stubbing a call to super possible?

2009-05-24 Thread Fernando Perez
> In the meantime I have used alias_method_chain to override the method > in the super class. I up this old post, but I was having the same problem mocking super() so I had to alias_method_chain my method. -- Posted via http://www.ruby-forum.com/. ___ r

Re: [rspec-users] Class method not being stubbed

2009-05-24 Thread Nick Hoffman
On Sun, May 24, 2009 at 2:13 PM, Fernando Perez wrote: >> Hi Fernando. In this case, I don't think it's a matter of using the >> debugger. > > I suspect a problem in: require 'lib/adsense_heaven_parser', the code > maybe never gets out of this require statement. The debugger would allow > you to i

Re: [rspec-users] Class method not being stubbed

2009-05-24 Thread Fernando Perez
> Hi Fernando. In this case, I don't think it's a matter of using the > debugger. I suspect a problem in: require 'lib/adsense_heaven_parser', the code maybe never gets out of this require statement. The debugger would allow you to immediately clear things out. -- Posted via http://www.ruby-fo

Re: [rspec-users] Writing specs pointed out I need to refactor my admin area

2009-05-24 Thread Andrew Premdas
2009/5/24 Fernando Perez : > So I tried to implement Django's AutoAdmin, but actually it quite > quickly blew in my face. Although the views all look similar, there > almost as many little differences as they are models and that's painful > to abstract. So I prefer to write my views for each model.

Re: [rspec-users] Class method not being stubbed

2009-05-24 Thread Nick Hoffman
On Sun, May 24, 2009 at 1:10 PM, Rick DeNatale wrote: > On Sun, May 24, 2009 at 12:25 PM, Nick Hoffman wrote: >> Hi guys. I'm setting an expectation on a class method. For some >> reason, the method isn't being stubbed, and the expectation isn't >> seeing the call. >> >> In KeywordListsController

Re: [rspec-users] Class method not being stubbed

2009-05-24 Thread Rick DeNatale
On Sun, May 24, 2009 at 12:25 PM, Nick Hoffman wrote: > Hi guys. I'm setting an expectation on a class method. For some > reason, the method isn't being stubbed, and the expectation isn't > seeing the call. > > In KeywordListsController#create, I call the private method > #create_keywords_and_asso

Re: [rspec-users] Class method not being stubbed

2009-05-24 Thread Nick Hoffman
On Sun, May 24, 2009 at 12:49 PM, Fernando Perez wrote: >> I've been beating my head against this for a couple of hours. Any >> thoughts? > The easiest for you is to use the debugger and go through each line in > the controller. > > Maybe @keyword_list.save is returning false? Stub it out and see

Re: [rspec-users] Writing specs pointed out I need to refactor my admin area

2009-05-24 Thread Fernando Perez
So I tried to implement Django's AutoAdmin, but actually it quite quickly blew in my face. Although the views all look similar, there almost as many little differences as they are models and that's painful to abstract. So I prefer to write my views for each model. Now I have another problem, so

Re: [rspec-users] Class method not being stubbed

2009-05-24 Thread Fernando Perez
> I've been beating my head against this for a couple of hours. Any > thoughts? The easiest for you is to use the debugger and go through each line in the controller. Maybe @keyword_list.save is returning false? Stub it out and see by yourself. -- Posted via http://www.ruby-forum.com/. __

[rspec-users] Class method not being stubbed

2009-05-24 Thread Nick Hoffman
Hi guys. I'm setting an expectation on a class method. For some reason, the method isn't being stubbed, and the expectation isn't seeing the call. In KeywordListsController#create, I call the private method #create_keywords_and_associate, which calls AdSenseHeavenParser#parse . Thus, some of my s

Re: [rspec-users] spec_server errors when reloading fixture replacement pl

2009-05-24 Thread Scott Taylor
Ben Mabey wrote: Scott Taylor wrote: Ben Johnson wrote: Did anyone ever figure out the factory_girl / machinist issues? I am having the same problems and can figure out how to fix it for the life of me. The first run works fine, then afterwards I get a bunch of these errors: No blueprint fo