Sha256: 4c4fef0c0630135a09c5aaf737edf579b0647a5f4591ccc0b52153fecbe3a1c4

Contents?: true

Size: 1.76 KB

Versions: 12

Compression:

Stored size: 1.76 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

# rubocop:disable Metrics/BlockLength
RSpec.describe MovieOrganizer, type: :module do
  context '#root' do
    it 'returns a Pathname instance' do
      expect(MovieOrganizer.root).to be_a(Pathname)
    end

    it 'returns the root directory' do
      dir = MovieOrganizer.root
      expect(dir.to_s).to match(/movie_organizer$/)
      expect(File.exist?(dir)).to eq(true)
    end
  end

  context '#current_environment' do
    before do
      @original_env = ENV['APP_ENV']
    end

    after do
      ENV['APP_ENV'] = @original_env
    end

    it "defaults to 'development'" do
      ENV.delete('APP_ENV')
      expect(MovieOrganizer.current_environment).to eq('development')
    end

    it 'returns the APP_ENV variable' do
      ENV['APP_ENV'] = 'asdf'
      expect(MovieOrganizer.current_environment).to eq('asdf')
    end
  end

  context '#config_file' do
    it 'returns the default config file' do
      expect(MovieOrganizer.config_file.to_s).to match(/.movie_organizer.yml$/)
    end

    it 'ensures the file exists' do
      expect(File.exist?(MovieOrganizer.config_file)).to eq(true)
    end
  end

  context '#source_directories' do
    context 'when configured' do
      it 'returns an array of strings' do
        settings = MovieOrganizer::Settings.new
        expect(MovieOrganizer.source_directories(settings)).to be_an(Array)
      end
    end

    context 'when not yet configured' do
      it 'returns an array of strings' do
        blank = MovieOrganizer.root.join('spec', 'fixtures', '.blank_settings.yml')
        settings = MovieOrganizer::Settings.new(blank)
        expect(MovieOrganizer.source_directories(settings, '~/Videos')).to be_an(Array)
      end
    end
  end
end
# rubocop:enable Metrics/BlockLength

Version data entries

12 entries across 12 versions & 1 rubygems

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