我一直低着头,觉得我可能犯了一个简单的错误,但我一直无法找到有关这个问题的任何信息.
我有一些Rails 5的请求规范,当我测试重定向时 - 但不是渲染模板 - 我得到一个错误,undefined method 'response_code' for nil:NilClass.这样做的原因似乎是,@response是nil,当匹配被称为(内ActionDispatch ::断言:: ResponseAssertions代码,而不是在我的代码).我能够使用cURL向API发出请求,并按预期返回响应.返回错误的位置在这里(这是ActionDispatch代码):
def generate_response_message(expected, actual = @response.response_code)
"Expected response to be a <#{code_with_name(expected)}>,"\
" but was a <#{code_with_name(actual)}>"
.dup.concat(location_if_redirected).concat(response_body_if_short)
end
Run Code Online (Sandbox Code Playgroud)
注意第一行,其中actualparam 的默认值设置为@response.response_code.
这是我的测试代码:
RSpec.describe "Admin registrations", type: :request do
describe "new sign-up" do
subject { get new_admin_registration_path }
it "redirects to home" do
expect(subject).to redirect_to(new_admin_session_path)
end
end
end
Run Code Online (Sandbox Code Playgroud)
测试日志中的相关行是:
Started GET "/admins/sign_up" for 127.0.0.1 at 2018-07-05 10:44:05 -0700
Processing …Run Code Online (Sandbox Code Playgroud) 我有一个使用 React Native 编写的 iOS 应用程序,直到我意识到 React Native 不适合我的需求,我需要使用 Xcode 编写应用程序。因为我的原始项目已经在 GitHub 上的一个存储库中,所以我想将我现有的 Git 存储库用于新的 Xcode 项目。
我是 IDE 的新手,有点害怕如果我只是将文件移到某些东西上会搞砸,我不知道如何修复它。有没有更正统的方法来做到这一点?我在谷歌上搜索了这个,并提出了很多建议,将新的 Git 存储库添加到现有的 Xcode 项目中,但不是相反。
我很感激我能得到的任何帮助!