Class: Spring::Test::RailsVersion

Inherits:
Object
  • Object
show all
Defined in:
lib/spring/test/rails_version.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string) ⇒ RailsVersion

Returns a new instance of RailsVersion.



6
7
8
# File 'lib/spring/test/rails_version.rb', line 6

def initialize(string)
  @version = Gem::Version.new(string)
end

Instance Attribute Details

#versionObject (readonly)

Returns the value of attribute version.



4
5
6
# File 'lib/spring/test/rails_version.rb', line 4

def version
  @version
end

Instance Method Details

#bundles_spring?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/spring/test/rails_version.rb', line 23

def bundles_spring?
  version.segments.take(2) == [4, 1] || version > Gem::Version.new("4.1")
end

#controller_tests_dirObject



19
20
21
# File 'lib/spring/test/rails_version.rb', line 19

def controller_tests_dir
  rails_3? ? 'functional' : 'controllers'
end

#majorObject



27
28
29
# File 'lib/spring/test/rails_version.rb', line 27

def major
  version.segments[0]
end

#minorObject



31
32
33
# File 'lib/spring/test/rails_version.rb', line 31

def minor
  version.segments[1]
end

#rails_3?Boolean Also known as: needs_testunit?

Returns:

  • (Boolean)


10
11
12
# File 'lib/spring/test/rails_version.rb', line 10

def rails_3?
  version < Gem::Version.new("4.0.0")
end

#test_commandObject



15
16
17
# File 'lib/spring/test/rails_version.rb', line 15

def test_command
  needs_testunit? ? 'bin/testunit' : 'bin/rake test'
end

#to_sObject



35
36
37
# File 'lib/spring/test/rails_version.rb', line 35

def to_s
  version.to_s
end