Module: RGitHook::TestSuite::RunnerMethods

Defined in:
lib/plugins/test.rb

Instance Method Summary collapse

Instance Method Details

#test(commit) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/plugins/test.rb', line 5

def test(commit)
  commit.properties['testing'] = true
  commit.save_properties
  in_temp_commit(commit) do |new_repo|
    # Some hacks to migrate rails app if found.
    if File.file?('./config/environment.rb')
      commit.properties['db:migrate'] = rake('db:migrate')
      commit.properties['db:test:prepare'] = rake('db:test:prepare')
    end  
    commit.properties['spec'] = test_spec(repo) if File.directory? File.join(repo.working_dir,'spec')
    commit.properties['cucumber'] = test_cucumber(repo) if File.directory? File.join(repo.working_dir,'features')
    commit.properties['test_unit'] = test_unit(repo) if File.directory? File.join(repo.working_dir,'test')
  end
  commit.properties["status"] = %w(spec cucumber test_unit).map{|t|commit.properties[t][1].exitstatus}.max
ensure
  commit.properties.delete 'testing'
  commit.save_properties
end

#test_cucumber(repo) ⇒ Object



28
29
30
# File 'lib/plugins/test.rb', line 28

def test_cucumber(repo)
  [%x(cucumber features/),$?]
end

#test_spec(repo) ⇒ Object



24
25
26
# File 'lib/plugins/test.rb', line 24

def test_spec(repo)
  [%x(spec spec/),$?]
end

#test_unit(repo) ⇒ Object



32
33
34
# File 'lib/plugins/test.rb', line 32

def test_unit(repo)
  [%x(testrb `find test -name '*.rb'`),$?]
end