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,74 +0,0 @@
1
- module Spec
2
- module Story
3
- module Runner
4
- class StoryRunner
5
- def self.current_story_runner
6
- @current_story_runner
7
- end
8
-
9
- def self.current_story_runner=(current_story_runner)
10
- @current_story_runner = current_story_runner
11
- end
12
-
13
- def self.scenario_from_current_story(scenario_name)
14
- current_story_runner.scenario_from_current_story(scenario_name)
15
- end
16
-
17
- attr_accessor :stories, :scenarios, :current_story
18
-
19
- def initialize(scenario_runner, world_creator = World)
20
- StoryRunner.current_story_runner = self
21
- @scenario_runner = scenario_runner
22
- @world_creator = world_creator
23
- @stories = []
24
- @scenarios_by_story = {}
25
- @scenarios = []
26
- @listeners = []
27
- end
28
-
29
- def Story(title, narrative, params = {}, &body)
30
- story = Story.new(title, narrative, params, &body)
31
- @stories << story
32
-
33
- # collect scenarios
34
- collector = ScenarioCollector.new(story)
35
- story.run_in(collector)
36
- @scenarios += collector.scenarios
37
- @scenarios_by_story[story.title] = collector.scenarios
38
- end
39
-
40
- def run_stories
41
- return if @stories.empty?
42
- @listeners.each { |l| l.run_started(scenarios.size) }
43
- success = true
44
- @stories.each do |story|
45
- story.assign_steps_to(World)
46
- @current_story = story
47
- @listeners.each { |l| l.story_started(story.title, story.narrative) }
48
- scenarios = @scenarios_by_story[story.title]
49
- scenarios.each do |scenario|
50
- type = story[:type] || Object
51
- args = story[:args] || []
52
- world = @world_creator.create(type, *args)
53
- success = success & @scenario_runner.run(scenario, world)
54
- end
55
- @listeners.each { |l| l.story_ended(story.title, story.narrative) }
56
- World.step_mother.clear
57
- end
58
- unique_steps = (World.step_names.collect {|n| Regexp === n ? n.source : n.to_s}).uniq.sort
59
- @listeners.each { |l| l.collected_steps(unique_steps) }
60
- @listeners.each { |l| l.run_ended }
61
- return success
62
- end
63
-
64
- def add_listener(listener)
65
- @listeners << listener
66
- end
67
-
68
- def scenario_from_current_story(scenario_name)
69
- @scenarios_by_story[@current_story.title].find {|s| s.name == scenario_name }
70
- end
71
- end
72
- end
73
- end
74
- end
@@ -1,14 +0,0 @@
1
-
2
- module Spec
3
- module Story
4
- class Scenario
5
- attr_accessor :name, :body, :story
6
-
7
- def initialize(story, name, &body)
8
- @story = story
9
- @name = name
10
- @body = body
11
- end
12
- end
13
- end
14
- end
@@ -1,70 +0,0 @@
1
- module Spec
2
- module Story
3
- class Step
4
- PARAM_PATTERN = /([^\\]|^)(\$(?!\$)\w*)/
5
- PARAM_OR_GROUP_PATTERN = /(\$(?!\$)\w*)|\(.*?\)/
6
-
7
- attr_reader :name
8
-
9
- def initialize(name, &block)
10
- init_name(name)
11
- init_expression(name)
12
- block_given? ? init_module(name, &block) : set_pending
13
- end
14
-
15
- def perform(instance, *args)
16
- raise Spec::Example::ExamplePendingError.new("Not Yet Implemented") if pending?
17
- instance.extend(@mod)
18
- instance.__send__(sanitize(@name), *args)
19
- end
20
-
21
- def matches?(name)
22
- !(name.strip =~ @expression).nil?
23
- end
24
-
25
- def parse_args(name)
26
- name.strip.match(@expression)[1..-1]
27
- end
28
-
29
- private
30
-
31
- def sanitize(a_string_or_regexp)
32
- return a_string_or_regexp.source if Regexp == a_string_or_regexp
33
- a_string_or_regexp.to_s
34
- end
35
-
36
- def init_module(name, &block)
37
- sanitized_name = sanitize(name)
38
- @mod = Module.new do
39
- define_method(sanitized_name, &block)
40
- end
41
- end
42
-
43
- def set_pending
44
- @pending = true
45
- end
46
-
47
- def pending?
48
- @pending == true
49
- end
50
-
51
- def init_name(name)
52
- @name = name
53
- end
54
-
55
- def init_expression(string_or_regexp)
56
- if String === string_or_regexp
57
- expression = string_or_regexp.dup
58
- %w<? ( ) [ ] { } ^ !>.each {|c| expression.gsub! c, "\\#{c}"}
59
- elsif Regexp === string_or_regexp
60
- expression = string_or_regexp.source
61
- end
62
- while expression =~ PARAM_PATTERN
63
- expression.sub!($2, "(.*?)")
64
- end
65
- @expression = Regexp.new("\\A#{expression}\\Z", Regexp::MULTILINE)
66
- end
67
-
68
- end
69
- end
70
- end
@@ -1,89 +0,0 @@
1
- module Spec
2
- module Story
3
-
4
- class StepGroupHash < Hash
5
- def initialize
6
- super do |h,k|
7
- h[k] = Spec::Story::StepGroup.new
8
- end
9
- end
10
- end
11
-
12
- class StepGroup
13
- def self.steps(&block)
14
- @step_group ||= StepGroup.new(false)
15
- @step_group.instance_eval(&block) if block
16
- @step_group
17
- end
18
-
19
- def initialize(init_defaults=true, &block)
20
- @hash_of_lists_of_steps = Hash.new {|h, k| h[k] = []}
21
- if init_defaults
22
- self.class.steps.add_to(self)
23
- end
24
- instance_eval(&block) if block
25
- end
26
-
27
- def find(type, name)
28
- @hash_of_lists_of_steps[type].each do |step|
29
- return step if step.matches?(name)
30
- end
31
- return nil
32
- end
33
-
34
- def GivenScenario(name, &block)
35
- create_matcher(:given_scenario, name, &block)
36
- end
37
-
38
- def Given(name, &block)
39
- create_matcher(:given, name, &block)
40
- end
41
-
42
- def When(name, &block)
43
- create_matcher(:when, name, &block)
44
- end
45
-
46
- def Then(name, &block)
47
- create_matcher(:then, name, &block)
48
- end
49
-
50
- alias :given_scenario :GivenScenario
51
- alias :given :Given
52
- alias :when :When
53
- alias :then :Then
54
-
55
- def add(type, steps)
56
- (@hash_of_lists_of_steps[type] << steps).flatten!
57
- end
58
-
59
- def clear
60
- @hash_of_lists_of_steps.clear
61
- end
62
-
63
- def empty?
64
- [:given_scenario, :given, :when, :then].each do |type|
65
- return false unless @hash_of_lists_of_steps[type].empty?
66
- end
67
- return true
68
- end
69
-
70
- def add_to(other_step_matchers)
71
- [:given_scenario, :given, :when, :then].each do |type|
72
- other_step_matchers.add(type, @hash_of_lists_of_steps[type])
73
- end
74
- end
75
-
76
- def <<(other_step_matchers)
77
- other_step_matchers.add_to(self) if other_step_matchers.respond_to?(:add_to)
78
- end
79
-
80
- # TODO - make me private
81
- def create_matcher(type, name, &block)
82
- matcher = Step.new(name, &block)
83
- @hash_of_lists_of_steps[type] << matcher
84
- matcher
85
- end
86
-
87
- end
88
- end
89
- end
@@ -1,38 +0,0 @@
1
- module Spec
2
- module Story
3
- class StepMother
4
- def initialize
5
- @steps = StepGroup.new
6
- end
7
-
8
- def use(new_step_group)
9
- @steps << new_step_group
10
- end
11
-
12
- def store(type, step)
13
- @steps.add(type, step)
14
- end
15
-
16
- def find(type, unstripped_name)
17
- name = unstripped_name.strip
18
- if @steps.find(type, name).nil?
19
- @steps.add(type,
20
- Step.new(name) do
21
- raise Spec::Example::ExamplePendingError.new("Unimplemented step: #{name}")
22
- end
23
- )
24
- end
25
- @steps.find(type, name)
26
- end
27
-
28
- def clear
29
- @steps.clear
30
- end
31
-
32
- def empty?
33
- @steps.empty?
34
- end
35
-
36
- end
37
- end
38
- end
@@ -1,39 +0,0 @@
1
- module Spec
2
- module Story
3
- class Story
4
- attr_reader :title, :narrative
5
-
6
- def initialize(title, narrative, params = {}, &body)
7
- @body = body
8
- @title = title
9
- @narrative = narrative
10
- @params = params
11
- end
12
-
13
- def [](key)
14
- @params[key]
15
- end
16
-
17
- def run_in(obj)
18
- obj.instance_eval(&@body)
19
- end
20
-
21
- def assign_steps_to(assignee)
22
- if steps=@params[:steps_for]
23
- steps = [steps] unless steps.is_a?(Array)
24
- steps.each do |step|
25
- if step.is_a?(StepGroup)
26
- assignee.use(step)
27
- else
28
- assignee.use(steps_for(step))
29
- end
30
- end
31
- end
32
- end
33
-
34
- def steps_for(key)
35
- $rspec_story_steps[key]
36
- end
37
- end
38
- end
39
- end
@@ -1,124 +0,0 @@
1
- require 'spec/expectations'
2
- require 'spec/matchers'
3
- require 'spec/example/pending'
4
-
5
- module Spec
6
- module Story
7
- =begin
8
- A World represents the actual instance a scenario will run in.
9
-
10
- The runner ensures any instance variables and methods defined anywhere
11
- in a story block are available to all the scenarios. This includes
12
- variables that are created or referenced inside Given, When and Then
13
- blocks.
14
- =end
15
- module World
16
- include ::Spec::Example::Pending
17
- include ::Spec::Matchers
18
-
19
- def self.create(cls = Object, *args)
20
- cls.new(*args).extend(World)
21
- end
22
-
23
- def self.listeners
24
- @listeners ||= []
25
- end
26
-
27
- def self.add_listener(listener)
28
- listeners() << listener
29
- end
30
-
31
- def self.step_mother
32
- @step_mother ||= StepMother.new
33
- end
34
-
35
- def self.use(steps)
36
- step_mother.use(steps)
37
- end
38
-
39
- def self.step_names
40
- @step_names ||= []
41
- end
42
-
43
- def self.run_given_scenario_with_suspended_listeners(world, type, name, scenario)
44
- current_listeners = Array.new(listeners)
45
- begin
46
- listeners.each { |l| l.found_scenario(type, name) }
47
- @listeners.clear
48
- scenario.perform(world, name) unless dry_run
49
- ensure
50
- @listeners.replace(current_listeners)
51
- end
52
- end
53
-
54
- def self.store_and_call(world, type, name, *args, &block)
55
- if block_given?
56
- step_mother.store(type, Step.new(name, &block))
57
- end
58
- step = step_mother.find(type, name)
59
-
60
- step_name = step.name
61
- step_names << step_name
62
-
63
- # It's important to have access to the parsed args here, so
64
- # we can give them to the listeners. The HTML reporter needs
65
- # the args so it can style them. See the generated output in
66
- # story_server/prototype/rspec_stories.html (generated by rake stories)
67
- args = step.parse_args(name) if args.empty?
68
- begin
69
- listeners.each { |l| l.step_upcoming(type, step_name, *args) }
70
- step.perform(world, *args) unless dry_run
71
- listeners.each { |l| l.step_succeeded(type, step_name, *args) }
72
- rescue Exception => e
73
- case e
74
- when Spec::Example::ExamplePendingError
75
- @listeners.each { |l| l.step_pending(type, step_name, *args) }
76
- else
77
- @listeners.each { |l| l.step_failed(type, step_name, *args) }
78
- end
79
- errors << e
80
- end
81
- end
82
-
83
- def self.errors
84
- @errors ||= []
85
- end
86
-
87
- def self.dry_run
88
- ::Spec::Story::Runner.dry_run
89
- end
90
-
91
- def start_collecting_errors
92
- errors.clear
93
- end
94
-
95
- def errors
96
- World.errors
97
- end
98
-
99
- def GivenScenario(name)
100
- World.run_given_scenario_with_suspended_listeners(self, :'given scenario', name, GivenScenario.new(name))
101
- @__previous_step = :given
102
- end
103
-
104
- def Given(name, *args, &block)
105
- World.store_and_call self, :given, name, *args, &block
106
- @__previous_step = :given
107
- end
108
-
109
- def When(name, *args, &block)
110
- World.store_and_call self, :when, name, *args, &block
111
- @__previous_step = :when
112
- end
113
-
114
- def Then(name, *args, &block)
115
- World.store_and_call self, :then, name, *args, &block
116
- @__previous_step = :then
117
- end
118
-
119
- def And(name, *args, &block)
120
- World.store_and_call self, @__previous_step, name, *args, &block
121
- end
122
- end
123
- end
124
- end