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.should redirect_to(signin_path) }

为什么我不能使用:

它的 { response.should redirect_to(signin_path) }

4

1 回答 1

2

AS ZippieJulianoapneadiving曾表示:

指定的别名

上下文它是一个别名来描述

您可以使用表单 its(:method) {expectation } 来调用主题上的方法:

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

its(:foo) { should == 0 }

测试这个

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