Sha256: e82b82ef39baf3a905c1696b331ef56ee968bed0eebda0afa404b3625071c086

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'

RSpec.describe CmQuiz::Review::GetUserInfo do
  describe '#perform' do
    let!(:project_api) do
      api = double
      allow(api).to receive(:request) do |verb, path, opts|
        double(success?: true, body: { email: email, name: name}.to_json, code: 200)
      end
      api
    end
    let(:hex) { '58714e1256' }
    let(:name) { "codementor-test-#{hex}" }
    let(:email) { "#{name}@codementor.io"}
    let(:service) do
      CmQuiz::Review::GetUserInfo.new({
        project_api: project_api
      })
    end
    before :each do
      factory = double(create: ['jwt', 'refresh_token'])
      allow(CmQuiz::Factory::User).to receive(:new).and_return(factory)
      allow(SecureRandom).to receive(:hex).and_return(hex)
    end

    it "should pass test" do
      test_result = service.perform

      expect(test_result).to eq(["get /me", true, nil])
      options = {
        headers: {
          'x-access-token' => 'jwt'
        }
      }
      args = [:get, '/me', options]
      expect(project_api).to have_received(:request).with(*args)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cm_quiz-0.0.2 spec/lib/cm_quiz/review/get_user_info_spec.rb
cm_quiz-0.0.1 spec/lib/cm_quiz/review/get_user_info_spec.rb