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 { [1]is_expected.to respond_to(:name) }

  it { [2]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 { [3]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 { [4]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 [5][email protected].

To post to this group, send email to [6][email protected].

To view this discussion on the web visit
[7]https://groups.google.com/d/msgid/rspec/a6c1df1a-7901-4e92-8
719-3d2846496d81%40googlegroups.com.

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

References

1. http://is_expected.to/
2. http://is_expected.to/
3. http://is_expected.to/
4. http://is_expected.to/
5. mailto:[email protected]
6. mailto:[email protected]
7. 
https://groups.google.com/d/msgid/rspec/a6c1df1a-7901-4e92-8719-3d2846496d81%40googlegroups.com?utm_medium=email&utm_source=footer
8. 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/1407687908.1134556.151125785.0D624AA0%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to