Thanks,
the problem was also that I forget to use reguruire 'test-helpers" .
This problem is solved.
Roelof
Op zondag 10 augustus 2014 18:25:11 UTC+2 schreef Xavier Shay:
> expected "Admin" to respond to :name
>
>
> This is saying 'expected the *string *"Admin" to respond', which isn't
> correct - you want to be testing against an *instance *of Admin.
>
> You need to either describe the class so the correct automatic subject is
> created:
>
> describe Admin do
> # ...
> end
>
> or explicitly assign a subject:
>
> describe "Admin" do
> subject { Admin.new }
> # ...
> end
>
> fwiw, I wouldn't typically test that an object responds to specific
> methods, they don't tend to be valuable tests. Consider testing specific
> behaviours that you are interested in - those methods should all be
> executed.
>
> Cheers,
> Xavier
>
> On Sun, Aug 10, 2014, at 09:33 PM, Roelof Wobben wrote:
>
> Sorry, here the right output :
>
>
> Failures:
>
>
>
>
>
> 1) Admin should respond to #name
>
>
>
> Failure/Error: it { is_expected.to respond_to(:name) }
> expected "Admin" to respond to :name
>
> # ./spec/models/admin_users_spec.rb:2:in `block (2 levels) in <top
> (required)>'
>
>
> 2) Admin should respond to #password
>
>
>
> Failure/Error: it { is_expected.to respond_to(:password) }
> expected "Admin" to respond to :password
>
> # ./spec/models/admin_users_spec.rb:3:in `block (2 levels) in <top
> (required)>'
>
>
> Finished in 0.00213 seconds (files took 0.16881 seconds to load)
>
>
>
> 4 examples, 2 failures
>
>
> Failed examples:
>
>
>
>
> rspec ./spec/models/admin_users_spec.rb:2 # Admin should respond to #name
> rspec ./spec/models/admin_users_spec.rb:3
> # Admin should respond to #password
>
>
> Op zondag 10 augustus 2014 13:25:25 UTC+2 schreef Roelof Wobben:
>
> Hello,
>
> I did make a admin user with Devise with rails g devise Admin.
> I see that I have name and password,
>
> But when I test it with this :
>
> 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
>
> I see this output :
>
> Failures:
>
> 1) admins should respond to #name
> Failure/Error: it { is_expected.to respond_to(:name) }
> expected "admins" to respond to :name
>
> # ./spec/models/admin_users_spec.rb:2:in `block (2 levels) in <top
> (required)>'
>
> 2) admins should respond to #password
> Failure/Error: it { is_expected.to respond_to(:password) }
> expected "admins" to respond to :password
>
> # ./spec/models/admin_users_spec.rb:3:in `block (2 levels) in <top
> (required)>'
>
> Finished in 0.00226 seconds (files took 0.16221 seconds to load)
>
>
> 4 examples, 2 failures
>
> Failed examples:
>
> rspec ./spec/models/admin_users_spec.rb:2 # admins should respond to #name
> rspec ./spec/models/admin_users_spec.rb:3
> # admins should respond to #password
>
> Roelof
>
>
>
> --
> 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 [email protected] <javascript:>.
> To post to this group, send email to [email protected] <javascript:>
> .
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rspec/a6c1df1a-7901-4e92-8719-3d2846496d81%40googlegroups.com
>
> <https://groups.google.com/d/msgid/rspec/a6c1df1a-7901-4e92-8719-3d2846496d81%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rspec/f9c7c91d-9fac-453c-baf5-eaa74dcbbb71%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.