Hekko,

what does the following mean?

1) PortfolioItemsController should render index
     Failure/Error: @portfolio = mock_model(Portfolio)
     undefined method `mock' for
#<RSpec::Core::ExampleGroup::Nested_1:0x0000010214bba0>
     # 
/Users/jan/.rvm/gems/ruby-1.9.2...@rails3/gems/actionpack-3.0.0/lib/action_dispatch/testing/assertions/routing.rb:177:in
`method_missing'
     # 
/Users/jan/.rvm/gems/ruby-1.9.2...@rails3/gems/rspec-rails-2.0.0.beta.22/lib/rspec/rails/mocks.rb:71:in
`mock_model'
     # ./spec/controllers/portfolio_items_controller_spec.rb:7:in `block (2
levels) in <top (required)>'

This is using mongoid, with rails 3

require 'spec_helper'

describe PortfolioItemsController do
  render_views

  before(:all) do
    @portfolio = mock_model(Portfolio) #dies here
    @item  = mock_model(PortfolioItem)
    @items = [...@item, mock_model(PortfolioItem)]
    PortfolioItem.stub!(:find).and_return(@item)
    PortfolioItem.stub!(:all).and_return(@items)
    @portfolio.stub!(:items).and_return(@items)
  end

  it "should render index" do
    response.should be_success
  end

end

#routes.rb
  resources :portfolios do
    resources :portfolio_items do
      resources :images
    end
  end

class Portfolio
  include Mongoid::Document
  validates_presence_of :title
  field :title, :type => String
  embed_many :items, :class_name => PortfolioItem.name
end

class PortfolioItem
  include Mongoid::Document
  embedded_in :portfolio, :inverse_of => :items
  field(:title)
  field(:description)
  field(:date)
  embed_many(:images)

  validates_presence_of :title, :date

end

Any idea, what I am doing wrong here?
On another note, I think be_success does not exist anymore, right?

-- 
Jan
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to