[rspec-users] Can't access actions of a singular nested resource

J2M james2mccarthy at gmail.com
Mon Aug 4 12:59:45 EDT 2008


Zach,

Rails 2.1
Rspec 1.1.4

What does your spec look like?

Thanks,
James

On Aug 4, 3:12 pm, "Zach Dennis" <zach.den... at gmail.com> wrote:
> Bastien,
>
> What version of Rails and rspec are you using? Using a singular
> resource like you presented works just fine for me,
>
> Zach
>
>
>
> On Thu, Jul 31, 2008 at 10:06 AM, Bastien <bastien.vauc... at gmail.com> wrote:
> > I can't figure out what I do wrong there, I have a nested controller
> > which is defined as a singular resource, the routing works properly,
> > but inside my specs the request never goes through the show action.
>
> > I keep on getting this error :
>
> > Spec::Mocks::MockExpectationError in 'Surveys::ReportController should
> > return the survey corresponding to the report'
> > Mock 'Class' expected :find with (any args) once, but received it 0
> > times
>
> > In my specs :
> > require File.expand_path(File.dirname(__FILE__) + '/../../
> > spec_helper')
> > describe Surveys::ReportController do
>
> >  it "should return the survey corresponding to the report" do
> >    Survey.should_receive(:find)
> >    get :show, :survey_id=>"34"
> >  end
>
> > end
>
> > In route.rb :
> > map.resources :surveys do |survey|
> >    survey.resource :report, :controller =>'surveys/report'
> > end
>
> > In controller/surveys/report_controller.rb :
> > class Surveys::ReportController < ApplicationController
>
> >  def show
> >    @survey = Survey.find(params[:survey_id])
>
> >    respond_to do |format|
> >      format.html
> >      format.xml
> >    end
> >  end
>
> > end
> > _______________________________________________
> > rspec-users mailing list
> > rspec-us... at rubyforge.org
> >http://rubyforge.org/mailman/listinfo/rspec-users
>
> --
> Zach Dennishttp://www.continuousthinking.comhttp://www.mutuallyhuman.com
> _______________________________________________
> rspec-users mailing list
> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users


More information about the rspec-users mailing list