1

このコードがあるとしましょう:

require 'spec_helper'

  describe "authorization" do

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

      describe "in the Users controller" do

      describe "submitting to the update action" do
        before { put user_path(user) }
        specify { response.should redirect_to(signin_path) }
      end
    end
  end
end

それ以外の:

指定 { response.shoredirect_to(signin_path) }

使用できなかった理由:

その { response.should redirect_to(signin_path) }

4

1 に答える 1

2

AS ZippieJulianoapneadivingは次のように述べています。

それにエイリアスを指定する

context説明するエイリアス

フォーム its(:method) { expected } を使用して、サブジェクトのメソッドを呼び出すことができます。

let(:bar) { Bar.new }
subject { bar }

its(:foo) { should == 0 }

これをテストする

class Bar
  def foo
    0
  end
end
于 2013-03-07T21:12:10.753 に答える