#499 √ invalid
browe

param_from tests fail in rspec 1.1.4

Reported by browe | August 19th, 2008 @ 11:04 PM | in No-Milestone-Assigned

Since upgrading to Rails 2.1 and Rspec 1.1.4 our old routing tests fail if they are using the params_from.

Here is a sample test that used to pass: params_from(:get, "/items").should == {:controller => "items", :action => "index"}

Which results in:

NoMethodError in 'ItemsController route recognition should generate params { :controller => 'items', action => 'index' } from GET /items' undefined method to_plain_segments' for #<ActionController::Routing::RouteSet:0xb746b178>

some more information about the environment: ruby --version ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]

rake --version rake, version 0.8.1

rcov --version rcov 0.8.1.2 2007-11-22

We are using rspec 1.1.4 and rspec on rails both as plugins without the rspec gem installed.

Comments and changes to this ticket

  • David Chelimsky

    David Chelimsky August 20th, 2008 @ 01:37 AM

    • → State changed from “new” to “open”
    • → Assigned user changed from “” to “David Chelimsky”

    Are you sure about your rspec and rails versions? Any chance you're on edge for either?

  • browe

    browe August 20th, 2008 @ 03:18 PM

    I am sure that I'm not on edge for rails. Here's the output: rails --version Rails 2.1.0

    I don't know how to get the version of rspec and the rspec_rails plugins to show. I'd like to know! They are both plugins.

    I confirmed that it works on Mac OSX but not on Ubuntu Linux - 8.04. Both have ruby 1.8.6.

  • browe

    browe August 20th, 2008 @ 06:34 PM

    I just removed all my rails setup and rake. then reinstalled, same issue with the route tests. I believe these are the generated tests. I don't think we wrote new ones yet.

  • David Chelimsky

    David Chelimsky August 22nd, 2008 @ 03:26 PM

    browe - when you run "rails --version" you're going to get the version of your installed rails gem. Your application could, however, have any other version of rails in vendor/rails.

    The reason I ask about the rails version is that I am not able to reproduce the error with rspec-1.1.4 and rails-2.1.0, but there were some changes recently to edge rails that caused similar problems with routing code examples, and that has not yet been fixed in rspec's edge.

    Can you verify that you don't have rails in vendor/?

  • browe

    browe August 22nd, 2008 @ 03:42 PM

    Output of gem list - just to make sure I don't have any others installed. gem list --local | grep rails rails (2.1.0)

    Vendor/plugin directory: action_mailer_tls backgroundrb rspec_autotest simple_captcha acts_as_list rspec rspec-rails

    We don't freeze the gems yet, but will on this next release. I ran everything on Mac OSX fine today and did some more tests on Linux. I found that when running rake spec - the routing errors don't fail. rake spec:rcov they do fail. I get 1 failed test running rake spec. When I run that test use spec ./spec/models/the_test.rb it passes. When I run spec ./spec.... for the routing tests they pass. So, no I am thinking that some how in the upgrade my paths are not correct for Rake and rspec to run properly after the upgrade on Ubuntu 8.0.4. On the mac I do not have the rspec gem installed, I did not have it installed on Ubuntu either. In order to run the spec ./specs/mytests.rb commands I did install the rspec 1.1.4 gem. What should be the ideal rspec implementation - because the rspec-rails plugin with the rspec gem seems to cause them to easily get out of sync every time you run gem update. Or you could freeze the rspec gem, net effect is that its in the vendor plugins anyway right? That's a lot in this one - Sorry it might be off topic. I really need to get this resolved, so we can have the upgrade complete and start writing new code again. thank you

  • David Chelimsky

    David Chelimsky August 22nd, 2008 @ 03:55 PM

    We recommend installing both rspec and rspec-rails as plugins.

    The next release (1.1.5) will also package rspec-rails as a gem, so you'll be able to use both gems if you want at that point.

    But using one plugin and one gem requires that they are correctly synched up and this often causes trouble.

    As for running rake spec:rcov, I just did that on a few different apps with various versions of rails and rspec and did not see any problems related to routes emerge.

    As for getting different results when you run one spec vs running them all, that's a pretty strong indication that there are dependencies between code examples - that one example is leaking state (in memory or in data) and another example is behaving differently depending on whether the first example was run or not.

    HTH

  • browe

    browe August 22nd, 2008 @ 04:02 PM

    1) 'Customer should be able to clone itself' FAILED expected: 2,

     got: 0 (using ==)
    

    ./spec/models/customer_spec.rb:29:

    Finished in 1.109744 seconds

    189 examples, 1 failure rake aborted! Command /usr/bin/ruby1.8 -I"/home/browe/dev/development/feedback/trunk/vendor/plugins/rspec/lib" "/home/browe/dev/development/feedback/trunk/vendor/plugins/rspec/bin/spec" "spec/models/flag_spec.rb" "spec/models/email_token_spec.rb" "spec/models/helpful_spec.rb" "spec/models/role_spec.rb" "spec/models/token_spec.rb" "spec/models/category_spec.rb" "spec/models/right_spec.rb" "spec/models/login_spec.rb" "spec/models/purchase_spec.rb" "spec/models/itemcomment_spec.rb" "spec/models/user_spec.rb" "spec/models/notification_spec.rb" "spec/models/blog_spec.rb" "spec/models/comment_spec.rb" "spec/models/level_spec.rb" "spec/models/article_spec.rb" "spec/models/tag_spec.rb" "spec/models/articlecomment_spec.rb" "spec/models/customer_spec.rb" "spec/models/item_spec.rb" --options "/home/browe/dev/development/feedback/trunk/spec/spec.opts" failed

    (See full trace by running task with --trace) browe@saturn:trunk$ spec spec/model/customer_spec.rb .....

    Finished in 0.23068 seconds

    5 examples, 0 failures

    Here is the example where I ran rake spec:models and get the failure - but when I run spec spec/model/customer_spec.rb (The test that failed) the test passes. Making me think that the rake tasks for rpsec are not correct for me.

  • browe

    browe August 22nd, 2008 @ 04:09 PM

    I am good with the install as plugins - we like that best at this point. For the test failing, I'm good with calling that a bad test setup, etc.

    What I still can't see is why all the route tests fail on Ubuntu on after the upgrade to Rails 2.1 and rspec 1.1.4 but work on Mac OSX. The only think I can think of is something in the paths of the rake tasks during the upgrade. I'll keep working on it.

  • David Chelimsky

    David Chelimsky August 22nd, 2008 @ 04:10 PM

    Can you post the failing example?

  • browe

    browe August 24th, 2008 @ 05:57 PM

    Failed test output - for the route issue. (I assume this is the one, I'll take credit for a bad test on the other, not worried about that, my fault not rspec I think on that one.) This one, I can't figure on Ubuntu.

    
    52)
    NoMethodError in 'ItemsController route recognition should generate params { :controller => 'items', action => 'index' } from GET /items'
    undefined method `to_plain_segments' for #<ActionController::Routing::RouteSet:0xb7487350>
    ./spec/controllers/items_routing_spec.rb:42:
    

    This is the test case that generated that error. All of the tests that use params_from generate this eror.

    
    it "should generate params { :controller => 'items', action => 'index' } from GET /items" do
      params_from(:get, "/items").should == {:controller => "items", :action => "index"}
    end
    

    Before the upgrade all of these passed in linux and this one passes on the mac.

  • browe

    browe August 22nd, 2008 @ 04:18 PM

    I'll add that in this same test file all the tests that use route_for are passing. So this test passes:

    it "should map { :controller => 'items', :action => 'index' } to /items" do

     route_for(:controller => "items", :action => "index").should == "/items"
    end
    
  • Zach Dennis

    Zach Dennis August 24th, 2008 @ 08:20 PM

    browe,

    That's definitely an odd error you're seeing. RouteSet#to_plain_segments was added back in January in the recognition_optimisation.rb file (long before 2.1.0 came out). Perhaps on your Ubuntu box this file isn't getting loaded.

    Can you freeze the Rails 2.1.0 gems in your project on the Ubuntu box, and remove any rails gems that are installed temporarily. Then re-rerun the spec. This will help isolate the issue.

    If it passes, re-install the rails gems and re-run the specs. If it still passes, then unfreeze the gems in your project and re-run the specs.

    It doesn't sound like this is an rspec/rspec-rails issue though.

  • browe

    browe August 25th, 2008 @ 03:57 PM

    I'll try this today. Thank you for the help. When we run rake spec without rcov, we seem to get the results we want, but overall I think we have lost confidence in the tests to say the build is correct from them, and will to do a full manual regression.

  • Ronald de Gunst

    Ronald de Gunst September 5th, 2008 @ 04:00 PM

    Hi,

    I have the same problem.

    The error arises in 'rake spec:rcov' and not in 'rake spec'. But: The error arises not always.

    Rcov problem? Ruby binaries on Ubuntu not ok? Also running rcov-0.8.1.2.0, rails 2.1, ruby 1.8.6 on Ubuntu 8.04

    see log of tasks below:

    first try.

    rgunst@rgunst-laptop:~/workspace/depender$ rake spec:rcov --trace (in /home/rgunst/workspace/depender) Invoke spec:rcov (first_time) Invoke spec:clobber_rcov (first_time) Execute spec:clobber_rcov Execute spec:rcov .......................................................................................................................................................................FFFFFF.......FFFFFFF............................................FFFFFFF.....................................

    1) NoMethodError in 'ApplicationKindsController route recognition should generate params for #update' undefined method to_plain_segments' for #<ActionController::Routing::RouteSet:0xb775d2c8> ./spec/controllers/application_kinds_routing_spec.rb:52: .. .. ..

    run again:

    rgunst@rgunst-laptop:~/workspace/depender$ rake spec:rcov --trace (in /home/rgunst/workspace/depender) Invoke spec:rcov (first_time) Invoke spec:clobber_rcov (first_time) Execute spec:clobber_rcov Execute spec:rcov ...................................................................................................................................................................................................................................................................................

    Finished in 3.707719 seconds

    275 examples, 0 failures

    Another try

    rgunst@rgunst-laptop:~/workspace/depender$ rake spec:rcov (in /home/rgunst/workspace/depender) ..................................................................... glibc detected /usr/bin/ruby1.8: munmap_chunk(): invalid pointer: 0x08e7be90 glibc detected /usr/bin/ruby1.8: corrupted double-linked list: 0x08e7be78

  • David Chelimsky

    David Chelimsky September 22nd, 2008 @ 12:40 PM

    • → State changed from “open” to “invalid”
    • → Tag changed from “1.1.4 rspec ruby1.8” to “1.1.4 rspec ruby1.8”

    I think it is clear that the issue is with rcov and not rspec.

    browe - there have been a number of rcov bugs reported recently that have been addressed in a fork at github: http://github.com/spicycode/rcov...>

    Please check that out and see if ti solves your problem.

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Behaviour Driven Development for Ruby.

Shared Ticket Bins