Skip to content

Commit

Permalink
Merge pull request #4 from JuzerShakir/vcr
Browse files Browse the repository at this point in the history
Record HTTP interactions with VCR
  • Loading branch information
JuzerShakir authored Dec 27, 2024
2 parents 59e1416 + 76042d2 commit cd80f59
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
imdb_title-*.gem
test.rb
test.rb
test/fixtures/vcr_cassettes
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ gem "minitest", "~> 5.20"
gem "minitest-hooks", "~> 1.5", ">= 1.5.2"
gem "rake", "~> 13.0", ">= 13.0.6"
gem "reek", "~> 6.1", ">= 6.1.4"
gem "require_all", "~> 3.0"
gem "standard", "~> 1.31", ">= 1.31.1"
gem "vcr", "~> 6.3", ">= 6.3.1"
gem "webmock", "~> 3.24"
18 changes: 18 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@ PATH
GEM
remote: http://rubygems.org/
specs:
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
base64 (0.1.1)
bigdecimal (3.1.9)
crack (1.0.0)
bigdecimal
rexml
date (3.4.1)
debug (1.10.0)
irb (~> 1.10)
reline (>= 0.3.8)
hashdiff (1.1.2)
httparty (0.21.0)
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
Expand All @@ -39,6 +46,7 @@ GEM
psych (5.2.2)
date
stringio
public_suffix (6.0.1)
racc (1.7.1)
rainbow (3.1.1)
rake (13.0.6)
Expand All @@ -51,6 +59,7 @@ GEM
regexp_parser (2.8.1)
reline (0.6.0)
io-console (~> 0.5)
require_all (3.0.0)
rexml (3.2.6)
rubocop (1.56.4)
base64 (~> 0.1.1)
Expand Down Expand Up @@ -84,6 +93,12 @@ GEM
rubocop-performance (~> 1.19.0)
stringio (3.1.2)
unicode-display_width (2.4.2)
vcr (6.3.1)
base64
webmock (3.24.0)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)

PLATFORMS
x86_64-linux
Expand All @@ -95,7 +110,10 @@ DEPENDENCIES
minitest-hooks (~> 1.5, >= 1.5.2)
rake (~> 13.0, >= 13.0.6)
reek (~> 6.1, >= 6.1.4)
require_all (~> 3.0)
standard (~> 1.31, >= 1.31.1)
vcr (~> 6.3, >= 6.3.1)
webmock (~> 3.24)

RUBY VERSION
ruby 3.2.2p53
Expand Down
9 changes: 9 additions & 0 deletions test/support/vcr_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

require "vcr"
require "webmock"

VCR.configure do |config|
config.cassette_library_dir = "test/fixtures/vcr_cassettes"
config.hook_into :webmock
end
18 changes: 13 additions & 5 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# frozen_string_literal: true

# load external libraries
require "debug"
require "minitest/autorun"
require "minitest/hooks"
require_relative "../lib/imdb_title"
require_relative "imdb_title_test"
require_relative "non_interactive_test"
require "debug"
require "require_all"

require_rel %w[
../lib/imdb_title
support
imdb_title_test
non_interactive_test
].freeze

# This helper class loads all the modules and methods required for the tests
class TestHelper < Minitest::Test
Expand All @@ -28,6 +34,8 @@ def self.inherited(subclass)
end

before(:all) do
@title = IMDb::Title.new "https://www.imdb.com/title/#{self.class::ID}"
id = self.class::ID

VCR.use_cassette(id) { @title = IMDb::Title.new "https://www.imdb.com/title/#{id}" }
end
end

0 comments on commit cd80f59

Please sign in to comment.