[rspec-users] Problems with RESTfully generated helpers

Lance Carlson lancecarlson at gmail.com
Wed Aug 8 16:48:10 EDT 2007


Yes,

  map.resources :labels do |label|
    label.resources :artists
  end

On 8/8/07, Jay Levitt <lists-rspec at shopwatch.org> wrote:
> David Chelimsky wrote:
> > On 8/8/07, Lance Carlson <lancecarlson at gmail.com> wrote:
> >> All I'm doing is passing the instance variables @label and @artist in
> >> the controller to the view using this code:
> >>
> >> @label = current_user.labels.find(params[:label_id])
> >> @artist = params[:id].nil? ? Artist.new : @label.artists.find(params[:id])
> >>
> >> By sending these two instance variables to the view, I don't need to
> >> specify these arguments and the view just works. Can you get it to
> >> work when you specify these instance variables in your controller?
> >
> > No. That's what I'm saying. I get the same ambigous URL error you
> > cited in the first email in this thread, but in the browser. Using
> > edge rails, edge rspec.
>
> Dumb question, but do you have the resource mapped in your routes.rb
> file?  Something like
>
> map.resources :artists
>
> Jay
>
> >
> >> -L
> >>
> >> On 8/8/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> >>> On 8/8/07, Lance Carlson <lancecarlson at gmail.com> wrote:
> >>>> I just passed label_artist_path(@label.id, @artist.id) into the view
> >>>> and it worked.. but I really don't want to have to pass those
> >>>> parameters in all my views. It looks ugly. Does anyone know a way
> >>>> around this without stubbing? It seems useless to test this view
> >>>> without allowing those methods to act out their real behavior.
> >>> Can you point me to docs that say you're supposed to be able to just
> >>> call label_artist_path without any args? I've not see such docs and I
> >>> can't get it to work in any of my views - and I'm talking about just
> >>> rendering the views at all, not getting specs to work.
> >>>
> >>>> -TIA
> >>>>
> >>>> On 8/8/07, Lance Carlson <lancecarlson at gmail.com> wrote:
> >>>>> ActionView::TemplateError in 'Edit Artist Page should render the edit
> >>>>> artist form'
> >>>>> label_artist_url failed to generate from {:controller=>"artists",
> >>>>> :action=>"show"} - you may have ambiguous routes, or you may need to
> >>>>> supply additional parameters for this route.  content_url has the
> >>>>> following required parameters: ["labels", :label_id, "artists", :id] -
> >>>>> are they all satisfied?
> >>>>> On line #3 of app/views/artists/edit.rhtml
> >>>>>
> >>>>>     1: <h1>Editing artist</h1>
> >>>>>     2:
> >>>>>     3: <% form_tag label_artist_path, :method => :put do %>
> >>>>>     4:   <%= render :partial => 'form' %>
> >>>>>     5:   <%= submit_tag 'Save' %>
> >>>>>     6: <% end %>
> >>>>>
> >>>>>
> >>>>> My spec looks like:
> >>>>>
> >>>>> require File.dirname(__FILE__) + '/../../spec_helper'
> >>>>>
> >>>>> describe 'Edit Artist Page' do
> >>>>>   before do
> >>>>>     @label = mock_model(Label)
> >>>>>     @artist = mock_model(Artist)
> >>>>>
> >>>>>     assigns[:label] = @label
> >>>>>     assigns[:artist] = @artist
> >>>>>   end
> >>>>>
> >>>>>   def render_edit
> >>>>>     render :template => 'artists/edit'
> >>>>>   end
> >>>>>
> >>>>>   it "should render the edit artist form" do
> >>>>>     render_edit
> >>>>>   end
> >>>>> end
> >>>>>
> >>>>> On 8/8/07, David Chelimsky <dchelimsky at gmail.com> wrote:
> >>>>>> On 8/8/07, Lance Carlson <lancecarlson at gmail.com> wrote:
> >>>>>>> I am using helper the RESTfully generated helper methods in my views.
> >>>>>>> My routes are nested so the helpers appear to need arguments passed to
> >>>>>>> them, but it works without arguments. Say for example I have pages and
> >>>>>>> comments. If I do page_comments_path without parameters, it works.
> >>>>>>> However, when I run the rspec test, it fails and tells me i'm missing
> >>>>>>> parameters. I tried to pass params[:page_id], but it still says it
> >>>>>>> needs parameters. I did fill in the parameters like it asked and the
> >>>>>>> test passed, but I think my views look cleaner without the arguments
> >>>>>>> being passed everywhere. Do I have to stub these methods to get my
> >>>>>>> views to pass, or is there some other way?
> >>>>>> It would be much easier to answer your question if you posted the
> >>>>>> actual spec and code.
> >>>>>>
> >>>>>>> TIA,
> >>>>>>> Lance
> >>>>>>> _______________________________________________
> >>>>>>> rspec-users mailing list
> >>>>>>> rspec-users at rubyforge.org
> >>>>>>> http://rubyforge.org/mailman/listinfo/rspec-users
> >>>>>>>
> >>>>>> _______________________________________________
> >>>>>> rspec-users mailing list
> >>>>>> rspec-users at rubyforge.org
> >>>>>> http://rubyforge.org/mailman/listinfo/rspec-users
> >>>>>>
> >>>> _______________________________________________
> >>>> rspec-users mailing list
> >>>> rspec-users at rubyforge.org
> >>>> http://rubyforge.org/mailman/listinfo/rspec-users
> >>>>
> >>> _______________________________________________
> >>> rspec-users mailing list
> >>> rspec-users at rubyforge.org
> >>> http://rubyforge.org/mailman/listinfo/rspec-users
> >>>
> >> _______________________________________________
> >> rspec-users mailing list
> >> rspec-users at rubyforge.org
> >> http://rubyforge.org/mailman/listinfo/rspec-users
> >>
> > _______________________________________________
> > rspec-users mailing list
> > rspec-users at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/rspec-users
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list