Help! Beginner Trying Test Driven Development

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 :users
validates_presence_of :name
end

All I want to do is pass the test, further functionality will be added
later.

class Team < ActiveRecord::Base
has_and_belongs_to_many :teams
validates_presence_of :name
end

I suppose you mean :users instead of :teams

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs