rspec 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/{CHANGES → History.txt} +116 -64
- data/Manifest.txt +403 -0
- data/{MIT-LICENSE → README.txt} +43 -0
- data/Rakefile +39 -212
- data/{TODO → TODO.txt} +0 -0
- data/bin/autospec +4 -0
- data/bin/spec +1 -1
- data/examples/pure/yielding_example.rb +33 -0
- data/examples/stories/game-of-life/.loadpath +5 -0
- data/examples/stories/game-of-life/behaviour/everything.rb +1 -1
- data/examples/stories/game-of-life/behaviour/stories/CellsWithMoreThanThreeNeighboursDie.story +17 -17
- data/init.rb +9 -0
- data/lib/autotest/discover.rb +1 -1
- data/lib/autotest/rspec.rb +3 -29
- data/lib/spec.rb +10 -12
- data/lib/spec/adapters.rb +1 -0
- data/lib/spec/adapters/ruby_engine.rb +26 -0
- data/lib/spec/adapters/ruby_engine/mri.rb +8 -0
- data/lib/spec/adapters/ruby_engine/rubinius.rb +8 -0
- data/lib/spec/example/errors.rb +6 -0
- data/lib/spec/example/example_group_methods.rb +17 -14
- data/lib/spec/example/example_matcher.rb +2 -0
- data/lib/spec/example/example_methods.rb +4 -9
- data/lib/spec/example/module_inclusion_warnings.rb +2 -1
- data/lib/spec/expectations/extensions/object.rb +2 -2
- data/lib/spec/expectations/handler.rb +8 -16
- data/lib/spec/extensions/main.rb +2 -17
- data/lib/spec/matchers.rb +8 -2
- data/lib/spec/matchers/be.rb +0 -3
- data/lib/spec/matchers/change.rb +44 -40
- data/lib/spec/matchers/has.rb +1 -1
- data/lib/spec/matchers/have.rb +17 -12
- data/lib/spec/matchers/operator_matcher.rb +10 -4
- data/lib/spec/matchers/simple_matcher.rb +113 -10
- data/lib/spec/mocks.rb +1 -1
- data/lib/spec/mocks/argument_constraints.rb +185 -0
- data/lib/spec/mocks/argument_expectation.rb +35 -173
- data/lib/spec/mocks/framework.rb +1 -1
- data/lib/spec/mocks/message_expectation.rb +30 -5
- data/lib/spec/mocks/methods.rb +14 -2
- data/lib/spec/mocks/mock.rb +4 -0
- data/lib/spec/mocks/proxy.rb +46 -5
- data/lib/spec/mocks/spec_methods.rb +9 -1
- data/lib/spec/rake/spectask.rb +14 -22
- data/lib/spec/rake/verify_rcov.rb +3 -3
- data/lib/spec/runner.rb +18 -6
- data/lib/spec/runner/backtrace_tweaker.rb +6 -7
- data/lib/spec/runner/command_line.rb +6 -17
- data/lib/spec/runner/drb_command_line.rb +1 -1
- data/lib/spec/runner/formatter/base_formatter.rb +3 -1
- data/lib/spec/runner/formatter/base_text_formatter.rb +5 -9
- data/lib/spec/runner/formatter/html_formatter.rb +1 -1
- data/lib/spec/runner/formatter/nested_text_formatter.rb +1 -1
- data/lib/spec/runner/formatter/progress_bar_formatter.rb +2 -2
- data/lib/spec/runner/formatter/specdoc_formatter.rb +1 -1
- data/lib/spec/runner/formatter/story/html_formatter.rb +62 -16
- data/lib/spec/runner/formatter/story/plain_text_formatter.rb +68 -16
- data/lib/spec/runner/formatter/story/progress_bar_formatter.rb +42 -0
- data/lib/spec/runner/heckle_runner.rb +2 -2
- data/lib/spec/runner/option_parser.rb +2 -1
- data/lib/spec/runner/options.rb +18 -9
- data/lib/spec/runner/reporter.rb +24 -4
- data/lib/spec/runner/spec_parser.rb +1 -1
- data/lib/spec/story/runner.rb +1 -2
- data/lib/spec/story/runner/story_mediator.rb +14 -0
- data/lib/spec/story/runner/story_parser.rb +20 -0
- data/lib/spec/story/step.rb +40 -28
- data/lib/spec/story/step_mother.rb +2 -1
- data/lib/spec/story/world.rb +6 -2
- data/lib/spec/version.rb +13 -22
- data/rake_tasks/failing_examples_with_html.rake +1 -1
- data/rake_tasks/verify_rcov.rake +2 -2
- data/rspec.gemspec +33 -0
- data/spec/autotest/rspec_spec.rb +90 -141
- data/spec/spec/adapters/ruby_engine_spec.rb +16 -0
- data/spec/spec/example/base_formatter_spec.rb +112 -0
- data/spec/spec/example/example_group_factory_spec.rb +2 -2
- data/spec/spec/example/example_group_methods_spec.rb +55 -4
- data/spec/spec/example/example_group_spec.rb +4 -3
- data/spec/spec/example/example_methods_spec.rb +18 -14
- data/spec/spec/example/pending_module_spec.rb +38 -0
- data/spec/spec/example/shared_example_group_spec.rb +1 -1
- data/spec/spec/expectations/extensions/object_spec.rb +0 -12
- data/spec/spec/extensions/main_spec.rb +3 -8
- data/spec/spec/matchers/change_spec.rb +16 -6
- data/spec/spec/matchers/handler_spec.rb +58 -37
- data/spec/spec/matchers/has_spec.rb +10 -0
- data/spec/spec/matchers/have_spec.rb +105 -2
- data/spec/spec/matchers/operator_matcher_spec.rb +35 -2
- data/spec/spec/matchers/simple_matcher_spec.rb +64 -2
- data/spec/spec/mocks/any_number_of_times_spec.rb +7 -0
- data/spec/spec/mocks/bug_report_496.rb +17 -0
- data/spec/spec/mocks/failing_mock_argument_constraints_spec.rb +7 -1
- data/spec/spec/mocks/hash_including_matcher_spec.rb +45 -24
- data/spec/spec/mocks/mock_spec.rb +55 -10
- data/spec/spec/mocks/nil_expectation_warning_spec.rb +54 -0
- data/spec/spec/mocks/null_object_mock_spec.rb +14 -0
- data/spec/spec/mocks/options_hash_spec.rb +18 -28
- data/spec/spec/mocks/partial_mock_spec.rb +2 -0
- data/spec/spec/mocks/passing_mock_argument_constraints_spec.rb +20 -6
- data/spec/spec/mocks/stub_spec.rb +7 -0
- data/spec/spec/runner/command_line_spec.rb +5 -12
- data/spec/spec/runner/drb_command_line_spec.rb +13 -6
- data/spec/spec/runner/formatter/html_formatter_spec.rb +2 -1
- data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +3 -3
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +20 -2
- data/spec/spec/runner/formatter/spec_mate_formatter_spec.rb +2 -1
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +3 -3
- data/spec/spec/runner/formatter/story/html_formatter_spec.rb +76 -2
- data/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb +161 -0
- data/spec/spec/runner/formatter/story/progress_bar_formatter_spec.rb +82 -0
- data/spec/spec/runner/heckle_runner_spec.rb +8 -8
- data/spec/spec/runner/option_parser_spec.rb +21 -6
- data/spec/spec/runner/output_one_time_fixture_runner.rb +1 -1
- data/spec/spec/runner/quiet_backtrace_tweaker_spec.rb +6 -0
- data/spec/spec/runner/reporter_spec.rb +51 -5
- data/spec/spec/runner/spec_parser_spec.rb +4 -4
- data/spec/spec/story/runner/plain_text_story_runner_spec.rb +2 -5
- data/spec/spec/story/runner/story_mediator_spec.rb +10 -0
- data/spec/spec/story/runner/story_parser_spec.rb +23 -6
- data/spec/spec/story/scenario_spec.rb +1 -3
- data/spec/spec/story/step_mother_spec.rb +12 -0
- data/spec/spec/story/step_spec.rb +57 -4
- data/spec/spec/story/story_spec.rb +1 -3
- data/spec/spec/story/world_spec.rb +1 -1
- data/spec/spec_helper.rb +21 -68
- data/stories/all.rb +1 -1
- data/stories/configuration/before_blocks.story +21 -0
- data/stories/configuration/stories.rb +7 -0
- data/stories/example_groups/stories.rb +3 -4
- data/stories/resources/spec/before_blocks_example.rb +32 -0
- data/stories/stories/multiline_steps.story +23 -0
- data/stories/stories/steps/multiline_steps.rb +13 -0
- data/stories/stories/stories.rb +6 -0
- data/story_server/prototype/javascripts/builder.js +136 -0
- data/story_server/prototype/javascripts/controls.js +972 -0
- data/story_server/prototype/javascripts/dragdrop.js +976 -0
- data/story_server/prototype/javascripts/effects.js +1117 -0
- data/story_server/prototype/javascripts/prototype.js +4140 -0
- data/story_server/prototype/javascripts/rspec.js +149 -0
- data/story_server/prototype/javascripts/scriptaculous.js +58 -0
- data/story_server/prototype/javascripts/slider.js +276 -0
- data/story_server/prototype/javascripts/sound.js +55 -0
- data/story_server/prototype/javascripts/unittest.js +568 -0
- data/story_server/prototype/lib/server.rb +24 -0
- data/story_server/prototype/stories.html +176 -0
- data/story_server/prototype/stylesheets/rspec.css +136 -0
- data/story_server/prototype/stylesheets/test.css +90 -0
- metadata +166 -166
- data/README +0 -36
- data/UPGRADE +0 -7
- data/bin/spec_translator +0 -8
- data/lib/spec/mocks/argument_constraint_matchers.rb +0 -31
- data/lib/spec/translator.rb +0 -114
- data/spec/spec/example/example_spec.rb +0 -53
- data/spec/spec/runner/execution_context_spec.rb +0 -37
- data/spec/spec/translator_spec.rb +0 -265
@@ -0,0 +1,16 @@
|
|
1
|
+
describe Spec::Adapters::RubyEngine do
|
2
|
+
it "should default to MRI" do
|
3
|
+
Spec::Adapters::RubyEngine.adapter.should be_an_instance_of(Spec::Adapters::RubyEngine::MRI)
|
4
|
+
end
|
5
|
+
|
6
|
+
it "should provide Rubinius for rbx" do
|
7
|
+
Spec::Adapters::RubyEngine.stub!(:engine).and_return('rbx')
|
8
|
+
Spec::Adapters::RubyEngine.adapter.should be_an_instance_of(Spec::Adapters::RubyEngine::Rubinius)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should try to find whatever is defined by the RUBY_ENGINE const" do
|
12
|
+
Object.stub!(:const_defined?).with('RUBY_ENGINE').and_return(true)
|
13
|
+
Object.stub!(:const_get).with('RUBY_ENGINE').and_return("xyz")
|
14
|
+
Spec::Adapters::RubyEngine.engine.should == "xyz"
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../spec_helper"
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Runner
|
5
|
+
module Formatter
|
6
|
+
describe BaseFormatter do
|
7
|
+
before :each do
|
8
|
+
@options, @where = nil, nil
|
9
|
+
@formatter = BaseFormatter.new(@options, @where)
|
10
|
+
end
|
11
|
+
|
12
|
+
class HaveInterfaceMatcher
|
13
|
+
def initialize(method)
|
14
|
+
@method = method
|
15
|
+
end
|
16
|
+
|
17
|
+
attr_reader :object
|
18
|
+
attr_reader :method
|
19
|
+
|
20
|
+
def matches?(object)
|
21
|
+
@object = object
|
22
|
+
object.respond_to?(@method)
|
23
|
+
end
|
24
|
+
|
25
|
+
def with(arity)
|
26
|
+
WithArity.new(self, @method, arity)
|
27
|
+
end
|
28
|
+
|
29
|
+
class WithArity
|
30
|
+
def initialize(matcher, method, arity)
|
31
|
+
@have_matcher = matcher
|
32
|
+
@method = method
|
33
|
+
@arity = arity
|
34
|
+
end
|
35
|
+
|
36
|
+
def matches?(an_object)
|
37
|
+
@have_matcher.matches?(an_object) && real_arity == @arity
|
38
|
+
end
|
39
|
+
|
40
|
+
def failure_message
|
41
|
+
"#{@have_matcher} should have method :#{@method} with #{argument_arity}, but it had #{real_arity}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def arguments
|
45
|
+
self
|
46
|
+
end
|
47
|
+
|
48
|
+
alias_method :argument, :arguments
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def real_arity
|
53
|
+
@have_matcher.object.method(@method).arity
|
54
|
+
end
|
55
|
+
|
56
|
+
def argument_arity
|
57
|
+
if @arity == 1
|
58
|
+
"1 argument"
|
59
|
+
else
|
60
|
+
"#{@arity} arguments"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def have_interface_for(method)
|
67
|
+
HaveInterfaceMatcher.new(method)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should have start as an interface with one argument"do
|
71
|
+
@formatter.should have_interface_for(:start).with(1).argument
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should have add_example_group as an interface with one argument" do
|
75
|
+
@formatter.should have_interface_for(:add_example_group).with(1).argument
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should have example_started as an interface with one argument" do
|
79
|
+
@formatter.should have_interface_for(:example_started).with(1).argument
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should have example_failed as an interface with three arguments" do
|
83
|
+
@formatter.should have_interface_for(:example_failed).with(3).arguments
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should have example_pending as an interface with three arguments" do
|
87
|
+
@formatter.should have_interface_for(:example_pending).with(3).arguments
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should have start_dump as an interface with zero arguments" do
|
91
|
+
@formatter.should have_interface_for(:start_dump).with(0).arguments
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should have dump_failure as an interface with two arguments" do
|
95
|
+
@formatter.should have_interface_for(:dump_failure).with(2).arguments
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should have dump_summary as an interface with two arguments" do
|
99
|
+
@formatter.should have_interface_for(:dump_failure).with(2).arguments
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should have dump_pending as an interface with zero arguments" do
|
103
|
+
@formatter.should have_interface_for(:dump_pending).with(0).arguments
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should have close as an interface with zero arguments" do
|
107
|
+
@formatter.should have_interface_for(:close).with(0).arguments
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -125,14 +125,14 @@ module Spec
|
|
125
125
|
it "should register ExampleGroup by default" do
|
126
126
|
example_group = Spec::Example::ExampleGroupFactory.create_example_group("The ExampleGroup") do
|
127
127
|
end
|
128
|
-
|
128
|
+
Spec::Runner.options.example_groups.should include(example_group)
|
129
129
|
end
|
130
130
|
|
131
131
|
it "should enable unregistering of ExampleGroups" do
|
132
132
|
example_group = Spec::Example::ExampleGroupFactory.create_example_group("The ExampleGroup") do
|
133
133
|
unregister
|
134
134
|
end
|
135
|
-
|
135
|
+
Spec::Runner.options.example_groups.should_not include(example_group)
|
136
136
|
end
|
137
137
|
|
138
138
|
after(:each) do
|
@@ -3,10 +3,12 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
3
3
|
module Spec
|
4
4
|
module Example
|
5
5
|
describe 'ExampleGroupMethods' do
|
6
|
-
|
6
|
+
include SandboxedOptions
|
7
7
|
attr_reader :example_group, :result, :reporter
|
8
8
|
before(:each) do
|
9
|
-
|
9
|
+
# See http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/525-arity-changed-on-partial-mocks#ticket-525-2
|
10
|
+
method_with_three_args = lambda { |arg1, arg2, arg3| }
|
11
|
+
options.formatters << mock("formatter", :null_object => true, :example_pending => method_with_three_args)
|
10
12
|
options.backtrace_tweaker = mock("backtrace_tweaker", :null_object => true)
|
11
13
|
@reporter = FakeReporter.new(@options)
|
12
14
|
options.reporter = reporter
|
@@ -128,8 +130,11 @@ module Spec
|
|
128
130
|
def testify
|
129
131
|
raise "This is not a real test"
|
130
132
|
end
|
133
|
+
def should_something
|
134
|
+
# forces the run
|
135
|
+
end
|
131
136
|
end
|
132
|
-
example_group.examples.length.should ==
|
137
|
+
example_group.examples.length.should == 1
|
133
138
|
example_group.run.should be_true
|
134
139
|
end
|
135
140
|
|
@@ -518,6 +523,52 @@ module Spec
|
|
518
523
|
example_group.registration_backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-1}")
|
519
524
|
end
|
520
525
|
end
|
526
|
+
|
527
|
+
describe "#run" do
|
528
|
+
it "should add_example_group if there are any examples to run" do
|
529
|
+
example_group = Class.new(ExampleGroup) do
|
530
|
+
it "should do something" do end
|
531
|
+
end
|
532
|
+
reporter.should_receive(:add_example_group)
|
533
|
+
example_group.run
|
534
|
+
end
|
535
|
+
|
536
|
+
it "should NOT add_example_group if there are no examples to run" do
|
537
|
+
example_group = Class.new(ExampleGroup) do end
|
538
|
+
reporter.should_not_receive(:add_example_group)
|
539
|
+
example_group.run
|
540
|
+
end
|
541
|
+
end
|
542
|
+
|
543
|
+
describe "#matcher_class=" do
|
544
|
+
it "should call new and matches? on the class used for matching examples" do
|
545
|
+
example_group = Class.new(ExampleGroup) do
|
546
|
+
it "should do something" do end
|
547
|
+
class << self
|
548
|
+
def specified_examples
|
549
|
+
["something"]
|
550
|
+
end
|
551
|
+
def to_s
|
552
|
+
"TestMatcher"
|
553
|
+
end
|
554
|
+
end
|
555
|
+
end
|
556
|
+
|
557
|
+
matcher = mock("matcher")
|
558
|
+
matcher.should_receive(:matches?).with(["something"]).any_number_of_times
|
559
|
+
|
560
|
+
matcher_class = Class.new
|
561
|
+
matcher_class.should_receive(:new).with("TestMatcher", "should do something").twice.and_return(matcher)
|
562
|
+
|
563
|
+
begin
|
564
|
+
ExampleGroupMethods.matcher_class = matcher_class
|
565
|
+
|
566
|
+
example_group.run
|
567
|
+
ensure
|
568
|
+
ExampleGroupMethods.matcher_class = ExampleMatcher
|
569
|
+
end
|
570
|
+
end
|
571
|
+
end
|
521
572
|
end
|
522
573
|
end
|
523
|
-
end
|
574
|
+
end
|
@@ -65,10 +65,11 @@ module Spec
|
|
65
65
|
end
|
66
66
|
|
67
67
|
describe ExampleGroup, "#run" do
|
68
|
-
|
68
|
+
include SandboxedOptions
|
69
69
|
attr_reader :example_group, :formatter, :reporter
|
70
70
|
before :each do
|
71
|
-
|
71
|
+
method_with_three_args = lambda { |arg1, arg2, arg3| }
|
72
|
+
@formatter = mock("formatter", :null_object => true, :example_pending => method_with_three_args)
|
72
73
|
options.formatters << formatter
|
73
74
|
options.backtrace_tweaker = mock("backtrace_tweaker", :null_object => true)
|
74
75
|
@reporter = FakeReporter.new(options)
|
@@ -233,7 +234,7 @@ module Spec
|
|
233
234
|
options.examples = ["should be run"]
|
234
235
|
end
|
235
236
|
|
236
|
-
it "should run only the example, when there
|
237
|
+
it "should run only the example, when there is only one" do
|
237
238
|
example_group.run
|
238
239
|
examples_that_were_run.should == ["should be run"]
|
239
240
|
end
|
@@ -23,9 +23,9 @@ module Spec
|
|
23
23
|
|
24
24
|
describe "lifecycle" do
|
25
25
|
before do
|
26
|
-
@original_rspec_options =
|
26
|
+
@original_rspec_options = Spec::Runner.options
|
27
27
|
@options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new)
|
28
|
-
|
28
|
+
Spec::Runner.use @options
|
29
29
|
@options.formatters << mock("formatter", :null_object => true)
|
30
30
|
@options.backtrace_tweaker = mock("backtrace_tweaker", :null_object => true)
|
31
31
|
@reporter = FakeReporter.new(@options)
|
@@ -43,7 +43,7 @@ module Spec
|
|
43
43
|
end
|
44
44
|
|
45
45
|
after do
|
46
|
-
|
46
|
+
Spec::Runner.use @original_rspec_options
|
47
47
|
ExampleMethods.instance_variable_set("@before_all_parts", [])
|
48
48
|
ExampleMethods.instance_variable_set("@before_each_parts", [])
|
49
49
|
ExampleMethods.instance_variable_set("@after_each_parts", [])
|
@@ -83,19 +83,23 @@ module Spec
|
|
83
83
|
ExampleMethods.count.should == 7
|
84
84
|
end
|
85
85
|
|
86
|
-
describe "
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
@example.instance_eval { @_matcher_description }.should == "should == 2"
|
86
|
+
describe "eval_block" do
|
87
|
+
describe "with a given description" do
|
88
|
+
it "should provide the given description" do
|
89
|
+
@example_group = Class.new(ExampleGroup) do end
|
90
|
+
@example = @example_group.it("given description") { 2.should == 2 }
|
91
|
+
@example.eval_block
|
92
|
+
@example.description.should == "given description"
|
93
|
+
end
|
95
94
|
end
|
96
95
|
|
97
|
-
|
98
|
-
|
96
|
+
describe "with no given description" do
|
97
|
+
it "should provide the generated description" do
|
98
|
+
@example_group = Class.new(ExampleGroup) do end
|
99
|
+
@example = @example_group.it { 2.should == 2 }
|
100
|
+
@example.eval_block
|
101
|
+
@example.description.should == "should == 2"
|
102
|
+
end
|
99
103
|
end
|
100
104
|
end
|
101
105
|
end
|
@@ -18,6 +18,17 @@ module Spec
|
|
18
18
|
}.should raise_error(ExamplePendingError, /TODO/)
|
19
19
|
end
|
20
20
|
|
21
|
+
it 'should raise an ExamplePendingError if a supplied block fails as expected with a mock' do
|
22
|
+
lambda {
|
23
|
+
include Pending
|
24
|
+
pending "TODO" do
|
25
|
+
m = mock('thing')
|
26
|
+
m.should_receive(:foo)
|
27
|
+
m.rspec_verify
|
28
|
+
end
|
29
|
+
}.should raise_error(ExamplePendingError, /TODO/)
|
30
|
+
end
|
31
|
+
|
21
32
|
it 'should raise a PendingExampleFixedError if a supplied block starts working' do
|
22
33
|
lambda {
|
23
34
|
include Pending
|
@@ -27,5 +38,32 @@ module Spec
|
|
27
38
|
}.should raise_error(PendingExampleFixedError, /TODO/)
|
28
39
|
end
|
29
40
|
end
|
41
|
+
|
42
|
+
describe ExamplePendingError do
|
43
|
+
it "should have the caller (from two calls from initialization)" do
|
44
|
+
two_calls_ago = caller[0]
|
45
|
+
ExamplePendingError.new("a message").pending_caller.should == two_calls_ago
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should keep the trace information from initialization" do
|
49
|
+
two_calls_ago = caller[0]
|
50
|
+
obj = ExamplePendingError.new("a message")
|
51
|
+
obj.pending_caller
|
52
|
+
def another_caller(obj)
|
53
|
+
obj.pending_caller
|
54
|
+
end
|
55
|
+
|
56
|
+
another_caller(obj).should == two_calls_ago
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should have the message provided" do
|
60
|
+
ExamplePendingError.new("a message").message.should == "a message"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should use a 'ExamplePendingError' as it's default message" do
|
64
|
+
ExamplePendingError.new.message.should == "Spec::Example::ExamplePendingError"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
30
68
|
end
|
31
69
|
end
|
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
3
3
|
module Spec
|
4
4
|
module Example
|
5
5
|
describe ExampleGroup, "with :shared => true" do
|
6
|
-
|
6
|
+
include SandboxedOptions
|
7
7
|
attr_reader :formatter, :example_group
|
8
8
|
before(:each) do
|
9
9
|
@formatter = Spec::Mocks::Mock.new("formatter", :null_object => true)
|
@@ -39,12 +39,6 @@ describe Object, "#should" do
|
|
39
39
|
}.should raise_error(Spec::Expectations::InvalidMatcherError)
|
40
40
|
end
|
41
41
|
|
42
|
-
it "should raise error if it receives nil" do
|
43
|
-
lambda {
|
44
|
-
@target.should nil
|
45
|
-
}.should raise_error(Spec::Expectations::InvalidMatcherError)
|
46
|
-
end
|
47
|
-
|
48
42
|
it "should raise error if it receives no argument and it is not used as a left side of an operator" do
|
49
43
|
pending "Is it even possible to catch this?"
|
50
44
|
lambda {
|
@@ -92,12 +86,6 @@ describe Object, "#should_not" do
|
|
92
86
|
}.should raise_error(Spec::Expectations::InvalidMatcherError)
|
93
87
|
end
|
94
88
|
|
95
|
-
it "should raise error if it receives nil" do
|
96
|
-
lambda {
|
97
|
-
@target.should_not nil
|
98
|
-
}.should raise_error(Spec::Expectations::InvalidMatcherError)
|
99
|
-
end
|
100
|
-
|
101
89
|
it "should raise error if it receives no argument and it is not used as a left side of an operator" do
|
102
90
|
pending "Is it even possible to catch this?"
|
103
91
|
lambda {
|
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
3
3
|
module Spec
|
4
4
|
module Extensions
|
5
5
|
describe Main do
|
6
|
-
|
6
|
+
include SandboxedOptions
|
7
7
|
before(:each) do
|
8
8
|
@main = Class.new do; include Main; end
|
9
9
|
end
|
@@ -12,11 +12,6 @@ module Spec
|
|
12
12
|
$rspec_story_steps = @original_rspec_story_steps
|
13
13
|
end
|
14
14
|
|
15
|
-
it "should create an Options object" do
|
16
|
-
@main.send(:rspec_options).should be_instance_of(Spec::Runner::Options)
|
17
|
-
@main.send(:rspec_options).should === $rspec_options
|
18
|
-
end
|
19
|
-
|
20
15
|
specify {@main.should respond_to(:describe)}
|
21
16
|
specify {@main.should respond_to(:context)}
|
22
17
|
|
@@ -30,7 +25,7 @@ module Spec
|
|
30
25
|
|
31
26
|
it "should registered ExampleGroups by default" do
|
32
27
|
example_group = @main.describe("The ExampleGroup") do end
|
33
|
-
|
28
|
+
Spec::Runner.options.example_groups.should include(example_group)
|
34
29
|
end
|
35
30
|
|
36
31
|
it "should not run unregistered ExampleGroups" do
|
@@ -38,7 +33,7 @@ module Spec
|
|
38
33
|
unregister
|
39
34
|
end
|
40
35
|
|
41
|
-
|
36
|
+
Spec::Runner.options.example_groups.should_not include(example_group)
|
42
37
|
end
|
43
38
|
|
44
39
|
it "should create a shared ExampleGroup with share_examples_for" do
|
@@ -55,10 +55,9 @@ describe "should change { block }" do
|
|
55
55
|
end.should fail_with("result should have changed, but is still 5")
|
56
56
|
end
|
57
57
|
|
58
|
-
it "should warn if passed a block using do/end" do
|
58
|
+
it "should warn if passed a block using do/end instead of {}" do
|
59
59
|
lambda do
|
60
|
-
lambda {}.should change do
|
61
|
-
end
|
60
|
+
lambda {}.should change do; end
|
62
61
|
end.should raise_error(Spec::Matchers::MatcherError, /block passed to should or should_not/)
|
63
62
|
end
|
64
63
|
end
|
@@ -79,10 +78,9 @@ describe "should_not change { block }" do
|
|
79
78
|
end.should fail_with("result should not have changed, but did change from 5 to 6")
|
80
79
|
end
|
81
80
|
|
82
|
-
it "should warn if passed a block using do/end" do
|
81
|
+
it "should warn if passed a block using do/end instead of {}" do
|
83
82
|
lambda do
|
84
|
-
lambda {}.should_not change do
|
85
|
-
end
|
83
|
+
lambda {}.should_not change do; end
|
86
84
|
end.should raise_error(Spec::Matchers::MatcherError, /block passed to should or should_not/)
|
87
85
|
end
|
88
86
|
end
|
@@ -317,3 +315,15 @@ describe "should change{ block }.from(old).to(new)" do
|
|
317
315
|
lambda { @instance.some_value = "cat" }.should change{@instance.some_value}.from("string").to("cat")
|
318
316
|
end
|
319
317
|
end
|
318
|
+
|
319
|
+
describe Spec::Matchers::Change do
|
320
|
+
it "should work when the receiver has implemented #send" do
|
321
|
+
@instance = SomethingExpected.new
|
322
|
+
@instance.some_value = "string"
|
323
|
+
def @instance.send(*args); raise "DOH! Library developers shouldn't use #send!" end
|
324
|
+
|
325
|
+
lambda {
|
326
|
+
lambda { @instance.some_value = "cat" }.should change(@instance, :some_value)
|
327
|
+
}.should_not raise_error
|
328
|
+
end
|
329
|
+
end
|