Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rpsec No examples found

Hello i have read the other questions similar to this and they didn't help.

Can anyone see what the problem is?

When i run rspec spec i receive this error

No examples found.


Finished in 0.00027 seconds (files took 0.07589 seconds to load)
0 examples, 0 failures

Here is the tree structure

enter image description here book.spec.rb

require 'spec_helper'

describe Book do

    before :each do
      @book = Book.new "Title", "Author", :category
    end

    describe "#new" do
        it "returns a new book object"
            @book.should be_an_instance_of Book
        end
    end

end

spec_helper.rb

require_relative '../library'
require_relative '../book'

require 'yaml'

I have ruby 2.2.1p85 Rails 4.2.3

like image 974
joeyk16 Avatar asked May 30 '26 18:05

joeyk16


1 Answers

The file name is wrong. You have book.spec.rb and it should be book_spec.rb.

Also:

  • You don't have to require any spec file in your spec_helper. When you run $ rspec it will read all '*_spec' files on your spec/ folder.
  • You should put that model test inside spec/models folder.

You can read more about the standard structure of a Rails test suite here: http://www.relishapp.com/rspec/rspec-rails/v/3-3/docs/directory-structure

And this is a great place to learn about good practices about Rspec. http://betterspecs.org/

like image 112
Nerian Avatar answered Jun 01 '26 20:06

Nerian