[rspec-devel] [ rspec-Bugs-6277 ] debris left by stubbing (trunk) [submitted by dastels]

noreply at rubyforge.org noreply at rubyforge.org
Thu Nov 9 14:44:55 EST 2006


Bugs item #6277, was opened at 2006-10-22 22:59
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=6277&group_id=797

>Category: mock module
Group: None
>Status: Closed
Resolution: None
Priority: 3
Submitted By: Nobody (None)
>Assigned to: Brian Takita (btakita)
Summary: debris left by stubbing (trunk) [submitted by dastels]

Initial Comment:
stubs leave some sort of residue

in one file/context (#1) I have:

context "Setting the name" do
  fixtures :users, :roles, :rights
  controller_name 'admin/dj'
  
  setup do
    roles(:admin).rights << rights(:admin)
    users(:rod).roles << roles(:admin)
    @session[:user] = users('rod').id
    
    @dj = Dj.new(:id => 1, :name => 'Joe')
    @dj.stub!(:update_attribute)
    @dj.stub!(:name).and_return('Dave')
    Dj.stub!(:find).and_return(@dj)
    Dj.should_receive(:find).with(:all).and_return([[@dj]])
  end
  
  specify "should update the name" do
    @dj.should_receive(:update_attribute).with(:name, 'Dave')
    post 'set_dj_name', :id => 1, :value => 'Dave'
  end
  
  specify "should render the list" do
    post 'set_dj_name', :id => 1, :value => 'Dave'
    response.should_have_rjs :replace_html, 'itemList', /Dave/
  end
  
  specify "should render the dj data" do
    post 'set_dj_name', :id => 1, :value => 'Dave'
    response.should_have_rjs :replace_html, 'itemData', /Dave/
  end
end

in another (#2):

context "Asking for a list" do
  fixtures :djs, :users, :roles, :rights
  controller_name 'admin/dj'

  setup do
    roles(:admin).rights << rights(:admin)
    users(:rod).roles << roles(:admin)
    @session[:user] = users('rod').id
    get 'list'
  end
  
  specify "should get some djs" do
    assigns('dj_list').should_not_be_nil
  end
  
  specify "should get all djs" do
    assigns('dj_list').size.should_equal 4
  end
end

if #1 runs first, both specs in #2 fail (the invoked action calls Dj.find(:all).  Failure is: "undefined method `find' for Dj:Class"

if #2 is run alone, or first, everythign passes.



----------------------------------------------------------------------

>Comment By: David Chelimsky (dchelimsky)
Date: 2006-11-09 19:44

Message:
Fixed in trunk (rev 1072)

----------------------------------------------------------------------

Comment By: David Chelimsky (dchelimsky)
Date: 2006-11-07 11:07

Message:
Is this still a problem in 0.7?

If so, can you provide some simple spec and code to reproduce?

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=6277&group_id=797


More information about the rspec-devel mailing list