授权规范不适用于put请求

时间:2012-08-24 09:56:46

标签: ruby-on-rails-3 rspec capybara factory-bot

我是Michael Hartls Ruby On Rails教程的第9章。在我的 authentication_pages_specs.rb 中,“提交更新操作”导致规范崩溃,错误“未定义的局部变量或方法`user'for#(NameError)”

require 'spec_helper'

describe "Authentication" do
  subject { page }


  describe "authorization" do

    describe "for non signed-in users" do
      let(:user) { FactoryGirl.create(:user) }

      describe "in the users controller" do
        describe "visiting the edit page" do
          before { visit edit_user_path(user)}
          it { should have_selector('title', text: 'Sign in')}
        end

        describe "submitting to the update action" do
          describe { put user_path(user)}  #Error on this line
          specify { response.should redirect_to(signin_path) }
        end
      end
    end

  end

end

是什么告诫规格会崩溃?

谢谢

1 个答案:

答案 0 :(得分:0)

在阻止之前放入put部件可以解决问题