jeudi 29 janvier 2015

create a post controller spec test

I am doing a controller test but it seems that spec.rb is wrong. Do you have a suggestion ?


This is my posts_controller.rb



class PostsController < ApplicationController

def create
@post = Post.new(params[:post])
if @post.save
redirect_to @wall
end
end

def destroy
@post.destroy
end

end


and this is my posts_controller_spec.rb



require 'rails_helper'

describe PostsController do

describe "#create" do
it "saves the new post in the wall" do
post :create, { wall_id: '1', content: "Some text I would like to put in my post" }

end
end

describe "#destroy" do
it "deletes the post in the wall" do

end
end
end


could you please help me to correct my spec.rb? Thanks


Aucun commentaire:

Enregistrer un commentaire