I'm using the latest versions of Rails, Rspec and Factory Girl and I'm getting a strange issue when I try to test my create or update logic. The controller in question is an Admin namespaced PostsController and the model is Post. The factory itself just creates a post with a title and a body.
describe 'create' do
before :all do
@new = Factory.build(:post)
end
it 'should be successful' do
post :create, :post => @new
response.should be_success
end
describe 'failure' do
it 'should not create a new page' do
lambda do
post :create, :post => @new
end.should_not change(Post, :count)
end
it 'should render the new template' do
post :create, :post => @new
response.should render_template('new')
end
end
end
The error I keep receiving is:
ActiveRecord::UnknownAttributeError: unknown attribute: post
I'm probably doing something extremely stupid but I'm just lost right now.
UPDATE
Just in case anyone should ever stumble across this...
I was doing something extremely stupid. I had an error in my controller where instead of calling Post.new(params[:post]) I was calling Post.new(params)...