Class: Bumps::ResultsPushFormatter

Inherits:
Cucumber::Ast::Visitor
  • Object
show all
Defined in:
lib/bumps/results_push_formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(step_mother, io, options) ⇒ ResultsPushFormatter

Returns a new instance of ResultsPushFormatter.



7
8
9
10
11
12
# File 'lib/bumps/results_push_formatter.rb', line 7

def initialize(step_mother, io, options)
  super step_mother
  @step_mother = step_mother
  @io = io
  @options = options
end

Instance Method Details

#push(results) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/bumps/results_push_formatter.rb', line 18

def push results
  uri = URI.parse(Bumps::Configuration.push_url)
  response, body = Net::HTTP.post_form uri, {:results => results}
  if response.code_type == Net::HTTPOK
    @io << "Successfully pushed results to #{Bumps::Configuration.push_url}\n\n"
  else
    @io << "Failed to push results to #{Bumps::Configuration.push_url} - HTTP #{response.code}: \n#{response.body}\n\n"
  end
end

#results_of_running(features) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/bumps/results_push_formatter.rb', line 28

def results_of_running features
  StringIO.open do |io|
    formatter = Bumps::Configuration.results_formatter.new step_mother, io, options
    formatter.visit_features features
    
    io.string
  end
end

#visit_features(features) ⇒ Object



14
15
16
# File 'lib/bumps/results_push_formatter.rb', line 14

def visit_features features
  push results_of_running(features)
end