Class: Bob::Test::AbstractSCMRepo

Inherits:
Object
  • Object
show all
Defined in:
lib/bob/test/scm/abstract.rb

Direct Known Subclasses

GitRepo, SvnRepo

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, base_dir = Bob.directory) ⇒ AbstractSCMRepo

Returns a new instance of AbstractSCMRepo.



5
6
7
8
# File 'lib/bob/test/scm/abstract.rb', line 5

def initialize(name, base_dir=Bob.directory)
  @name   = name
  @path   = File.join(base_dir, @name.to_s)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/bob/test/scm/abstract.rb', line 3

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/bob/test/scm/abstract.rb', line 3

def path
  @path
end

Instance Method Details

#add_commit(message, &action) ⇒ Object



14
15
16
17
18
19
# File 'lib/bob/test/scm/abstract.rb', line 14

def add_commit(message, &action)
  Dir.chdir(path) do
    yield action
    commit(message)
  end
end

#add_failing_commitObject



21
22
23
24
25
26
27
# File 'lib/bob/test/scm/abstract.rb', line 21

def add_failing_commit
  add_commit "This commit will fail" do
    system "echo '#{build_script(false)}' > test"
    system "chmod +x test"
    add    "test"
  end
end

#add_successful_commitObject



29
30
31
32
33
34
35
# File 'lib/bob/test/scm/abstract.rb', line 29

def add_successful_commit
  add_commit "This commit will work" do
    system "echo '#{build_script(true)}' > test"
    system "chmod +x test"
    add    "test"
  end
end

#commitsObject

Raises:

  • (NotImplementedError)


37
38
39
# File 'lib/bob/test/scm/abstract.rb', line 37

def commits
  raise NotImplementedError
end

#destroyObject



10
11
12
# File 'lib/bob/test/scm/abstract.rb', line 10

def destroy
  FileUtils.rm_r path if File.directory?(path)
end

#headObject



41
42
43
# File 'lib/bob/test/scm/abstract.rb', line 41

def head
  commits.last[:identifier]
end