Sha256: 92621dcac74fa01b466a1f449d14dd8d9bfa6ac4df5d2893aebb7e352792fe8c

Contents?: true

Size: 1.56 KB

Versions: 56

Compression:

Stored size: 1.56 KB

Contents

# encoding: utf-8
require 'spec_helper'
require 'fedux_org_stdlib/version_management/rubygem_version_file_parser'

RSpec.describe FeduxOrgStdlib::VersionManagement::RubygemVersionFileParser do
  let(:parser) { FeduxOrgStdlib::VersionManagement::RubygemVersionFileParser.new }

  context '#parse' do
    it 'extracts version number' do
      write_file(
      'version.rb',
      <<-EOS.strip_heredoc
       #main MyLibrary
       module MyLibrary
         VERSION = '0.0.0'
       end
      EOS
      )

      parser.parse(absolute_path('version.rb'))

      expect(parser.version).to eq('0.0.0')
    end

    it 'extracts modules' do
      write_file(
      'version.rb',
      <<-EOS.strip_heredoc
        #main MyLibrary
        module MyLibrary
          VERSION = '0.0.0'
        end
      EOS
      )

      parser.parse(absolute_path('version.rb'))

      expect(parser.modules).to eq(['MyLibrary'])
    end

    it 'extracts nested modules as well' do
      write_file(
      'version.rb',
      <<-EOS.strip_heredoc
      #main MyLibrary
      module MyLibrary
        module MyClass
          VERSION = '0.0.0'
        end
      end
      EOS
      )

      parser.parse(absolute_path('version.rb'))

      expect(parser.modules).to eq(%w(MyLibrary MyClass))
    end

    it 'fails if version cannot be extracted' do
      write_file(
      'version.rb',
      <<-EOS.strip_heredoc
        #main MyLibrary
      EOS
      )

      expect do
        parser.parse(absolute_path('version.rb'))
      end.to raise_error VersionManagement::Exceptions::VersionFileInvalid
    end
  end
end

Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
fedux_org-stdlib-0.10.6 spec/version_management/rubygem_version_file_parser_spec.rb
fedux_org-stdlib-0.10.5 spec/version_management/rubygem_version_file_parser_spec.rb
fedux_org-stdlib-0.10.4 spec/version_management/rubygem_version_file_parser_spec.rb
fedux_org-stdlib-0.10.3 spec/version_management/rubygem_version_file_parser_spec.rb
fedux_org-stdlib-0.10.2 spec/version_management/rubygem_version_file_parser_spec.rb
fedux_org-stdlib-0.10.1 spec/version_management/rubygem_version_file_parser_spec.rb
fedux_org-stdlib-0.10.0 spec/version_management/rubygem_version_file_parser_spec.rb
fedux_org-stdlib-0.9.8 spec/version_management/rubygem_version_file_parser_spec.rb
fedux_org-stdlib-0.9.7 spec/version_management/rubygem_version_file_parser_spec.rb
fedux_org-stdlib-0.9.6 spec/version_management/rubygem_version_file_parser_spec.rb
fedux_org-stdlib-0.9.5 spec/version_management/rubygem_version_file_parser_spec.rb
fedux_org-stdlib-0.9.4 spec/version_management/rubygem_version_file_parser_spec.rb
fedux_org-stdlib-0.9.2 spec/version_management/rubygem_version_file_parser_spec.rb
fedux_org-stdlib-0.9.1 spec/version_management/rubygem_version_file_parser_spec.rb
fedux_org-stdlib-0.9.0 spec/version_management/rubygem_version_file_parser_spec.rb
fedux_org-stdlib-0.8.11 spec/version_management/rubygem_version_file_parser_spec.rb
fedux_org-stdlib-0.8.10 spec/version_management/rubygem_version_file_parser_spec.rb
fedux_org-stdlib-0.8.9 spec/version_management/rubygem_version_file_parser_spec.rb
fedux_org-stdlib-0.8.8 spec/version_management/rubygem_version_file_parser_spec.rb
fedux_org-stdlib-0.8.7 spec/version_management/rubygem_version_file_parser_spec.rb