Sha256: f5d284efba3fdbaaed33d391ab16c4da6e4fcd08024c33dbc08c975a4c101a3e

Contents?: true

Size: 1.89 KB

Versions: 10

Compression:

Stored size: 1.89 KB

Contents

# frozen_string_literal: true

# rubocop:disable Metrics/BlockLength
module MovieOrganizer
  RSpec.describe Media, type: :lib do
    include_context 'media_shared'

    context '.subtype' do
      tv_shows = {
        'SnnEnn' => 'The.Walking.Dead.S04E08.HDTV.x264-2HD',
        'nxn'    => 'The.Walking.Dead.4x0.HDTV.x264-2HD',
        'nnxn'   => 'The.Walking.Dead.12x8.HDTV.x264-2HD',
        'nnxnn'  => 'The.Walking.Dead.12x08.HDTV.x264-2HD',
        'nxnn'   => 'The.Walking.Dead.2x18.HDTV.x264-2HD'
      }

      tv_shows.each_pair do |syntax, filename|
        it "returns a TvShow with season and episode syntax: #{syntax}" do
          filename = create_test_file(
            filename: filename,
            extension: 'mp4'
          ).first
          expect(Media.subtype(filename, default_options)).to be_a(TvShow)
        end
      end

      movies = [
        'Coco.2017.1080p.BluRay.x264-[BOGUS.IT]',
        'Beetlejuice',
        'Justice.League.2017.1080p.BluRay.x264-[YTS.AM]'
      ]

      movies.each do |filename|
        it "returns a Movie for '#{filename}'" do
          expect(Tmdb::Movie).to receive(:find).at_least(1).times.and_return([1])
          filename = create_test_file(
            filename: filename
          ).first
          expect(Media.subtype(filename, default_options)).to be_a(Movie)
        end
      end

      videos = [
        'IMG_2052',
        'IMG_3322',
        'VID_3322',
        'VIDEO_3322',
        'Our Summer Vacation',
        'Tom and Jerry on the Beach'
      ]

      videos.each do |filename|
        it "returns a Video for '#{filename}'" do
          expect(Tmdb::Movie).to receive(:find).at_least(1).times.and_return([])
          filename = create_test_file(
            filename: filename
          ).first
          expect(Media.subtype(filename, default_options)).to be_a(Video)
        end
      end
    end
  end
end
# rubocop:enable Metrics/BlockLength

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
movie_organizer-0.1.9 spec/lib/movie_organizer/media_spec.rb
movie_organizer-0.1.8 spec/lib/movie_organizer/media_spec.rb
movie_organizer-0.1.7 spec/lib/movie_organizer/media_spec.rb
movie_organizer-0.1.6 spec/lib/movie_organizer/media_spec.rb
movie_organizer-0.1.5 spec/lib/movie_organizer/media_spec.rb
movie_organizer-0.1.4 spec/lib/movie_organizer/media_spec.rb
movie_organizer-0.1.3 spec/lib/movie_organizer/media_spec.rb
movie_organizer-0.1.2 spec/lib/movie_organizer/media_spec.rb
movie_organizer-0.1.1 spec/lib/movie_organizer/media_spec.rb
movie_organizer-0.1.0 spec/lib/movie_organizer/media_spec.rb