Sha256: c52a85736ae04e29d79b638245cba9fc38822349db1f3b6bcc7fd97f0c3ff4ef

Contents?: true

Size: 790 Bytes

Versions: 13

Compression:

Stored size: 790 Bytes

Contents

module Tests
  class Version
    def initialize(version)
      @version = Gem::Version.new(version.to_s + '')
    end

    def <(other_version)
      compare?(:<, other_version)
    end

    def <=(other_version)
      compare?(:<=, other_version)
    end

    def ==(other_version)
      compare?(:==, other_version)
    end

    def >=(other_version)
      compare?(:>=, other_version)
    end

    def >(other_version)
      compare?(:>, other_version)
    end

    def =~(other_version)
      Gem::Requirement.new(other_version).satisfied_by?(version)
    end

    def to_s
      version.to_s
    end

    protected

    attr_reader :version

    private

    def compare?(op, other_version)
      Gem::Requirement.new("#{op} #{other_version}").satisfied_by?(version)
    end
  end
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
shoulda-matchers-3.1.3 spec/support/tests/version.rb
shoulda-matchers-4.0.0.rc1 spec/support/tests/version.rb
shoulda-3.6.0 test/support/tests/version.rb
shoulda-matchers-3.1.2 spec/support/tests/version.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/shoulda-matchers-2.8.0/spec/support/tests/version.rb
shoulda-matchers-3.1.1 spec/support/tests/version.rb
shoulda-matchers-3.1.0 spec/support/tests/version.rb
shoulda-matchers-3.0.1 spec/support/tests/version.rb
shoulda-matchers-3.0.0 spec/support/tests/version.rb
shoulda-matchers-3.0.0.rc1 spec/support/tests/version.rb
shoulda-matchers-2.8.0 spec/support/tests/version.rb
shoulda-matchers-2.8.0.rc2 spec/support/tests/version.rb
shoulda-matchers-2.8.0.rc1 spec/support/tests/version.rb