开发者

Can I use Rspec and respond_with in Rails 3.1?

My specs passed until I changed to respond_with in my generated controller. I ran across this issue on github, but it was closed some time ago. I'm stumped as to what to do next. How can I fix this problem?

  #campaigns_controller.rb
  # POST /campaigns
  # POST /campaigns.json开发者_StackOverflow
  def create
    @campaign = Campaign.new(params[:campaign])
    respond_with(@campaign)
  end

#campaigns_controller_spec.rb
describe "with valid params" do
  it "creates a new Campaign" do
    expect {
      post :create, :campaign => valid_attributes
    }.to change(Campaign, :count).by(1)
  end

Errors:
Failure/Error: expect {
       count should have been changed by 1, but was changed by 0
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜