- First question
I am getting this error when running my tests:
b spec/views/projects/index.rhtml_spec.rb spec/views/projects/
uninitialized constant ProjectsHelper (NameError)
The first time I saw this I figured I would just get everything
working by commenting out the
within the view tests. And that let everything run fine. Then I see
the same error again at the same file (index.rhtml.spec.rb), so I
delete the line, and everything runs fine. Then the next time I run
the tests the same error is being thrown, but is now pointing to a
different file where the line is commented out.
What is going on here? Is this a common rSpec bug?
- Next question.
When I run the tests I get the following error for one of the auto-
created tests, and cannot figure out why it is throwing it.
describe “/projects/new.rhtml” do
@project = mock_model(Project)
assigns[:project] = @project
it “should render new form” do
# THIS IS THE LINE THE ERROR IS BEING THROWN ON
Here is the error message
ActionView::TemplateError in ‘/projects/new.rhtml should render new
Mock ‘Project_1000’ received unexpected message :name with (no args)
On line #3 of app/views/projects/_form.rhtml
1: <p> 2: <label for="project_name">Name:</label> 3: <%= f.text_field :name %> 4: </p> 5: 6: <p>
Here is a snippet from the _form.rhtml file
Name: <%= f.text_field :name %>
Description: <%= f.text_area :description %>
After seeing this error I thought I would set the name parameter in
the mock object. After doing so the test failed again, but because
the description was not set.
- Yet another question
Is there some crazy bugs with the setup scripts?
I have found for the second time that the required files within the
script/ folder, as well as the spec_helper.rb and spec_opts, are never
created. Luckily for me I had one or two test projects that used on
of the older versions of rSpec so I was able to copy them over.
I can’t see something like this not being fixed, so is it just me?
- And finally
- I created a simple Person model with rspec_model and a person
controller with rspec_controller.
- The person model was created with one field: name:string
- There is no additional code within the person model class.
I then run the tests expecting everything to pass but I get one error
thrown saying that the person model is invalid.
ActiveRecord::StatementInvalid in ‘Person should be valid’
require File.dirname(FILE) + ‘/…/spec_helper’
describe Person do
@person = Person.new
it “should be valid” do
Any help would be appreciated.