假设我有这段代码:
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)}
答案 0 :(得分:2)
AS Zippie,Juliano,apneadiving已声明:
指定为 it
的别名上下文是 describe
的别名您可以使用表单(:method){expectation}来调用主题上的方法:
let(:bar) { Bar.new }
subject { bar }
its(:foo) { should == 0 }
测试这个
class Bar
def foo
0
end
end