Class: SmartTest::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_test/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root, test_folder = "spec") ⇒ Project

Returns a new instance of Project.

Raises:



5
6
7
8
9
# File 'lib/smart_test/project.rb', line 5

def initialize(root, test_folder = "spec")
  @root = root
  @test_folder = test_folder
  raise NoTestFolderError unless File.exists? File.join(root, test_folder)
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



3
4
5
# File 'lib/smart_test/project.rb', line 3

def root
  @root
end

#test_folderObject (readonly)

Returns the value of attribute test_folder.



3
4
5
# File 'lib/smart_test/project.rb', line 3

def test_folder
  @test_folder
end

Instance Method Details

#test_file?(file) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/smart_test/project.rb', line 23

def test_file?(file)
  file =~ /\A#{test_folder}\/.*#{test_folder}\.rb\Z/i
end

#test_filesObject



19
20
21
# File 'lib/smart_test/project.rb', line 19

def test_files
  Dir.glob "#{test_folder}/**/*_#{test_folder}.rb"
end

#using_bundle?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/smart_test/project.rb', line 11

def using_bundle?
  @using_bundle ||= File.exists?(File.join root, "Gemfile")
end

#using_git?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/smart_test/project.rb', line 15

def using_git?
  @using_git ||= File.exists?(File.join root, ".git")
end