Class: Gitnesse::Hooks
- Inherits:
-
Object
- Object
- Gitnesse::Hooks
- Defined in:
- lib/gitnesse/hooks.rb
Constant Summary collapse
- DIR =
File.("./#{@config.features_dir}/support")
- PATH =
File.("./#{@config.features_dir}/support/gitnesse.rb")
Class Method Summary collapse
-
.append_results(scenario) ⇒ Object
Public: Used by Gitnesse hook to append results to wiki page for feature.
-
.create! ⇒ Object
Public: Copies Gitnesse Cucumber hooks to Cucumber’s support dir.
-
.destroy! ⇒ Object
Public: Removes existing Gitnesse hooks in Cucumber’s support dir.
Class Method Details
.append_results(scenario) ⇒ Object
Public: Used by Gitnesse hook to append results to wiki page for feature
scenario - Cucumber scenario passed by post-scenario hook
Returns nothing
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/gitnesse/hooks.rb', line 30 def self.append_results(scenario) Gitnesse::ConfigLoader.find_and_load dir = Gitnesse::DirManager.project_dir if scenario.respond_to?(:scenario_outline) file = scenario.scenario_outline.file.gsub(/^#{@config.features_dir}\//, '') name = "#{scenario.scenario_outline.name}" subtitle = scenario.name.gsub(/(^\|\s+|\s+\|$)/, '').gsub(/\s+\|/, ',') else file = scenario.file.gsub(/^#{@config.features_dir}\//, '') name = scenario.name subtitle = nil end page = file.gsub("/", " > ") status = scenario.status @wiki = Gitnesse::Wiki.new(@config.repository_url, dir, clone: false) page = @wiki.pages.find { |f| f.wiki_path.include?(page) } return unless page page.append_result name, status, subtitle @wiki.repo.add(page.wiki_path) end |
.create! ⇒ Object
Public: Copies Gitnesse Cucumber hooks to Cucumber’s support dir.
Returns nothing
11 12 13 14 15 16 |
# File 'lib/gitnesse/hooks.rb', line 11 def self.create! FileUtils.mkdir_p DIR unless File.directory?(DIR) file = File.("#{File.dirname(__FILE__)}/hooks/gitnesse.rb") FileUtils.cp file, PATH end |
.destroy! ⇒ Object
Public: Removes existing Gitnesse hooks in Cucumber’s support dir
Returns nothing
21 22 23 |
# File 'lib/gitnesse/hooks.rb', line 21 def self.destroy! FileUtils.rm PATH, force: true end |