Class: Cuukie::Formatter

Inherits:
Object
  • Object
show all
Includes:
CodeSnippets
Defined in:
lib/cuukie/formatter.rb

Instance Method Summary collapse

Methods included from CodeSnippets

#backtrace_to_snippet, #code_snippet

Constructor Details

#initializeFormatter

Returns a new instance of Formatter.



8
9
10
11
12
13
14
15
# File 'lib/cuukie/formatter.rb', line 8

def initialize(*)
  @server = ENV['CUUKIE_SERVER'] || 'http://localhost:4569'
  RestClient.get "#{@server}/ping"
rescue
  puts "I cannot find the cuukie server on #{@server}."
  puts "Please start the server with cuukie --server."
  exit
end

Instance Method Details

#after_features(features) ⇒ Object



71
72
73
# File 'lib/cuukie/formatter.rb', line 71

def after_features(features)
  post 'after_features', { :duration => features.duration }
end

#after_step_result(keyword, step_match, multiline_arg, status) ⇒ Object



63
64
65
# File 'lib/cuukie/formatter.rb', line 63

def after_step_result(keyword, step_match, multiline_arg, status, *)
  post 'after_step_result', { :status => status }
end

#after_stepsObject



67
68
69
# File 'lib/cuukie/formatter.rb', line 67

def after_steps(*)
  post 'after_steps'
end

#before_feature(feature) ⇒ Object



21
22
23
24
# File 'lib/cuukie/formatter.rb', line 21

def before_feature(feature)
  post 'before_feature', { :short_name => feature.short_name,
                           :description => feature.description }
end

#before_featuresObject



17
18
19
# File 'lib/cuukie/formatter.rb', line 17

def before_features(*)
  post 'before_features'
end

#before_step(step) ⇒ Object



36
37
38
39
40
# File 'lib/cuukie/formatter.rb', line 36

def before_step(step)
  post 'before_step', { :keyword => step.keyword,
                        :name => step.name,
                        :file_colon_line => step.file_colon_line }
end

#before_table_rowObject



42
43
44
# File 'lib/cuukie/formatter.rb', line 42

def before_table_row(*)
  post 'before_table_row'
end

#doc_string(string) ⇒ Object



50
51
52
# File 'lib/cuukie/formatter.rb', line 50

def doc_string(string)
  post 'doc_string', { :multiline_string => string }
end

#exception(exception) ⇒ Object



54
55
56
57
58
59
60
61
# File 'lib/cuukie/formatter.rb', line 54

def exception(exception, *)
  source = backtrace_to_snippet(exception.backtrace)
  post 'exception', { :message => exception.message,
                      :backtrace => exception.backtrace.join('\n'),
                      :raw_lines => source[:raw_lines],
                      :first_line => source[:first_line],
                      :marked_line => source[:marked_line]  }
end

#feature_name(keyword) ⇒ Object



26
27
28
# File 'lib/cuukie/formatter.rb', line 26

def feature_name(keyword, *)
  post 'feature_name', { :keyword => keyword }
end

#scenario_name(keyword, name, file_colon_line) ⇒ Object



30
31
32
33
34
# File 'lib/cuukie/formatter.rb', line 30

def scenario_name(keyword, name, file_colon_line, *)
  post 'scenario_name', { :keyword => keyword,
                          :name => name,
                          :file_colon_line => file_colon_line }
end

#table_cell_value(value) ⇒ Object



46
47
48
# File 'lib/cuukie/formatter.rb', line 46

def table_cell_value(value, *)
  post 'table_cell_value', { :value => value }
end