Question

Trying to figure out this error:

ActionView::Template::Error:
       No route matches 
         {:controller=>"evaluations", 
          :action=>"note", 
          :student_group_id=>#  
            <StudentGroup id: 2, 
             name: "Rainbow Class", 
             user_id: 1, 
             created_at: "2013-08-18 10:45:46", 
             updated_at: "2013-08-18 10:45:46", 
             number_of_students: nil, 
             type_of_group: "Adult class (18+)">, 
           :student_id=>nil}

this works fine in the browser, it's only failing in the tests.

here's the code:

<%= link_to "!", eval_note_path({ student_group_id: @student_group, student_id: @student_group.students.first }) %>

and the test - i know i need a stub in the before block, but i'm not sure how to make rspec do what i want. have looked around on SO, but stubbing seems to be quite dependent on the circumstance and I can't figure it out:

describe "GET 'index" do

  before(:each) do
    @index = get :index
    @student_group.stub(:students.first).and_return(1)      
  end

  ...

  it "should have an evaluation link" do
    @index
    response.should have_selector('a', 
                                   href: eval_note_path({ 
                                         student_group_id: @student_group, 
                                         student_id: @student
                                         }),
                                   content: "!")
  end

end
Was it helpful?

Solution

Try with @student_group.id It should work.

it "should have an evaluation link" do
    @index
    response.should have_selector('a', 
                                   href: eval_note_path({ 
                                         student_group_id: @student_group.id, 
                                         student_id: @student
                                         }),
                                   content: "!")

Thanks

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top