rspec-core 2.0.0.beta.9 → 2.0.0.beta.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/VERSION +1 -1
  2. data/features/configuration/custom_settings.feature +86 -0
  3. data/features/formatters/custom_formatter.feature +1 -1
  4. data/lib/rspec/core.rb +6 -1
  5. data/lib/rspec/core/backward_compatibility.rb +3 -5
  6. data/lib/rspec/core/command_line.rb +52 -0
  7. data/lib/rspec/core/configuration.rb +106 -118
  8. data/lib/rspec/core/configuration_options.rb +30 -88
  9. data/lib/rspec/core/deprecation.rb +3 -4
  10. data/lib/rspec/core/drb_command_line.rb +29 -0
  11. data/lib/rspec/core/formatters/base_formatter.rb +3 -8
  12. data/lib/rspec/core/formatters/base_text_formatter.rb +2 -2
  13. data/lib/rspec/core/formatters/documentation_formatter.rb +2 -2
  14. data/lib/rspec/core/kernel_extensions.rb +1 -1
  15. data/lib/rspec/core/metadata.rb +11 -11
  16. data/lib/rspec/core/option_parser.rb +84 -0
  17. data/lib/rspec/core/runner.rb +17 -42
  18. data/lib/rspec/core/world.rb +2 -2
  19. data/lib/rspec/monkey.rb +1 -0
  20. data/lib/rspec/monkey/spork/test_framework/rspec.rb +7 -0
  21. data/rspec-core.gemspec +18 -59
  22. data/spec/rspec/core/configuration_options_spec.rb +91 -7
  23. data/spec/rspec/core/configuration_spec.rb +52 -18
  24. data/spec/rspec/core/deprecations_spec.rb +4 -2
  25. data/spec/rspec/core/drb_command_line_spec.rb +151 -0
  26. data/spec/rspec/core/formatters/base_formatter_spec.rb +2 -1
  27. data/spec/rspec/core/formatters/base_text_formatter_spec.rb +1 -2
  28. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +1 -2
  29. data/spec/rspec/core/formatters/progress_formatter_spec.rb +1 -2
  30. data/spec/rspec/core/resources/a_spec.rb +1 -1
  31. data/spec/rspec/core/runner_spec.rb +38 -27
  32. data/spec/rspec/core/shared_example_group_spec.rb +1 -1
  33. data/spec/spec_helper.rb +56 -41
  34. metadata +17 -58
  35. data/example_specs/failing/README.txt +0 -7
  36. data/example_specs/failing/diffing_spec.rb +0 -38
  37. data/example_specs/failing/failing_implicit_docstrings_example.rb +0 -19
  38. data/example_specs/failing/failure_in_after.rb +0 -10
  39. data/example_specs/failing/failure_in_before.rb +0 -10
  40. data/example_specs/failing/mocking_example.rb +0 -40
  41. data/example_specs/failing/mocking_with_flexmock.rb +0 -26
  42. data/example_specs/failing/mocking_with_mocha.rb +0 -25
  43. data/example_specs/failing/mocking_with_rr.rb +0 -27
  44. data/example_specs/failing/partial_mock_example.rb +0 -20
  45. data/example_specs/failing/pending_example.rb +0 -9
  46. data/example_specs/failing/predicate_example.rb +0 -34
  47. data/example_specs/failing/raising_example.rb +0 -47
  48. data/example_specs/failing/spec_helper.rb +0 -1
  49. data/example_specs/failing/syntax_error_example.rb +0 -7
  50. data/example_specs/failing/team_spec.rb +0 -43
  51. data/example_specs/failing/timeout_behaviour.rb +0 -7
  52. data/example_specs/passing/custom_formatter.rb +0 -12
  53. data/example_specs/passing/custom_matchers.rb +0 -54
  54. data/example_specs/passing/dynamic_spec.rb +0 -9
  55. data/example_specs/passing/file_accessor.rb +0 -19
  56. data/example_specs/passing/file_accessor_spec.rb +0 -38
  57. data/example_specs/passing/filtered_formatter.rb +0 -18
  58. data/example_specs/passing/filtered_formatter_example.rb +0 -31
  59. data/example_specs/passing/greeter_spec.rb +0 -31
  60. data/example_specs/passing/helper_method_example.rb +0 -14
  61. data/example_specs/passing/implicit_docstrings_example.rb +0 -18
  62. data/example_specs/passing/io_processor.rb +0 -8
  63. data/example_specs/passing/io_processor_spec.rb +0 -21
  64. data/example_specs/passing/mocking_example.rb +0 -27
  65. data/example_specs/passing/multi_threaded_example_group_runner.rb +0 -26
  66. data/example_specs/passing/nested_classes_example.rb +0 -36
  67. data/example_specs/passing/options_example.rb +0 -31
  68. data/example_specs/passing/options_formatter.rb +0 -20
  69. data/example_specs/passing/partial_mock_example.rb +0 -29
  70. data/example_specs/passing/pending_example.rb +0 -20
  71. data/example_specs/passing/predicate_example.rb +0 -27
  72. data/example_specs/passing/shared_example_group_example.rb +0 -81
  73. data/example_specs/passing/shared_stack_examples.rb +0 -36
  74. data/example_specs/passing/spec_helper.rb +0 -1
  75. data/example_specs/passing/stack.rb +0 -36
  76. data/example_specs/passing/stack_spec.rb +0 -64
  77. data/example_specs/passing/stack_spec_with_nested_example_groups.rb +0 -67
  78. data/example_specs/passing/stubbing_example.rb +0 -69
  79. data/example_specs/passing/subject_example.rb +0 -45
  80. data/example_specs/passing/yielding_example.rb +0 -33
  81. data/example_specs/ruby1.9.compatibility/access_to_constants_spec.rb +0 -85
  82. data/example_specs/spec_helper.rb +0 -10
  83. data/features/configuration/custom_options.feature +0 -71
@@ -1,81 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- module SharedExampleGroupExample
4
- class OneThing
5
- def what_things_do
6
- "stuff"
7
- end
8
- end
9
-
10
- class AnotherThing
11
- def what_things_do
12
- "stuff"
13
- end
14
- end
15
-
16
- class YetAnotherThing
17
- def what_things_do
18
- "stuff"
19
- end
20
- end
21
-
22
- # A SharedExampleGroup is an example group that doesn't get run.
23
- # You can create one like this:
24
- share_examples_for "most things" do
25
- def helper_method
26
- "helper method"
27
- end
28
-
29
- it "should do what things do" do
30
- @thing.what_things_do.should == "stuff"
31
- end
32
- end
33
-
34
- # A SharedExampleGroup is also a module. If you create one like this it gets
35
- # assigned to the constant MostThings
36
- share_as :MostThings do
37
- def helper_method
38
- "helper method"
39
- end
40
-
41
- it "should do what things do" do
42
- @thing.what_things_do.should == "stuff"
43
- end
44
- end
45
-
46
- describe OneThing do
47
- # Now you can include the shared example group like this, which
48
- # feels more like what you might say ...
49
- it_should_behave_like "most things"
50
-
51
- before(:each) { @thing = OneThing.new }
52
-
53
- it "should have access to helper methods defined in the shared example group" do
54
- helper_method.should == "helper method"
55
- end
56
- end
57
-
58
- describe AnotherThing do
59
- # ... or you can include the example group like this, which
60
- # feels more like the programming language we love.
61
- it_should_behave_like MostThings
62
-
63
- before(:each) { @thing = AnotherThing.new }
64
-
65
- it "should have access to helper methods defined in the shared example group" do
66
- helper_method.should == "helper method"
67
- end
68
- end
69
-
70
- describe YetAnotherThing do
71
- #... or you can include the example group like this, which
72
- #feels more like the programming language we love.
73
- include MostThings
74
-
75
- before(:each) { @thing = AnotherThing.new }
76
-
77
- it "should have access to helper methods defined in the shared example group" do
78
- helper_method.should == "helper method"
79
- end
80
- end
81
- end
@@ -1,36 +0,0 @@
1
- shared_examples_for "non-empty Stack" do
2
-
3
- it { @stack.should_not be_empty }
4
-
5
- it "should return the top item when sent #peek" do
6
- @stack.peek.should == @last_item_added
7
- end
8
-
9
- it "should NOT remove the top item when sent #peek" do
10
- @stack.peek.should == @last_item_added
11
- @stack.peek.should == @last_item_added
12
- end
13
-
14
- it "should return the top item when sent #pop" do
15
- @stack.pop.should == @last_item_added
16
- end
17
-
18
- it "should remove the top item when sent #pop" do
19
- @stack.pop.should == @last_item_added
20
- unless @stack.empty?
21
- @stack.pop.should_not == @last_item_added
22
- end
23
- end
24
-
25
- end
26
-
27
- shared_examples_for "non-full Stack" do
28
-
29
- it { @stack.should_not be_full }
30
-
31
- it "should add to the top when sent #push" do
32
- @stack.push "newly added top item"
33
- @stack.peek.should == "newly added top item"
34
- end
35
-
36
- end
@@ -1 +0,0 @@
1
- require File.expand_path('../../spec_helper.rb', __FILE__)
@@ -1,36 +0,0 @@
1
- class StackUnderflowError < RuntimeError
2
- end
3
-
4
- class StackOverflowError < RuntimeError
5
- end
6
-
7
- class Stack
8
-
9
- def initialize
10
- @items = []
11
- end
12
-
13
- def push object
14
- raise StackOverflowError if @items.length == 10
15
- @items.push object
16
- end
17
-
18
- def pop
19
- raise StackUnderflowError if @items.empty?
20
- @items.delete @items.last
21
- end
22
-
23
- def peek
24
- raise StackUnderflowError if @items.empty?
25
- @items.last
26
- end
27
-
28
- def empty?
29
- @items.empty?
30
- end
31
-
32
- def full?
33
- @items.length == 10
34
- end
35
-
36
- end
@@ -1,64 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
- require File.dirname(__FILE__) + "/stack"
3
- require File.dirname(__FILE__) + '/shared_stack_examples'
4
-
5
- describe Stack, " (empty)" do
6
- before(:each) do
7
- @stack = Stack.new
8
- end
9
-
10
- # This uses @stack (because the described class is Stack) auto-generates the
11
- # description "should be empty"
12
- it { should be_empty }
13
-
14
- it_should_behave_like "non-full Stack"
15
-
16
- it "should complain when sent #peek" do
17
- lambda { @stack.peek }.should raise_error(StackUnderflowError)
18
- end
19
-
20
- it "should complain when sent #pop" do
21
- lambda { @stack.pop }.should raise_error(StackUnderflowError)
22
- end
23
- end
24
-
25
- describe Stack, " (with one item)" do
26
- before(:each) do
27
- @stack = Stack.new
28
- @stack.push 3
29
- @last_item_added = 3
30
- end
31
-
32
- it_should_behave_like "non-empty Stack"
33
- it_should_behave_like "non-full Stack"
34
-
35
- end
36
-
37
- describe Stack, " (with one item less than capacity)" do
38
- before(:each) do
39
- @stack = Stack.new
40
- (1..9).each { |i| @stack.push i }
41
- @last_item_added = 9
42
- end
43
-
44
- it_should_behave_like "non-empty Stack"
45
- it_should_behave_like "non-full Stack"
46
- end
47
-
48
- describe Stack, " (full)" do
49
- before(:each) do
50
- @stack = Stack.new
51
- (1..10).each { |i| @stack.push i }
52
- @last_item_added = 10
53
- end
54
-
55
- # NOTE that this one auto-generates the description "should be full"
56
- it { @stack.should be_full }
57
-
58
- it_should_behave_like "non-empty Stack"
59
-
60
- it "should complain on #push" do
61
- lambda { @stack.push Object.new }.should raise_error(StackOverflowError)
62
- end
63
-
64
- end
@@ -1,67 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
- require File.dirname(__FILE__) + '/stack'
3
- require File.dirname(__FILE__) + '/shared_stack_examples'
4
-
5
- describe Stack do
6
-
7
- before(:each) do
8
- @stack = Stack.new
9
- end
10
-
11
- describe "(empty)" do
12
-
13
- it { @stack.should be_empty }
14
-
15
- it_should_behave_like "non-full Stack"
16
-
17
- it "should complain when sent #peek" do
18
- lambda { @stack.peek }.should raise_error(StackUnderflowError)
19
- end
20
-
21
- it "should complain when sent #pop" do
22
- lambda { @stack.pop }.should raise_error(StackUnderflowError)
23
- end
24
-
25
- end
26
-
27
- describe "(with one item)" do
28
-
29
- before(:each) do
30
- @stack.push 3
31
- @last_item_added = 3
32
- end
33
-
34
- it_should_behave_like "non-empty Stack"
35
- it_should_behave_like "non-full Stack"
36
-
37
- end
38
-
39
- describe "(with one item less than capacity)" do
40
-
41
- before(:each) do
42
- (1..9).each { |i| @stack.push i }
43
- @last_item_added = 9
44
- end
45
-
46
- it_should_behave_like "non-empty Stack"
47
- it_should_behave_like "non-full Stack"
48
- end
49
-
50
- describe "(full)" do
51
-
52
- before(:each) do
53
- (1..10).each { |i| @stack.push i }
54
- @last_item_added = 10
55
- end
56
-
57
- it { @stack.should be_full }
58
-
59
- it_should_behave_like "non-empty Stack"
60
-
61
- it "should complain on #push" do
62
- lambda { @stack.push Object.new }.should raise_error(StackOverflowError)
63
- end
64
-
65
- end
66
-
67
- end
@@ -1,69 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- describe "A consumer of a stub" do
4
- it "should be able to stub methods on any Object" do
5
- obj = Object.new
6
- obj.stub!(:foobar).and_return {:return_value}
7
- obj.foobar.should equal(:return_value)
8
- end
9
- end
10
-
11
- class StubbableClass
12
- def self.find id
13
- return :original_return
14
- end
15
- end
16
-
17
- describe "A stubbed method on a class" do
18
- it "should return the stubbed value" do
19
- StubbableClass.stub!(:find).and_return(:stub_return)
20
- StubbableClass.find(1).should equal(:stub_return)
21
- end
22
-
23
- it "should revert to the original method after each spec" do
24
- StubbableClass.find(1).should equal(:original_return)
25
- end
26
-
27
- it "can stub! and mock the same message" do
28
- StubbableClass.stub!(:msg).and_return(:stub_value)
29
- StubbableClass.should_receive(:msg).with(:arg).and_return(:mock_value)
30
-
31
- StubbableClass.msg.should equal(:stub_value)
32
- StubbableClass.msg(:other_arg).should equal(:stub_value)
33
- StubbableClass.msg(:arg).should equal(:mock_value)
34
- StubbableClass.msg(:another_arg).should equal(:stub_value)
35
- StubbableClass.msg(:yet_another_arg).should equal(:stub_value)
36
- StubbableClass.msg.should equal(:stub_value)
37
- end
38
- end
39
-
40
- describe "A mock" do
41
- it "can stub!" do
42
- mock = mock("stubbing mock")
43
- mock.stub!(:msg).and_return(:value)
44
- (1..10).each {mock.msg.should equal(:value)}
45
- end
46
-
47
- it "can stub! and mock" do
48
- mock = mock("stubbing mock")
49
- mock.stub!(:stub_message).and_return(:stub_value)
50
- mock.should_receive(:mock_message).once.and_return(:mock_value)
51
- (1..10).each {mock.stub_message.should equal(:stub_value)}
52
- mock.mock_message.should equal(:mock_value)
53
- (1..10).each {mock.stub_message.should equal(:stub_value)}
54
- end
55
-
56
- it "can stub! and mock the same message" do
57
- mock = mock("stubbing mock")
58
- mock.stub!(:msg).and_return(:stub_value)
59
- mock.should_receive(:msg).with(:arg).and_return(:mock_value)
60
- mock.msg.should equal(:stub_value)
61
- mock.msg(:other_arg).should equal(:stub_value)
62
- mock.msg(:arg).should equal(:mock_value)
63
- mock.msg(:another_arg).should equal(:stub_value)
64
- mock.msg(:yet_another_arg).should equal(:stub_value)
65
- mock.msg.should equal(:stub_value)
66
- end
67
- end
68
-
69
-
@@ -1,45 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- module SubjectExample
4
- class OneThing
5
- attr_accessor :what_things_do
6
- def initialize
7
- self.what_things_do = "stuff"
8
- end
9
- end
10
-
11
- # implicit subject
12
- describe OneThing do
13
- it "should do what things do" do
14
- subject.what_things_do.should == "stuff"
15
- end
16
- it "should be a OneThing" do
17
- should == subject
18
- end
19
- its(:what_things_do) { should == "stuff" }
20
- end
21
-
22
- # explicit subject
23
- describe SubjectExample::OneThing do
24
- subject { SubjectExample::OneThing.new }
25
- it "should do what things do" do
26
- subject.what_things_do.should == "stuff"
27
- end
28
- it "should be a OneThing" do
29
- should == subject
30
- end
31
- its(:what_things_do) { should == "stuff" }
32
- end
33
-
34
- # modified subject
35
- describe OneThing do
36
- subject { SubjectExample::OneThing.new }
37
- before { subject.what_things_do = "more stuff" }
38
- it "should do what things do" do
39
- subject.what_things_do.should == "more stuff"
40
- end
41
- its(:what_things_do) { should == "more stuff" }
42
- end
43
-
44
- end
45
-
@@ -1,33 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- class MessageAppender
4
-
5
- def initialize(appendage)
6
- @appendage = appendage
7
- end
8
-
9
- def append_to(message)
10
- if_told_to_yield do
11
- message << @appendage
12
- end
13
- end
14
-
15
- end
16
-
17
- describe "a message expectation yielding to a block" do
18
- it "should yield if told to" do
19
- appender = MessageAppender.new("appended to")
20
- appender.should_receive(:if_told_to_yield).and_yield
21
- message = ""
22
- appender.append_to(message)
23
- message.should == "appended to"
24
- end
25
-
26
- it "should not yield if not told to" do
27
- appender = MessageAppender.new("appended to")
28
- appender.should_receive(:if_told_to_yield)
29
- message = ""
30
- appender.append_to(message)
31
- message.should == ""
32
- end
33
- end
@@ -1,85 +0,0 @@
1
- # courtesy of Matthias Hennemeyer
2
- #
3
- # The following should pass against ruby 1.8 and 1.9. It currently only passes
4
- # 1.8 (as of 1/2/2009)
5
- #
6
- # Once cucumber supports ruby 1.9, this should be moved to cucumber scenarios instead.
7
- module Foo
8
- module Bar
9
-
10
- module ModuleInEnclosingModule;end
11
- class ClassInEnclosingModule;end
12
- def method_in_enclosing_module;end
13
- CONSTANT_IN_ENCLOSING_MODULE = 0
14
-
15
- describe "Examples trying to access constants defined in an enclosing module" do
16
-
17
- it "can access Modules" do
18
- ModuleInEnclosingModule
19
- end
20
- it "can access Classes" do
21
- ClassInEnclosingModule.new
22
- end
23
- it "can access CONSTANTS" do
24
- CONSTANT_IN_ENCLOSING_MODULE
25
- end
26
- it "can NOT access methods" do
27
- lambda {method_in_enclosing_module}.should raise_error(/undefined/)
28
- end
29
-
30
- describe "from a nested example group" do
31
-
32
- it "can access Modules" do
33
- ModuleInEnclosingModule
34
- end
35
- it "can access Classes" do
36
- ClassInEnclosingModule.new
37
- end
38
- it "can access CONSTANTS" do
39
- CONSTANT_IN_ENCLOSING_MODULE
40
- end
41
- it "can NOT access methods" do
42
- lambda {method_in_enclosing_module}.should raise_error(/undefined/)
43
- end
44
-
45
- end
46
-
47
- end
48
-
49
- describe "Examples trying to access constants defined in the example group" do
50
-
51
- module ModuleDefinedInGroup;end
52
- class ClassDefinedInGroup; end
53
- def method_defined_in_group; end
54
- CONSTANT_DEFINED_IN_GROUP = 0
55
-
56
- it "can access Modules" do
57
- ModuleDefinedInGroup
58
- end
59
- it "can access Classes" do
60
- ClassDefinedInGroup.new
61
- end
62
- it "can access CONSTANTS" do
63
- CONSTANT_DEFINED_IN_GROUP
64
- end
65
- it "can access methods" do
66
- method_defined_in_group
67
- end
68
-
69
- describe "that live inside a nested group" do
70
- it "can access Modules" do
71
- ModuleDefinedInGroup
72
- end
73
- it "can access Classes" do
74
- ClassDefinedInGroup.new
75
- end
76
- it "can access CONSTANTS" do
77
- CONSTANT_DEFINED_IN_GROUP
78
- end
79
- it "can access methods" do
80
- method_defined_in_group
81
- end
82
- end
83
- end
84
- end
85
- end