class Team < ActiveRecord::Base
has_and_belongs_to_many :teams
validates_presence_of :name
end
I suppose you mean :users instead of :teams
On Oct 24, 8:12 am, Loff Stoff
<li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:> I''m new to unit testing and Rails in general. I''ve
decided to build my
> projects in a TDD manner, but this has left me with some early
> questions.
> I have this test written out:
>
> describe User do
> it "should add user to team" do
> team = Team.create(:name => "Tigers")
> akash = User.create(:name => "Akash")
> akash.teams << team
> akash.memberships.size.should == 1
> john = User.create(:name => "John")
> john.buddyup_with(akash)
> john.memberships.size.should == 1
> akash.buddys.should include(john)
> end
> end
>
> Ideally, users may join many teams, and teams may have many members. If
> a user is paired up with another user through "buddyup", those
users
> will share all of the same teams.
> I''ve started on the User model, but I''m lost at this
point. Can
> somebody help me out? Here''s what I have so far:
>
> class User < ActiveRecord::Base
> has_and_belongs_to_many :teams
> validates_presence_of :name
> end
>
> class Team < ActiveRecord::Base
> has_and_belongs_to_many :teams
> validates_presence_of :name
> end
>
> All I want to do is pass the test, further functionality will be added
> later.
>
> --
> Posted viahttp://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.