diff --git a/.rubocop.yml b/.rubocop.yml index dd7f0e2..34ae2b2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,14 +6,16 @@ # guidelines for contributions. # # Any of these may be changed. -AllCops: - TargetRubyVersion: "3.2.2" - -StringLiterals: - Enabled: false +require: + - rubocop-minitest + - rubocop-rake + - standard -SpaceInsideHashLiteralBraces: - Enabled: false +inherit_gem: + standard: config/base.yml -Style/ClassVars: - Enabled: false +AllCops: + TargetRubyVersion: 3.2.2 + NewCops: enable + Exclude: + - "test.rb" diff --git a/Gemfile b/Gemfile index a63dc16..43a3635 100644 --- a/Gemfile +++ b/Gemfile @@ -13,6 +13,9 @@ 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 "rubocop", "~> 1.69", ">= 1.69.2" +gem "rubocop-minitest", "~> 0.36.0" +gem "rubocop-rake", "~> 0.6.0" gem "standard", "~> 1.31", ">= 1.31.1" gem "vcr", "~> 6.3", ">= 6.3.1" gem "webmock", "~> 3.24" diff --git a/Gemfile.lock b/Gemfile.lock index a99ab03..5b36af5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -13,6 +13,7 @@ GEM ast (2.4.2) base64 (0.1.1) bigdecimal (3.1.9) + concurrent-ruby (1.3.4) crack (1.0.0) bigdecimal rexml @@ -20,6 +21,34 @@ GEM debug (1.10.0) irb (~> 1.10) reline (>= 0.3.8) + dry-configurable (1.2.0) + dry-core (~> 1.0, < 2) + zeitwerk (~> 2.6) + dry-core (1.0.2) + concurrent-ruby (~> 1.0) + logger + zeitwerk (~> 2.6) + dry-inflector (1.1.0) + dry-initializer (3.1.1) + dry-logic (1.5.0) + concurrent-ruby (~> 1.0) + dry-core (~> 1.0, < 2) + zeitwerk (~> 2.6) + dry-schema (1.13.4) + concurrent-ruby (~> 1.0) + dry-configurable (~> 1.0, >= 1.0.1) + dry-core (~> 1.0, < 2) + dry-initializer (~> 3.0) + dry-logic (>= 1.4, < 2) + dry-types (>= 1.7, < 2) + zeitwerk (~> 2.6) + dry-types (1.7.2) + bigdecimal (~> 3.0) + concurrent-ruby (~> 1.0) + dry-core (~> 1.0) + dry-inflector (~> 1.0) + dry-logic (~> 1.4) + zeitwerk (~> 2.6) hashdiff (1.1.2) httparty (0.21.0) mini_mime (>= 1.0.0) @@ -28,10 +57,10 @@ GEM irb (1.14.3) rdoc (>= 4.0.0) reline (>= 0.4.2) - json (2.6.3) - kwalify (0.7.2) + json (2.9.1) language_server-protocol (3.17.0.3) lint_roller (1.1.0) + logger (1.6.4) mini_mime (1.1.5) minitest (5.20.0) minitest-hooks (1.5.2) @@ -39,8 +68,8 @@ GEM multi_xml (0.6.0) nokogiri (1.15.4-x86_64-linux) racc (~> 1.4) - parallel (1.23.0) - parser (3.2.2.3) + parallel (1.26.3) + parser (3.3.6.0) ast (~> 2.4.1) racc psych (5.2.2) @@ -52,53 +81,60 @@ GEM rake (13.0.6) rdoc (6.10.0) psych (>= 4.0.0) - reek (6.1.4) - kwalify (~> 0.7.0) - parser (~> 3.2.0) + reek (6.3.0) + dry-schema (~> 1.13.0) + parser (~> 3.3.0) rainbow (>= 2.0, < 4.0) - regexp_parser (2.8.1) + rexml (~> 3.1) + regexp_parser (2.10.0) 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) + rubocop (1.69.2) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.2.3) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.1, < 2.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.36.2, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.29.0) - parser (>= 3.2.1.0) - rubocop-performance (1.19.1) - rubocop (>= 1.7.0, < 2.0) - rubocop-ast (>= 0.4.0) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.37.0) + parser (>= 3.3.1.0) + rubocop-minitest (0.36.0) + rubocop (>= 1.61, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-performance (1.23.0) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rake (0.6.0) + rubocop (~> 1.0) ruby-progressbar (1.13.0) - standard (1.31.1) + standard (1.43.0) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.0) - rubocop (~> 1.56.2) + rubocop (~> 1.69.1) standard-custom (~> 1.0.0) - standard-performance (~> 1.2) + standard-performance (~> 1.6) standard-custom (1.0.2) lint_roller (~> 1.0) rubocop (~> 1.50) - standard-performance (1.2.0) + standard-performance (1.6.0) lint_roller (~> 1.1) - rubocop-performance (~> 1.19.0) + rubocop-performance (~> 1.23.0) stringio (3.1.2) - unicode-display_width (2.4.2) + unicode-display_width (3.1.3) + unicode-emoji (~> 4.0, >= 4.0.4) + unicode-emoji (4.0.4) vcr (6.3.1) base64 webmock (3.24.0) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) + zeitwerk (2.7.1) PLATFORMS x86_64-linux @@ -111,6 +147,9 @@ DEPENDENCIES rake (~> 13.0, >= 13.0.6) reek (~> 6.1, >= 6.1.4) require_all (~> 3.0) + rubocop (~> 1.69, >= 1.69.2) + rubocop-minitest (~> 0.36.0) + rubocop-rake (~> 0.6.0) standard (~> 1.31, >= 1.31.1) vcr (~> 6.3, >= 6.3.1) webmock (~> 3.24) diff --git a/Rakefile b/Rakefile index c616c7a..c61b7cb 100644 --- a/Rakefile +++ b/Rakefile @@ -47,6 +47,6 @@ end desc "linting & code smell detector" task :analysis do - sh "standardrb" + sh "rubocop" sh "reek" end diff --git a/imdb_title.gemspec b/imdb_title.gemspec index 9617b74..d6b8acd 100644 --- a/imdb_title.gemspec +++ b/imdb_title.gemspec @@ -17,9 +17,10 @@ Gem::Specification.new do |s| s.metadata = { "source_code_uri" => "https://github.com/JuzerShakir/imdb", "changelog_uri" => "https://github.com/JuzerShakir/imdb/blob/master/CHANGELOG.md", - "bug_tracker_uri" => "https://github.com/JuzerShakir/imdb/issues" + "bug_tracker_uri" => "https://github.com/JuzerShakir/imdb/issues", + "rubygems_mfa_required" => "true" } - s.add_runtime_dependency "httparty", "~> 0.21.0" - s.add_runtime_dependency "nokogiri", "~> 1.15", ">= 1.15.4" + s.add_dependency "httparty", "~> 0.21.0" + s.add_dependency "nokogiri", "~> 1.15", ">= 1.15.4" s.required_ruby_version = ">= 2.7.0" end diff --git a/lib/helper.rb b/lib/helper.rb index 2a61001..daf27dc 100644 --- a/lib/helper.rb +++ b/lib/helper.rb @@ -5,5 +5,4 @@ require "httparty" # load all files & folders of the current directory 'lib' -lib = __dir__ -Dir.glob(File.join(lib, "**", "*.rb")).sort.each(&method(:require)) +Dir.glob(File.join(__dir__, "**", "*.rb")).each(&method(:require)) diff --git a/test/exceptions_test.rb b/test/exceptions_test.rb index 9b3c4de..b71ff05 100644 --- a/test/exceptions_test.rb +++ b/test/exceptions_test.rb @@ -6,9 +6,12 @@ # tests for custom exceptions class ExceptionsTest < Minitest::Test def test_invalid_url - assert_raises(IMDb::InvalidURL) do - IMDb::Title.new("http://www.example.com") - IMDb::Title.new("https://www.imdb.com/title/tt549199490/") + assert_raises(IMDb::InvalidURL) { IMDb::Title.new("http://www.example.com") } + end + + def test_invalid_id + VCR.use_cassette("wrong_id") do + assert_raises(IMDb::InvalidURL) { IMDb::Title.new("https://www.imdb.com/title/tt549199490/") } end end end diff --git a/test/titles/episode_test.rb b/test/titles/episode_test.rb index 815453b..d4c45b4 100644 --- a/test/titles/episode_test.rb +++ b/test/titles/episode_test.rb @@ -7,15 +7,16 @@ class EpisodeTest < TestHelper ID = "tt9166672" # open wide, o earth - def test_title = super title.title, "Open Wide, O Earth" + def test_title = super(title.title, "Open Wide, O Earth") def test_release_date release_date = title.release_date - super release_date + super(release_date) + assert_equal("May 20, 2019 (United States)", release_date) end - def test_duration = super title.duration, "1 hour 5 minutes" + def test_duration = super(title.duration, "1 hour 5 minutes") def test_instance_of_class = assert_kind_of(Episode, title) end diff --git a/test/titles/in_development_test.rb b/test/titles/in_development_test.rb index 7b6ab88..8532043 100644 --- a/test/titles/in_development_test.rb +++ b/test/titles/in_development_test.rb @@ -7,10 +7,11 @@ class TitleInDevelopmentTest < TestHelper ID = "tt4576032" # blade - def test_title = super title.title, "300: The Resurgence" + def test_title = super(title.title, "300: The Resurgence") def test_tagline tagline = title.tagline + assert(tagline.is_a?(String) || tagline.nil?) end @@ -20,5 +21,5 @@ def test_popularity = assert_nil(title.popularity) def test_release_date = assert_nil(title.release_date) - def test_production_companies = super title.production_companies + def test_production_companies = super(title.production_companies) end diff --git a/test/titles/movie_test.rb b/test/titles/movie_test.rb index b6901dd..609961a 100644 --- a/test/titles/movie_test.rb +++ b/test/titles/movie_test.rb @@ -9,18 +9,20 @@ class MovieTest < TestHelper def test_instance_of_class = assert_kind_of(Movie, title) - def test_title = super title.title, "The Shawshank Redemption" + def test_title = super(title.title, "The Shawshank Redemption") - def test_duration = super title.duration, "2 hours 22 minutes" + def test_duration = super(title.duration, "2 hours 22 minutes") def test_budget budget = title.budget + assert_kind_of(String, budget) assert_match(/\A\$\d+(?:,\d{3})*\z/, budget) end def test_revenue revenue = title.revenue + assert_kind_of(String, revenue) assert_match(/\A\$\d+(?:,\d{3})*\z/, revenue) end diff --git a/test/titles/tv_show_test.rb b/test/titles/tv_show_test.rb index 25d483b..1883594 100644 --- a/test/titles/tv_show_test.rb +++ b/test/titles/tv_show_test.rb @@ -7,9 +7,9 @@ class TvShowTest < TestHelper ID = "tt0903747" # breaking bad - def test_title = super title.title, "Breaking Bad" + def test_title = super(title.title, "Breaking Bad") - def test_duration = super title.duration, "45 minutes" + def test_duration = super(title.duration, "45 minutes") def test_instance_of_class = assert_kind_of(TvShow, title) end diff --git a/test/titles/video_game_test.rb b/test/titles/video_game_test.rb index 465df9d..d65989d 100644 --- a/test/titles/video_game_test.rb +++ b/test/titles/video_game_test.rb @@ -7,11 +7,12 @@ class VideoGameTest < TestHelper ID = "tt2140553" # the last of us - def test_title = super title.title, "The Last of Us" + def test_title = super(title.title, "The Last of Us") def test_release_date release_date = title.release_date - super release_date + super(release_date) + assert_equal("June 14, 2013 (United States)", release_date) end