I'm working my way through Michael Hartl's Rails Tutorial. I hit a snag in Chapter 3 Section 3 on Testing. After generating two controllers - home and help, I ran the following in the terminal:
bundle exec rake test
The test should have passed but I received the following error for both the home and help controllers:
1) Error:
StaticPagesControllerTest#test_should_get_home:
SyntaxError: /home/ubuntu/workspace/sample_app/app/controllers /application_controller.rb:7: syntax error, unexpected tSTRING_BEG, expecting keyword_end
render :text "hello, world!"
^
app/controllers/static_pages_controller.rb:1:in `<top (required)>'
I have reviewed the code and haven't seen anywhere the end keyword should be required.
My static_pages_controller_test.rb file is setup as follows:
require 'test_helper'
class StaticPagesControllerTest < ActionController::TestCase
test "should get home" do
get :home
assert_response :success
end
test "should get help" do
get :help
assert_response :success
end
end
static_pages_controller.rb has the following code:
class StaticPagesController < ApplicationController
def home
end
def help
end
end
application_controller.rb has this code:
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
def hello
render :text "hello, world!"
end
end
routes.rb has this code:
Rails.application.routes.draw do
get 'static_pages/home'
get 'static_pages/help'
root 'application#hello'
end
Any thoughts on what the problem might be? I have search this site with no luck. Thanks in advance for your help.
Aucun commentaire:
Enregistrer un commentaire