Sha256: 8f395091fee789b1e1bc1f96f90f0c090df2f0be430f1efaf3139e7b0b7668af

Contents?: true

Size: 1.43 KB

Versions: 12

Compression:

Stored size: 1.43 KB

Contents

require "spec_helper"
require "logstash/util/plugin_version"

describe LogStash::Util::PluginVersion do
  subject { LogStash::Util::PluginVersion }

  context "#find_version!" do
    it 'raises an PluginNoVersionError if we cant find the plugin in the gem path' do
      dummy_name ='this-character-doesnt-exist-in-the-marvel-universe'
      expect { subject.find_version!(dummy_name) }.to raise_error(LogStash::PluginNoVersionError)
    end

    it 'returns the version of the gem' do
      expect { subject.find_version!('bundler') }.not_to raise_error
    end
  end

  context "#new" do
    it 'accepts a Gem::Version instance as argument' do
      version = Gem::Version.new('1.0.1')
      expect(subject.new(version).to_s).to eq(version.to_s)
    end

    it 'accepts an array for defining the version' do
      version = subject.new(1, 0, 2)
      expect(version.to_s).to eq('1.0.2')
    end
  end

  context "When comparing instances" do
    it 'allow to check if the version is newer or older' do
      old_version = subject.new(0, 1, 0)
      new_version = subject.new(1, 0, 1)

      expect(old_version).to be < new_version
      expect(old_version).to be <= new_version
      expect(new_version).to be > old_version
      expect(new_version).to be >= old_version
    end

    it 'return true if the version are equal' do
      version1 = subject.new(0, 1, 0)
      version2 = subject.new(0, 1, 0)

      expect(version1).to eq(version2)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
logstash-core-1.5.2.2-java spec/util/plugin_version_spec.rb
logstash-core-1.5.2.1-java spec/util/plugin_version_spec.rb
logstash-core-1.5.2-java spec/util/plugin_version_spec.rb
logstash-core-1.5.2.snapshot2-java spec/util/plugin_version_spec.rb
logstash-core-1.5.2.snapshot1-java spec/util/plugin_version_spec.rb
logstash-core-1.5.1-java spec/util/plugin_version_spec.rb
logstash-core-1.5.1.snapshot1-java spec/util/plugin_version_spec.rb
logstash-core-1.5.0-java spec/util/plugin_version_spec.rb
logstash-core-1.5.0.snapshot1-java spec/util/plugin_version_spec.rb
logstash-core-1.5.0.rc4-java spec/util/plugin_version_spec.rb
logstash-core-1.5.0.rc4.snapshot2-java spec/util/plugin_version_spec.rb
logstash-core-1.5.0.rc4.snapshot1-java spec/util/plugin_version_spec.rb