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



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

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

#add_failing_commitObject



17
18
19
20
21
22
23
# File 'lib/bob/test/scm/abstract.rb', line 17

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



25
26
27
28
29
30
31
# File 'lib/bob/test/scm/abstract.rb', line 25

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)


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

def commits
  raise NotImplementedError
end

#headObject



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

def head
  commits.last["identifier"]
end