rspec-core 2.0.0.beta.15 → 2.0.0.beta.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/Gemfile +2 -0
  2. data/VERSION +1 -1
  3. data/features/README.markdown +12 -0
  4. data/features/command_line/example_name_option.feature +9 -9
  5. data/features/command_line/line_number_appended_to_path.feature +44 -44
  6. data/features/command_line/line_number_option.feature +4 -4
  7. data/features/configuration/custom_settings.feature +3 -3
  8. data/features/configuration/options_file.feature +3 -3
  9. data/features/example_groups/describe_aliases.feature +1 -1
  10. data/features/example_groups/nested_groups.feature +7 -7
  11. data/features/filtering/inclusion_filters.feature +10 -10
  12. data/features/formatters/custom_formatter.feature +1 -1
  13. data/features/hooks/around_hooks.feature +13 -13
  14. data/features/hooks/before_and_after_hooks.feature +38 -16
  15. data/features/hooks/described_class.feature +1 -1
  16. data/features/hooks/halt.feature +1 -1
  17. data/features/mock_framework_integration/use_flexmock.feature +1 -1
  18. data/features/mock_framework_integration/use_mocha.feature +1 -1
  19. data/features/mock_framework_integration/use_rr.feature +1 -1
  20. data/features/mock_framework_integration/use_rspec.feature +1 -1
  21. data/features/pending/pending_examples.feature +13 -13
  22. data/features/subject/explicit_subject.feature +4 -4
  23. data/features/subject/implicit_subject.feature +2 -2
  24. data/lib/rspec/core/backward_compatibility.rb +0 -6
  25. data/lib/rspec/core/command_line.rb +16 -27
  26. data/lib/rspec/core/configuration.rb +13 -4
  27. data/lib/rspec/core/example.rb +3 -2
  28. data/lib/rspec/core/formatters.rb +2 -11
  29. data/lib/rspec/core/formatters/base_formatter.rb +7 -3
  30. data/lib/rspec/core/formatters/base_text_formatter.rb +4 -0
  31. data/lib/rspec/core/formatters/html_formatter.rb +350 -0
  32. data/lib/rspec/core/formatters/snippet_extractor.rb +52 -0
  33. data/lib/rspec/core/formatters/text_mate_formatter.rb +18 -0
  34. data/lib/rspec/core/mocking/with_rspec.rb +6 -6
  35. data/lib/rspec/core/option_parser.rb +2 -0
  36. data/lib/rspec/core/runner.rb +11 -11
  37. data/lib/rspec/core/world.rb +10 -13
  38. data/rspec-core.gemspec +26 -10
  39. data/spec/rspec/core/command_line_spec.rb +1 -9
  40. data/spec/rspec/core/configuration_spec.rb +31 -15
  41. data/spec/rspec/core/drb_command_line_spec.rb +42 -34
  42. data/spec/rspec/core/formatters/html_formatted-1.8.7.html +280 -0
  43. data/spec/rspec/core/formatters/html_formatted-1.9.1.html +260 -0
  44. data/spec/rspec/core/formatters/html_formatted-1.9.2.html +260 -0
  45. data/spec/rspec/core/formatters/html_formatter_spec.rb +71 -0
  46. data/spec/rspec/core/formatters/snippet_extractor_spec.rb +18 -0
  47. data/spec/rspec/core/formatters/text_mate_formatted-1.8.7.html +280 -0
  48. data/spec/rspec/core/formatters/text_mate_formatter_spec.rb +67 -0
  49. data/spec/rspec/core/resources/formatter_specs.rb +36 -0
  50. data/spec/rspec/core/shared_example_group_spec.rb +12 -12
  51. data/spec/spec_helper.rb +26 -21
  52. metadata +28 -12
@@ -10,5 +10,5 @@ Feature: described class
10
10
  end
11
11
  """
12
12
  When I run "rspec ./spec/example_spec.rb"
13
- Then I should see "1 example, 0 failures"
13
+ Then the output should contain "1 example, 0 failures"
14
14
 
@@ -23,4 +23,4 @@ Feature: halt
23
23
  end
24
24
  """
25
25
  When I run "rspec ./spec/example_spec.rb"
26
- Then I should see "1 example, 1 failure"
26
+ Then the output should contain "1 example, 1 failure"
@@ -19,5 +19,5 @@ Feature: mock with flexmock
19
19
  end
20
20
  """
21
21
  When I run "rspec ./flexmock_example_spec.rb"
22
- Then I should see "1 example, 0 failures"
22
+ Then the output should contain "1 example, 0 failures"
23
23
  And the exit status should be 0
@@ -19,5 +19,5 @@ Feature: mock with mocha
19
19
  end
20
20
  """
21
21
  When I run "rspec ./mocha_example_spec.rb"
22
- Then I should see "1 example, 0 failures"
22
+ Then the output should contain "1 example, 0 failures"
23
23
  And the exit status should be 0
@@ -19,5 +19,5 @@ Feature: mock with rr
19
19
  end
20
20
  """
21
21
  When I run "rspec ./rr_example_spec.rb"
22
- Then I should see "1 example, 0 failures"
22
+ Then the output should contain "1 example, 0 failures"
23
23
  And the exit status should be 0
@@ -19,5 +19,5 @@ Feature: mock with rspec
19
19
  end
20
20
  """
21
21
  When I run "rspec ./rspec_example_spec.rb"
22
- Then I should see "1 example, 0 failures"
22
+ Then the output should contain "1 example, 0 failures"
23
23
  And the exit status should be 0
@@ -12,9 +12,9 @@ Feature: pending examples
12
12
  """
13
13
  When I run "rspec ./example_without_block_spec.rb"
14
14
  Then the exit status should be 0
15
- And I should see "1 example, 0 failures, 1 pending"
16
- And I should see "Not Yet Implemented"
17
- And I should see "example_without_block_spec.rb:2"
15
+ And the output should contain "1 example, 0 failures, 1 pending"
16
+ And the output should contain "Not Yet Implemented"
17
+ And the output should contain "example_without_block_spec.rb:2"
18
18
 
19
19
  Scenario: pending any arbitary reason, with no block
20
20
  Given a file named "pending_without_block_spec.rb" with:
@@ -28,9 +28,9 @@ Feature: pending examples
28
28
  """
29
29
  When I run "rspec ./pending_without_block_spec.rb"
30
30
  Then the exit status should be 0
31
- And I should see "1 example, 0 failures, 1 pending"
32
- And I should see "(something else getting finished)"
33
- And I should see "pending_without_block_spec.rb:2"
31
+ And the output should contain "1 example, 0 failures, 1 pending"
32
+ And the output should contain "(something else getting finished)"
33
+ And the output should contain "pending_without_block_spec.rb:2"
34
34
 
35
35
  Scenario: pending any arbitary reason, with a block that fails
36
36
  Given a file named "pending_with_failing_block_spec.rb" with:
@@ -45,9 +45,9 @@ Feature: pending examples
45
45
  """
46
46
  When I run "rspec ./pending_with_failing_block_spec.rb"
47
47
  Then the exit status should be 0
48
- And I should see "1 example, 0 failures, 1 pending"
49
- And I should see "(something else getting finished)"
50
- And I should see "pending_with_failing_block_spec.rb:2"
48
+ And the output should contain "1 example, 0 failures, 1 pending"
49
+ And the output should contain "(something else getting finished)"
50
+ And the output should contain "pending_with_failing_block_spec.rb:2"
51
51
 
52
52
  Scenario: pending any arbitary reason, with a block that passes
53
53
  Given a file named "pending_with_passing_block_spec.rb" with:
@@ -62,7 +62,7 @@ Feature: pending examples
62
62
  """
63
63
  When I run "rspec ./pending_with_passing_block_spec.rb"
64
64
  Then the exit status should not be 0
65
- And I should see "1 example, 1 failure"
66
- And I should see "FIXED"
67
- And I should see "Expected pending 'something else getting finished' to fail. No Error was raised."
68
- And I should see "pending_with_passing_block_spec.rb:3"
65
+ And the output should contain "1 example, 1 failure"
66
+ And the output should contain "FIXED"
67
+ And the output should contain "Expected pending 'something else getting finished' to fail. No Error was raised."
68
+ And the output should contain "pending_with_passing_block_spec.rb:3"
@@ -15,7 +15,7 @@ Feature: explicit subject
15
15
  end
16
16
  """
17
17
  When I run "rspec ./top_level_subject_spec.rb"
18
- Then I should see "1 example, 0 failures"
18
+ Then the output should contain "1 example, 0 failures"
19
19
 
20
20
  Scenario: subject in a nested group
21
21
  Given a file named "nested_subject_spec.rb" with:
@@ -32,7 +32,7 @@ Feature: explicit subject
32
32
  end
33
33
  """
34
34
  When I run "rspec ./nested_subject_spec.rb"
35
- Then I should see "1 example, 0 failures"
35
+ Then the output should contain "1 example, 0 failures"
36
36
 
37
37
  Scenario: access subject from before block
38
38
  Given a file named "top_level_subject_spec.rb" with:
@@ -46,7 +46,7 @@ Feature: explicit subject
46
46
  end
47
47
  """
48
48
  When I run "rspec ./top_level_subject_spec.rb"
49
- Then I should see "1 example, 0 failures"
49
+ Then the output should contain "1 example, 0 failures"
50
50
 
51
51
  Scenario: subject using helper method
52
52
  Given a file named "helper_subject_spec.rb" with:
@@ -64,4 +64,4 @@ Feature: explicit subject
64
64
  end
65
65
  """
66
66
  When I run "rspec ./helper_subject_spec.rb"
67
- Then I should see "1 example, 0 failures"
67
+ Then the output should contain "1 example, 0 failures"
@@ -14,7 +14,7 @@ Feature: implicit subject
14
14
  end
15
15
  """
16
16
  When I run "rspec ./top_level_subject_spec.rb"
17
- Then I should see "1 example, 0 failures"
17
+ Then the output should contain "1 example, 0 failures"
18
18
 
19
19
  Scenario: subject in a nested group
20
20
  Given a file named "nested_subject_spec.rb" with:
@@ -28,4 +28,4 @@ Feature: implicit subject
28
28
  end
29
29
  """
30
30
  When I run "rspec ./nested_subject_spec.rb"
31
- Then I should see "1 example, 0 failures"
31
+ Then the output should contain "1 example, 0 failures"
@@ -1,11 +1,5 @@
1
1
  module RSpec
2
2
  module Core
3
- class Configuration
4
- def mock_with(use_me_to_mock)
5
- self.mock_framework = use_me_to_mock
6
- end
7
- end
8
-
9
3
  module ConstMissing
10
4
  def const_missing(name)
11
5
  case name
@@ -1,29 +1,26 @@
1
1
  module RSpec
2
2
  module Core
3
3
  class CommandLine
4
- def initialize(args_or_options)
5
- if RSpec::Core::ConfigurationOptions === args_or_options
6
- @options = args_or_options
7
- else
8
- @options = RSpec::Core::ConfigurationOptions.new(args_or_options)
9
- @options.parse_options
10
- end
11
- @options.configure(configuration)
12
- configuration.require_files_to_run
13
- configuration.configure_mock_framework
4
+ def initialize(options, configuration=RSpec::configuration, world=RSpec::world)
5
+ @options = options
6
+ @configuration = configuration
7
+ @world = world
14
8
  end
15
9
 
16
10
  def run(err, out)
17
- configuration.error_stream = err
18
- configuration.output_stream = out
19
- world.announce_inclusion_filter
20
-
21
- configuration.reporter.report(example_count) do |reporter|
11
+ @options.configure(@configuration)
12
+ @configuration.error_stream = err
13
+ @configuration.output_stream = out
14
+ @configuration.require_files_to_run
15
+ @configuration.configure_mock_framework
16
+ @world.announce_inclusion_filter
17
+
18
+ @configuration.reporter.report(example_count) do |reporter|
22
19
  begin
23
- configuration.run_hook(:before, :suite)
20
+ @configuration.run_hook(:before, :suite)
24
21
  example_groups.run_examples(reporter)
25
22
  ensure
26
- configuration.run_hook(:after, :suite)
23
+ @configuration.run_hook(:after, :suite)
27
24
  end
28
25
  end
29
26
 
@@ -33,7 +30,7 @@ module RSpec
33
30
  private
34
31
 
35
32
  def example_count
36
- world.example_count
33
+ @world.example_count
37
34
  end
38
35
 
39
36
  module ExampleGroups
@@ -47,15 +44,7 @@ module RSpec
47
44
  end
48
45
 
49
46
  def example_groups
50
- world.example_groups.extend(ExampleGroups)
51
- end
52
-
53
- def configuration
54
- RSpec.configuration
55
- end
56
-
57
- def world
58
- RSpec.world
47
+ @world.example_groups.extend(ExampleGroups)
59
48
  end
60
49
  end
61
50
  end
@@ -12,7 +12,7 @@ module RSpec
12
12
  alias_method "#{name}?", "#{opts[:alias]}?"
13
13
  else
14
14
  define_method("#{name}=") {|val| settings[name] = val}
15
- define_method(name) { settings.has_key?(name) ? settings[name] : opts[:default] }
15
+ define_method(name) { settings.has_key?(name) ? settings[name] : opts[:default] }
16
16
  define_method("#{name}?") { !!(send name) }
17
17
  end
18
18
  end
@@ -40,7 +40,7 @@ module RSpec
40
40
  /bin\/spec/,
41
41
  /lib\/rspec\/(core|expectations|matchers|mocks)/
42
42
  ]
43
-
43
+
44
44
  # :call-seq:
45
45
  # add_setting(:name)
46
46
  # add_setting(:name, :default => "default_value")
@@ -91,7 +91,7 @@ module RSpec
91
91
  @settings ||= {}
92
92
  end
93
93
 
94
- def clear_inclusion_filter
94
+ def clear_inclusion_filter # :nodoc:
95
95
  self.filter = nil
96
96
  end
97
97
 
@@ -99,6 +99,10 @@ module RSpec
99
99
  backtrace_clean_patterns.any? { |regex| line =~ regex }
100
100
  end
101
101
 
102
+ def mock_with(mock_framework)
103
+ settings[:mock_framework] = mock_framework
104
+ end
105
+
102
106
  def require_mock_framework_adapter
103
107
  require case mock_framework.to_s
104
108
  when /rspec/i
@@ -115,7 +119,7 @@ module RSpec
115
119
  end
116
120
 
117
121
  def full_backtrace=(bool)
118
- backtrace_clean_patterns.clear
122
+ settings[:backtrace_clean_patterns] = []
119
123
  end
120
124
 
121
125
  def color_enabled=(bool)
@@ -177,6 +181,10 @@ EOM
177
181
  formatter_class = case formatter_to_use.to_s
178
182
  when 'd', 'doc', 'documentation', 's', 'n', 'spec', 'nested'
179
183
  RSpec::Core::Formatters::DocumentationFormatter
184
+ when 'h', 'html'
185
+ RSpec::Core::Formatters::HtmlFormatter
186
+ when 't', 'textmate'
187
+ RSpec::Core::Formatters::TextMateFormatter
180
188
  when 'progress'
181
189
  RSpec::Core::Formatters::ProgressFormatter
182
190
  else
@@ -220,6 +228,7 @@ EOM
220
228
  end
221
229
 
222
230
  def filter_run_including(options={})
231
+ # TODO (DC 2010-07-03) this should probably warn when the unless clause returns true
223
232
  self.filter = options unless filter and filter[:line_number] || filter[:full_description]
224
233
  end
225
234
 
@@ -39,7 +39,7 @@ module RSpec
39
39
  @example_group_instance = example_group_instance
40
40
  @example_group_instance.example = self
41
41
 
42
- start
42
+ start(reporter)
43
43
 
44
44
  begin
45
45
  unless pending
@@ -90,7 +90,8 @@ module RSpec
90
90
  @example_group_class.ancestors.reverse.map{|a| a.hooks[:around][:each]}).flatten
91
91
  end
92
92
 
93
- def start
93
+ def start(reporter)
94
+ reporter.example_started(self)
94
95
  record :started_at => Time.now
95
96
  end
96
97
 
@@ -3,15 +3,6 @@ require 'rspec/core/formatters/base_formatter'
3
3
  require 'rspec/core/formatters/base_text_formatter'
4
4
  require 'rspec/core/formatters/documentation_formatter'
5
5
  require 'rspec/core/formatters/progress_formatter'
6
+ require 'rspec/core/formatters/html_formatter'
7
+ require 'rspec/core/formatters/text_mate_formatter'
6
8
 
7
- module RSpec
8
-
9
- module Core
10
-
11
- module Formatters
12
-
13
- end
14
-
15
- end
16
-
17
- end
@@ -58,16 +58,20 @@ module RSpec
58
58
  @duration = Time.now - @start
59
59
  end
60
60
 
61
- def example_passed(example)
61
+ def example_started(example)
62
62
  examples << example
63
63
  end
64
64
 
65
+ def example_passed(example)
66
+ end
67
+
65
68
  def example_pending(example)
66
- examples << example
67
69
  end
68
70
 
69
71
  def example_failed(example)
70
- examples << example
72
+ end
73
+
74
+ def message(message)
71
75
  end
72
76
 
73
77
  # This method is invoked at the beginning of the execution of each example group.
@@ -4,6 +4,10 @@ module RSpec
4
4
 
5
5
  class BaseTextFormatter < BaseFormatter
6
6
 
7
+ def message(message)
8
+ output.puts message
9
+ end
10
+
7
11
  def dump_failures
8
12
  output.puts
9
13
  failed_examples.each_with_index do |failed_example, index|
@@ -0,0 +1,350 @@
1
+ require 'erb'
2
+ require 'rspec/core/formatters/base_text_formatter'
3
+
4
+ module RSpec
5
+ module Core
6
+ module Formatters
7
+ class HtmlFormatter < BaseTextFormatter
8
+ include ERB::Util # for the #h method
9
+
10
+ def method_missing(m, *a, &b)
11
+ # no-op
12
+ end
13
+
14
+ def message(message)
15
+ end
16
+
17
+ def initialize(output)
18
+ super
19
+ @example_group_number = 0
20
+ @example_number = 0
21
+ @header_red = nil
22
+ end
23
+
24
+ # The number of the currently running example_group
25
+ def example_group_number
26
+ @example_group_number
27
+ end
28
+
29
+ # The number of the currently running example (a global counter)
30
+ def example_number
31
+ @example_number
32
+ end
33
+
34
+ def start(example_count)
35
+ super
36
+ @output.puts html_header
37
+ @output.puts report_header
38
+ @output.flush
39
+ end
40
+
41
+ def add_example_group(example_group)
42
+ super
43
+ @example_group_red = false
44
+ @example_group_number += 1
45
+ unless example_group_number == 1
46
+ @output.puts " </dl>"
47
+ @output.puts "</div>"
48
+ end
49
+ @output.puts "<div class=\"example_group\">"
50
+ @output.puts " <dl>"
51
+ @output.puts " <dt id=\"example_group_#{example_group_number}\">#{h(example_group.description)}</dt>"
52
+ @output.flush
53
+ end
54
+
55
+ def start_dump(duration)
56
+ @output.puts " </dl>"
57
+ @output.puts "</div>"
58
+ @output.flush
59
+ end
60
+
61
+ def example_started(example)
62
+ super
63
+ @example_number += 1
64
+ end
65
+
66
+ def example_passed(example)
67
+ move_progress
68
+ @output.puts " <dd class=\"spec passed\"><span class=\"passed_spec_name\">#{h(example.description)}</span></dd>"
69
+ @output.flush
70
+ end
71
+
72
+ def example_failed(example)
73
+ counter = 0
74
+ exception = example.metadata[:execution_result][:exception_encountered]
75
+ extra = extra_failure_content(exception)
76
+ failure_style = 'failed'
77
+ failure_style = RSpec::Core::PendingExampleFixedError === exception ? 'pending_fixed' : 'failed'
78
+ @output.puts " <script type=\"text/javascript\">makeRed('rspec-header');</script>" unless @header_red
79
+ @header_red = true
80
+ @output.puts " <script type=\"text/javascript\">makeRed('example_group_#{example_group_number}');</script>" unless @example_group_red
81
+ @example_group_red = true
82
+ move_progress
83
+ @output.puts " <dd class=\"spec #{failure_style}\">"
84
+ @output.puts " <span class=\"failed_spec_name\">#{h(example.description)}</span>"
85
+ @output.puts " <div class=\"failure\" id=\"failure_#{counter}\">"
86
+ @output.puts " <div class=\"message\"><pre>#{h(exception.message)}</pre></div>" unless exception.nil?
87
+ @output.puts " <div class=\"backtrace\"><pre>#{format_backtrace(exception.backtrace, example).join("\n")}</pre></div>" if exception
88
+ @output.puts extra unless extra == ""
89
+ @output.puts " </div>"
90
+ @output.puts " </dd>"
91
+ @output.flush
92
+ end
93
+
94
+ def example_pending(example)
95
+ message = example.metadata[:execution_result][:pending_message]
96
+ @output.puts " <script type=\"text/javascript\">makeYellow('rspec-header');</script>" unless @header_red
97
+ @output.puts " <script type=\"text/javascript\">makeYellow('example_group_#{example_group_number}');</script>" unless @example_group_red
98
+ move_progress
99
+ @output.puts " <dd class=\"spec not_implemented\"><span class=\"not_implemented_spec_name\">#{h(example.description)} (PENDING: #{h(message)})</span></dd>"
100
+ @output.flush
101
+ end
102
+
103
+ # Override this method if you wish to output extra HTML for a failed spec. For example, you
104
+ # could output links to images or other files produced during the specs.
105
+ #
106
+ def extra_failure_content(exception)
107
+ require 'rspec/core/formatters/snippet_extractor'
108
+ @snippet_extractor ||= SnippetExtractor.new
109
+ " <pre class=\"ruby\"><code>#{@snippet_extractor.snippet(exception)}</code></pre>"
110
+ end
111
+
112
+ def move_progress
113
+ @output.puts " <script type=\"text/javascript\">moveProgressBar('#{percent_done}');</script>"
114
+ @output.flush
115
+ end
116
+
117
+ def percent_done
118
+ result = 100.0
119
+ if @example_count > 0
120
+ result = ((example_number).to_f / @example_count.to_f * 1000).to_i / 10.0
121
+ end
122
+ result
123
+ end
124
+
125
+ def dump_failures
126
+ end
127
+
128
+ def dump_pending
129
+ end
130
+
131
+ def dump_summary
132
+ if dry_run?
133
+ totals = "This was a dry-run"
134
+ else
135
+ totals = "#{example_count} example#{'s' unless example_count == 1}, #{failure_count} failure#{'s' unless failure_count == 1}"
136
+ totals << ", #{pending_count} pending" if pending_count > 0
137
+ end
138
+ @output.puts "<script type=\"text/javascript\">document.getElementById('duration').innerHTML = \"Finished in <strong>#{duration} seconds</strong>\";</script>"
139
+ @output.puts "<script type=\"text/javascript\">document.getElementById('totals').innerHTML = \"#{totals}\";</script>"
140
+ @output.puts "</div>"
141
+ @output.puts "</div>"
142
+ @output.puts "</body>"
143
+ @output.puts "</html>"
144
+ @output.flush
145
+ end
146
+
147
+ def html_header
148
+ <<-EOF
149
+ <?xml version="1.0" encoding="UTF-8"?>
150
+ <!DOCTYPE html
151
+ PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
152
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
153
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
154
+ <head>
155
+ <title>RSpec results</title>
156
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
157
+ <meta http-equiv="Expires" content="-1" />
158
+ <meta http-equiv="Pragma" content="no-cache" />
159
+ <style type="text/css">
160
+ body {
161
+ margin: 0;
162
+ padding: 0;
163
+ background: #fff;
164
+ font-size: 80%;
165
+ }
166
+ </style>
167
+ <script type="text/javascript">
168
+ // <![CDATA[
169
+ #{global_scripts}
170
+ // ]]>
171
+ </script>
172
+ <style type="text/css">
173
+ #{global_styles}
174
+ </style>
175
+ </head>
176
+ <body>
177
+ EOF
178
+ end
179
+
180
+ def report_header
181
+ <<-EOF
182
+ <div class="rspec-report">
183
+
184
+ <div id="rspec-header">
185
+ <div id="label">
186
+ <h1>RSpec Code Examples</h1>
187
+ </div>
188
+
189
+ <div id="summary">
190
+ <p id="totals">&nbsp;</p>
191
+ <p id="duration">&nbsp;</p>
192
+ </div>
193
+ </div>
194
+
195
+ <div class="results">
196
+ EOF
197
+ end
198
+
199
+ def global_scripts
200
+ <<-EOF
201
+ function moveProgressBar(percentDone) {
202
+ document.getElementById("rspec-header").style.width = percentDone +"%";
203
+ }
204
+ function makeRed(element_id) {
205
+ document.getElementById(element_id).style.background = '#C40D0D';
206
+ document.getElementById(element_id).style.color = '#FFFFFF';
207
+ }
208
+
209
+ function makeYellow(element_id) {
210
+ if (element_id == "rspec-header" && document.getElementById(element_id).style.background != '#C40D0D')
211
+ {
212
+ document.getElementById(element_id).style.background = '#FAF834';
213
+ document.getElementById(element_id).style.color = '#000000';
214
+ }
215
+ else
216
+ {
217
+ document.getElementById(element_id).style.background = '#FAF834';
218
+ document.getElementById(element_id).style.color = '#000000';
219
+ }
220
+ }
221
+ EOF
222
+ end
223
+
224
+ def global_styles
225
+ <<-EOF
226
+ #rspec-header {
227
+ background: #65C400; color: #fff; height: 4em;
228
+ }
229
+
230
+ .rspec-report h1 {
231
+ margin: 0px 10px 0px 10px;
232
+ padding: 10px;
233
+ font-family: "Lucida Grande", Helvetica, sans-serif;
234
+ font-size: 1.8em;
235
+ position: absolute;
236
+ }
237
+
238
+ #summary {
239
+ margin: 0; padding: 5px 10px;
240
+ font-family: "Lucida Grande", Helvetica, sans-serif;
241
+ text-align: right;
242
+ top: 0px;
243
+ right: 0px;
244
+ float:right;
245
+ }
246
+
247
+ #summary p {
248
+ margin: 0 0 0 2px;
249
+ }
250
+
251
+ #summary #totals {
252
+ font-size: 1.2em;
253
+ }
254
+
255
+ .example_group {
256
+ margin: 0 10px 5px;
257
+ background: #fff;
258
+ }
259
+
260
+ dl {
261
+ margin: 0; padding: 0 0 5px;
262
+ font: normal 11px "Lucida Grande", Helvetica, sans-serif;
263
+ }
264
+
265
+ dt {
266
+ padding: 3px;
267
+ background: #65C400;
268
+ color: #fff;
269
+ font-weight: bold;
270
+ }
271
+
272
+ dd {
273
+ margin: 5px 0 5px 5px;
274
+ padding: 3px 3px 3px 18px;
275
+ }
276
+
277
+ dd.spec.passed {
278
+ border-left: 5px solid #65C400;
279
+ border-bottom: 1px solid #65C400;
280
+ background: #DBFFB4; color: #3D7700;
281
+ }
282
+
283
+ dd.spec.failed {
284
+ border-left: 5px solid #C20000;
285
+ border-bottom: 1px solid #C20000;
286
+ color: #C20000; background: #FFFBD3;
287
+ }
288
+
289
+ dd.spec.not_implemented {
290
+ border-left: 5px solid #FAF834;
291
+ border-bottom: 1px solid #FAF834;
292
+ background: #FCFB98; color: #131313;
293
+ }
294
+
295
+ dd.spec.pending_fixed {
296
+ border-left: 5px solid #0000C2;
297
+ border-bottom: 1px solid #0000C2;
298
+ color: #0000C2; background: #D3FBFF;
299
+ }
300
+
301
+ .backtrace {
302
+ color: #000;
303
+ font-size: 12px;
304
+ }
305
+
306
+ a {
307
+ color: #BE5C00;
308
+ }
309
+
310
+ /* Ruby code, style similar to vibrant ink */
311
+ .ruby {
312
+ font-size: 12px;
313
+ font-family: monospace;
314
+ color: white;
315
+ background-color: black;
316
+ padding: 0.1em 0 0.2em 0;
317
+ }
318
+
319
+ .ruby .keyword { color: #FF6600; }
320
+ .ruby .constant { color: #339999; }
321
+ .ruby .attribute { color: white; }
322
+ .ruby .global { color: white; }
323
+ .ruby .module { color: white; }
324
+ .ruby .class { color: white; }
325
+ .ruby .string { color: #66FF00; }
326
+ .ruby .ident { color: white; }
327
+ .ruby .method { color: #FFCC00; }
328
+ .ruby .number { color: white; }
329
+ .ruby .char { color: white; }
330
+ .ruby .comment { color: #9933CC; }
331
+ .ruby .symbol { color: white; }
332
+ .ruby .regex { color: #44B4CC; }
333
+ .ruby .punct { color: white; }
334
+ .ruby .escape { color: white; }
335
+ .ruby .interp { color: white; }
336
+ .ruby .expr { color: white; }
337
+
338
+ .ruby .offending { background-color: gray; }
339
+ .ruby .linenum {
340
+ width: 75px;
341
+ padding: 0.1em 1em 0.2em 0;
342
+ color: #000000;
343
+ background-color: #FFFBD3;
344
+ }
345
+ EOF
346
+ end
347
+ end
348
+ end
349
+ end
350
+ end