Class: CommitLive::Test
- Inherits:
-
Object
- Object
- CommitLive::Test
- Defined in:
- lib/commit-live/tests/runner.rb
Constant Summary collapse
- REPO_BELONGS_TO_US =
[ 'commit-live-students' ]
Instance Method Summary collapse
- #check_lesson_dir ⇒ Object
-
#initialize ⇒ Test
constructor
A new instance of Test.
- #put_error_msg ⇒ Object
- #run ⇒ Object
- #set_git ⇒ Object
- #strategy ⇒ Object
Constructor Details
#initialize ⇒ Test
Returns a new instance of Test.
12 13 14 15 |
# File 'lib/commit-live/tests/runner.rb', line 12 def initialize() check_lesson_dir die if !strategy end |
Instance Method Details
#check_lesson_dir ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/commit-live/tests/runner.rb', line 25 def check_lesson_dir git = set_git netrc = CommitLive::NetrcInteractor.new() netrc.read(machine: 'ga-extra') username = netrc.login if git.remote.url.match(/#{username}/i).nil? && git.remote.url.match(/#{REPO_BELONGS_TO_US.join('|').gsub('-','\-')}/i).nil? put_error_msg end end |
#put_error_msg ⇒ Object
35 36 37 38 39 |
# File 'lib/commit-live/tests/runner.rb', line 35 def put_error_msg puts "It doesn't look like you're in a lesson directory." puts 'Please cd into an appropriate directory and try again.' exit 1 end |
#run ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/commit-live/tests/runner.rb', line 41 def run strategy.check_dependencies strategy.configure results = strategy.run puts 'Updating lesson status...' lessonName = File.basename(Dir.getwd) if results # test case passed CommitLive::Status.new().update('test_case_pass', lessonName) else # test case failed CommitLive::Status.new().update('test_case_fail', lessonName) end end |
#set_git ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/commit-live/tests/runner.rb', line 17 def set_git begin Git.open(FileUtils.pwd) rescue => e put_error_msg end end |
#strategy ⇒ Object
56 57 58 |
# File 'lib/commit-live/tests/runner.rb', line 56 def strategy @strategy ||= strategies.map{ |s| s.new() }.detect(&:detect) end |