Assertions don't work with Cucumber #1104

Closed
tmoskun opened this Issue Aug 6, 2011 · 6 comments

Projects

None yet

3 participants

@tmoskun
tmoskun commented Aug 6, 2011

It's rubinius 1.2.5dev (1.8.7 151932a yyyy-mm-dd JI) [i686-pc-linux-gnu]

When running a Cucumber step such as:
'Given no user exists with an email of "email@example.com"'
(such steps can be created with the gem "clearance")

I get the following error:

undefined method `add_assertion' on nil:NilClass. (NoMethodError)
  kernel/delta/kernel.rb:79:in `method_missing'
  /home/tanya/rubinius/lib/test/unit/testcase.rb:129:in `add_assertion'
  /home/tanya/rubinius/lib/test/unit/assertions.rb:494:in `_wrap_assertion'
  /home/tanya/rubinius/lib/test/unit/assertions.rb:46:in `assert_block'
  /home/tanya/rubinius/lib/test/unit/assertions.rb:83:in `assert_equal'
  /home/tanya/rubinius/lib/test/unit/assertions.rb:172:in `assert_nil'
  ./features/step_definitions/clearance/clearance_steps.rb:22:in `__script__':in `/^no user exists with an email of "(.*)"$/'
  features/clearance/visitor_resets_password.feature:8:in `Given no user exists with an email of "email@example.com"'

After a little research, I discovered that the error in /rubinius/lib/test/unit/testcase.rb:129:in `add_assertion' is due to the method "run" in /home/tanya/rubinius/lib/test/unit/testcase.rb:73 never called to initialize the @_result variable, hence its value is nil.

Also, there were 2 more small bugs:

  1. Installation of gems with native extensions failed because it couldn't locate the /rubinious/include/ruby.h file. It's easy to reproduce by running "gem install RedCloth". To make it pass, I had to put a link called "include" into the /rubinious directory pointing to /rubinius/vm/capi/include.
  2. The rake command didn't run because the first line in the file "/rubinius/gems/bin/rake" referred to "Users/even/.../rbx" which was never my own path to rbx (probably hardcoded). It worked after I replaced the first line with my own path to rbx.

That was the rbx day in Mountain View.

@dbussink
Member

Is this still a problem? If not, we should close this issue.

@frodsan
Contributor
frodsan commented Nov 17, 2012

@tmoskun Is this still an issue? Could you try this with Rubinius 2.0.0.rc1 or master version? Thanks!

@tmoskun
tmoskun commented Nov 19, 2012

I have installed Rubinius 2.0.0.rc1 and tested with the same small project. It still gives exactly the same exception just the line numbers became different:

undefined method add_assertion' on nil:NilClass. (NoMethodError) kernel/delta/kernel.rb:81:inmethod_missing'
/home/tanya/.rvm/rubies/rbx-2.0.0pre/lib/18/test/unit/testcase.rb:125:in
add_assertion' /home/tanya/.rvm/rubies/rbx-2.0.0pre/lib/18/test/unit/assertions.rb:494:in_wrap_assertion'
/home/tanya/.rvm/rubies/rbx-2.0.0pre/lib/18/test/unit/assertions.rb:46:in
assert_block' /home/tanya/.rvm/rubies/rbx-2.0.0pre/lib/18/test/unit/assertions.rb:83:inassert_equal'
/home/tanya/.rvm/rubies/rbx-2.0.0pre/lib/18/test/unit/assertions.rb:172:in
assert_nil' ./features/step_definitions/clearance/clearance_steps.rb:22:inscript':in /^no user exists with an email of "(.*)"$/' features/clearance/visitor_resets_password.feature:8:inGiven
no user exists with an email of "email@example.com"'

I didn't encounter the other 2 small bugs this time.

@dbussink
Member

Can you give us the exact steps to reproduce this? Please assume we know nothing and describe the steps in detail, so we can recreate the problem. Right now I have no idea how I could recreate the problem here locally.

@tmoskun
tmoskun commented Nov 19, 2012

it was run on Ubuntu 11

  1. Download the project from my github account, it's called "mongo-example"
    https://github.com/tmoskun/mongo-example
  2. Install a MongoDB database server http://www.mongodb.org/downloads
    http://docs.mongodb.org/manual/installation/
  3. Start the server with "sudo mongod"
  4. Start the interactive shell with "mongo"
  5. in the shell:

    use mongo_story_test
    db.createCollection("users")
    db.createCollection("stories")
    db.createCollection("comments")
    db.stories.ensureIndex('voters')
    exit

  6. cd mongo-example
  7. bundle install
  8. cucumber

Sorry, if I missed something with the installation, I already had everything installed.

Alternatively, without installing a MongoDB database server :
use the beginning of this article http://rubylearning.com/blog/2010/10/05/outside-in-development/ to generate the sample project
(I didn't run it, but it's the same feature as in my example)

  1. gem install suspenders --pre
  2. suspenders create twiddr
  3. cd twiddr
  4. Assuming that the database exists
  5. rake db:migrate
  6. rails generate clearance:views
  7. cucumber

Also, please, refer to my first bug description pointing to the cause. If you like, I myself can look into fixing it and submitting a pull request.

@dbussink
Member

I just tested with Ruby 1.8.7 and it has the exact same failures. That to me points to a general problem with the tests, not to a problem in Rubinius.

In Ruby 1.9.3 and Rubinius 1.9 mode, this problem doesn't show. Therefore I'm closing this, since our behavior matches for both 1.8 and 1.9.

@dbussink dbussink closed this Nov 19, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment