class Transpec::RSpecVersion
Gem::Version caches its instances with class variable @@all, so we should not inherit it.
Constants
- RSPEC_2_99
- RSPEC_3_0
Attributes
gem_version[R]
Public Class Methods
define_feature(feature, version_string, options = {})
click to toggle source
# File lib/transpec/rspec_version.rb, line 13 def self.define_feature(feature, version_string, options = {}) available_version = new(version_string) exception_version_strings = Array(options[:except]) exception_versions = exception_version_strings.map { |s| new(s) } define_singleton_method("#{feature}_available_version") do available_version end define_method("#{feature}_available?") do self >= available_version && !exception_versions.include?(self) end end
new(version)
click to toggle source
# File lib/transpec/rspec_version.rb, line 28 def initialize(version) @gem_version = if version.is_a?(Gem::Version) version else Gem::Version.new(version) end end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/transpec/rspec_version.rb, line 36 def <=>(other) gem_version <=> other.gem_version end
rspec_2_99?()
click to toggle source
# File lib/transpec/rspec_version.rb, line 73 def rspec_2_99? RSPEC_2_99 <= self && self < RSPEC_3_0 end
rspec_3?()
click to toggle source
# File lib/transpec/rspec_version.rb, line 77 def rspec_3? self >= RSPEC_3_0 end
to_s()
click to toggle source
# File lib/transpec/rspec_version.rb, line 40 def to_s gem_version.to_s end