dchelimsky-rspec 1.1.11.7 → 1.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,82 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../../spec_helper'
2
- require 'spec/runner/formatter/story/progress_bar_formatter'
3
-
4
- module Spec
5
- module Runner
6
- module Formatter
7
- module Story
8
- describe ProgressBarFormatter do
9
- before :each do
10
- # given
11
- @out = StringIO.new
12
- @out.stub!(:tty?).and_return(true)
13
- @tweaker = mock('tweaker')
14
- @tweaker.stub!(:tweak_backtrace)
15
- @options = mock('options')
16
- @options.stub!(:colour).and_return(true)
17
- @options.stub!(:backtrace_tweaker).and_return(@tweaker)
18
-
19
- @formatter = ProgressBarFormatter.new(@options, @out)
20
- end
21
-
22
- it 'should print some white space before test summary' do
23
- #when
24
- @formatter.run_started(1)
25
- @formatter.run_ended
26
-
27
- #then
28
- @out.string.should =~ /^\n{2}/
29
- end
30
-
31
- it "should print how long tests took to complete" do
32
- #when
33
- now = Time.now
34
- future = now+1
35
- Time.stub!(:now).and_return(now)
36
- @formatter.run_started(1)
37
- Time.stub!(:now).and_return(future)
38
- @formatter.run_ended
39
-
40
- #then
41
- @out.string.should include("Finished in %f seconds" % (future-now))
42
- end
43
-
44
-
45
- it "should push green dot for passing scenario" do
46
- #when
47
- @formatter.scenario_started('','')
48
- @formatter.step_succeeded('', '')
49
- @formatter.scenario_ended
50
- @formatter.story_ended '', ''
51
-
52
- #then
53
- @out.string.should eql("\e[32m.\e[0m")
54
- end
55
-
56
- it "should push red F for failure scenario" do
57
- #when
58
- @formatter.scenario_started('','')
59
- @formatter.step_failed('', '')
60
- @formatter.scenario_failed('', '', '')
61
- @formatter.story_ended '', ''
62
-
63
- #then
64
- @out.string.should eql("\e[31mF\e[0m")
65
- end
66
-
67
- it "should push yellow P for pending scenario" do
68
- #when
69
- @formatter.scenario_started('','')
70
- @formatter.step_pending('', '')
71
- @formatter.scenario_pending('story', '', '')
72
- @formatter.story_ended '', ''
73
-
74
- #then
75
- @out.string.should eql("\e[33mP\e[0m")
76
- end
77
-
78
- end
79
- end
80
- end
81
- end
82
- end
@@ -1,46 +0,0 @@
1
- module Spec
2
- module Story
3
- class StoryBuilder
4
- def initialize
5
- @title = 'a story'
6
- @narrative = 'narrative'
7
- end
8
-
9
- def title(value)
10
- @title = value
11
- self
12
- end
13
-
14
- def narrative(value)
15
- @narrative = value
16
- self
17
- end
18
-
19
- def to_story(&block)
20
- block = lambda {} unless block_given?
21
- Story.new @title, @narrative, &block
22
- end
23
- end
24
-
25
- class ScenarioBuilder
26
- def initialize
27
- @name = 'a scenario'
28
- @story = StoryBuilder.new.to_story
29
- end
30
-
31
- def name(value)
32
- @name = value
33
- self
34
- end
35
-
36
- def story(value)
37
- @story = value
38
- self
39
- end
40
-
41
- def to_scenario(&block)
42
- Scenario.new @story, @name, &block
43
- end
44
- end
45
- end
46
- end
@@ -1,161 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../../spec_helper'
2
-
3
- module Spec
4
- module Story
5
- module Extensions
6
- describe "the main object extended with Main", :shared => true do
7
- before(:each) do
8
- @main = Class.new do; include Main; end
9
- @original_rspec_story_steps, $rspec_story_steps = $rspec_story_steps, nil
10
- end
11
-
12
- after(:each) do
13
- $rspec_story_steps = @original_rspec_story_steps
14
- end
15
-
16
- def have_step(type, name)
17
- return simple_matcher(%[step group containing a #{type} named #{name.inspect}]) do |actual|
18
- Spec::Story::Step === actual.find(type, name)
19
- end
20
- end
21
- end
22
-
23
- describe Main, "#run_story" do
24
- it_should_behave_like "the main object extended with Main"
25
-
26
- it "should create a PlainTextStoryRunner with run_story" do
27
- Spec::Story::Runner::PlainTextStoryRunner.should_receive(:new).and_return(mock("runner", :null_object => true))
28
- @main.run_story
29
- end
30
-
31
- it "should yield the runner if arity == 1" do
32
- File.should_receive(:read).with("some/path").and_return("Story: foo")
33
- $main_spec_runner = nil
34
- @main.run_story("some/path") do |runner|
35
- $main_spec_runner = runner
36
- end
37
- $main_spec_runner.should be_an_instance_of(Spec::Story::Runner::PlainTextStoryRunner)
38
- end
39
-
40
- it "should run in the runner if arity == 0" do
41
- File.should_receive(:read).with("some/path").and_return("Story: foo")
42
- $main_spec_runner = nil
43
- @main.run_story("some/path") do
44
- $main_spec_runner = self
45
- end
46
- $main_spec_runner.should be_an_instance_of(Spec::Story::Runner::PlainTextStoryRunner)
47
- end
48
-
49
- it "should tell the PlainTextStoryRunner to run with run_story" do
50
- runner = mock("runner")
51
- Spec::Story::Runner::PlainTextStoryRunner.should_receive(:new).and_return(runner)
52
- runner.should_receive(:run)
53
- @main.run_story
54
- end
55
- end
56
-
57
- describe Main, "#steps_for" do
58
- it_should_behave_like "the main object extended with Main"
59
-
60
- it "should have no steps for a non existent key" do
61
- @main.steps_for(:key).find(:given, "foo").should be_nil
62
- end
63
-
64
- it "should create steps for a key" do
65
- $main_spec_invoked = false
66
- @main.steps_for(:key) do
67
- Given("foo") {
68
- $main_spec_invoked = true
69
- }
70
- end
71
- @main.steps_for(:key).find(:given, "foo").perform(Object.new, "foo")
72
- $main_spec_invoked.should be_true
73
- end
74
-
75
- it "should append steps to steps_for a given key" do
76
- @main.steps_for(:key) do
77
- Given("first") {}
78
- end
79
- @main.steps_for(:key) do
80
- Given("second") {}
81
- end
82
- @main.steps_for(:key).should have_step(:given, "first")
83
- @main.steps_for(:key).should have_step(:given, "second")
84
- end
85
- end
86
-
87
- describe Main, "#with_steps_for adding new steps" do
88
- it_should_behave_like "the main object extended with Main"
89
-
90
- it "should result in a group containing pre-existing steps and newly defined steps" do
91
- first_group = @main.steps_for(:key) do
92
- Given("first") {}
93
- end
94
- second_group = @main.with_steps_for(:key) do
95
- Given("second") {}
96
- end
97
-
98
- second_group.should have_step(:given, "first")
99
- second_group.should have_step(:given, "second")
100
- end
101
-
102
- it "should not add its steps to the existing group" do
103
- first_group = @main.steps_for(:key) do
104
- Given("first") {}
105
- end
106
- second_group = @main.with_steps_for(:key) do
107
- Given("second") {}
108
- end
109
-
110
- first_group.should have_step(:given, "first")
111
- first_group.should_not have_step(:given, "second")
112
- end
113
- end
114
-
115
- describe Main, "#with_steps_for running a story" do
116
- it_should_behave_like "the main object extended with Main"
117
-
118
- before(:each) do
119
- @runner = mock("runner")
120
- @runner_step_group = StepGroup.new
121
- @runner.stub!(:steps).and_return(@runner_step_group)
122
- @runner.stub!(:run)
123
- Spec::Story::Runner::PlainTextStoryRunner.stub!(:new).and_return(@runner)
124
- end
125
-
126
- it "should create a PlainTextStoryRunner with a path" do
127
- Spec::Story::Runner::PlainTextStoryRunner.should_receive(:new).with('path/to/file',{}).and_return(@runner)
128
- @main.with_steps_for(:foo) do
129
- run 'path/to/file'
130
- end
131
- end
132
-
133
- it "should create a PlainTextStoryRunner with a path and options" do
134
- Spec::Story::Runner::PlainTextStoryRunner.should_receive(:new).with(anything,{:bar => :baz}).and_return(@runner)
135
- @main.with_steps_for(:foo) do
136
- run 'path/to/file', :bar => :baz
137
- end
138
- end
139
-
140
- it "should pass the group it creates to the runner's steps" do
141
- steps = @main.steps_for(:ice_cream) do
142
- Given("vanilla") {}
143
- end
144
- @main.with_steps_for(:ice_cream) do
145
- run 'foo'
146
- end
147
- @runner_step_group.should have_step(:given, "vanilla")
148
- end
149
-
150
- it "should run a story" do
151
- @runner.should_receive(:run)
152
- Spec::Story::Runner::PlainTextStoryRunner.should_receive(:new).and_return(@runner)
153
- @main.with_steps_for(:foo) do
154
- run 'path/to/file'
155
- end
156
- end
157
-
158
- end
159
- end
160
- end
161
- end
@@ -1,14 +0,0 @@
1
- require File.dirname(__FILE__) + '/story_helper'
2
-
3
- require 'spec/story'
4
-
5
- describe Kernel, "#Story" do
6
- before(:each) do
7
- Kernel.stub!(:at_exit)
8
- end
9
-
10
- it "should delegate to ::Spec::Story::Runner.story_runner" do
11
- ::Spec::Story::Runner.story_runner.should_receive(:Story)
12
- story = Story("title","narrative"){}
13
- end
14
- end
@@ -1,27 +0,0 @@
1
- require File.dirname(__FILE__) + '/story_helper'
2
-
3
- module Spec
4
- module Story
5
- describe GivenScenario do
6
- it 'should execute a scenario from the current story in its world' do
7
- # given
8
- class MyWorld
9
- attr :scenario_ran
10
- end
11
- instance = World.create(MyWorld)
12
- scenario = ScenarioBuilder.new.to_scenario do
13
- @scenario_ran = true
14
- end
15
- Runner::StoryRunner.should_receive(:scenario_from_current_story).with('scenario name').and_return(scenario)
16
-
17
- step = GivenScenario.new 'scenario name'
18
-
19
- # when
20
- step.perform(instance, nil)
21
-
22
- # then
23
- instance.scenario_ran.should be_true
24
- end
25
- end
26
- end
27
- end
@@ -1,90 +0,0 @@
1
- require File.dirname(__FILE__) + '/../story_helper'
2
-
3
- module Spec
4
- module Story
5
- module Runner
6
- describe PlainTextStoryRunner do
7
- before(:each) do
8
- StoryParser.stub!(:new).and_return(@parser = mock("parser"))
9
- @parser.stub!(:parse).and_return([])
10
- File.stub!(:read).with("path").and_return("this\nand that")
11
- end
12
-
13
- it "should provide access to steps" do
14
- runner = PlainTextStoryRunner.new("path")
15
-
16
- runner.steps do |add|
17
- add.given("baz") {}
18
- end
19
-
20
- runner.steps.find(:given, "baz").should_not be_nil
21
- end
22
-
23
- it "should parse a story file" do
24
- runner = PlainTextStoryRunner.new("path")
25
- @parser.should_receive(:parse).with(["this", "and that"])
26
- runner.run(mock('runner'))
27
- end
28
-
29
- it "should build up a mediator with its own steps and the singleton story_runner" do
30
- @story_runner = mock('story runner', :null_object => true)
31
-
32
- runner = PlainTextStoryRunner.new("path")
33
-
34
- Spec::Story::Runner::StoryMediator.should_receive(:new).with(
35
- runner.steps, @story_runner, {}
36
- ).and_return(mediator = stub("mediator", :run_stories => nil))
37
- runner.run(@story_runner)
38
- end
39
-
40
- it "should build up a parser with the mediator" do
41
- runner = PlainTextStoryRunner.new("path")
42
- Spec::Story::Runner::StoryMediator.should_receive(:new).and_return(mediator = stub("mediator", :run_stories => nil))
43
- Spec::Story::Runner::StoryParser.should_receive(:new).with(mediator).and_return(@parser)
44
- runner.run(stub("story_runner"))
45
- end
46
-
47
- it "should tell the mediator to run the stories" do
48
- runner = PlainTextStoryRunner.new("path")
49
- mediator = mock("mediator")
50
- Spec::Story::Runner::StoryMediator.should_receive(:new).and_return(mediator)
51
- mediator.should_receive(:run_stories)
52
- runner.run(mock('runner'))
53
- end
54
-
55
- it "should accept a block instead of a path" do
56
- runner = PlainTextStoryRunner.new do |runner|
57
- runner.load("path/to/story")
58
- end
59
- File.should_receive(:read).with("path/to/story").and_return("this\nand that")
60
- runner.run(mock('runner'))
61
- end
62
-
63
- it "should tell you if you try to run with no path set" do
64
- runner = PlainTextStoryRunner.new
65
- lambda {
66
- runner.run(mock('runner'))
67
- }.should raise_error(RuntimeError, "You must set a path to the file with the story. See the RDoc.")
68
- end
69
-
70
- it "should pass options to the mediator" do
71
- runner = PlainTextStoryRunner.new("path", :foo => :bar)
72
- Spec::Story::Runner::StoryMediator.should_receive(:new).
73
- with(anything, anything, :foo => :bar).
74
- and_return(mediator = stub("mediator", :run_stories => nil))
75
- runner.run(mock('runner'))
76
- end
77
-
78
- it "should provide access to its options" do
79
- runner = PlainTextStoryRunner.new("path")
80
- runner[:foo] = :bar
81
- Spec::Story::Runner::StoryMediator.should_receive(:new).
82
- with(anything, anything, :foo => :bar).
83
- and_return(mediator = stub("mediator", :run_stories => nil))
84
- runner.run mock('runner')
85
- end
86
-
87
- end
88
- end
89
- end
90
- end
@@ -1,27 +0,0 @@
1
- require File.dirname(__FILE__) + '/../story_helper'
2
-
3
- module Spec
4
- module Story
5
- module Runner
6
- describe ScenarioCollector do
7
- it 'should construct scenarios with the supplied story' do
8
- # given
9
- story = stub_everything('story')
10
- scenario_collector = ScenarioCollector.new(story)
11
-
12
- # when
13
- scenario_collector.Scenario 'scenario1' do end
14
- scenario_collector.Scenario 'scenario2' do end
15
- scenarios = scenario_collector.scenarios
16
-
17
- # then
18
- scenario_collector.should have(2).scenarios
19
- scenarios.first.name.should == 'scenario1'
20
- scenarios.first.story.should equal(story)
21
- scenarios.last.name.should == 'scenario2'
22
- scenarios.last.story.should equal(story)
23
- end
24
- end
25
- end
26
- end
27
- end