Re: [rspec-users] Rails - Mock going out of scope?

2007-07-18 Thread Mikel Lindsaar
Makes total sense. Thank you _very_ much David :) All works well and handles another question I have on a disrelated matter. By the way, loving RSpec. Makes testing a lot more interesting and rewarding. Thanks for all your work. Regards Mikel On 7/19/07, David Chelimsky <[EMAIL PROTECTED]>

Re: [rspec-users] Rails - Mock going out of scope?

2007-07-18 Thread David Chelimsky
D'oh. I should have figured this out on first sighting: The parent method does a find, so it retrieves a new object from the db - not the instance of Node you have defined. This new instance has no language associated with it (because the one you gave it pretends to exist by sporting an ID, but is

Re: [rspec-users] need help getting a word right

2007-07-18 Thread Mikel Lindsaar
I like the it "should..." do end calls, specifiy as well makes sense. So what is the problem? I think we should take a look at what comments are for. Essentially the "should blah" text acts as a comment on the spec. One that is then picked up by RSpec and inserted to make our specifications mor

Re: [rspec-users] need help getting a word right

2007-07-18 Thread barsalou
Well in that specific case, please seems like a good choice please do @thing.should be_somthing end But If you had text in between then it wouldn't seem the same: please "whatever text" do @thing.should be_something end Quoting David Chelimsky <[EMAIL PROTECTED]>: > H

Re: [rspec-users] Rails - Mock going out of scope?

2007-07-18 Thread Mikel Lindsaar
Using 1.2.3 and RSpec with the RSpec Rails plugin installed from CURRENT on the RSpec SVN server. On 7/19/07, Mikel Lindsaar <[EMAIL PROTECTED]> wrote: > Crap, I totally, forgot to mention, sorry David. I am using betternestedset > > http://wiki.rubyonrails.org/rails/pages/BetterNestedSet > > scr

Re: [rspec-users] Rails - Mock going out of scope?

2007-07-18 Thread Mikel Lindsaar
Crap, I totally, forgot to mention, sorry David. I am using betternestedset http://wiki.rubyonrails.org/rails/pages/BetterNestedSet script/plugin source svn://rubyforge.org/var/svn/betternestedset script/plugin install betternestedset Regards Mikel On 7/19/07, David Chelimsky <[EMAIL PROTECT

Re: [rspec-users] Rails - Mock going out of scope?

2007-07-18 Thread David Chelimsky
Here are the errors I'm getting now: 1) NoMethodError in 'Node instance should return it's parent's language if it is a child' undefined method `move_to_child_of' for # ./spec/models/node_spec.rb:20: 2) NameError in 'Node instance should return it's own language if it is root' undefined local var

Re: [rspec-users] Rails - Mock going out of scope?

2007-07-18 Thread Mikel Lindsaar
Here are the migrations: class CreateNodes < ActiveRecord::Migration def self.up create_table ("nodes", :options => 'ENGINE=InnoDB DEFAULT CHARSET=utf8', :force => true) do |t| t.column "title",:string t.column "language_id", :integer t.column "parent_id",

Re: [rspec-users] Rails - Mock going out of scope?

2007-07-18 Thread David Chelimsky
You might also want to try this w/ another mock framework like mocha or flexmock (or rr if you're on edge). If you do, please report the results here. Thx On 7/18/07, David Chelimsky <[EMAIL PROTECTED]> wrote: > Would you mind posting the migrations? > > On 7/18/07, Mikel Lindsaar <[EMAIL PROTECT

Re: [rspec-users] Rails - Mock going out of scope?

2007-07-18 Thread David Chelimsky
Would you mind posting the migrations? On 7/18/07, Mikel Lindsaar <[EMAIL PROTECTED]> wrote: > Heya David, > > Thanks for the reply. > > No, that didn't work, get the same error: > > NoMethodError in 'Node instance should return it's parent's language > if it is a child' > You have a nil object wh

Re: [rspec-users] Rails - Mock going out of scope?

2007-07-18 Thread Mikel Lindsaar
Heya David, Thanks for the reply. No, that didn't work, get the same error: NoMethodError in 'Node instance should return it's parent's language if it is a child' You have a nil object when you didn't expect it! The error occurred while evaluating nil.name If I include the fixture :languages,

Re: [rspec-users] need help getting a word right

2007-07-18 Thread Robert Feldt
On 7/19/07, David Chelimsky <[EMAIL PROTECTED]> wrote: Hey all, I see examples showing up that look like this: describe Thing do before(:each) do @thing = Thing.new end it do @thing.should be_something end end This will produce output like this: Thing - should be something

Re: [rspec-users] need help getting a word right

2007-07-18 Thread Kyle Hargraves
David Chelimsky wrote: > Consise? Yes. But I'm not psyched about 'specify' either. There IS a > perfect word for this situation. What is it? Suggestions? Personally, I disagree. For examples like that, I think 'specify' is a pretty ideal word. It reads exactly as I want it to. Depending on what

Re: [rspec-users] need help getting a word right

2007-07-18 Thread Daniel N
On 7/19/07, David Chelimsky <[EMAIL PROTECTED]> wrote: Hey all, I see examples showing up that look like this: describe Thing do before(:each) do @thing = Thing.new end it do @thing.should be_something end end This will produce output like this: Thing - should be something

[rspec-users] need help getting a word right

2007-07-18 Thread David Chelimsky
Hey all, I see examples showing up that look like this: describe Thing do before(:each) do @thing = Thing.new end it do @thing.should be_something end end This will produce output like this: Thing - should be something But "it do" is driving me mad :( We need a better word. O

Re: [rspec-users] Rails - Mock going out of scope?

2007-07-18 Thread David Chelimsky
On 7/18/07, Mikel Lindsaar <[EMAIL PROTECTED]> wrote: > Hello list, > > I think I have a rails related RSpec problem with a mock going out of > scope on a recursive call to a model. > > The code is at: http://pastie.textmate.org/79821 if you want to see it > highlighted. I have pasted it below as

Re: [rspec-users] stopping on first failure

2007-07-18 Thread David Chelimsky
On 7/18/07, Esad Hajdarevic <[EMAIL PROTECTED]> wrote: > Hi! > > Is there an option that I could provide to the spec runner that would > make it stop after it > encounters the first spec that fails? Not yet. Please submit an RFE if you'd like to see it: http://rubyforge.org/tracker/?group_id=797

[rspec-users] stopping on first failure

2007-07-18 Thread Esad Hajdarevic
Hi! Is there an option that I could provide to the spec runner that would make it stop after it encounters the first spec that fails? Esad ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] Mocking Rails association collections

2007-07-18 Thread David Chelimsky
On 7/18/07, court3nay <[EMAIL PROTECTED]> wrote: > Any chance of some prettier syntax for that? There's always a chance. What do you propose? > > --- > Courtenay > > On Jul 18, 2007, at 2:30 PM, "David Chelimsky" <[EMAIL PROTECTED]> > wrote: > > > On 7/18/07, Paul <[EMAIL PROTECTED]> wrote: >

[rspec-users] Rails - Mock going out of scope?

2007-07-18 Thread Mikel Lindsaar
Hello list, I think I have a rails related RSpec problem with a mock going out of scope on a recursive call to a model. The code is at: http://pastie.textmate.org/79821 if you want to see it highlighted. I have pasted it below as well. Basically, I have an acts_as_nested_set model called "Node"

Re: [rspec-users] Mocking Rails association collections

2007-07-18 Thread Paul
I eventually ended up using this, from a somewhat-related post to this list a couple months ago: def assoc_mock(stubs = {}) proxy = mock('association_proxy') stubs.each do |method, ret| proxy.stub!(method).and_return(ret) end proxy end Then I can do something like I wanted: @comment

Re: [rspec-users] Mocking Rails association collections

2007-07-18 Thread court3nay
Any chance of some prettier syntax for that? --- Courtenay On Jul 18, 2007, at 2:30 PM, "David Chelimsky" <[EMAIL PROTECTED]> wrote: > On 7/18/07, Paul <[EMAIL PROTECTED]> wrote: >> Rails model association collections allow you to do nifty things >> like: >> >> article.comments.find(:al

Re: [rspec-users] Mocking Rails association collections

2007-07-18 Thread court3nay
Any chance of some prettier syntax for that? --- Courtenay On Jul 18, 2007, at 2:30 PM, "David Chelimsky" <[EMAIL PROTECTED]> wrote: > On 7/18/07, Paul <[EMAIL PROTECTED]> wrote: >> Rails model association collections allow you to do nifty things >> like: >> >> article.comments.find(:all

Re: [rspec-users] Mocking Rails association collections

2007-07-18 Thread David Chelimsky
On 7/18/07, Paul <[EMAIL PROTECTED]> wrote: > Rails model association collections allow you to do nifty things like: > > article.comments.find(:all, :conditions => {:created_at > 1.day.ago}) > > Has anyone found a good way to mock this up? I'm currently doing this: > > @comment1 = mock_model(Co

[rspec-users] Mocking Rails association collections

2007-07-18 Thread Paul
Rails model association collections allow you to do nifty things like: article.comments.find(:all, :conditions => {:created_at > 1.day.ago}) Has anyone found a good way to mock this up? I'm currently doing this: @comment1 = mock_model(Comment) comments = mock(Array) comments.stub!(:find)