From b32bac90b47f42234b753cbe53dd5c2a9af9ce53 Mon Sep 17 00:00:00 2001 From: Thomas Dziedzic Date: Thu, 11 Jun 2020 17:30:25 -0500 Subject: [PATCH] fix keybase spec --- Gemfile | 2 + Gemfile.lock | 11 ++++ .../render_expected_kb_username.yml | 59 +++++++++++++++++++ spec/requests/keybase_proofs_spec.rb | 4 +- spec/support/vcr.rb | 4 ++ 5 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 fixtures/vcr_cassettes/render_expected_kb_username.yml create mode 100644 spec/support/vcr.rb diff --git a/Gemfile b/Gemfile index 60d00f37..174be1d5 100644 --- a/Gemfile +++ b/Gemfile @@ -55,4 +55,6 @@ group :test, :development do gem "faker" gem "byebug" gem "rb-readline" + gem "vcr" + gem "webmock" # used to support vcr end diff --git a/Gemfile.lock b/Gemfile.lock index 2f760bd7..6f88a8b8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -70,6 +70,8 @@ GEM commonmarker (0.21.0) ruby-enum (~> 0.5) concurrent-ruby (1.1.6) + crack (0.4.3) + safe_yaml (~> 1.0.0) crass (1.0.6) database_cleaner (1.8.5) diff-lcs (1.3) @@ -92,6 +94,7 @@ GEM good_migrations (0.0.2) activerecord (>= 3.1) railties (>= 3.1) + hashdiff (1.0.1) hashery (2.1.2) htmlentities (4.3.4) i18n (1.8.2) @@ -212,6 +215,7 @@ GEM ruby-rc4 (0.1.5) ruumba (0.1.14) rubocop + safe_yaml (1.0.5) scenic (1.5.2) activerecord (>= 4.0.0) railties (>= 4.0.0) @@ -241,6 +245,11 @@ GEM execjs (>= 0.3.0, < 3) unicode-display_width (1.7.0) uniform_notifier (1.13.0) + vcr (6.0.0) + webmock (3.8.3) + addressable (>= 2.3.6) + crack (>= 0.3.2) + hashdiff (>= 0.4.0, < 2.0.0) websocket-driver (0.7.1) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) @@ -289,6 +298,8 @@ DEPENDENCIES sprockets-rails (= 2.3.3) transaction_retry uglifier (>= 1.3.0) + vcr + webmock BUNDLED WITH 2.1.4 diff --git a/fixtures/vcr_cassettes/render_expected_kb_username.yml b/fixtures/vcr_cassettes/render_expected_kb_username.yml new file mode 100644 index 00000000..ce6444c4 --- /dev/null +++ b/fixtures/vcr_cassettes/render_expected_kb_username.yml @@ -0,0 +1,59 @@ +--- +http_interactions: +- request: + method: get + uri: https://keybase.io/_/api/1.0/user/pic_url.json?username=cryptojim + body: + encoding: US-ASCII + string: '' + headers: + Host: + - keybase.io + Cookie: + - '' + Referer: + - https://keybase.io/_/api/1.0/user/pic_url.json?username=cryptojim + User-Agent: + - Mozilla/5.0 (compatible) + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 11 Jun 2020 22:28:50 GMT + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '77' + Connection: + - keep-alive + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - 1; mode=block + X-Content-Type-Options: + - nosniff + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET + Access-Control-Allow-Headers: + - Content-Type, Authorization, Content-Length, X-Requested-With + Access-Control-Allow-Credentials: + - 'false' + Cache-Control: + - no-store + Etag: + - W/"4d-JswfwKfhQJbTftnpUPSRYMA4ubo" + Strict-Transport-Security: + - max-age=31536000; includeSubdomains; preload + body: + encoding: UTF-8 + string: '{"status":{"code":205,"desc":"cryptojim: user not found","name":"NOT_FOUND"}}' + recorded_at: Thu, 11 Jun 2020 22:28:50 GMT +recorded_with: VCR 6.0.0 diff --git a/spec/requests/keybase_proofs_spec.rb b/spec/requests/keybase_proofs_spec.rb index cf641086..15bb5091 100644 --- a/spec/requests/keybase_proofs_spec.rb +++ b/spec/requests/keybase_proofs_spec.rb @@ -17,7 +17,9 @@ describe 'keybase proofs', type: :request do context 'new' do it 'renders the expected kb_username' do - get '/keybase_proofs/new', params: new_params + VCR.use_cassette('render_expected_kb_username') do + get '/keybase_proofs/new', params: new_params + end expect(response.body).to include(kb_username) end end diff --git a/spec/support/vcr.rb b/spec/support/vcr.rb new file mode 100644 index 00000000..14e04aa4 --- /dev/null +++ b/spec/support/vcr.rb @@ -0,0 +1,4 @@ +VCR.configure do |config| + config.cassette_library_dir = 'fixtures/vcr_cassettes' + config.hook_into :webmock +end