Sha256: a8b664603b87d0537c010e71986739a30a86da7b199d3a186e2bcac755b3046d
Contents?: true
Size: 1.15 KB
Versions: 10
Compression:
Stored size: 1.15 KB
Contents
module WebmockStubsHelper RSpec.configure do |config| config.include self end def disable_webmock WebMock.allow_net_connect! yield WebMock.disable_net_connect! end def stub_client_credentials_request stub_request(:post, "https://client-id:client-secret@#{accounts_host}/oauth/token") .with(:body => {"grant_type"=>"client_credentials"}) .to_return(successful_json_response(access_token: "client-credentials-token")) end def stub_current_user_requests stub_request(:get, "https://#{accounts_host}/api/v1/users/current.json") .with(query: { access_token: "valid-access-token" }) .to_return(successful_json_response(mock_user_response)) stub_request(:get, "https://#{accounts_host}/api/v1/users/current.json") .with(query: { access_token: "invalid-access-token" }) .to_return(status: 401, body: "") end def accounts_host "accounts2.applicaster.com" end def mock_user_response { id: "123" } end def successful_json_response(body) { status: 200, body: body.to_json, headers: { "Content-Type" => "application/json" } } end end
Version data entries
10 entries across 10 versions & 1 rubygems