rspec 1.1.11 → 1.1.12
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +4 -0
- data/History.txt +55 -0
- data/Manifest.txt +102 -122
- data/README.txt +30 -12
- data/Rakefile +10 -10
- data/TODO.txt +10 -2
- data/{failing_examples → examples/failing}/README.txt +0 -0
- data/{failing_examples → examples/failing}/diffing_spec.rb +0 -0
- data/{failing_examples → examples/failing}/failing_autogenerated_docstrings_example.rb +0 -0
- data/{failing_examples/failure_in_teardown.rb → examples/failing/failure_in_after.rb} +1 -1
- data/{failing_examples/failure_in_setup.rb → examples/failing/failure_in_before.rb} +1 -1
- data/{failing_examples → examples/failing}/mocking_example.rb +0 -0
- data/{failing_examples → examples/failing}/mocking_with_flexmock.rb +0 -0
- data/{failing_examples → examples/failing}/mocking_with_mocha.rb +0 -0
- data/{failing_examples → examples/failing}/mocking_with_rr.rb +0 -0
- data/{failing_examples → examples/failing}/partial_mock_example.rb +0 -0
- data/{failing_examples → examples/failing}/predicate_example.rb +5 -0
- data/{failing_examples → examples/failing}/raising_example.rb +0 -0
- data/{failing_examples → examples/failing}/spec_helper.rb +1 -1
- data/{failing_examples → examples/failing}/syntax_error_example.rb +0 -0
- data/{failing_examples → examples/failing}/team_spec.rb +0 -0
- data/{failing_examples → examples/failing}/timeout_behaviour.rb +0 -0
- data/examples/{pure → passing}/autogenerated_docstrings_example.rb +6 -0
- data/examples/{pure → passing}/before_and_after_example.rb +0 -0
- data/examples/{pure → passing}/behave_as_example.rb +0 -0
- data/examples/{pure → passing}/custom_expectation_matchers.rb +0 -0
- data/examples/{pure → passing}/custom_formatter.rb +1 -1
- data/examples/{pure → passing}/dynamic_spec.rb +2 -2
- data/examples/{pure → passing}/file_accessor.rb +0 -0
- data/examples/{pure → passing}/file_accessor_spec.rb +0 -0
- data/examples/{pure → passing}/greeter_spec.rb +0 -0
- data/examples/{pure → passing}/helper_method_example.rb +0 -0
- data/examples/{pure → passing}/io_processor.rb +0 -0
- data/examples/{pure → passing}/io_processor_spec.rb +0 -0
- data/examples/{pure → passing}/legacy_spec.rb +0 -0
- data/examples/{pure → passing}/mocking_example.rb +0 -0
- data/examples/{pure/multi_threaded_behaviour_runner.rb → passing/multi_threaded_example_group_runner.rb} +1 -3
- data/examples/{pure → passing}/nested_classes_example.rb +0 -0
- data/examples/{pure → passing}/partial_mock_example.rb +0 -0
- data/examples/{pure → passing}/pending_example.rb +0 -0
- data/examples/{pure → passing}/predicate_example.rb +0 -0
- data/examples/{pure → passing}/priority.txt +0 -0
- data/examples/{pure → passing}/shared_example_group_example.rb +0 -0
- data/examples/{pure → passing}/shared_stack_examples.rb +1 -3
- data/examples/passing/simple_matcher_example.rb +31 -0
- data/examples/{pure → passing}/spec_helper.rb +0 -0
- data/examples/{pure → passing}/stack.rb +0 -0
- data/examples/{pure → passing}/stack_spec.rb +3 -2
- data/examples/{pure → passing}/stack_spec_with_nested_example_groups.rb +0 -0
- data/examples/{pure → passing}/stubbing_example.rb +0 -0
- data/examples/{pure → passing}/yielding_example.rb +0 -0
- data/examples/ruby1.9.compatibility/access_to_constants_spec.rb +86 -0
- data/features/before_and_after_blocks/before_and_after_blocks.feature +168 -0
- data/{stories/example_groups/autogenerated_docstrings → features/example_groups/autogenerated_docstrings.feature} +5 -5
- data/{stories/example_groups/example_group_with_should_methods → features/example_groups/example_group_with_should_methods.feature} +3 -3
- data/{stories/example_groups/nested_groups → features/example_groups/nested_groups.feature} +4 -4
- data/{stories/example_groups/output → features/example_groups/output.feature} +3 -8
- data/{stories/interop/examples_and_tests_together → features/interop/examples_and_tests_together.feature} +5 -4
- data/features/interop/test_but_not_test_unit.feature +14 -0
- data/{stories/interop/test_case_with_should_methods → features/interop/test_case_with_should_methods.feature} +2 -2
- data/{stories/mock_framework_integration/use_flexmock.story → features/mock_framework_integration/use_flexmock.feature} +1 -1
- data/features/step_definitions/running_rspec.rb +54 -0
- data/features/support/env.rb +26 -0
- data/{stories/resources → features/support}/helpers/cmdline.rb +0 -0
- data/{stories/resources → features/support}/helpers/story_helper.rb +1 -1
- data/{stories/resources → features/support}/matchers/smart_match.rb +0 -0
- data/{plugins → lib/adapters}/mock_frameworks/flexmock.rb +1 -1
- data/{plugins → lib/adapters}/mock_frameworks/mocha.rb +1 -1
- data/{plugins → lib/adapters}/mock_frameworks/rr.rb +1 -1
- data/{plugins → lib/adapters}/mock_frameworks/rspec.rb +2 -2
- data/lib/autotest/rspec.rb +4 -3
- data/lib/spec.rb +2 -27
- data/lib/spec/dsl.rb +1 -0
- data/lib/spec/{extensions → dsl}/main.rb +10 -10
- data/lib/spec/example.rb +175 -1
- data/lib/spec/example/before_and_after_hooks.rb +30 -24
- data/lib/spec/example/example_group.rb +1 -0
- data/lib/spec/example/example_group_factory.rb +26 -9
- data/lib/spec/example/example_group_methods.rb +138 -113
- data/lib/spec/example/example_methods.rb +88 -25
- data/lib/spec/example/shared_example_group.rb +28 -21
- data/lib/spec/expectations.rb +22 -18
- data/lib/spec/expectations/handler.rb +16 -36
- data/lib/spec/interop/test/unit/testcase.rb +19 -17
- data/lib/spec/interop/test/unit/testresult.rb +1 -1
- data/lib/spec/interop/test/unit/testsuite_adapter.rb +1 -1
- data/lib/spec/matchers.rb +7 -28
- data/lib/spec/matchers/be.rb +103 -116
- data/lib/spec/matchers/be_close.rb +6 -22
- data/lib/spec/matchers/eql.rb +7 -25
- data/lib/spec/matchers/equal.rb +7 -25
- data/lib/spec/matchers/errors.rb +5 -0
- data/lib/spec/matchers/exist.rb +8 -14
- data/lib/spec/matchers/generated_descriptions.rb +48 -0
- data/lib/spec/matchers/has.rb +12 -28
- data/lib/spec/matchers/include.rb +12 -9
- data/lib/spec/matchers/match.rb +8 -27
- data/lib/spec/matchers/match_array.rb +79 -0
- data/lib/spec/matchers/method_missing.rb +9 -0
- data/lib/spec/matchers/operator_matcher.rb +39 -48
- data/lib/spec/matchers/raise_error.rb +4 -8
- data/lib/spec/matchers/respond_to.rb +33 -8
- data/lib/spec/matchers/throw_symbol.rb +49 -17
- data/lib/spec/matchers/wrap_expectation.rb +55 -0
- data/lib/spec/mocks/argument_constraints.rb +77 -5
- data/lib/spec/mocks/message_expectation.rb +7 -7
- data/lib/spec/mocks/proxy.rb +14 -12
- data/lib/spec/rake/spectask.rb +4 -6
- data/lib/spec/ruby.rb +9 -0
- data/lib/spec/runner.rb +37 -162
- data/lib/spec/runner/backtrace_tweaker.rb +5 -3
- data/lib/spec/runner/class_and_arguments_parser.rb +7 -9
- data/lib/spec/runner/command_line.rb +6 -8
- data/lib/spec/{example → runner}/configuration.rb +46 -47
- data/lib/spec/runner/example_group_runner.rb +15 -4
- data/lib/spec/runner/formatter/base_text_formatter.rb +4 -3
- data/lib/spec/runner/formatter/html_formatter.rb +14 -11
- data/lib/spec/runner/formatter/nested_text_formatter.rb +2 -2
- data/lib/spec/runner/heckle_runner.rb +58 -56
- data/lib/spec/runner/option_parser.rb +8 -4
- data/lib/spec/runner/options.rb +29 -14
- data/lib/spec/runner/reporter.rb +1 -1
- data/lib/spec/runner/spec_parser.rb +11 -9
- data/lib/spec/story/runner.rb +40 -42
- data/lib/spec/story/runner/story_runner.rb +10 -6
- data/lib/spec/story/world.rb +66 -70
- data/lib/spec/version.rb +4 -2
- data/{rake_tasks → resources/rake}/examples.rake +0 -0
- data/{rake_tasks → resources/rake}/examples_with_rcov.rake +0 -0
- data/{rake_tasks → resources/rake}/failing_examples_with_html.rake +0 -0
- data/{rake_tasks → resources/rake}/verify_rcov.rake +0 -0
- data/{stories/resources → resources}/spec/example_group_with_should_methods.rb +1 -1
- data/{stories/resources → resources}/spec/simple_spec.rb +1 -1
- data/resources/spec/spec_with_flexmock.rb +19 -0
- data/{stories/resources → resources}/test/spec_and_test_together.rb +1 -1
- data/resources/test/spec_including_test_but_not_unit.rb +11 -0
- data/{stories/resources → resources}/test/test_case_with_should_methods.rb +2 -2
- data/rspec.gemspec +16 -6
- data/spec/autotest/autotest_helper.rb +2 -2
- data/spec/autotest/discover_spec.rb +4 -15
- data/spec/autotest/failed_results_re_spec.rb +24 -0
- data/spec/autotest/rspec_spec.rb +2 -38
- data/spec/spec/dsl/main_spec.rb +88 -0
- data/spec/spec/example/example_group_class_definition_spec.rb +6 -2
- data/spec/spec/example/example_group_factory_spec.rb +50 -10
- data/spec/spec/example/example_group_methods_spec.rb +210 -160
- data/spec/spec/example/example_group_spec.rb +44 -52
- data/spec/spec/example/example_matcher_spec.rb +6 -23
- data/spec/spec/example/example_methods_spec.rb +176 -54
- data/spec/spec/example/helper_method_spec.rb +24 -0
- data/spec/spec/example/pending_module_spec.rb +2 -8
- data/spec/spec/example/shared_example_group_spec.rb +56 -80
- data/spec/spec/expectations/extensions/object_spec.rb +0 -50
- data/spec/spec/expectations/wrap_expectation_spec.rb +30 -0
- data/spec/spec/interop/test/unit/spec_spec.rb +1 -5
- data/spec/spec/interop/test/unit/test_unit_spec_helper.rb +4 -0
- data/spec/spec/matchers/be_close_spec.rb +12 -10
- data/spec/spec/matchers/be_spec.rb +62 -7
- data/spec/spec/matchers/description_generation_spec.rb +19 -0
- data/spec/spec/matchers/eql_spec.rb +7 -6
- data/spec/spec/matchers/equal_spec.rb +7 -6
- data/spec/spec/matchers/handler_spec.rb +4 -43
- data/spec/spec/matchers/has_spec.rb +1 -1
- data/spec/spec/matchers/have_spec.rb +23 -18
- data/spec/spec/matchers/include_spec.rb +24 -0
- data/spec/spec/matchers/match_array_spec.rb +83 -0
- data/spec/spec/matchers/matcher_methods_spec.rb +1 -13
- data/spec/spec/matchers/raise_error_spec.rb +18 -0
- data/spec/spec/matchers/respond_to_spec.rb +71 -9
- data/spec/spec/matchers/throw_symbol_spec.rb +85 -43
- data/spec/spec/mocks/bug_report_11545_spec.rb +4 -5
- data/spec/spec/mocks/bug_report_496.rb +11 -9
- data/spec/spec/mocks/bug_report_600_spec.rb +22 -0
- data/spec/spec/mocks/hash_including_matcher_spec.rb +39 -2
- data/spec/spec/mocks/hash_not_including_matcher_spec.rb +67 -0
- data/spec/spec/mocks/mock_spec.rb +5 -6
- data/spec/spec/mocks/nil_expectation_warning_spec.rb +2 -2
- data/spec/spec/mocks/passing_mock_argument_constraints_spec.rb +18 -3
- data/spec/spec/mocks/stub_spec.rb +6 -0
- data/spec/spec/mocks/stubbed_message_expectations_spec.rb +14 -0
- data/spec/spec/runner/command_line_spec.rb +4 -4
- data/spec/spec/runner/configuration_spec.rb +301 -0
- data/spec/spec/runner/drb_command_line_spec.rb +4 -4
- data/spec/spec/runner/example_group_runner_spec.rb +33 -0
- data/spec/spec/runner/formatter/base_formatter_spec.rb +13 -102
- data/spec/spec/runner/formatter/base_text_formatter_spec.rb +23 -0
- data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +5 -5
- data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +3 -3
- data/spec/spec/runner/formatter/html_formatted-1.8.4.html +6 -6
- data/spec/spec/runner/formatter/html_formatted-1.8.5-jruby.html +9 -9
- data/spec/spec/runner/formatter/html_formatted-1.8.5.html +6 -6
- data/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html +10 -10
- data/spec/spec/runner/formatter/html_formatted-1.8.6.html +39 -30
- data/spec/spec/runner/formatter/html_formatted-1.8.7.html +379 -0
- data/spec/spec/runner/formatter/html_formatted-1.9.1.html +379 -0
- data/spec/spec/runner/formatter/html_formatter_spec.rb +14 -13
- data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +5 -5
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +7 -17
- data/spec/spec/runner/formatter/spec_mate_formatter_spec.rb +18 -17
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +5 -5
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.4.html +6 -6
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +33 -30
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.7.html +373 -0
- data/spec/spec/runner/formatter/text_mate_formatted-1.9.1.html +373 -0
- data/spec/spec/runner/heckler_spec.rb +16 -9
- data/spec/spec/runner/option_parser_spec.rb +3 -18
- data/spec/spec/runner/options_spec.rb +27 -8
- data/spec/spec/runner/reporter_spec.rb +5 -5
- data/spec/spec/runner/resources/custom_example_group_runner.rb +14 -0
- data/spec/spec/runner/resources/utf8_encoded.rb +7 -0
- data/spec/spec/runner/spec_parser_spec.rb +85 -79
- data/spec/spec/spec_spec.rb +21 -0
- data/spec/spec_helper.rb +9 -1
- data/story_server/prototype/javascripts/prototype.js +1 -1
- metadata +119 -131
- data/examples/stories/adder.rb +0 -13
- data/examples/stories/addition +0 -34
- data/examples/stories/addition.rb +0 -9
- data/examples/stories/calculator.rb +0 -65
- data/examples/stories/game-of-life/.loadpath +0 -5
- data/examples/stories/game-of-life/README.txt +0 -21
- data/examples/stories/game-of-life/behaviour/everything.rb +0 -6
- data/examples/stories/game-of-life/behaviour/examples/examples.rb +0 -3
- data/examples/stories/game-of-life/behaviour/examples/game_behaviour.rb +0 -35
- data/examples/stories/game-of-life/behaviour/examples/grid_behaviour.rb +0 -66
- data/examples/stories/game-of-life/behaviour/stories/CellsWithLessThanTwoNeighboursDie.story +0 -21
- data/examples/stories/game-of-life/behaviour/stories/CellsWithMoreThanThreeNeighboursDie.story +0 -21
- data/examples/stories/game-of-life/behaviour/stories/EmptySpacesWithThreeNeighboursCreateACell.story +0 -42
- data/examples/stories/game-of-life/behaviour/stories/ICanCreateACell.story +0 -42
- data/examples/stories/game-of-life/behaviour/stories/ICanKillACell.story +0 -17
- data/examples/stories/game-of-life/behaviour/stories/TheGridWraps.story +0 -53
- data/examples/stories/game-of-life/behaviour/stories/create_a_cell.rb +0 -52
- data/examples/stories/game-of-life/behaviour/stories/helper.rb +0 -6
- data/examples/stories/game-of-life/behaviour/stories/kill_a_cell.rb +0 -26
- data/examples/stories/game-of-life/behaviour/stories/steps.rb +0 -5
- data/examples/stories/game-of-life/behaviour/stories/stories.rb +0 -3
- data/examples/stories/game-of-life/behaviour/stories/stories.txt +0 -22
- data/examples/stories/game-of-life/life.rb +0 -3
- data/examples/stories/game-of-life/life/game.rb +0 -23
- data/examples/stories/game-of-life/life/grid.rb +0 -43
- data/examples/stories/helper.rb +0 -9
- data/examples/stories/steps/addition_steps.rb +0 -18
- data/lib/spec/adapters.rb +0 -1
- data/lib/spec/adapters/ruby_engine.rb +0 -26
- data/lib/spec/adapters/ruby_engine/mri.rb +0 -8
- data/lib/spec/adapters/ruby_engine/rubinius.rb +0 -8
- data/lib/spec/extensions.rb +0 -4
- data/lib/spec/extensions/class.rb +0 -24
- data/lib/spec/extensions/metaclass.rb +0 -7
- data/lib/spec/extensions/object.rb +0 -6
- data/spec/spec/adapters/ruby_engine_spec.rb +0 -16
- data/spec/spec/example/configuration_spec.rb +0 -296
- data/spec/spec/example/example_runner_spec.rb +0 -194
- data/spec/spec/extensions/main_spec.rb +0 -71
- data/stories/all.rb +0 -5
- data/stories/configuration/before_blocks.story +0 -21
- data/stories/configuration/stories.rb +0 -7
- data/stories/example_groups/stories.rb +0 -7
- data/stories/helper.rb +0 -6
- data/stories/interop/stories.rb +0 -7
- data/stories/mock_framework_integration/stories.rb +0 -7
- data/stories/pending_stories/README +0 -3
- data/stories/resources/spec/before_blocks_example.rb +0 -32
- data/stories/resources/spec/spec_with_flexmock.rb +0 -18
- data/stories/resources/steps/running_rspec.rb +0 -50
- data/stories/resources/stories/failing_story.rb +0 -15
- data/stories/stories/multiline_steps.story +0 -23
- data/stories/stories/steps/multiline_steps.rb +0 -13
- data/stories/stories/stories.rb +0 -6
@@ -1,13 +1,11 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
2
|
|
3
3
|
class LiarLiarPantsOnFire
|
4
|
-
|
5
|
-
extend Spec::MetaClass
|
6
|
-
def respond_to?(sym)
|
4
|
+
def respond_to?(sym, incl_private=false)
|
7
5
|
true
|
8
6
|
end
|
9
7
|
|
10
|
-
def self.respond_to?(sym)
|
8
|
+
def self.respond_to?(sym, incl_private=false)
|
11
9
|
true
|
12
10
|
end
|
13
11
|
end
|
@@ -28,6 +26,7 @@ describe 'should_receive' do
|
|
28
26
|
end
|
29
27
|
|
30
28
|
it 'should cleanup after itself' do
|
31
|
-
LiarLiarPantsOnFire.
|
29
|
+
(class << LiarLiarPantsOnFire; self; end).instance_methods.should_not include("something")
|
32
30
|
end
|
33
31
|
end
|
32
|
+
|
@@ -1,16 +1,18 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module BugReport496
|
4
|
+
class BaseClass
|
5
|
+
end
|
5
6
|
|
6
|
-
class SubClass < BaseClass
|
7
|
-
end
|
7
|
+
class SubClass < BaseClass
|
8
|
+
end
|
8
9
|
|
9
|
-
describe "a message expectation on a base class object" do
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
describe "a message expectation on a base class object" do
|
11
|
+
it "should correctly pick up message sent to it subclass" do
|
12
|
+
pending("fix for http://rspec.lighthouseapp.com/projects/5645/tickets/496") do
|
13
|
+
BaseClass.should_receive(:new).once
|
14
|
+
SubClass.new
|
15
|
+
end
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
|
+
|
3
|
+
module BugReport600
|
4
|
+
class ExampleClass
|
5
|
+
def self.method_that_uses_define_method
|
6
|
+
define_method "defined_method" do |attributes|
|
7
|
+
load_address(address, attributes)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "stubbing a class method" do
|
13
|
+
it "should work" do
|
14
|
+
ExampleClass.should_receive(:define_method).with("defined_method")
|
15
|
+
ExampleClass.method_that_uses_define_method
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should restore the original method" do
|
19
|
+
ExampleClass.method_that_uses_define_method
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -27,6 +27,32 @@ module Spec
|
|
27
27
|
hash_including(:a => anything, :b => 2).should == {:a => "1", :b => 2}
|
28
28
|
end
|
29
29
|
end
|
30
|
+
|
31
|
+
describe "when passed only keys or keys mixed with key/value pairs" do
|
32
|
+
it "should match if the key is present" do
|
33
|
+
hash_including(:a).should == {:a => 1, :b => 2}
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should match if more keys are present" do
|
37
|
+
hash_including(:a, :b).should == {:a => 1, :b => 2, :c => 3}
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should match a string against a given key" do
|
41
|
+
hash_including(:a).should == {:a => "1", :b => 2}
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should match if passed one key and one key/value pair" do
|
45
|
+
hash_including(:a, :b => 2).should == {:a => 1, :b => 2}
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should match if passed many keys and one key/value pair" do
|
49
|
+
hash_including(:a, :b, :c => 3).should == {:a => 1, :b => 2, :c => 3, :d => 4}
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should match if passed many keys and many key/value pairs" do
|
53
|
+
hash_including(:a, :b, :c => 3, :e => 5).should == {:a => 1, :b => 2, :c => 3, :d => 4, :e => 5}
|
54
|
+
end
|
55
|
+
end
|
30
56
|
end
|
31
57
|
|
32
58
|
describe "failing" do
|
@@ -34,11 +60,22 @@ module Spec
|
|
34
60
|
hash_including(:a => 1).should_not == 1
|
35
61
|
end
|
36
62
|
|
37
|
-
|
38
63
|
it "should not match a hash with a missing key" do
|
39
64
|
hash_including(:a => 1).should_not == {:b => 2}
|
40
65
|
end
|
41
|
-
|
66
|
+
|
67
|
+
it "should not match a hash with a missing key" do
|
68
|
+
hash_including(:a).should_not == {:b => 2}
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should not match an empty hash with a given key" do
|
72
|
+
hash_including(:a).should_not == {}
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should not match a hash with a missing key when one pair is matching" do
|
76
|
+
hash_including(:a, :b => 2).should_not == {:b => 2}
|
77
|
+
end
|
78
|
+
|
42
79
|
it "should not match a hash with an incorrect value" do
|
43
80
|
hash_including(:a => 1, :b => 2).should_not == {:a => 1, :b => 3}
|
44
81
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Mocks
|
5
|
+
module ArgumentConstraints
|
6
|
+
describe HashNotIncludingConstraint do
|
7
|
+
|
8
|
+
it "should describe itself properly" do
|
9
|
+
HashNotIncludingConstraint.new(:a => 5).description.should == "hash_not_including(:a=>5)"
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "passing" do
|
13
|
+
it "should match a hash without the specified key" do
|
14
|
+
hash_not_including(:c).should == {:a => 1, :b => 2}
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should match a hash with the specified key, but different value" do
|
18
|
+
hash_not_including(:b => 3).should == {:a => 1, :b => 2}
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should match a hash without the specified key, given as anything()" do
|
22
|
+
hash_not_including(:c => anything).should == {:a => 1, :b => 2}
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should match an empty hash" do
|
26
|
+
hash_not_including(:a).should == {}
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should match a hash without any of the specified keys" do
|
30
|
+
hash_not_including(:a, :b, :c).should == { :d => 7}
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "failing" do
|
36
|
+
it "should not match a non-hash" do
|
37
|
+
hash_not_including(:a => 1).should_not == 1
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should not match a hash with a specified key" do
|
41
|
+
hash_not_including(:b).should_not == {:b => 2}
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should not match a hash with the specified key/value pair" do
|
45
|
+
hash_not_including(:b => 2).should_not == {:a => 1, :b => 2}
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should not match a hash with the specified key" do
|
49
|
+
hash_not_including(:a, :b => 3).should_not == {:a => 1, :b => 2}
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should not match a hash with one of the specified keys" do
|
53
|
+
hash_not_including(:a, :b).should_not == {:b => 2}
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should not match a hash with some of the specified keys" do
|
57
|
+
hash_not_including(:a, :b, :c).should_not == {:a => 1, :b => 2}
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should not match a hash with one key/value pair included" do
|
61
|
+
hash_not_including(:a, :b, :c, :d => 7).should_not == { :d => 7}
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -3,7 +3,6 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
3
3
|
module Spec
|
4
4
|
module Mocks
|
5
5
|
describe Mock do
|
6
|
-
|
7
6
|
before(:each) do
|
8
7
|
@mock = mock("test mock")
|
9
8
|
end
|
@@ -227,7 +226,7 @@ module Spec
|
|
227
226
|
it "should yield 0 args to blocks that take a variable number of arguments" do
|
228
227
|
@mock.should_receive(:yield_back).with(no_args()).once.and_yield
|
229
228
|
a = nil
|
230
|
-
@mock.yield_back {|*a
|
229
|
+
@mock.yield_back {|*x| a = x}
|
231
230
|
a.should == []
|
232
231
|
@mock.rspec_verify
|
233
232
|
end
|
@@ -245,7 +244,7 @@ module Spec
|
|
245
244
|
it "should yield one arg to blocks that take a variable number of arguments" do
|
246
245
|
@mock.should_receive(:yield_back).with(no_args()).once.and_yield(99)
|
247
246
|
a = nil
|
248
|
-
@mock.yield_back {|*a
|
247
|
+
@mock.yield_back {|*x| a = x}
|
249
248
|
a.should == [99]
|
250
249
|
@mock.rspec_verify
|
251
250
|
end
|
@@ -264,7 +263,7 @@ module Spec
|
|
264
263
|
it "should yield many args to blocks that take a variable number of arguments" do
|
265
264
|
@mock.should_receive(:yield_back).with(no_args()).once.and_yield(99, 27, "go")
|
266
265
|
a = nil
|
267
|
-
@mock.yield_back {|*a
|
266
|
+
@mock.yield_back {|*x| a = x}
|
268
267
|
a.should == [99, 27, "go"]
|
269
268
|
@mock.rspec_verify
|
270
269
|
end
|
@@ -283,7 +282,7 @@ module Spec
|
|
283
282
|
it "should yield single value" do
|
284
283
|
@mock.should_receive(:yield_back).with(no_args()).once.and_yield(99)
|
285
284
|
a = nil
|
286
|
-
@mock.yield_back {|a
|
285
|
+
@mock.yield_back {|x| a = x}
|
287
286
|
a.should == 99
|
288
287
|
@mock.rspec_verify
|
289
288
|
end
|
@@ -302,7 +301,7 @@ module Spec
|
|
302
301
|
it "should yield two values" do
|
303
302
|
@mock.should_receive(:yield_back).with(no_args()).once.and_yield('wha', 'zup')
|
304
303
|
a, b = nil
|
305
|
-
@mock.yield_back {|a
|
304
|
+
@mock.yield_back {|x,y| a=x; b=y}
|
306
305
|
a.should == 'wha'
|
307
306
|
b.should == 'zup'
|
308
307
|
@mock.rspec_verify
|
@@ -6,7 +6,7 @@ module Spec
|
|
6
6
|
describe "an expectation set on nil" do
|
7
7
|
|
8
8
|
it "should issue a warning with file and line number information" do
|
9
|
-
expected_warning =
|
9
|
+
expected_warning = %r%An expectation of :foo was set on nil. Called from #{__FILE__}:#{__LINE__+3}(:in `block \(2 levels\) in <module:Mocks>')?. Use allow_message_expectations_on_nil to disable warnings.%
|
10
10
|
Kernel.should_receive(:warn).with(expected_warning)
|
11
11
|
|
12
12
|
nil.should_receive(:foo)
|
@@ -43,7 +43,7 @@ module Spec
|
|
43
43
|
nil.foo
|
44
44
|
end
|
45
45
|
|
46
|
-
example_group.run.should be_true
|
46
|
+
example_group.run(Spec::Runner.options).should be_true
|
47
47
|
|
48
48
|
end
|
49
49
|
|
@@ -26,13 +26,28 @@ module Spec
|
|
26
26
|
@mock.random_call(false)
|
27
27
|
end
|
28
28
|
|
29
|
-
it "should accept fixnum as
|
30
|
-
@mock.should_receive(:random_call).with(
|
29
|
+
it "should accept fixnum as kind_of(Numeric)" do
|
30
|
+
@mock.should_receive(:random_call).with(kind_of(Numeric))
|
31
31
|
@mock.random_call(1)
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should accept float as an_instance_of(Numeric)" do
|
35
|
-
@mock.should_receive(:random_call).with(
|
35
|
+
@mock.should_receive(:random_call).with(kind_of(Numeric))
|
36
|
+
@mock.random_call(1.5)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "accepts fixnum as instance_of(Fixnum)" do
|
40
|
+
@mock.should_receive(:random_call).with(instance_of(Fixnum))
|
41
|
+
@mock.random_call(1)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should NOT accept fixnum as instance_of(Numeric)" do
|
45
|
+
@mock.should_not_receive(:random_call).with(instance_of(Numeric))
|
46
|
+
@mock.random_call(1)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should NOT accept float as instance_of(Numeric)" do
|
50
|
+
@mock.should_not_receive(:random_call).with(instance_of(Numeric))
|
36
51
|
@mock.random_call(1.5)
|
37
52
|
end
|
38
53
|
|
@@ -137,6 +137,12 @@ module Spec
|
|
137
137
|
@stub.foo("bar")
|
138
138
|
@stub.foo("baz")
|
139
139
|
end
|
140
|
+
|
141
|
+
it "calculates return value by executing block passed to #and_return" do
|
142
|
+
@mock.stub!(:something).with("a","b","c").and_return { |a,b,c| c+b+a }
|
143
|
+
@mock.something("a","b","c").should == "cba"
|
144
|
+
@mock.rspec_verify
|
145
|
+
end
|
140
146
|
end
|
141
147
|
|
142
148
|
describe "A method stub with args" do
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Mocks
|
5
|
+
describe "Example with stubbed and then called message" do
|
6
|
+
it "should fail if the message is expected and then subsequently not called again" do
|
7
|
+
mock_obj = mock("mock", :msg => nil)
|
8
|
+
mock_obj.msg
|
9
|
+
mock_obj.should_receive(:msg)
|
10
|
+
lambda { mock_obj.rspec_verify }.should raise_error(Spec::Mocks::MockExpectationError)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -11,19 +11,19 @@ module Spec
|
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should run directory" do
|
14
|
-
file = File.dirname(__FILE__) + '/../../../examples/
|
15
|
-
run_with(OptionParser.parse([file,"-p","
|
14
|
+
file = File.dirname(__FILE__) + '/../../../examples/passing'
|
15
|
+
run_with(OptionParser.parse([file,"-p","**/*_spec.rb,**/*_example.rb"], @err, @out))
|
16
16
|
|
17
17
|
@out.rewind
|
18
18
|
@out.read.should =~ /\d+ examples, 0 failures, 3 pending/n
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should run file" do
|
22
|
-
file = File.dirname(__FILE__) + '/../../../
|
22
|
+
file = File.dirname(__FILE__) + '/../../../examples/failing/predicate_example.rb'
|
23
23
|
run_with(OptionParser.parse([file], @err, @out))
|
24
24
|
|
25
25
|
@out.rewind
|
26
|
-
@out.read.should =~ /
|
26
|
+
@out.read.should =~ /3 examples, 2 failures/n
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should raise when file does not exist" do
|
@@ -0,0 +1,301 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Runner
|
5
|
+
describe Configuration do
|
6
|
+
with_sandboxed_options do
|
7
|
+
with_sandboxed_config do
|
8
|
+
describe "#mock_with" do
|
9
|
+
it "should default mock framework to rspec" do
|
10
|
+
config.mock_framework.should =~ /\/adapters\/mock_frameworks\/rspec$/
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should set rspec mocking explicitly" do
|
14
|
+
config.mock_with(:rspec)
|
15
|
+
config.mock_framework.should =~ /\/adapters\/mock_frameworks\/rspec$/
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should set mocha" do
|
19
|
+
config.mock_with(:mocha)
|
20
|
+
config.mock_framework.should =~ /\/adapters\/mock_frameworks\/mocha$/
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should set flexmock" do
|
24
|
+
config.mock_with(:flexmock)
|
25
|
+
config.mock_framework.should =~ /\/adapters\/mock_frameworks\/flexmock$/
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should set rr" do
|
29
|
+
config.mock_with(:rr)
|
30
|
+
config.mock_framework.should =~ /\/adapters\/mock_frameworks\/rr$/
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should set an arbitrary adapter module" do
|
34
|
+
adapter = Module.new
|
35
|
+
config.mock_with(adapter)
|
36
|
+
config.mock_framework.should == adapter
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#include" do
|
41
|
+
|
42
|
+
before(:each) do
|
43
|
+
@example_group_class = Class.new(ExampleGroup) {}
|
44
|
+
Spec::Example::ExampleGroupFactory.register(:foobar, @example_group_class)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should include the submitted module in ExampleGroup subclasses" do
|
48
|
+
mod = Module.new
|
49
|
+
config.include mod
|
50
|
+
Class.new(@example_group_class).included_modules.should include(mod)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should scope modules to be included for a specific type" do
|
54
|
+
mod = Module.new
|
55
|
+
config.include mod, :type => :foobar
|
56
|
+
Class.new(@example_group_class).included_modules.should include(mod)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should not include modules in a type they are not intended for" do
|
60
|
+
mod = Module.new
|
61
|
+
@other_example_group_class = Class.new(ExampleGroup)
|
62
|
+
Spec::Example::ExampleGroupFactory.register(:baz, @other_example_group_class)
|
63
|
+
|
64
|
+
config.include mod, :type => :foobar
|
65
|
+
|
66
|
+
Class.new(@other_example_group_class).included_modules.should_not include(mod)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "accepts an Array of types" do
|
70
|
+
mod = Module.new
|
71
|
+
@other_example_group_class = Class.new(ExampleGroup)
|
72
|
+
Spec::Example::ExampleGroupFactory.register(:baz, @other_example_group_class)
|
73
|
+
|
74
|
+
config.include mod, :type => [:foobar, :baz]
|
75
|
+
|
76
|
+
Class.new(@example_group_class).included_modules.should include(mod)
|
77
|
+
Class.new(@other_example_group_class).included_modules.should include(mod)
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "#extend" do
|
83
|
+
|
84
|
+
before(:each) do
|
85
|
+
@example_group_class = Class.new(ExampleGroup) {}
|
86
|
+
Spec::Example::ExampleGroupFactory.register(:foobar, @example_group_class)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should extend all groups" do
|
90
|
+
mod = Module.new
|
91
|
+
ExampleGroup.should_receive(:extend).with(mod)
|
92
|
+
Spec::Runner.configuration.extend mod
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should extend specified groups" do
|
96
|
+
mod = Module.new
|
97
|
+
@example_group_class.should_receive(:extend).with(mod)
|
98
|
+
Spec::Runner.configuration.extend mod, :type => :foobar
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should not extend non-specified groups" do
|
102
|
+
@other_example_group_class = Class.new(ExampleGroup)
|
103
|
+
Spec::Example::ExampleGroupFactory.register(:baz, @other_example_group_class)
|
104
|
+
|
105
|
+
mod = Module.new
|
106
|
+
@other_example_group_class.should_not_receive(:extend)
|
107
|
+
|
108
|
+
Spec::Runner.configuration.extend mod, :type => :foobar
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "ordering methods: " do
|
115
|
+
|
116
|
+
before(:each) do
|
117
|
+
@special_example_group = Class.new(ExampleGroup).describe("special_example_group")
|
118
|
+
@special_child_example_group = Class.new(@special_example_group).describe("special_child_example_group")
|
119
|
+
@nonspecial_example_group = Class.new(ExampleGroup).describe("nonspecial_example_group")
|
120
|
+
Spec::Example::ExampleGroupFactory.register(:special, @special_example_group)
|
121
|
+
Spec::Example::ExampleGroupFactory.register(:special_child, @special_child_example_group)
|
122
|
+
Spec::Example::ExampleGroupFactory.register(:non_special, @nonspecial_example_group)
|
123
|
+
@example_group = @special_child_example_group.describe "Special Example Group"
|
124
|
+
@unselected_example_group = Class.new(@nonspecial_example_group).describe "Non Special Example Group"
|
125
|
+
end
|
126
|
+
|
127
|
+
describe "#prepend_before" do
|
128
|
+
it "prepends the before block on all instances of the passed in type" do
|
129
|
+
order = []
|
130
|
+
config.prepend_before(:all) do
|
131
|
+
order << :prepend__before_all
|
132
|
+
end
|
133
|
+
config.prepend_before(:all, :type => :special) do
|
134
|
+
order << :special_prepend__before_all
|
135
|
+
end
|
136
|
+
config.prepend_before(:all, :type => :special_child) do
|
137
|
+
order << :special_child_prepend__before_all
|
138
|
+
end
|
139
|
+
config.prepend_before(:each) do
|
140
|
+
order << :prepend__before_each
|
141
|
+
end
|
142
|
+
config.prepend_before(:each, :type => :special) do
|
143
|
+
order << :special_prepend__before_each
|
144
|
+
end
|
145
|
+
config.prepend_before(:each, :type => :special_child) do
|
146
|
+
order << :special_child_prepend__before_each
|
147
|
+
end
|
148
|
+
config.prepend_before(:all, :type => :non_special) do
|
149
|
+
order << :special_prepend__before_all
|
150
|
+
end
|
151
|
+
config.prepend_before(:each, :type => :non_special) do
|
152
|
+
order << :special_prepend__before_each
|
153
|
+
end
|
154
|
+
@example_group.it "calls prepend_before" do
|
155
|
+
end
|
156
|
+
|
157
|
+
@example_group.run(options)
|
158
|
+
order.should == [
|
159
|
+
:prepend__before_all,
|
160
|
+
:special_prepend__before_all,
|
161
|
+
:special_child_prepend__before_all,
|
162
|
+
:prepend__before_each,
|
163
|
+
:special_prepend__before_each,
|
164
|
+
:special_child_prepend__before_each
|
165
|
+
]
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
describe "#append_before" do
|
170
|
+
|
171
|
+
it "calls append_before on the type" do
|
172
|
+
order = []
|
173
|
+
config.append_before(:all) do
|
174
|
+
order << :append_before_all
|
175
|
+
end
|
176
|
+
config.append_before(:all, :type => :special) do
|
177
|
+
order << :special_append_before_all
|
178
|
+
end
|
179
|
+
config.append_before(:all, :type => :special_child) do
|
180
|
+
order << :special_child_append_before_all
|
181
|
+
end
|
182
|
+
config.append_before(:each) do
|
183
|
+
order << :append_before_each
|
184
|
+
end
|
185
|
+
config.append_before(:each, :type => :special) do
|
186
|
+
order << :special_append_before_each
|
187
|
+
end
|
188
|
+
config.append_before(:each, :type => :special_child) do
|
189
|
+
order << :special_child_append_before_each
|
190
|
+
end
|
191
|
+
config.append_before(:all, :type => :non_special) do
|
192
|
+
order << :special_append_before_all
|
193
|
+
end
|
194
|
+
config.append_before(:each, :type => :non_special) do
|
195
|
+
order << :special_append_before_each
|
196
|
+
end
|
197
|
+
@example_group.it "calls append_before" do
|
198
|
+
end
|
199
|
+
|
200
|
+
@example_group.run(options)
|
201
|
+
order.should == [
|
202
|
+
:append_before_all,
|
203
|
+
:special_append_before_all,
|
204
|
+
:special_child_append_before_all,
|
205
|
+
:append_before_each,
|
206
|
+
:special_append_before_each,
|
207
|
+
:special_child_append_before_each
|
208
|
+
]
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
describe "#prepend_after" do
|
213
|
+
|
214
|
+
it "prepends the after block on all instances of the passed in type" do
|
215
|
+
order = []
|
216
|
+
config.prepend_after(:all) do
|
217
|
+
order << :prepend__after_all
|
218
|
+
end
|
219
|
+
config.prepend_after(:all, :type => :special) do
|
220
|
+
order << :special_prepend__after_all
|
221
|
+
end
|
222
|
+
config.prepend_after(:all, :type => :special) do
|
223
|
+
order << :special_child_prepend__after_all
|
224
|
+
end
|
225
|
+
config.prepend_after(:each) do
|
226
|
+
order << :prepend__after_each
|
227
|
+
end
|
228
|
+
config.prepend_after(:each, :type => :special) do
|
229
|
+
order << :special_prepend__after_each
|
230
|
+
end
|
231
|
+
config.prepend_after(:each, :type => :special) do
|
232
|
+
order << :special_child_prepend__after_each
|
233
|
+
end
|
234
|
+
config.prepend_after(:all, :type => :non_special) do
|
235
|
+
order << :special_prepend__after_all
|
236
|
+
end
|
237
|
+
config.prepend_after(:each, :type => :non_special) do
|
238
|
+
order << :special_prepend__after_each
|
239
|
+
end
|
240
|
+
@example_group.it "calls prepend_after" do
|
241
|
+
end
|
242
|
+
|
243
|
+
@example_group.run(options)
|
244
|
+
order.should == [
|
245
|
+
:special_child_prepend__after_each,
|
246
|
+
:special_prepend__after_each,
|
247
|
+
:prepend__after_each,
|
248
|
+
:special_child_prepend__after_all,
|
249
|
+
:special_prepend__after_all,
|
250
|
+
:prepend__after_all
|
251
|
+
]
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
describe "#append_after" do
|
256
|
+
|
257
|
+
it "calls append_after on the type" do
|
258
|
+
order = []
|
259
|
+
config.append_after(:all) do
|
260
|
+
order << :append__after_all
|
261
|
+
end
|
262
|
+
config.append_after(:all, :type => :special) do
|
263
|
+
order << :special_append__after_all
|
264
|
+
end
|
265
|
+
config.append_after(:all, :type => :special_child) do
|
266
|
+
order << :special_child_append__after_all
|
267
|
+
end
|
268
|
+
config.append_after(:each) do
|
269
|
+
order << :append__after_each
|
270
|
+
end
|
271
|
+
config.append_after(:each, :type => :special) do
|
272
|
+
order << :special_append__after_each
|
273
|
+
end
|
274
|
+
config.append_after(:each, :type => :special_child) do
|
275
|
+
order << :special_child_append__after_each
|
276
|
+
end
|
277
|
+
config.append_after(:all, :type => :non_special) do
|
278
|
+
order << :non_special_append_after_all
|
279
|
+
end
|
280
|
+
config.append_after(:each, :type => :non_special) do
|
281
|
+
order << :non_special_append_after_each
|
282
|
+
end
|
283
|
+
@example_group.it "calls append_after" do
|
284
|
+
end
|
285
|
+
|
286
|
+
@example_group.run(options)
|
287
|
+
order.should == [
|
288
|
+
:special_child_append__after_each,
|
289
|
+
:special_append__after_each,
|
290
|
+
:append__after_each,
|
291
|
+
:special_child_append__after_all,
|
292
|
+
:special_append__after_all,
|
293
|
+
:append__after_all
|
294
|
+
]
|
295
|
+
end
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
299
|
+
end
|
300
|
+
end
|
301
|
+
end
|