Got stuck with:
' undefined method `post' for #<Class:0x000001058c0f68> (NoMethodError)'
on testing controller create
action.
I'm using Rails 4, rpsec, and Factory Girl
Controller:
def create
@post = Post.new(post_params)
@post.user_id = current_user.id
if @post.save
flash[:success] = "Yay! Post created!"
redirect_to root_path
else
# flash[:error] = @post.errors.full_messages
render 'new'
end
end
Test:
describe '#create' do
post 'create', FactoryGirl.attributes_for(:post, user: @user)
response.should be_successful
end