Sha256: 8e46fc35d83ac7dc29da6d1b2fab6446039a3136c5c6ed94f56c6899cf45f502

Contents?: true

Size: 1.26 KB

Versions: 42

Compression:

Stored size: 1.26 KB

Contents

require_relative '../../test_helper.rb'
require 'generator/files/metadata_files'

module Generator
  module Files
    class MetadataFilesTest < Minitest::Test
      FixturePaths = Paths.new(
        metadata: 'test/fixtures/metadata',
        track: 'test/fixtures/ruby'
      )

      class TestMetadataFiles
        def initialize
          @paths = FixturePaths
          @slug = 'alpha'
        end
        attr_reader :paths, :slug
        include MetadataFiles
      end

      def test_canonical_data
        subject = TestMetadataFiles.new
        assert_instance_of CanonicalDataFile, subject.canonical_data
      end
    end

    class CanonicalDataFileTest < Minitest::Test
      def test_version_for_file_that_does_not_exist
        subject = CanonicalDataFile.new(filename: 'nonexistant')
        assert_nil subject.version
      end

      def test_version
        subject = CanonicalDataFile.new(filename: 'has version key')
        Files.stub(:read, '{"version": "1.2.3"}' ) do
          assert_equal "1.2.3", subject.version
        end
      end

      def test_version_not_present
        subject = CanonicalDataFile.new(filename: 'no version key')
        Files.stub(:read, '{ "json": true }' ) do
          assert_nil subject.version
        end
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/ruby/test/generator/files/metadata_files_test.rb
trackler-2.2.1.179 tracks/ruby/test/generator/files/metadata_files_test.rb
trackler-2.2.1.178 tracks/ruby/test/generator/files/metadata_files_test.rb
trackler-2.2.1.177 tracks/ruby/test/generator/files/metadata_files_test.rb
trackler-2.2.1.176 tracks/ruby/test/generator/files/metadata_files_test.rb
trackler-2.2.1.175 tracks/ruby/test/generator/files/metadata_files_test.rb
trackler-2.2.1.174 tracks/ruby/test/generator/files/metadata_files_test.rb
trackler-2.2.1.173 tracks/ruby/test/generator/files/metadata_files_test.rb
trackler-2.2.1.172 tracks/ruby/test/generator/files/metadata_files_test.rb
trackler-2.2.1.171 tracks/ruby/test/generator/files/metadata_files_test.rb
trackler-2.2.1.170 tracks/ruby/test/generator/files/metadata_files_test.rb
trackler-2.2.1.169 tracks/ruby/test/generator/files/metadata_files_test.rb
trackler-2.2.1.167 tracks/ruby/test/generator/files/metadata_files_test.rb
trackler-2.2.1.166 tracks/ruby/test/generator/files/metadata_files_test.rb
trackler-2.2.1.165 tracks/ruby/test/generator/files/metadata_files_test.rb
trackler-2.2.1.164 tracks/ruby/test/generator/files/metadata_files_test.rb
trackler-2.2.1.163 tracks/ruby/test/generator/files/metadata_files_test.rb
trackler-2.2.1.162 tracks/ruby/test/generator/files/metadata_files_test.rb
trackler-2.2.1.161 tracks/ruby/test/generator/files/metadata_files_test.rb
trackler-2.2.1.160 tracks/ruby/test/generator/files/metadata_files_test.rb