cuukie 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env ruby
2
- lib = File.dirname(__FILE__) + '/../lib'
3
- $:.unshift lib unless $:.include? lib
4
-
5
- require 'cuukie/server'
6
- module Cuukie
7
- Server.set :port, ARGV[0] || 4569
8
- Server.run!
9
- end
@@ -1,23 +0,0 @@
1
- module Cuukie
2
- module CodeSnippets
3
- NULL_SNIPPET = Hash.new
4
-
5
- def code_snippet(file, line)
6
- return NULL_SNIPPET unless File.exist? file
7
-
8
- all_lines = File.open(file) {|f| f.readlines}
9
- return NULL_SNIPPET unless line <= all_lines.size
10
-
11
- first_line = [1, line - 2].max
12
-
13
- {:first_line => first_line,
14
- :marked_line => line,
15
- :raw_lines => all_lines[(first_line - 1)..line].join }
16
- end
17
-
18
- def backtrace_to_snippet(backtrace)
19
- return NULL_SNIPPET unless backtrace[0] =~ /(.*):(\d+)/
20
- code_snippet $1, $2.to_i
21
- end
22
- end
23
- end
@@ -1,90 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/code_snippets"
2
- require 'rest-client'
3
- require 'json'
4
-
5
- module Cucumber
6
- module Formatter
7
- class Cuukie
8
- include ::Cuukie::CodeSnippets
9
-
10
- def initialize(step_mother, path_or_io, options)
11
- @server = ENV['CUUKIE_SERVER'] || 'http://localhost:4569'
12
- ping
13
- rescue
14
- puts "I cannot find the cuukie_server on #{@server}."
15
- puts "Please start the server with the cuukie_server command."
16
- exit
17
- end
18
-
19
- def before_features(features)
20
- post 'before_features'
21
- end
22
-
23
- def before_feature(feature)
24
- post 'before_feature', { :short_name => feature.short_name,
25
- :description => feature.description }
26
- end
27
-
28
- def scenario_name(keyword, name, file_colon_line, source_indent)
29
- post 'scenario_name', { :keyword => keyword,
30
- :name => name,
31
- :file_colon_line => file_colon_line }
32
- end
33
-
34
- def before_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background)
35
- post 'before_step_result', { :keyword => keyword,
36
- :name => step_match.format_args,
37
- :file_colon_line => step_match.file_colon_line }
38
- end
39
-
40
- def exception(exception, status)
41
- source = backtrace_to_snippet(exception.backtrace)
42
- post 'exception', { :message => exception.message,
43
- :backtrace => exception.backtrace.join('\n'),
44
- :first_line => source[:first_line],
45
- :marked_line => source[:marked_line],
46
- :raw_lines => source[:raw_lines] }
47
- end
48
-
49
- def after_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background)
50
- post 'after_step_result', { :status => status }
51
- end
52
-
53
- def after_steps(*)
54
- post 'after_steps'
55
- end
56
-
57
- def before_table_row(table_row)
58
- post 'before_table_row'
59
- end
60
-
61
- def table_cell_value(value, status)
62
- post 'table_cell_value', { :value => value }
63
- end
64
-
65
- def doc_string(string)
66
- post 'doc_string', { :multiline_string => string }
67
- end
68
-
69
- def after_features(features)
70
- post 'after_features', { :duration => features.duration }
71
- end
72
-
73
- private
74
-
75
- def post(url, params = {})
76
- RestClient.post "#{@server}/#{url}", params.to_json
77
- end
78
-
79
- def ping
80
- RestClient.get "#{@server}/ping"
81
- end
82
- end
83
- end
84
- end
85
-
86
- require 'cucumber/cli/options'
87
- Cucumber::Cli::Options::BUILTIN_FORMATS['cuukie'] = [
88
- 'Cucumber::Formatter::Cuukie',
89
- 'Shows Cucumber results on a web page as they run'
90
- ]