rspec-formatter-webkit 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/History.md +6 -0
  2. data/LICENSE +27 -0
  3. data/README.md +30 -0
  4. data/Rakefile +51 -0
  5. data/data/rspec-formatter-webkit/css/textmate-rspec.css +332 -0
  6. data/data/rspec-formatter-webkit/images/clock.png +0 -0
  7. data/data/rspec-formatter-webkit/images/cross_circle.png +0 -0
  8. data/data/rspec-formatter-webkit/images/cross_circle_frame.png +0 -0
  9. data/data/rspec-formatter-webkit/images/cross_octagon.png +0 -0
  10. data/data/rspec-formatter-webkit/images/cross_octagon_frame.png +0 -0
  11. data/data/rspec-formatter-webkit/images/cross_shield.png +0 -0
  12. data/data/rspec-formatter-webkit/images/exclamation.png +0 -0
  13. data/data/rspec-formatter-webkit/images/exclamation_frame.png +0 -0
  14. data/data/rspec-formatter-webkit/images/exclamation_shield.png +0 -0
  15. data/data/rspec-formatter-webkit/images/exclamation_small.png +0 -0
  16. data/data/rspec-formatter-webkit/images/plus_circle.png +0 -0
  17. data/data/rspec-formatter-webkit/images/plus_circle_frame.png +0 -0
  18. data/data/rspec-formatter-webkit/images/question.png +0 -0
  19. data/data/rspec-formatter-webkit/images/question_frame.png +0 -0
  20. data/data/rspec-formatter-webkit/images/question_shield.png +0 -0
  21. data/data/rspec-formatter-webkit/images/question_small.png +0 -0
  22. data/data/rspec-formatter-webkit/images/tick.png +0 -0
  23. data/data/rspec-formatter-webkit/images/tick_circle.png +0 -0
  24. data/data/rspec-formatter-webkit/images/tick_circle_frame.png +0 -0
  25. data/data/rspec-formatter-webkit/images/tick_shield.png +0 -0
  26. data/data/rspec-formatter-webkit/images/tick_small.png +0 -0
  27. data/data/rspec-formatter-webkit/images/tick_small_circle.png +0 -0
  28. data/data/rspec-formatter-webkit/images/ticket.png +0 -0
  29. data/data/rspec-formatter-webkit/images/ticket_arrow.png +0 -0
  30. data/data/rspec-formatter-webkit/images/ticket_exclamation.png +0 -0
  31. data/data/rspec-formatter-webkit/images/ticket_minus.png +0 -0
  32. data/data/rspec-formatter-webkit/images/ticket_pencil.png +0 -0
  33. data/data/rspec-formatter-webkit/images/ticket_plus.png +0 -0
  34. data/data/rspec-formatter-webkit/images/ticket_small.png +0 -0
  35. data/data/rspec-formatter-webkit/js/jquery-1.4.2.min.js +154 -0
  36. data/data/rspec-formatter-webkit/js/textmate-rspec.js +402 -0
  37. data/data/rspec-formatter-webkit/templates/failed.rhtml +35 -0
  38. data/data/rspec-formatter-webkit/templates/footer.rhtml +9 -0
  39. data/data/rspec-formatter-webkit/templates/header.rhtml +35 -0
  40. data/data/rspec-formatter-webkit/templates/page.rhtml +131 -0
  41. data/data/rspec-formatter-webkit/templates/passed.rhtml +10 -0
  42. data/data/rspec-formatter-webkit/templates/pending-fixed.rhtml +25 -0
  43. data/data/rspec-formatter-webkit/templates/pending.rhtml +14 -0
  44. data/docs/tmrspec-example.png +0 -0
  45. data/docs/tmrspecopts-shellvar.png +0 -0
  46. data/lib/rspec/core/formatters/web_kit.rb +4 -0
  47. data/lib/rspec/core/formatters/webkit.rb +223 -0
  48. data.tar.gz.sig +0 -0
  49. metadata +202 -0
  50. metadata.gz.sig +0 -0
Binary file
Binary file
@@ -0,0 +1,4 @@
1
+ # Alow the formatter to be loaded as rspec/core/formatters/web_kit
2
+
3
+ require 'rspec/core/formatters/webkit'
4
+
@@ -0,0 +1,223 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pp'
4
+ require 'rbconfig'
5
+ require 'erb'
6
+ require 'pathname'
7
+
8
+ require 'rspec'
9
+ require 'rspec/core/formatters/base_text_formatter'
10
+ require 'rspec/core/formatters/snippet_extractor'
11
+
12
+ class RSpec::Core::Formatters::WebKit < RSpec::Core::Formatters::BaseTextFormatter
13
+ include ERB::Util
14
+
15
+ # Version constant
16
+ VERSION = '2.1.0'
17
+
18
+ # Look up the datadir falling back to a relative path (mostly for prerelease testing)
19
+ DEFAULT_DATADIR = Pathname( Config.datadir('rspec-formatter-webkit') )
20
+ if DEFAULT_DATADIR.exist?
21
+ BASE_PATH = DEFAULT_DATADIR
22
+ else
23
+ BASE_PATH = Pathname( __FILE__ ).dirname.parent.parent.parent.parent +
24
+ 'data/rspec-formatter-webkit'
25
+ end
26
+
27
+ # The base HREF used in the header to map stuff to the datadir
28
+ BASE_HREF = "file://#{BASE_PATH}/"
29
+
30
+ # The directory to grab ERb templates out of
31
+ TEMPLATE_DIR = BASE_PATH + 'templates'
32
+
33
+ # The page part templates
34
+ HEADER_TEMPLATE = TEMPLATE_DIR + 'header.rhtml'
35
+ PASSED_EXAMPLE_TEMPLATE = TEMPLATE_DIR + 'passed.rhtml'
36
+ FAILED_EXAMPLE_TEMPLATE = TEMPLATE_DIR + 'failed.rhtml'
37
+ PENDING_EXAMPLE_TEMPLATE = TEMPLATE_DIR + 'pending.rhtml'
38
+ PENDFIX_EXAMPLE_TEMPLATE = TEMPLATE_DIR + 'pending-fixed.rhtml'
39
+ FOOTER_TEMPLATE = TEMPLATE_DIR + 'footer.rhtml'
40
+
41
+
42
+ ### Create a new formatter
43
+ def initialize( output ) # :notnew:
44
+ super
45
+ @previous_nesting_depth = 0
46
+ @example_number = 0
47
+ @failcounter = 0
48
+ @snippet_extractor = RSpec::Core::Formatters::SnippetExtractor.new
49
+ @example_templates = {
50
+ :passed => self.load_template(PASSED_EXAMPLE_TEMPLATE),
51
+ :failed => self.load_template(FAILED_EXAMPLE_TEMPLATE),
52
+ :pending => self.load_template(PENDING_EXAMPLE_TEMPLATE),
53
+ :pending_fixed => self.load_template(PENDFIX_EXAMPLE_TEMPLATE),
54
+ }
55
+
56
+ Thread.current['logger-output'] = []
57
+ end
58
+
59
+
60
+ ######
61
+ public
62
+ ######
63
+
64
+ # Attributes made readable for ERb
65
+ attr_reader :example_group_number, :example_number, :example_count
66
+
67
+ # The counter for failed example IDs
68
+ attr_accessor :failcounter
69
+
70
+
71
+ ### Start the page by rendering the header.
72
+ def start( example_count )
73
+ @output.puts self.render_header( example_count )
74
+ @output.flush
75
+ end
76
+
77
+
78
+ ### Callback called by each example group when it's entered --
79
+ def example_group_started( example_group )
80
+ super
81
+ nesting_depth = example_group.ancestors.length
82
+
83
+ # Close the previous example groups if this one isn't a
84
+ # descendent of the previous one
85
+ if @previous_nesting_depth.nonzero? && @previous_nesting_depth >= nesting_depth
86
+ ( @previous_nesting_depth - nesting_depth + 1 ).times do
87
+ @output.puts " </dl>", "</section>", " </dd>"
88
+ end
89
+ end
90
+
91
+ @output.puts "<!-- nesting: %d, previous: %d -->" %
92
+ [ nesting_depth, @previous_nesting_depth ]
93
+ @previous_nesting_depth = nesting_depth
94
+
95
+ if @previous_nesting_depth == 1
96
+ @output.puts %{<section class="example-group">}
97
+ else
98
+ @output.puts %{<dd class="nested-group"><section class="example-group">}
99
+ end
100
+
101
+ @output.puts %{ <dl>},
102
+ %{ <dt id="%s">%s</dt>} % [
103
+ example_group.name.gsub(/[\W_]+/, '-').downcase,
104
+ h(example_group.description)
105
+ ]
106
+ @output.flush
107
+ end
108
+ alias_method :add_example_group, :example_group_started
109
+
110
+
111
+ ### Fetch any log messages added to the thread-local Array
112
+ def log_messages
113
+ return Thread.current[ 'logger-output' ] || []
114
+ end
115
+
116
+
117
+ ### Callback -- called when the examples are finished.
118
+ def start_dump
119
+ @previous_nesting_depth.downto( 1 ) do |i|
120
+ @output.puts " </dl>",
121
+ "</section>"
122
+ @output.puts " </dd>" unless i == 1
123
+ end
124
+
125
+ @output.flush
126
+ end
127
+
128
+
129
+ ### Callback -- called when an example is entered
130
+ def example_started( example )
131
+ @example_number += 1
132
+ Thread.current[ 'logger-output' ] ||= []
133
+ Thread.current[ 'logger-output' ].clear
134
+ end
135
+
136
+
137
+ ### Callback -- called when an example is exited with no failures.
138
+ def example_passed( example )
139
+ status = 'passed'
140
+ @output.puts( @example_templates[:passed].result(binding()) )
141
+ @output.flush
142
+ end
143
+
144
+
145
+ ### Callback -- called when an example is exited with a failure.
146
+ def example_failed( example )
147
+ super
148
+
149
+ counter = self.failcounter += 1
150
+ exception = example.metadata[:execution_result][:exception]
151
+ extra = self.extra_failure_content( exception )
152
+ template = if exception.is_a?( RSpec::Core::PendingExampleFixedError )
153
+ then @example_templates[:pending_fixed]
154
+ else @example_templates[:failed]
155
+ end
156
+
157
+ @output.puts( template.result(binding()) )
158
+ @output.flush
159
+ end
160
+
161
+
162
+ ### Callback -- called when an example is exited via a 'pending'.
163
+ def example_pending( example )
164
+ status = 'pending'
165
+ @output.puts( @example_templates[:pending].result(binding()) )
166
+ @output.flush
167
+ end
168
+
169
+
170
+ ### Format backtrace lines to include a textmate link to the file/line in question.
171
+ def backtrace_line( line )
172
+ return nil unless line = super
173
+ return nil if line =~ %r{r?spec/mate|textmate-command}
174
+ return h( line.strip ).gsub( /([^:]*\.rb):(\d*)/ ) do
175
+ "<a href=\"txmt://open?url=file://#{File.expand_path($1)}&amp;line=#{$2}\">#{$1}:#{$2}</a> "
176
+ end
177
+ end
178
+
179
+
180
+ ### Return any stuff that should be appended to the current example
181
+ ### because it's failed. Returns a snippet of the source around the
182
+ ### failure.
183
+ def extra_failure_content( exception )
184
+ return '' unless exception
185
+ snippet = @snippet_extractor.snippet( exception )
186
+ return " <pre class=\"ruby\"><code>#{snippet}</code></pre>"
187
+ end
188
+
189
+
190
+ ### Returns content to be output when a failure occurs during the run; overridden to
191
+ ### do nothing, as failures are handled by #example_failed.
192
+ def dump_failures( *unused )
193
+ end
194
+
195
+
196
+ ### Output the content generated at the end of the run.
197
+ def dump_summary( duration, example_count, failure_count, pending_count )
198
+ @output.puts self.render_footer( duration, example_count, failure_count, pending_count )
199
+ @output.flush
200
+ end
201
+
202
+
203
+ ### Render the header template in the context of the receiver.
204
+ def render_header( example_count )
205
+ template = self.load_template( HEADER_TEMPLATE )
206
+ return template.result( binding() )
207
+ end
208
+
209
+
210
+ ### Render the footer template in the context of the receiver.
211
+ def render_footer( duration, example_count, failure_count, pending_count )
212
+ template = self.load_template( FOOTER_TEMPLATE )
213
+ return template.result( binding() )
214
+ end
215
+
216
+
217
+ ### Load the ERB template at +templatepath+ and return it.
218
+ ### @param [Pathname] templatepath the fully-qualified path to the template file
219
+ def load_template( templatepath )
220
+ return ERB.new( templatepath.read, nil, '%<>' ).freeze
221
+ end
222
+
223
+ end # class RSpec::Core::Formatter::WebKitFormatter
data.tar.gz.sig ADDED
Binary file
metadata ADDED
@@ -0,0 +1,202 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-formatter-webkit
3
+ version: !ruby/object:Gem::Version
4
+ hash: 11
5
+ prerelease: false
6
+ segments:
7
+ - 2
8
+ - 1
9
+ - 0
10
+ version: 2.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Michael Granger
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain:
17
+ - |
18
+ -----BEGIN CERTIFICATE-----
19
+ MIIDLDCCAhSgAwIBAgIBADANBgkqhkiG9w0BAQUFADA8MQwwCgYDVQQDDANnZWQx
20
+ FzAVBgoJkiaJk/IsZAEZFgdfYWVyaWVfMRMwEQYKCZImiZPyLGQBGRYDb3JnMB4X
21
+ DTEwMDkxNjE0NDg1MVoXDTExMDkxNjE0NDg1MVowPDEMMAoGA1UEAwwDZ2VkMRcw
22
+ FQYKCZImiZPyLGQBGRYHX2FlcmllXzETMBEGCgmSJomT8ixkARkWA29yZzCCASIw
23
+ DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALy//BFxC1f/cPSnwtJBWoFiFrir
24
+ h7RicI+joq/ocVXQqI4TDWPyF/8tqkvt+rD99X9qs2YeR8CU/YiIpLWrQOYST70J
25
+ vDn7Uvhb2muFVqq6+vobeTkILBEO6pionWDG8jSbo3qKm1RjKJDwg9p4wNKhPuu8
26
+ KGue/BFb67KflqyApPmPeb3Vdd9clspzqeFqp7cUBMEpFS6LWxy4Gk+qvFFJBJLB
27
+ BUHE/LZVJMVzfpC5Uq+QmY7B+FH/QqNndn3tOHgsPadLTNimuB1sCuL1a4z3Pepd
28
+ TeLBEFmEao5Dk3K/Q8o8vlbIB/jBDTUx6Djbgxw77909x6gI9doU4LD5XMcCAwEA
29
+ AaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFJeoGkOr9l4B
30
+ +saMkW/ZXT4UeSvVMA0GCSqGSIb3DQEBBQUAA4IBAQBG2KObvYI2eHyyBUJSJ3jN
31
+ vEnU3d60znAXbrSd2qb3r1lY1EPDD3bcy0MggCfGdg3Xu54z21oqyIdk8uGtWBPL
32
+ HIa9EgfFGSUEgvcIvaYqiN4jTUtidfEFw+Ltjs8AP9gWgSIYS6Gr38V0WGFFNzIH
33
+ aOD2wmu9oo/RffW4hS/8GuvfMzcw7CQ355wFR4KB/nyze+EsZ1Y5DerCAagMVuDQ
34
+ U0BLmWDFzPGGWlPeQCrYHCr+AcJz+NRnaHCKLZdSKj/RHuTOt+gblRex8FAh8NeA
35
+ cmlhXe46pZNJgWKbxZah85jIjx95hR8vOI+NAM5iH9kOqK13DrxacTKPhqj5PjwF
36
+ -----END CERTIFICATE-----
37
+
38
+ date: 2010-12-22 00:00:00 -08:00
39
+ default_executable:
40
+ dependencies:
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ prerelease: false
44
+ requirement: &id001 !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ~>
48
+ - !ruby/object:Gem::Version
49
+ hash: 3
50
+ segments:
51
+ - 2
52
+ - 3
53
+ - 0
54
+ version: 2.3.0
55
+ type: :runtime
56
+ version_requirements: *id001
57
+ - !ruby/object:Gem::Dependency
58
+ name: hoe-yard
59
+ prerelease: false
60
+ requirement: &id002 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ hash: 31
66
+ segments:
67
+ - 0
68
+ - 1
69
+ - 2
70
+ version: 0.1.2
71
+ type: :development
72
+ version_requirements: *id002
73
+ - !ruby/object:Gem::Dependency
74
+ name: hoe
75
+ prerelease: false
76
+ requirement: &id003 !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ hash: 47
82
+ segments:
83
+ - 2
84
+ - 8
85
+ - 0
86
+ version: 2.8.0
87
+ type: :development
88
+ version_requirements: *id003
89
+ description: |-
90
+ This is a formatter for RSpec 2 that takes advantage of features in [WebKit](http://webkit.org/) to make the output from RSpec in Textmate more fun.
91
+
92
+ Test output looks like this:
93
+
94
+ ![Example Output](http://deveiate.org/images/tmrspec-example.png)
95
+ email:
96
+ - ged@FaerieMUD.org
97
+ executables: []
98
+
99
+ extensions: []
100
+
101
+ extra_rdoc_files:
102
+ - History.md
103
+ files:
104
+ - LICENSE
105
+ - README.md
106
+ - Rakefile
107
+ - data/rspec-formatter-webkit/css/textmate-rspec.css
108
+ - data/rspec-formatter-webkit/images/clock.png
109
+ - data/rspec-formatter-webkit/images/cross_circle.png
110
+ - data/rspec-formatter-webkit/images/cross_circle_frame.png
111
+ - data/rspec-formatter-webkit/images/cross_octagon.png
112
+ - data/rspec-formatter-webkit/images/cross_octagon_frame.png
113
+ - data/rspec-formatter-webkit/images/cross_shield.png
114
+ - data/rspec-formatter-webkit/images/exclamation.png
115
+ - data/rspec-formatter-webkit/images/exclamation_frame.png
116
+ - data/rspec-formatter-webkit/images/exclamation_shield.png
117
+ - data/rspec-formatter-webkit/images/exclamation_small.png
118
+ - data/rspec-formatter-webkit/images/plus_circle.png
119
+ - data/rspec-formatter-webkit/images/plus_circle_frame.png
120
+ - data/rspec-formatter-webkit/images/question.png
121
+ - data/rspec-formatter-webkit/images/question_frame.png
122
+ - data/rspec-formatter-webkit/images/question_shield.png
123
+ - data/rspec-formatter-webkit/images/question_small.png
124
+ - data/rspec-formatter-webkit/images/tick.png
125
+ - data/rspec-formatter-webkit/images/tick_circle.png
126
+ - data/rspec-formatter-webkit/images/tick_circle_frame.png
127
+ - data/rspec-formatter-webkit/images/tick_shield.png
128
+ - data/rspec-formatter-webkit/images/tick_small.png
129
+ - data/rspec-formatter-webkit/images/tick_small_circle.png
130
+ - data/rspec-formatter-webkit/images/ticket.png
131
+ - data/rspec-formatter-webkit/images/ticket_arrow.png
132
+ - data/rspec-formatter-webkit/images/ticket_exclamation.png
133
+ - data/rspec-formatter-webkit/images/ticket_minus.png
134
+ - data/rspec-formatter-webkit/images/ticket_pencil.png
135
+ - data/rspec-formatter-webkit/images/ticket_plus.png
136
+ - data/rspec-formatter-webkit/images/ticket_small.png
137
+ - data/rspec-formatter-webkit/js/jquery-1.4.2.min.js
138
+ - data/rspec-formatter-webkit/js/textmate-rspec.js
139
+ - data/rspec-formatter-webkit/templates/failed.rhtml
140
+ - data/rspec-formatter-webkit/templates/footer.rhtml
141
+ - data/rspec-formatter-webkit/templates/header.rhtml
142
+ - data/rspec-formatter-webkit/templates/page.rhtml
143
+ - data/rspec-formatter-webkit/templates/passed.rhtml
144
+ - data/rspec-formatter-webkit/templates/pending-fixed.rhtml
145
+ - data/rspec-formatter-webkit/templates/pending.rhtml
146
+ - docs/tmrspec-example.png
147
+ - docs/tmrspecopts-shellvar.png
148
+ - lib/rspec/core/formatters/web_kit.rb
149
+ - lib/rspec/core/formatters/webkit.rb
150
+ - History.md
151
+ has_rdoc: yard
152
+ homepage: http://deveiate.org/webkit-rspec-formatter.html
153
+ licenses:
154
+ - BSD
155
+ post_install_message: |+
156
+
157
+
158
+ You can use this formatter from TextMate (if you're using RSpec 2.0.0
159
+ or later) bysetting the TM_RSPEC_OPTS shell variable (in the
160
+ 'Advanced' preference pane) to:
161
+
162
+ --format RSpec::Core::Formatters::WebKit
163
+
164
+ Have fun!
165
+
166
+ rdoc_options:
167
+ - --use-cache
168
+ - --protected
169
+ - --verbose
170
+ - --title
171
+ - RspecFormatterWebkit Documentation
172
+ require_paths:
173
+ - lib
174
+ required_ruby_version: !ruby/object:Gem::Requirement
175
+ none: false
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ hash: 57
180
+ segments:
181
+ - 1
182
+ - 8
183
+ - 7
184
+ version: 1.8.7
185
+ required_rubygems_version: !ruby/object:Gem::Requirement
186
+ none: false
187
+ requirements:
188
+ - - ">="
189
+ - !ruby/object:Gem::Version
190
+ hash: 3
191
+ segments:
192
+ - 0
193
+ version: "0"
194
+ requirements: []
195
+
196
+ rubyforge_project: rspec-formatter-webkit
197
+ rubygems_version: 1.3.7
198
+ signing_key:
199
+ specification_version: 3
200
+ summary: This is a formatter for RSpec 2 that takes advantage of features in [WebKit](http://webkit.org/) to make the output from RSpec in Textmate more fun
201
+ test_files: []
202
+
metadata.gz.sig ADDED
Binary file