Still new to Specs...
How do I create a spec to test a model method? Specifically, here is my
spec:
#testing model
describe User do
it "should have many user roles" do
User.reflect_on_association(:user_roles).should_not be_nil
end
it "should have many roles though user roles" do
User.reflect_on_association(:roles).should_not be_nil
end
it "should know what role it has" do
#User.should
end
end
The last spec is incomplete... basically, I will want the code to be
something like this:
class User < ActiveRecord::Base
has_many :user_roles
has_many :roles, :through => :user_roles
def has_role?(role)
self.roles.count(:conditions => ['name = ?', role]) > 0
end
end
How would I spec the last method?
Thanks
--
dp
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users