dchelimsky-rspec 1.1.11.7 → 1.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. data/History.txt +1 -1
  2. data/features/support/helpers/story_helper.rb +0 -3
  3. data/lib/spec/example/example_group_methods.rb +1 -1
  4. data/lib/spec/matchers.rb +1 -1
  5. data/lib/spec/mocks.rb +3 -3
  6. data/lib/spec/mocks/argument_expectation.rb +14 -14
  7. data/lib/spec/mocks/framework.rb +1 -1
  8. data/lib/spec/mocks/message_expectation.rb +1 -1
  9. data/lib/spec/mocks/mock.rb +3 -4
  10. data/lib/spec/mocks/spec_methods.rb +10 -1
  11. data/lib/spec/version.rb +2 -2
  12. data/rspec.gemspec +3 -3
  13. data/spec/spec/mocks/hash_including_matcher_spec.rb +4 -4
  14. data/spec/spec/mocks/hash_not_including_matcher_spec.rb +3 -3
  15. data/spec/spec/mocks/mock_spec.rb +25 -0
  16. data/spec/spec/runner/reporter_spec.rb +1 -1
  17. data/spec/spec_helper.rb +0 -1
  18. metadata +3 -3
  19. data/lib/spec/mocks/argument_constraints.rb +0 -237
  20. data/lib/spec/runner/formatter/story/html_formatter.rb +0 -174
  21. data/lib/spec/runner/formatter/story/plain_text_formatter.rb +0 -194
  22. data/lib/spec/runner/formatter/story/progress_bar_formatter.rb +0 -42
  23. data/lib/spec/story.rb +0 -10
  24. data/lib/spec/story/extensions.rb +0 -3
  25. data/lib/spec/story/extensions/main.rb +0 -86
  26. data/lib/spec/story/extensions/regexp.rb +0 -9
  27. data/lib/spec/story/extensions/string.rb +0 -9
  28. data/lib/spec/story/given_scenario.rb +0 -14
  29. data/lib/spec/story/runner.rb +0 -57
  30. data/lib/spec/story/runner/plain_text_story_runner.rb +0 -48
  31. data/lib/spec/story/runner/scenario_collector.rb +0 -18
  32. data/lib/spec/story/runner/scenario_runner.rb +0 -54
  33. data/lib/spec/story/runner/story_mediator.rb +0 -137
  34. data/lib/spec/story/runner/story_parser.rb +0 -247
  35. data/lib/spec/story/runner/story_runner.rb +0 -74
  36. data/lib/spec/story/scenario.rb +0 -14
  37. data/lib/spec/story/step.rb +0 -70
  38. data/lib/spec/story/step_group.rb +0 -89
  39. data/lib/spec/story/step_mother.rb +0 -38
  40. data/lib/spec/story/story.rb +0 -39
  41. data/lib/spec/story/world.rb +0 -124
  42. data/spec/spec/matchers/mock_constraint_matchers_spec.rb +0 -24
  43. data/spec/spec/mocks/failing_mock_argument_constraints_spec.rb +0 -95
  44. data/spec/spec/mocks/passing_mock_argument_constraints_spec.rb +0 -145
  45. data/spec/spec/runner/formatter/story/html_formatter_spec.rb +0 -135
  46. data/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb +0 -600
  47. data/spec/spec/runner/formatter/story/progress_bar_formatter_spec.rb +0 -82
  48. data/spec/spec/story/builders.rb +0 -46
  49. data/spec/spec/story/extensions/main_spec.rb +0 -161
  50. data/spec/spec/story/extensions_spec.rb +0 -14
  51. data/spec/spec/story/given_scenario_spec.rb +0 -27
  52. data/spec/spec/story/runner/plain_text_story_runner_spec.rb +0 -90
  53. data/spec/spec/story/runner/scenario_collector_spec.rb +0 -27
  54. data/spec/spec/story/runner/scenario_runner_spec.rb +0 -214
  55. data/spec/spec/story/runner/story_mediator_spec.rb +0 -143
  56. data/spec/spec/story/runner/story_parser_spec.rb +0 -401
  57. data/spec/spec/story/runner/story_runner_spec.rb +0 -294
  58. data/spec/spec/story/runner_spec.rb +0 -93
  59. data/spec/spec/story/scenario_spec.rb +0 -18
  60. data/spec/spec/story/step_group_spec.rb +0 -157
  61. data/spec/spec/story/step_mother_spec.rb +0 -84
  62. data/spec/spec/story/step_spec.rb +0 -272
  63. data/spec/spec/story/story_helper.rb +0 -2
  64. data/spec/spec/story/story_spec.rb +0 -84
  65. data/spec/spec/story/world_spec.rb +0 -423
  66. data/story_server/prototype/javascripts/builder.js +0 -136
  67. data/story_server/prototype/javascripts/controls.js +0 -972
  68. data/story_server/prototype/javascripts/dragdrop.js +0 -976
  69. data/story_server/prototype/javascripts/effects.js +0 -1117
  70. data/story_server/prototype/javascripts/prototype.js +0 -4140
  71. data/story_server/prototype/javascripts/rspec.js +0 -149
  72. data/story_server/prototype/javascripts/scriptaculous.js +0 -58
  73. data/story_server/prototype/javascripts/slider.js +0 -276
  74. data/story_server/prototype/javascripts/sound.js +0 -55
  75. data/story_server/prototype/javascripts/unittest.js +0 -568
  76. data/story_server/prototype/lib/server.rb +0 -24
  77. data/story_server/prototype/stories.html +0 -176
  78. data/story_server/prototype/stylesheets/rspec.css +0 -136
  79. data/story_server/prototype/stylesheets/test.css +0 -90
@@ -1,174 +0,0 @@
1
- require 'erb'
2
- require 'spec/runner/formatter/base_text_formatter'
3
-
4
- module Spec
5
- module Runner
6
- module Formatter
7
- module Story
8
- class HtmlFormatter < BaseTextFormatter
9
- include ERB::Util
10
-
11
- def initialize(options, where)
12
- super
13
- @previous_type = nil
14
- @scenario_text = ""
15
- @story_text = ""
16
- @scenario_failed = false
17
- @story_failed = false
18
- end
19
-
20
- def run_started(count)
21
- @output.puts <<-EOF
22
- <?xml version="1.0" encoding="UTF-8"?>
23
- <!DOCTYPE html
24
- PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
25
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
26
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
27
- <head>
28
- <title>Stories</title>
29
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
30
- <meta http-equiv="Expires" content="-1" />
31
- <meta http-equiv="Pragma" content="no-cache" />
32
- <script src="javascripts/prototype.js" type="text/javascript"></script>
33
- <script src="javascripts/scriptaculous.js" type="text/javascript"></script>
34
- <script src="javascripts/rspec.js" type="text/javascript"></script>
35
- <link href="stylesheets/rspec.css" rel="stylesheet" type="text/css" />
36
- </head>
37
- <body>
38
- <div id="container">
39
- EOF
40
- end
41
-
42
- def collected_steps(steps)
43
- unless steps.empty?
44
- @output.puts " <ul id=\"stock_steps\" style=\"display: none;\">"
45
- steps.each do |step|
46
- @output.puts " <li>#{step}</li>"
47
- end
48
- @output.puts " </ul>"
49
- end
50
- end
51
-
52
- def run_ended
53
- @output.puts <<-EOF
54
- </div>
55
- </body>
56
- </head>
57
- EOF
58
- end
59
-
60
- def story_started(title, narrative)
61
- @story_failed = false
62
- @story_text = <<-EOF
63
- <dt>Story: #{h title}</dt>
64
- <dd>
65
- <p>
66
- #{h(narrative).split("\n").join("<br />")}
67
- </p>
68
- EOF
69
- end
70
-
71
- def story_ended(title, narrative)
72
- if @story_failed
73
- @output.puts <<-EOF
74
- <dl class="story failed">
75
- EOF
76
- else
77
- @output.puts <<-EOF
78
- <dl class="story passed">
79
- EOF
80
- end
81
- @output.puts <<-EOF
82
- #{@story_text}
83
- </dd>
84
- </dl>
85
- EOF
86
- end
87
-
88
- def scenario_started(story_title, scenario_name)
89
- @previous_type = nil
90
- @scenario_failed = false
91
- @scenario_text = <<-EOF
92
- <dt>Scenario: #{h scenario_name}</dt>
93
- <dd>
94
- <ul class="steps">
95
- EOF
96
- end
97
-
98
- def scenario_ended
99
- if @scenario_failed
100
- @story_text += <<-EOF
101
- <dl class="failed">
102
- EOF
103
- else
104
- @story_text += <<-EOF
105
- <dl class="passed">
106
- EOF
107
- end
108
-
109
- @story_text += <<-EOF
110
- #{@scenario_text}
111
- </ul>
112
- </dd>
113
- </dl>
114
- EOF
115
- end
116
-
117
- def found_scenario(type, description)
118
- end
119
-
120
- def scenario_succeeded(story_title, scenario_name)
121
- scenario_ended
122
- end
123
-
124
- def scenario_pending(story_title, scenario_name, reason)
125
- scenario_ended
126
- end
127
-
128
- def scenario_failed(story_title, scenario_name, err)
129
- @scenario_failed = true
130
- @story_failed = true
131
- scenario_ended
132
- end
133
-
134
- def step_upcoming(type, description, *args)
135
- end
136
-
137
- def step_succeeded(type, description, *args)
138
- print_step('passed', type, description, *args) # TODO: uses succeeded CSS class
139
- end
140
-
141
- def step_pending(type, description, *args)
142
- print_step('pending', type, description, *args)
143
- end
144
-
145
- def step_failed(type, description, *args)
146
- print_step('failed', type, description, *args)
147
- end
148
-
149
- def print_step(klass, type, description, *args)
150
- spans = args.map { |arg| "<span class=\"param\">#{arg}</span>" }
151
- desc_string = description.step_name
152
- arg_regexp = description.arg_regexp
153
- inner = if(type == @previous_type)
154
- "And "
155
- else
156
- "#{type.to_s.capitalize} "
157
- end
158
- i = -1
159
- inner += desc_string.gsub(arg_regexp) { |param| spans[i+=1] }
160
-
161
- @scenario_text += " <li class=\"#{klass}\">#{inner}</li>\n"
162
-
163
- if type == :'given scenario'
164
- @previous_type = :given
165
- else
166
- @previous_type = type
167
- end
168
-
169
- end
170
- end
171
- end
172
- end
173
- end
174
- end
@@ -1,194 +0,0 @@
1
- require 'spec/runner/formatter/base_text_formatter'
2
-
3
- module Spec
4
- module Runner
5
- module Formatter
6
- module Story
7
- class PlainTextFormatter < BaseTextFormatter
8
- def initialize(options, where)
9
- super
10
- @successful_scenario_count = 0
11
- @pending_scenario_count = 0
12
-
13
- @pre_story_pending_count = 0
14
- @pre_story_successful_count = 0
15
-
16
- @failed_scenarios = []
17
- @pending_steps = []
18
- @previous_type = nil
19
-
20
- @scenario_body_text = ""
21
- @story_body_text = ""
22
-
23
- @scenario_head_text = ""
24
- @story_head_text = ""
25
-
26
- @scenario_failed = false
27
- @story_failed = false
28
- end
29
-
30
- def run_started(count)
31
- @count = count
32
- @output.puts "Running #@count scenarios\n\n"
33
- end
34
-
35
- def story_started(title, narrative)
36
- @pre_story_pending_count = @pending_scenario_count
37
- @pre_story_successful_count = @successful_scenario_count
38
-
39
- @current_story_title = title
40
- @story_failed = false
41
- @story_body_text = ""
42
- @story_head_text = "Story: #{title}\n\n"
43
-
44
- narrative.each_line do |line|
45
- @story_head_text += " "
46
- @story_head_text += line
47
- end
48
- end
49
-
50
- def story_ended(title, narrative)
51
- if @story_failed
52
- @output.print red(@story_head_text)
53
- elsif @pre_story_successful_count == @successful_scenario_count &&
54
- @pending_scenario_count >= @pre_story_pending_count
55
- @output.print yellow(@story_head_text)
56
- else
57
- @output.print green(@story_head_text)
58
- end
59
- @output.print @story_body_text
60
- @output.puts
61
- @output.puts
62
- end
63
-
64
- def scenario_started(story_title, scenario_name)
65
- @current_scenario_name = scenario_name
66
- @scenario_already_failed = false
67
- @scenario_head_text = "\n\n Scenario: #{scenario_name}"
68
- @scenario_body_text = ""
69
- @scenario_ok = true
70
- @scenario_pending = false
71
- @scenario_failed = false
72
- end
73
-
74
- def scenario_succeeded(story_title, scenario_name)
75
- @successful_scenario_count += 1
76
- scenario_ended
77
- end
78
-
79
- def scenario_failed(story_title, scenario_name, err)
80
- @options.backtrace_tweaker.tweak_backtrace(err)
81
- @failed_scenarios << [story_title, scenario_name, err] unless @scenario_already_failed
82
- @scenario_already_failed = true
83
- @story_failed = true
84
- @scenario_failed = true
85
- scenario_ended
86
- end
87
-
88
- def scenario_pending(story_title, scenario_name, msg)
89
- @pending_scenario_count += 1 unless @scenario_already_failed
90
- @scenario_pending = true
91
- @scenario_already_failed = true
92
- scenario_ended
93
- end
94
-
95
- def scenario_ended
96
- if @scenario_failed
97
- @story_body_text += red(@scenario_head_text)
98
- elsif @scenario_pending
99
- @story_body_text += yellow(@scenario_head_text)
100
- else
101
- @story_body_text += green(@scenario_head_text)
102
- end
103
- @story_body_text += @scenario_body_text
104
- end
105
-
106
- def run_ended
107
- summary_text = "#@count scenarios: #@successful_scenario_count succeeded, #{@failed_scenarios.size} failed, #@pending_scenario_count pending"
108
- if !@failed_scenarios.empty?
109
- @output.puts red(summary_text)
110
- elsif !@pending_steps.empty?
111
- @output.puts yellow(summary_text)
112
- else
113
- @output.puts green(summary_text)
114
- end
115
- unless @pending_steps.empty?
116
- @output.puts "\nPending Steps:"
117
- @pending_steps.each_with_index do |pending, i|
118
- story_name, scenario_name, msg = pending
119
- @output.puts "#{i+1}) #{story_name} (#{scenario_name}): #{msg}"
120
- end
121
- end
122
- unless @failed_scenarios.empty?
123
- @output.print "\nFAILURES:"
124
- @failed_scenarios.each_with_index do |failure, i|
125
- title, scenario_name, err = failure
126
- @output.print "\n #{i+1}) "
127
- @output.print red("#{title} (#{scenario_name}) FAILED")
128
- @output.print red("\n #{err.class}: #{err.message}")
129
- @output.print "\n #{err.backtrace.join("\n")}\n"
130
- end
131
- end
132
- end
133
-
134
- def step_upcoming(type, description, *args)
135
- end
136
-
137
- def step_succeeded(type, description, *args)
138
- found_step(type, description, false, false, *args)
139
- end
140
-
141
- def step_pending(type, description, *args)
142
- found_step(type, description, false, true, *args)
143
- @pending_steps << [@current_story_title, @current_scenario_name, description]
144
- @scenario_body_text += yellow(" (PENDING)")
145
- @scenario_pending = true
146
- @scenario_ok = false
147
- end
148
-
149
- def step_failed(type, description, *args)
150
- found_step(type, description, true, @scenario_pending, *args)
151
- if @scenario_pending
152
- @scenario_body_text += yellow(" (SKIPPED)")
153
- else
154
- @scenario_body_text += red(@scenario_ok ? " (FAILED)" : " (SKIPPED)")
155
- end
156
- @scenario_ok = false
157
- end
158
-
159
- def collected_steps(steps)
160
- end
161
-
162
- def method_missing(sym, *args, &block) #:nodoc:
163
- # noop - ignore unknown messages
164
- end
165
-
166
- private
167
-
168
- def found_step(type, description, failed, pending, *args)
169
- desc_string = description.step_name
170
- arg_regexp = description.arg_regexp
171
- text = if(type == @previous_type)
172
- "\n And "
173
- else
174
- "\n\n #{type.to_s.capitalize} "
175
- end
176
- i = -1
177
- text << desc_string.gsub(arg_regexp) { |param| args[i+=1] }
178
- if pending
179
- @scenario_body_text += yellow(text)
180
- else
181
- @scenario_body_text += (failed ? red(text) : green(text))
182
- end
183
-
184
- if type == :'given scenario'
185
- @previous_type = :given
186
- else
187
- @previous_type = type
188
- end
189
- end
190
- end
191
- end
192
- end
193
- end
194
- end
@@ -1,42 +0,0 @@
1
- require 'spec/runner/formatter/story/plain_text_formatter'
2
-
3
- module Spec
4
- module Runner
5
- module Formatter
6
- module Story
7
- class ProgressBarFormatter < PlainTextFormatter
8
-
9
- def story_started(title, narrative) end
10
- def story_ended(title, narrative) end
11
-
12
- def run_started(count)
13
- @start_time = Time.now
14
- super
15
- end
16
-
17
- def run_ended
18
- @output.puts
19
- @output.puts
20
- @output.puts "Finished in %f seconds" % (Time.now - @start_time)
21
- @output.puts
22
- super
23
- end
24
-
25
- def scenario_ended
26
- if @scenario_failed
27
- @output.print red('F')
28
- @output.flush
29
- elsif @scenario_pending
30
- @output.print yellow('P')
31
- @output.flush
32
- else
33
- @output.print green('.')
34
- @output.flush
35
- end
36
- end
37
-
38
- end
39
- end
40
- end
41
- end
42
- end
data/lib/spec/story.rb DELETED
@@ -1,10 +0,0 @@
1
- require 'spec'
2
- require 'spec/story/extensions'
3
- require 'spec/story/given_scenario'
4
- require 'spec/story/runner'
5
- require 'spec/story/scenario'
6
- require 'spec/story/step'
7
- require 'spec/story/step_group'
8
- require 'spec/story/step_mother'
9
- require 'spec/story/story'
10
- require 'spec/story/world'
@@ -1,3 +0,0 @@
1
- require 'spec/story/extensions/main'
2
- require 'spec/story/extensions/string'
3
- require 'spec/story/extensions/regexp'
@@ -1,86 +0,0 @@
1
- module Spec
2
- module Story
3
- module Extensions
4
- module Main
5
- def Story(title, narrative, params = {}, &body)
6
- ::Spec::Story::Runner.story_runner.Story(title, narrative, params, &body)
7
- end
8
-
9
- # Calling this deprecated is silly, since it hasn't been released yet. But, for
10
- # those who are reading this - this will be deleted before the 1.1 release.
11
- def run_story(*args, &block)
12
- runner = Spec::Story::Runner::PlainTextStoryRunner.new(*args)
13
- runner.instance_eval(&block) if block
14
- runner.run
15
- end
16
-
17
- # Creates (or appends to an existing) a namespaced group of steps for use in Stories
18
- #
19
- # == Examples
20
- #
21
- # # Creating a new group
22
- # steps_for :forms do
23
- # When("user enters $value in the $field field") do ... end
24
- # When("user submits the $form form") do ... end
25
- # end
26
- def steps_for(tag, &block)
27
- steps = rspec_story_steps[tag]
28
- steps.instance_eval(&block) if block
29
- steps
30
- end
31
-
32
- # Creates a context for running a Plain Text Story with specific groups of Steps.
33
- # Also supports adding arbitrary steps that will only be accessible to
34
- # the Story being run.
35
- #
36
- # == Examples
37
- #
38
- # # Run a Story with one group of steps
39
- # with_steps_for :checking_accounts do
40
- # run File.dirname(__FILE__) + "/withdraw_cash"
41
- # end
42
- #
43
- # # Run a Story, adding steps that are only available for this Story
44
- # with_steps_for :accounts do
45
- # Given "user is logged in as account administrator"
46
- # run File.dirname(__FILE__) + "/reconcile_accounts"
47
- # end
48
- #
49
- # # Run a Story with steps from two groups
50
- # with_steps_for :checking_accounts, :savings_accounts do
51
- # run File.dirname(__FILE__) + "/transfer_money"
52
- # end
53
- #
54
- # # Run a Story with a specific Story extension
55
- # with_steps_for :login, :navigation do
56
- # run File.dirname(__FILE__) + "/user_changes_password", :type => RailsStory
57
- # end
58
- def with_steps_for(*tags, &block)
59
- steps = Spec::Story::StepGroup.new do
60
- extend StoryRunnerStepGroupAdapter
61
- end
62
- tags.each {|tag| steps << rspec_story_steps[tag]}
63
- steps.instance_eval(&block) if block
64
- steps
65
- end
66
-
67
- private
68
-
69
- module StoryRunnerStepGroupAdapter
70
- def run(path, options={})
71
- runner = Spec::Story::Runner::PlainTextStoryRunner.new(path, options)
72
- runner.steps << self
73
- runner.run
74
- end
75
- end
76
-
77
- def rspec_story_steps # :nodoc:
78
- $rspec_story_steps ||= Spec::Story::StepGroupHash.new
79
- end
80
-
81
- end
82
- end
83
- end
84
- end
85
-
86
- include Spec::Story::Extensions::Main