1. First question
----------------------------------------
I am getting this error when running my tests:
...
b spec/views/projects/index.rhtml_spec.rb spec/views/projects/
new.rhtml_spec.rb
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:266:in `load_missing_constant'':
uninitialized constant ProjectsHelper (NameError)
...
The first time I saw this I figured I would just get everything
working by commenting out the
+++
include ProjectHelper
+++
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?
2. 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
  before do
    @project = mock_model(Project)
    @project.stub!(:new_record?).and_return(true)
    assigns[:project] = @project
  end
  it "should render new form" do
    render "/projects/new.rhtml"
      # THIS IS THE LINE THE ERROR IS BEING THROWN ON
      response.should have_tag("form[action=?][method=post]",
projects_path) do
    end
  end
end
Here is the error message
+++++++
ActionView::TemplateError in ''/projects/new.rhtml should render new
form''
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
<p>
        <label for="project_name">Name:</label>
        <%= f.text_field :name %>
</p>
<p>
        <label
for="project_description">Description:</label>
        <%= f.text_area :description %>
</p>
+++++++++++
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.
3. 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?
4. 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''
ActiveRecord::StatementInvalid
./spec/models/person_spec.rb:5:in `new''
./spec/models/person_spec.rb:5:
script/spec:4:
+++++
require File.dirname(__FILE__) + ''/../spec_helper''
describe Person do
  before(:each) do
    @person = Person.new
  end
  it "should be valid" do
    @person.should be_valid
  end
end
+++++
Any ideas?
Any help would be appreciated.
Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Sorry if I am stating the obvious here, but my comments are interleaved. Also, consider joining the rspec Google Group.> 1. First question > ---------------------------------------- > > I am getting this error when running my tests: > ... > b spec/views/projects/index.rhtml_spec.rb spec/views/projects/ > new.rhtml_spec.rb > /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/ > active_support/dependencies.rb:266:in `load_missing_constant'': > uninitialized constant ProjectsHelper (NameError)Is the name ProjectHelper or ProjectsHelper?> The first time I saw this I figured I would just get everything > working by commenting out the > +++ > include ProjectHelper > +++ ><snip>> 2. 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 > before do > @project = mock_model(Project) > @project.stub!(:new_record?).and_return(true)@project.stub!(:name).and_return(''bob dylan'')> assigns[:project] = @project > end > > it "should render new form" do > render "/projects/new.rhtml" > # THIS IS THE LINE THE ERROR IS BEING THROWN ON > response.should have_tag("form[action=?][method=post]", > projects_path) do > end > end > end > > Here is the error message > +++++++ > ActionView::TemplateError in ''/projects/new.rhtml should render new > form'' > 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 > <p> > <label for="project_name">Name:</label> > <%= f.text_field :name %> > </p> > > <p> > <label for="project_description">Description:</label> > <%= f.text_area :description %> > </p> > > +++++++++++ > > 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. > > 3. 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?script/generate rspec> 4. 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.Are you sure your test database is set up correctly?> +++++ > ActiveRecord::StatementInvalid in ''Person should be valid'' > ActiveRecord::StatementInvalid > ./spec/models/person_spec.rb:5:in `new'' > ./spec/models/person_spec.rb:5: > script/spec:4: > > +++++ > require File.dirname(__FILE__) + ''/../spec_helper'' > > describe Person do > before(:each) do > @person = Person.new > end > > it "should be valid" do > @person.should be_valid > end > end > +++++--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
There is another script that I have to run? :) (Elevator music...) I
ran it and that answers the file missing question.
** For the Person validation issues, it seems the problem was that I
had my tests running from a sqlite3 database with the database set
to :memory:.  After changing this to a file all the base tests now
pass.
As for the first problem listed, I typed the project controller wrong
when posting as it should be ProjectsController, but I do have the
correct version of it within the code.
$ rake spec
(in /Users/chrisolsen/Projects/Rails/Portfolio/trunk)
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:266:in `load_missing_constant'':
uninitialized constant ProjectsHelper (NameError)
        from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/
active_support/dependencies.rb:452:in `const_missing''
helpers/projects_helper_spec.rb
---------------------
require File.dirname(__FILE__) + ''/../spec_helper''
describe ProjectsHelper do # Helper methods can be called directly in
the examples (it blocks)
end
---------------------
BTW I did search for a google rspec group, but one didn''t seem to turn
up, I swear :)
Thanks for the help
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Does anyone know why I am having these class issues? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---