更新:这实际上工作正常。请忽略此问题
我以前能够在RSpec控制器测试中调用ss.getRange (1,1).setFormula (code here);
,但这在RSpec request spec中没有任何作用....它不会产生错误,但它也没有任何效果。是否有其他方法可以放入请求规范中的调试器?
E.g:
byebug
上面是调试器,下面没有:
# spec/controllers/users_controller_spec.rb
require 'rails_helper'
describe UsersController do
describe "GET #index logged out" do
it "returns 401 when not logged in" do
get :index, format: :json_api
expect(response).to have_http_status(401)
byebug
end
end
end
答案 0 :(得分:1)
我已在我的环境中测试过您的文件
# specs/requests/users_request_spec.rb
require 'rails_helper'
describe "companies", type: :request do
describe 'GET /companies logged out' do
it 'returns 401 when not logged in' do
binding.pry # => this stops execution
get '/companies.json_api'
expect(response).to have_http_status(401)
binding.pry # => this does not
end
end
end
我的理由:
Failure/Error: get '/companies.json_api'
ActionController::RoutingError:
No route matches [GET] "/companies.json_api"
# ./spec/requests/users_request_spec.rb:6:in `block (3 levels) in <top (required)>'
要使其到达调试器,不应该有异常。你确定和你一样吗?