SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Member
    Join Date
    Apr 2003
    Location
    Brooklyn
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question undefined method 'assert_select'

    I am going through the new "Build your own Ruby on Rails web application" book and I have hit a snag. In chapter 6 "Testing the controller" when I run:

    rake test:functionals I keep getting one error.

    when I run it with --trace here is the result:

    Code:
    C:\rails\shovell>rake test:functionals --trace
    (in C:/rails/shovell)
    ** Invoke test:functionals (first_time)
    ** Invoke db:test:prepare (first_time)
    ** Invoke environment (first_time)
    ** Execute environment
    ** Execute db:test:prepare
    ** Invoke db:test:clone (first_time)
    ** Invoke db:schema:dump (first_time)
    ** Invoke environment
    ** Execute db:schema:dump
    ** Execute db:test:clone
    ** Invoke db:schema:load (first_time)
    ** Invoke environment
    ** Execute db:schema:load
    ** Execute test:functionals
    c:/ruby/bin/ruby -Ilib;test "c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/
    rake_test_loader.rb" "test/functional/story_controller_test.rb"
    Loaded suite c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/rake_test_loader
    
    Started
    ....E
    Finished in 0.125 seconds.
    
      1) Error:
    test_should_show_new_form(StoryControllerTest):
    NoMethodError: undefined method `assert_select' for #<StoryControllerTest:0x33ff
    874>
        c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/test_
    process.rb:432:in `method_missing'
        ./test/functional/story_controller_test.rb:32:in `test_should_show_new_form'
    
    
    5 tests, 11 assertions, 0 failures, 1 errors
    rake aborted!
    Command failed with status (1): [c:/ruby/bin/ruby -Ilib;test "c:/ruby/lib/r...]
    c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:722:in `sh'
    c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:729:in `sh'
    c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:812:in `sh'
    c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:747:in `ruby'
    c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:812:in `ruby'
    c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/testtask.rb:117:in `define'
    c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:831:in `verbose'
    c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake/testtask.rb:102:in `define'
    c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `execute'
    c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in `execute'
    c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:357:in `invoke'
    c:/ruby/lib/ruby/1.8/thread.rb:135:in `synchronize'
    c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in `invoke'
    c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run'
    c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run'
    c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.1/bin/rake:7
    c:/ruby/bin/rake.bat:25

    The error I found is in red.

    I see that 'assert_select' is an undefined method but don't know how to proceed.

    Here is where assert_select gets called from:

    Code:
    def test_should_show_new_form
        get :new
        assert_select 'form p', :count => 3
    end
    Any help would be appreciated.

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    What version of Rails did you install? Make sure you have 1.2. You can find out by typing 'rails -v' in the terminal/command prompt.

  3. #3
    SitePoint Member
    Join Date
    Apr 2003
    Location
    Brooklyn
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope I've got 1.1.6

    Is there an easy way to "Upgrade" without wiping out my project?

    Thanks again for the insight and the speedy response!

    Keith

  4. #4
    SitePoint Member
    Join Date
    Apr 2003
    Location
    Brooklyn
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    One more issue "require_gem is obsolete"

    I'm getting this warning:
    Code:
    c:0:Warning: require_gem is obsolete.  Use gem instead.
    I've modified my boot.rb so that both lines that read "require_gem" now say "gem" but I still have the same problem.

    Any Solutions for this?

    Thanks

  5. #5
    SitePoint Member bhutz's Avatar
    Join Date
    May 2004
    Location
    Bedford
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I get the same problem although I got it when trying to use radrails and instant-rails.
    In my configuration for the rails and rake paths I was using those found in instant rails...I changed this to use the ones I had installed from the Ruby standalone and it seemed to work just fine...I get the message
    '(in G:/Documents and Settings/C/user/depot)'

    and I can see my databases in the 'data' perspective of radrails

  6. #6
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can update rails using RubyGems: `gem update` (this will update all gems). This will not wipe out your project ;-).

  7. #7
    SitePoint Member
    Join Date
    Feb 2007
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i'm running 1.2 and i was having the same problem until i updated the config/environment.rb file. check the RAILS_GEM_VERSION if it's set to 1.1.6 you can just comment it out and it should work fine.

    john

  8. #8
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Deprecation warnings

    I'm working through the fixtures testing in Chapter 7. It's working fine but I'm receiving the following deprecation warnings:

    DEPRECATION WARNING: votes_count ....
    DEPRECATION WARNING: votes_count ....
    DEPRECATION WARNING: has_votes? ....

    Is this anything to be concerned about?

  9. #9
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think the "new" way to do this is `obj.votes.size` instead of obj.votes_count and `not obj.votes.empty?` instead of `obj.has_votes?`

    The warnings tell you that the way you're doing it is old, and will most likely be removed from Rails 2.0.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •