Class: Bob::Test::AbstractRepo
- Inherits:
-
Object
- Object
- Bob::Test::AbstractRepo
- Defined in:
- lib/bob/test/repo.rb
Instance Method Summary collapse
- #add_commit(message) ⇒ Object
- #add_failing_commit ⇒ Object
- #add_successful_commit ⇒ Object
- #command ⇒ Object
- #create ⇒ Object
- #head ⇒ Object
-
#initialize(name = "test_repo") ⇒ AbstractRepo
constructor
A new instance of AbstractRepo.
- #script(status) ⇒ Object
- #short_head ⇒ Object
Constructor Details
#initialize(name = "test_repo") ⇒ AbstractRepo
Returns a new instance of AbstractRepo.
3 4 5 |
# File 'lib/bob/test/repo.rb', line 3 def initialize(name = "test_repo") @path = Bob.directory.join(name) end |
Instance Method Details
#add_commit(message) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/bob/test/repo.rb', line 14 def add_commit() Dir.chdir(@path) { yield commit() } end |
#add_failing_commit ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/bob/test/repo.rb', line 29 def add_failing_commit add_commit("This commit will fail") { system "echo '#{script(1)}' > test" system "chmod +x test" add "test" } end |
#add_successful_commit ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/bob/test/repo.rb', line 21 def add_successful_commit add_commit("This commit will work") { `echo '#{script(0)}' > test` `chmod +x test` add "test" } end |
#command ⇒ Object
45 46 47 |
# File 'lib/bob/test/repo.rb', line 45 def command "./test" end |
#create ⇒ Object
7 8 9 10 11 12 |
# File 'lib/bob/test/repo.rb', line 7 def create add_commit("First commit") { `echo 'just a test repo' >> README` add "README" } end |
#head ⇒ Object
37 38 39 |
# File 'lib/bob/test/repo.rb', line 37 def head commits.last["id"] end |
#script(status) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/bob/test/repo.rb', line 49 def script(status) <<SH #!/bin/sh echo "Running tests..." exit #{status} SH end |
#short_head ⇒ Object
41 42 43 |
# File 'lib/bob/test/repo.rb', line 41 def short_head head[0..6] end |