why do I see other output ?

22 views
Skip to first unread message

Roelof Wobben

unread,
Jun 26, 2014, 8:05:55 AM6/26/14
to rs...@googlegroups.com
Hello,

I follow this tutorial to test my app : http://everydayrails.com/2012/03/19/testing-series-rspec-models-factory-girl.html
the only thing I do it different that I use my own app.

I did all the steps and at some point I have to do : rspec spec/models/contributie_spec.rb

According to the page I have to see a lot of pending tests.
But all  I see is this :

No examples found.

Finished in 0.00028 seconds (files took 0.07798 seconds to load)
0 examples, 0 failures

You can see what I have done here : https://github.com/roelof1967/finance

Can anyone tell me what went wrong ?

Roelof


Myron Marston

unread,
Jun 26, 2014, 11:49:18 AM6/26/14
to rs...@googlegroups.com
spec/models/contributie_spec.rb is empty:


It looks like you tried to get it to work in spec/contributor_spec.rb:


...but you'll need to run `rspec spec/contributie_spec.rb` to run that spec file.  Or you can just run `rspec` and it'll run them all.

Note that for that second file you've got `contributie` (lower case) which ruby will treat as a local variable or method call (neither of which are defined in this context) so you'll get a `NameError`.  I think you want `Contributie` (note the capitol C), which is the constant you are describing there.

HTH,
Myron

Roelof Wobben

unread,
Jun 26, 2014, 2:20:37 PM6/26/14
to rs...@googlegroups.com
Changed it .See the new commit but now I see this error :



Op donderdag 26 juni 2014 17:49:18 UTC+2 schreef Myron Marston:
On Thursday, June 26, 2014 5:05:55 AM UTC-7, Roelof Wobben wrote:
Hello,

I follow this tutorial to test my app : http://everydayrails.com/2012/03/19/testing-series-rspec-models-factory-girl.html
the only thing I do it different that I use my own app.

I did all the steps and at some point I have to do : rspec spec/models/contributie_spec.rb


/home/roelof/rails/wissel-finance/spec/models/contributie_spec.rb:3:in `<top (required)>': undefined local variable or method `contributie' for main:Object (NameError)
    from /var/lib/gems/1.9.1/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in `load'
    from /var/lib/gems/1.9.1/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in `block in load_spec_files'
    from /var/lib/gems/1.9.1/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in `each'
    from /var/lib/gems/1.9.1/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in `load_spec_files'
    from /var/lib/gems/1.9.1/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:97:in `setup'
    from /var/lib/gems/1.9.1/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:85:in `run'
    from /var/lib/gems/1.9.1/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:70:in `run'
    from /var/lib/gems/1.9.1/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:38:in `invoke'
    from /var/lib/gems/1.9.1/gems/rspec-core-3.0.2/exe/rspec:4:in `<top (required)>'
    from /usr/local/bin/rspec:23:in `load'
    from /usr/local/bin/rspec:23:in `<main>'
roelof@roelof-System-Product-Name:~/rails/wissel-finance$ rspec spec/models/contributie_spec.rb
/home/roelof/rails/wissel-finance/spec/models/contributie_spec.rb:3:in `<top (required)>': uninitialized constant Contributie (NameError)
    from /var/lib/gems/1.9.1/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in `load'
    from /var/lib/gems/1.9.1/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in `block in load_spec_files'
    from /var/lib/gems/1.9.1/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in `each'
    from /var/lib/gems/1.9.1/gems/rspec-core-3.0.2/lib/rspec/core/configuration.rb:1057:in `load_spec_files'
    from /var/lib/gems/1.9.1/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:97:in `setup'
    from /var/lib/gems/1.9.1/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:85:in `run'
    from /var/lib/gems/1.9.1/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:70:in `run'
    from /var/lib/gems/1.9.1/gems/rspec-core-3.0.2/lib/rspec/core/runner.rb:38:in `invoke'
    from /var/lib/gems/1.9.1/gems/rspec-core-3.0.2/exe/rspec:4:in `<top (required)>'
    from /usr/local/bin/rspec:23:in `load'
    from /usr/local/bin/rspec:23:in `<main>'


So schould I do require  app/models/contributie.rb  above the test file or is there a better solution ?

Roelof
 

Myron Marston

unread,
Jun 26, 2014, 3:49:56 PM6/26/14
to rs...@googlegroups.com
As I said before:

Roelof Wobben

unread,
Jun 26, 2014, 3:54:28 PM6/26/14
to rs...@googlegroups.com
I did change that file :

require 'spec_helper'

describe Contributie do
  it "has a valid soort"
  it "has a valid bedrag"
end

the first file I deleted.

Roelof


Op donderdag 26 juni 2014 21:49:56 UTC+2 schreef Myron Marston:

Aaron Kromer

unread,
Jun 26, 2014, 5:56:41 PM6/26/14
to rs...@googlegroups.com

It looks like you are using rspec-rails 3, while the tutorial was written with RSpec 2. You need to use require 'rails_helper' instead of require 'spec_helper' in your spec file.



--
You received this message because you are subscribed to the Google Groups "rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rspec+un...@googlegroups.com.
To post to this group, send email to rs...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/f15f1903-78c2-4bad-8cfd-3397c83691ff%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages