Reputation: 341
I'm working with the book 'Agile Web Development With Rails 4', I'm a complete beginner and not understanding a few issues.
I just tried the rake test:models
command
I was given back:
rake aborted!
SyntaxError: /Users/********/Desktop/depot/test/models/product_test.rb:11: syntax error, unexpected end-of-input, expecting keyword_end
What does this exactly mean? I've followed the book word for word and have encountered this problem.
Thanks in advance for your helpful answers and thoughts!
Here's the product_test.rb code
require 'test_helper'
class ProductTest < ActiveSupport::TestCase
test "product attributes must not be empty" do
product = Product.new
assert product.invalid?
assert product.errors[:title].any?
assert product.errors[:description].any?
assert product.errors[:price].any?
assert product.errors[:image_url].any?
end
Upvotes: 1
Views: 1380
Reputation:
You have 2 blocks but only one end statement; there needs to be another end
at the end:
require 'test_helper'
class ProductTest < ActiveSupport::TestCase # <== this is the start of the class
test "product attributes must not be empty" do # <== this is the start of a block
product = Product.new assert product.invalid?
assert product.errors[:title].any?
assert product.errors[:description].any?
assert product.errors[:price].any?
assert product.errors[:image_url].any?
end # <== this is missing
end # <== this is the end of the class
class
is the start of one block and the do
at the end of the test
line is another.
This type of error always gets reported against the last line of the file because it cannot tell there is a missing end
until it gets to the end of the file and doesn't find it.
Upvotes: 1
Reputation: 33542
You are missing an end
for do
block.Adding it should fix the error.
require 'test_helper'
class ProductTest < ActiveSupport::TestCase
test "product attributes must not be empty" do
product = Product.new
assert product.invalid?
assert product.errors[:title].any?
assert product.errors[:description].any?
assert product.errors[:price].any?
assert product.errors[:image_url].any?
end #do end
end #class end
Upvotes: 0