no examples found

492 views
Skip to first unread message

Roelof Wobben

unread,
Aug 8, 2014, 12:25:19 PM8/8/14
to rs...@googlegroups.com
Hello,

I have made this file into spec/models/admin_users.rb

require 'rails_helper'
 
RSpec.describe Admin, type: :model do
 
def build_valid_user(opts = {})
valid_opts = {
name: "Example adminUser",
email: "admi...@example.com",
password: "foobar",
password_confirmation: "foobar",
}
User.new valid_opts.merge(opts)
end
 
it { should respond_to(:name) }
it { should respond_to(:password) }
 
context "given a valid user" do
subject(:any_valid_user) { build_valid_user }
 
it { should be_valid }
end

but when I do rspec spec/  I see this output:

No examples found.                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                 
Finished in 0.00023 seconds (files took 0.07842 seconds to load)                                                                                                                                                                                                                 
0 examples, 0 failures                                             

Roelof


Myron Marston

unread,
Aug 8, 2014, 12:39:57 PM8/8/14
to rs...@googlegroups.com
Your file name (spec/models/admin_users.rb) doesn't match the default value of the `pattern` option:


Rename your file to `spec/models/admin_users_spec.rb` and it should work.  If you'd like to use an alternate pattern, you can choose a different value for the `--pattern` option and put it in `.rspec`.

Myron

Roelof Wobben

unread,
Aug 8, 2014, 1:51:15 PM8/8/14
to rs...@googlegroups.com
Thanks,

Now I have to find a good example of a rspec 3.0 where  I can test responds_to.
I found a example but that one does not work.

Roelof


Op vrijdag 8 augustus 2014 18:39:57 UTC+2 schreef Myron Marston:

Roelof Wobben

unread,
Aug 8, 2014, 2:12:08 PM8/8/14
to rs...@googlegroups.com
Found one.

I now use this one :

RSpec.describe Admin do
  it { is_expected.to respond_to(:name) }
  it { is_expected.to respond_to(:password) }
  it { is_expected.not_to respond_to(:to_model) }
  it { is_expected.not_to respond_to(:compact, :flatten) }
end

but then I see this error message :   uninitialized constant Admin (NameError)

Does Devise not make the controller because I do not see any controller made by Devise.

Roelof


Op vrijdag 8 augustus 2014 19:51:15 UTC+2 schreef Roelof Wobben:

Myron Marston

unread,
Aug 8, 2014, 4:04:00 PM8/8/14
to rs...@googlegroups.com
On Friday, August 8, 2014 11:12:08 AM UTC-7, Roelof Wobben wrote:
Found one.

I now use this one :

RSpec.describe Admin do
  it { is_expected.to respond_to(:name) }
  it { is_expected.to respond_to(:password) }
  it { is_expected.not_to respond_to(:to_model) }
  it { is_expected.not_to respond_to(:compact, :flatten) }
end

but then I see this error message :   uninitialized constant Admin (NameError)

Does Devise not make the controller because I do not see any controller made by Devise.

Roelof

The error indicates that there isn't an `Admin` constant.  You'll need to define one and/or load the file that already defines it.

Re: Devise...you should ask on the devise mailing list.  I have no idea.

Myron
Reply all
Reply to author
Forward
0 new messages