Skip to content

Commit 08d582d

Browse files
committed
Switch integrations specs to use vcr
1 parent 35d20e2 commit 08d582d

11 files changed

Lines changed: 1293 additions & 13 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,10 @@ Integration Tests
236236
rspec --tag integration
237237
```
238238

239-
By default, this runs the integration tests against the Sandbox API with an official CloudConvert account.
240-
If you would like to use your own account, you can set your API key using the `CLOUDCONVERT_API_KEY` enviroment variable.
239+
By default, this runs the integration tests against [VCR recordings](https://github.com/vcr/vcr) of the Sandbox API with an official CloudConvert account.
240+
If you would like to use your own account, you can set your API key using the `CLOUDCONVERT_API_KEY` environment variable.
241241
In this case you need to whitelist the following MD5 hashes for Sandbox API (using the CloudConvert dashboard).
242+
If you want the tests to do real web requests pass `VCR=off`.
242243

243244
```
244245
53d6fe6b688c31c565907c81de625046 input.pdf

cloudconvert.gemspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
1919
spec.add_dependency "faraday_middleware", "~> 1.0"
2020
spec.add_dependency "forwardable"
2121
spec.add_dependency "json"
22-
spec.add_dependency "memoizable", "~> 0.4.0"
22+
spec.add_dependency "memoizable", "~> 0.4"
2323
spec.add_dependency "mimemagic", "~> 0.3.5"
2424
spec.add_dependency "openssl"
2525
spec.add_dependency "ostruct"
@@ -34,4 +34,5 @@ Gem::Specification.new do |spec|
3434
spec.add_development_dependency "securerandom"
3535
spec.add_development_dependency "simplecov", "~> 0.16"
3636
spec.add_development_dependency "webmock"
37+
spec.add_development_dependency "vcr", "~> 6.0"
3738
end

spec/integration/jobs_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require "integration_helper"
22

3-
describe CloudConvert::Resources::Jobs, :integration do
3+
describe CloudConvert::Resources::Jobs, :integration, :vcr do
44
let(:cloudconvert) do
55
CloudConvert::Client.new({
66
api_key: CLOUDCONVERT_API_KEY,

spec/integration/tasks_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
require "integration_helper"
22

3-
describe CloudConvert::Resources::Tasks, :integration do
3+
describe CloudConvert::Resources::Tasks, :integration, :vcr do
44
let(:cloudconvert) do
55
CloudConvert::Client.new({
66
api_key: CLOUDCONVERT_API_KEY,
77
sandbox: true,
88
})
99
end
1010

11-
it "performs import/upload task" do
11+
it "performs import upload task" do
1212
# create task
1313
@task = cloudconvert.tasks.create({
1414
operation: "import/upload",
@@ -25,7 +25,7 @@
2525
expect(@task.result.files.first.filename).to eq "input.pdf"
2626
end
2727

28-
it "performs import/url task" do
28+
it "performs import url task" do
2929
# create task
3030
@task = cloudconvert.tasks.create({
3131
operation: "import/url",

spec/integration/users_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require "integration_helper"
22

3-
describe CloudConvert::Resources::Users, :integration do
3+
describe CloudConvert::Resources::Users, :integration, :vcr do
44
let(:cloudconvert) do
55
CloudConvert::Client.new({
66
api_key: CLOUDCONVERT_API_KEY,
@@ -12,7 +12,7 @@
1212
cloudconvert.users.me
1313
end
1414

15-
it "returns extended information of the user" do
15+
it "performs user query" do
1616
expect(user).to be_a CloudConvert::User
1717
end
1818
end

spec/integration/vcr/CloudConvert_Resources_Jobs/performs_upload_and_download_of_file.yml

Lines changed: 620 additions & 0 deletions
Large diffs are not rendered by default.

spec/integration/vcr/CloudConvert_Resources_Tasks/performs_import_upload_task.yml

Lines changed: 332 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/integration/vcr/CloudConvert_Resources_Tasks/performs_import_url_task.yml

Lines changed: 276 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/integration/vcr/CloudConvert_Resources_Users/performs_user_query.yml

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/integration_helper.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1-
CLOUDCONVERT_API_KEY = ENV["CLOUDCONVERT_API_KEY"] || "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjI4YmE3OGQyZjc1NWM5ZGE3Yjg1NDRhMWRkMjg2NWM4N2U0YzI5NWI0NzQ0Zjc4ZDNmMzA3OWM2NjU3ZjI0MjVhOTMyYjIxMjU5ZGU2NWQ4In0.eyJhdWQiOiIxIiwianRpIjoiMjhiYTc4ZDJmNzU1YzlkYTdiODU0NGExZGQyODY1Yzg3ZTRjMjk1YjQ3NDRmNzhkM2YzMDc5YzY2NTdmMjQyNWE5MzJiMjEyNTlkZTY1ZDgiLCJpYXQiOjE1NTkwNjc3NzcsIm5iZiI6MTU1OTA2Nzc3NywiZXhwIjo0NzE0NzQxMzc3LCJzdWIiOiIzNzExNjc4NCIsInNjb3BlcyI6WyJ1c2VyLnJlYWQiLCJ1c2VyLndyaXRlIiwidGFzay5yZWFkIiwidGFzay53cml0ZSIsIndlYmhvb2sucmVhZCIsIndlYmhvb2sud3JpdGUiXX0.IkmkfDVGwouCH-ICFAShQMHyFAHK3y90CSoissUVD8h5HFG4GqN5DEw0IFzlPr1auUKp3H1pAvPutdIQtrDMTmUUmGMUb2dRlCAuQdqxa81Q5KAmcKDgOg2YTWOWEGMy3jETTb7W6vyNGsT_3DFMapMdeOw1jdIUTMZqW3QbSCeGXj3PMRnhI7YynaDtmktjzO9IUDHbeT2HRzzMiep97KvVZNjYtZvgM-kbUjE6Mm68_kA8JMuQeor0Yg7896JPV0YM3-MnHf7elKgoCJbfBCDAbvSX_ZYsSI7IGoLLb0mgJVfFcH_HMYAHhJj5cUEJN2Iml-FkODqrRk72bVxyJs9j1GPQBl4ORXuU9yrjUgHrRaZ5YM__LwsUQB3AuB92oyQseCjULn1sWM1PzIXCcyVjKZSp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jYtZvgM-kbUjE6Mm68_kA8JMuQeor0Yg7896JPV0YM3-MnHf7elKgoCJbfBCDAbvSX_ZYsSI7IGoLLb0mgJVfFcH_HMYAHhJj5cUEJN2Iml-FkODqrRk72bVxyJs9j1GPQBl4ORXuU9yrjUgHrRaZ5YM__LwsUQB3AuB92oyQseCjULn1sWM1PzIXCcyVjKZSpn9LAAGNf9paCF-_G9ok9tZKccRouCiYl9v5XbmuxV8hXYp6fXZxyaAkj_JN2kErVSkxYzVyyZL1e220aFFnbch6nDvLFHgi-WeTQHFQDzuHsM8RKRixV8uD7pk3de4AEYg0EWqZHCr82qY7TGdSQvuAS0QIy3B89OwQW0ROW4k3Yw0XIKgKSYWyKnc7huc7yPQUIDDDAOa5OojXrVY5ZuL_hwQMIOmejcHTKFdAgzAaVnRkC8_FfVh4wHCPBaHjze9hRp5n4O1pnPFI")
4+
5+
VCR.configure do |config|
6+
config.cassette_library_dir = File.expand_path("integration/vcr", __dir__)
7+
config.configure_rspec_metadata!
8+
config.default_cassette_options = { record: ENV.fetch("VCR_RECORD_MODE", :once).to_sym }
9+
config.hook_into :webmock unless ENV["VCR"] == "off"
10+
end
211

312
WebMock.allow_net_connect!

0 commit comments

Comments
 (0)