|
2 | 2 |
|
3 | 3 | RSpec.describe Code0::Identities::Provider::Discord do |
4 | 4 | subject(:service_response) do |
5 | | - described_class.new(lambda { |
6 | | - { |
7 | | - redirect_uri: redirect_uri, |
8 | | - client_id: client_id, |
9 | | - client_secret: client_secret |
10 | | - } |
11 | | - }).load_identity(code: code) |
| 5 | + described_class.new({ |
| 6 | + redirect_uri: redirect_uri, |
| 7 | + client_id: client_id, |
| 8 | + client_secret: client_secret |
| 9 | + }).load_identity(code: code) |
12 | 10 | end |
13 | 11 |
|
14 | 12 | let(:redirect_uri) { SecureRandom.hex } |
|
34 | 32 | end |
35 | 33 | end |
36 | 34 |
|
37 | | - context "when everything is valid" do |
| 35 | + shared_examples "when everything is valid" do |
38 | 36 | let(:access_token) { SecureRandom.hex } |
39 | 37 | let(:response_body) { { id: 1, username: "name", email: "example@code0.tech" }.to_json } |
40 | 38 |
|
|
65 | 63 | expect(service_response.email).to eq("example@code0.tech") |
66 | 64 | end |
67 | 65 | end |
| 66 | + |
| 67 | + context "when config is Proc" do |
| 68 | + subject(:service_response) do |
| 69 | + described_class.new(lambda { |
| 70 | + { |
| 71 | + redirect_uri: redirect_uri, |
| 72 | + client_id: client_id, |
| 73 | + client_secret: client_secret |
| 74 | + } |
| 75 | + }).load_identity(code: code) |
| 76 | + end |
| 77 | + |
| 78 | + it_behaves_like "when everything is valid" |
| 79 | + end |
| 80 | + |
| 81 | + context "when config is a hash" do |
| 82 | + it_behaves_like "when everything is valid" |
| 83 | + end |
68 | 84 | end |
0 commit comments