我是Rails的新手,特别是写测试。当我运行测试时,我不断收到错误undefined method allow
和undefined method allow_any_instance_of'
。 我检查了Rspec> 3应该接受允许的语法,我的代码中有什么问题?未定义的方法`允许'为#<RSpec :: Rspec 3.6.0
describe "GET #show" do
let(:sample_json_list) {
"{\"files\":[{\"title\":\"discourse-2017-08-24-085545-v20170803123704.sql.gz\",\"id\":\"0B7WjYjWZJv_4MENlYUM2SjkyU1E\",\"size\":\"14070939\",\"created_at\":\"2017-08-24T06:56:21.698+00:00\"}]}"
}
before {
allow_any_instance_of(DiscourseDownloadFromDrive::DriveDownloader).to receive(:json_list).and_return(sample_json_list)
}
it "renders the json" do
get :show
response.body.should == sample_json_list
end
end
你可以用'-b'选项运行你的规范并显示更多日志吗? – Tai