我可以在Rails 3.1中使用Rspec和respond_with吗?

时间:2011-09-15 00:34:02

标签: rspec ruby-on-rails-3.1

我的规格通过,直到我在生成的控制器中更改为respond_with。我在github上遇到了this问题,但它在不久前关闭了。我很难过接下来要做什么。我该如何解决这个问题?

  #campaigns_controller.rb
  # POST /campaigns
  # POST /campaigns.json
  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 个答案:

没有答案