Class: Ace::TestRunner::Molecules::RakeIntegration
- Inherits:
-
Object
- Object
- Ace::TestRunner::Molecules::RakeIntegration
- Defined in:
- lib/ace/test_runner/molecules/rake_integration.rb
Overview
Manages Rakefile integration for ace-test
Constant Summary collapse
- BACKUP_EXTENSION =
".ace-backup"- MARKER_COMMENT =
"# ace-test-runner integration"
Instance Method Summary collapse
-
#check_status ⇒ Object
Check if ace-test is currently set as default.
-
#initialize(rakefile_path = "Rakefile") ⇒ RakeIntegration
constructor
A new instance of RakeIntegration.
-
#set_default ⇒ Object
Set ace-test as the default rake test runner.
-
#unset_default ⇒ Object
Remove ace-test as the default rake test runner.
Constructor Details
#initialize(rakefile_path = "Rakefile") ⇒ RakeIntegration
Returns a new instance of RakeIntegration.
14 15 16 |
# File 'lib/ace/test_runner/molecules/rake_integration.rb', line 14 def initialize(rakefile_path = "Rakefile") @rakefile_path = rakefile_path end |
Instance Method Details
#check_status ⇒ Object
Check if ace-test is currently set as default
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ace/test_runner/molecules/rake_integration.rb', line 53 def check_status if !rakefile_exists? { integrated: false, message: "No Rakefile found in current directory", rakefile_exists: false } elsif already_integrated? { integrated: true, message: "ace-test is currently set as default rake test runner", rakefile_exists: true, backup_exists: backup_exists? } else { integrated: false, message: "ace-test is not set as default rake test runner", rakefile_exists: true, has_test_task: has_test_task? } end end |
#set_default ⇒ Object
Set ace-test as the default rake test runner
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ace/test_runner/molecules/rake_integration.rb', line 19 def set_default validate_environment! if already_integrated? return {success: true, message: "ace-test is already set as default rake test runner"} end backup_rakefile inject_ace_test_config {success: true, message: "Successfully set ace-test as default rake test runner"} rescue => e restore_from_backup if backup_exists? {success: false, message: "Failed to set ace-test as default: #{e.}"} end |
#unset_default ⇒ Object
Remove ace-test as the default rake test runner
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ace/test_runner/molecules/rake_integration.rb', line 36 def unset_default unless already_integrated? return {success: true, message: "ace-test is not currently set as default"} end if backup_exists? restore_from_backup {success: true, message: "Successfully restored original Rakefile"} else remove_ace_test_config {success: true, message: "Successfully removed ace-test configuration"} end rescue => e {success: false, message: "Failed to unset ace-test as default: #{e.}"} end |