In almost all my controllers I scope everything through an @account
model object, e.g:
#teams_controller.rb
def new
@team = @account.teams.build
end
So far I have got passing specs using these:
describe TeamsController do
let(:account) { Account.new }
before(:each) do
Account.stub!(:find_by_subdomain!).and_return(account)
account.stub!(:teams)
end
describe "GET new" do
let(:team) { Team.new("account_id" => account.id) }
before(:each) do
account.teams.should_receive(:build).and_return(team)
end
it "assigns @team to a new scoped instance of Team" do
get :new
assigns[:team].should eq(team)
end
it "renders the new template" do
get :new
response.should render_template("new")
end
end
end
I am interested to know if this is best practice for scoping everything
through an existing model object.
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users