Skip to content

Instantly share code, notes, and snippets.

@tubbo
Forked from mfifth/gist:66e51447c1d016d190e8345c6dc95e5e
Last active May 21, 2016 23:27
Show Gist options
  • Save tubbo/6f30d47a94763612b909a688bbd5b2b5 to your computer and use it in GitHub Desktop.
Save tubbo/6f30d47a94763612b909a688bbd5b2b5 to your computer and use it in GitHub Desktop.
# The error message
undefined method `comments_path' for #<#<Class:0x007f01f0513be8>:0x00000003b43928>
Did you mean? font_path
Extracted source (around line #1):
1
2
3
4
5
<%= simple_form_for([@topic, @comment]) do |f| %>
<%= f.input :text %>
<%= f.button :submit, class: "new btn-primary" %>
<% end %>
# The routes, in case there is something wrong here.
Rails.application.routes.draw do
root 'forums#index'
namespace :admin do
resources :users
root 'application#index'
get '/admin/forums' => "forums#index"
resources :forums
end
devise_for :users
resources :forums, only: [:show, :index] do
resources :topics do
resources :comments, only: [:create, :new, :destroy, :edit]
end
end
end
# The test that is failing
require 'rails_helper'
RSpec.describe "Users can leave comments" do
let(:user) { FactoryGirl.create(:user) }
let(:topic) { FactoryGirl.create(:topic, author: user, forum: forum) }
let(:forum) { FactoryGirl.create(:forum) }
before do
login_as(user)
visit forum_topic_path(forum, topic)
end
scenario 'with valid attributes' do
click_link "Add Comment"
fill_in "Text", with: "This is some random text for a comment"
click_button "Create Comment"
expect(page).to have_content "Comment has been created."
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment