Tag: 测试覆盖

Oauth模型关注测试覆盖存根

我试图找出在这个课程上达到100%测试覆盖率的最佳方法。 我概述了我的完整规范,我希望有人可以指出我正确的方向。 我的假设是将Oauth2请求存根,但我似乎无法做到这一点。 我正在使用Rails 4。 规格 RSpec.describe ‘AppOmniAuthentication’, type: :concern do let(:klass) { User } let(:user) { create(:user) } let(:user_oauth_json_response) do unfiltered_oauth_packet = load_json_fixture(‘app_omni_authentication_spec’) unfiltered_oauth_packet[‘provider’] = unfiltered_oauth_packet[‘provider’].to_sym unfiltered_oauth_packet[‘uid’] = unfiltered_oauth_packet[‘uid’].to_i unfiltered_oauth_packet end before do OmniAuth.config.test_mode = true OmniAuth.config.mock_auth[:app] = OmniAuth::AuthHash.new( user_oauth_json_response, credentials: { token: ENV[‘APP_CLIENT_ID’], secret: ENV[‘APP_CLIENT_SECRET’] } ) end describe ‘#from_omniauth’ do let(:app_oauth) { […]