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,7 +0,0 @@
1
- "Why have failing examples?", you might ask.
2
-
3
- They allow us to see failure messages. RSpec wants to provide meaningful and helpful failure messages. The failures in this directory not only provide you a way of seeing the failure messages, but they provide RSpec's own specs a way of describing what they should look like and ensuring they stay correct.
4
-
5
- To see the types of messages you can expect, stand in this directory and run:
6
-
7
- ../bin/rspec ./*.rb
@@ -1,38 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- describe "Running specs with --diff" do
4
- it "should print diff of different strings" do
5
- uk = <<-EOF
6
- RSpec is a
7
- behaviour driven development
8
- framework for Ruby
9
- EOF
10
- usa = <<-EOF
11
- RSpec is a
12
- behavior driven development
13
- framework for Ruby
14
- EOF
15
- usa.should == uk
16
- end
17
-
18
- class Animal
19
- def initialize(name,species)
20
- @name,@species = name,species
21
- end
22
-
23
- def inspect
24
- <<-EOA
25
- <Animal
26
- name=#{@name},
27
- species=#{@species}
28
- >
29
- EOA
30
- end
31
- end
32
-
33
- it "should print diff of different objects' pretty representation" do
34
- expected = Animal.new "bob", "giraffe"
35
- actual = Animal.new "bob", "tortoise"
36
- expected.should eq(actual)
37
- end
38
- end
@@ -1,19 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- # Run spec w/ -fs to see the output of this file
4
-
5
- describe "Failing examples with no descriptions" do
6
-
7
- # description is auto-generated as "should equal(5)" based on the last #should
8
- it do
9
- 3.should equal(2)
10
- 5.should equal(5)
11
- end
12
-
13
- it { 3.should be > 5 }
14
-
15
- it { ["a"].should include("b") }
16
-
17
- it { [1,2,3].should_not respond_to(:size) }
18
-
19
- end
@@ -1,10 +0,0 @@
1
- describe "This example" do
2
-
3
- it "should be listed as failing in after" do
4
- end
5
-
6
- after(:each) do
7
- NonExistentClass.new
8
- end
9
-
10
- end
@@ -1,10 +0,0 @@
1
- describe "This example" do
2
-
3
- before(:each) do
4
- NonExistentClass.new
5
- end
6
-
7
- it "should be listed as failing in each" do
8
- end
9
-
10
- end
@@ -1,40 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- describe "Mocker" do
4
-
5
- it "should be able to call mock()" do
6
- mock = mock("poke me")
7
- mock.should_receive(:poke)
8
- mock.poke
9
- end
10
-
11
- it "should fail when expected message not received" do
12
- mock = mock("poke me")
13
- mock.should_receive(:poke)
14
- end
15
-
16
- it "should fail when messages are received out of order" do
17
- mock = mock("one two three")
18
- mock.should_receive(:one).ordered
19
- mock.should_receive(:two).ordered
20
- mock.should_receive(:three).ordered
21
- mock.one
22
- mock.three
23
- mock.two
24
- end
25
-
26
- it "should get yelled at when sending unexpected messages" do
27
- mock = mock("don't talk to me")
28
- mock.should_not_receive(:any_message_at_all)
29
- mock.any_message_at_all
30
- end
31
-
32
- it "has a bug we need to fix" do
33
- pending "here is the bug" do
34
- # Actually, no. It's fixed. This will fail because it passes :-)
35
- mock = mock("Bug")
36
- mock.should_receive(:hello)
37
- mock.hello
38
- end
39
- end
40
- end
@@ -1,26 +0,0 @@
1
- # stub frameworks like to gum up Object, so this is deliberately
2
- # set NOT to run so that you don't accidentally run it when you
3
- # run this dir.
4
-
5
- # To run it, stand in this directory and say:
6
- #
7
- # RUN_FLEXMOCK_EXAMPLE=true ruby ../bin/spec mocking_with_flexmock.rb
8
-
9
- if ENV['RUN_FLEXMOCK_EXAMPLE']
10
- Spec::Runner.configure do |config|
11
- config.mock_framework = :flexmock
12
- end
13
-
14
- describe "Flexmocks" do
15
- it "should fail when the expected message is received with wrong arguments" do
16
- m = flexmock("now flex!")
17
- m.should_receive(:msg).with("arg").once
18
- m.msg("other arg")
19
- end
20
-
21
- it "should fail when the expected message is not received at all" do
22
- m = flexmock("now flex!")
23
- m.should_receive(:msg).with("arg").once
24
- end
25
- end
26
- end
@@ -1,25 +0,0 @@
1
- # stub frameworks like to gum up Object, so this is deliberately
2
- # set NOT to run so that you don't accidentally run it when you
3
- # run this dir.
4
-
5
- # To run it, stand in this directory and say:
6
- #
7
- # RUN_MOCHA_EXAMPLE=true ruby ../bin/spec mocking_with_mocha.rb
8
-
9
- if ENV['RUN_MOCHA_EXAMPLE']
10
- Spec::Runner.configure do |config|
11
- config.mock_framework = :mocha
12
- end
13
- describe "Mocha framework" do
14
- it "should should be made available by saying config.mock_framework = :mocha" do
15
- m = mock()
16
- m.expects(:msg).with("arg")
17
- m.msg
18
- end
19
- it "should should be made available by saying config.mock_framework = :mocha" do
20
- o = Object.new
21
- o.expects(:msg).with("arg")
22
- o.msg
23
- end
24
- end
25
- end
@@ -1,27 +0,0 @@
1
- # stub frameworks like to gum up Object, so this is deliberately
2
- # set NOT to run so that you don't accidentally run it when you
3
- # run this dir.
4
-
5
- # To run it, stand in this directory and say:
6
- #
7
- # RUN_RR_EXAMPLE=true ruby ../bin/spec mocking_with_rr.rb
8
-
9
- if ENV['RUN_RR_EXAMPLE']
10
- Spec::Runner.configure do |config|
11
- config.mock_framework = :rr
12
- end
13
- describe "RR framework" do
14
- it "should should be made available by saying config.mock_framework = :rr" do
15
- o = Object.new
16
- mock(o).msg("arg")
17
- o.msg
18
- end
19
- it "should should be made available by saying config.mock_framework = :rr" do
20
- o = Object.new
21
- mock(o) do |m|
22
- m.msg("arg")
23
- end
24
- o.msg
25
- end
26
- end
27
- end
@@ -1,20 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- class MockableClass
4
- def self.find id
5
- return :original_return
6
- end
7
- end
8
-
9
- describe "A partial mock" do
10
-
11
- it "should work at the class level (but fail here due to the type mismatch)" do
12
- MockableClass.should_receive(:find).with(1).and_return {:stub_return}
13
- MockableClass.find("1").should equal(:stub_return)
14
- end
15
-
16
- it "should revert to the original after each spec" do
17
- MockableClass.find(1).should equal(:original_return)
18
- end
19
-
20
- end
@@ -1,9 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- describe "pending example (which is fixed)" do
4
- it %Q|reports "FIXED ... Expected ... to fail. No Error was raised."| do
5
- pending("for some reason") do
6
- # success
7
- end
8
- end
9
- end
@@ -1,34 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- class BddFramework
4
- def intuitive?
5
- true
6
- end
7
-
8
- def adopted_quickly?
9
- #this will cause failures because it reallly SHOULD be adopted quickly
10
- false
11
- end
12
- end
13
-
14
- describe "BDD framework" do
15
-
16
- before(:each) do
17
- @bdd_framework = BddFramework.new
18
- end
19
-
20
- it "should be adopted quickly" do
21
- #this will fail because it reallly SHOULD be adopted quickly
22
- @bdd_framework.should be_adopted_quickly
23
- end
24
-
25
- it "should be intuitive" do
26
- @bdd_framework.should be_intuitive
27
- end
28
-
29
- it "should not respond to test" do
30
- #this will fail
31
- @bdd_framework.test
32
- end
33
-
34
- end
@@ -1,47 +0,0 @@
1
- describe "This example" do
2
-
3
- it "should show that a NoMethodError is raised but an Exception was expected" do
4
- proc { ''.nonexistent_method }.should raise_error
5
- end
6
-
7
- it "should pass" do
8
- proc { ''.nonexistent_method }.should raise_error(NoMethodError)
9
- end
10
-
11
- it "should show that a NoMethodError is raised but a SyntaxError was expected" do
12
- proc { ''.nonexistent_method }.should raise_error(SyntaxError)
13
- end
14
-
15
- it "should show that nothing is raised when SyntaxError was expected" do
16
- proc { }.should raise_error(SyntaxError)
17
- end
18
-
19
- it "should show that a NoMethodError is raised but a Exception was expected" do
20
- proc { ''.nonexistent_method }.should_not raise_error
21
- end
22
-
23
- it "should show that a NoMethodError is raised" do
24
- proc { ''.nonexistent_method }.should_not raise_error(NoMethodError)
25
- end
26
-
27
- it "should also pass" do
28
- proc { ''.nonexistent_method }.should_not raise_error(SyntaxError)
29
- end
30
-
31
- it "should show that a NoMethodError is raised when nothing expected" do
32
- proc { ''.nonexistent_method }.should_not raise_error(Exception)
33
- end
34
-
35
- it "should show that the wrong message was received" do
36
- proc { raise StandardError.new("what is an enterprise?") }.should raise_error(StandardError, "not this")
37
- end
38
-
39
- it "should show that the unexpected error/message was thrown" do
40
- proc { raise StandardError.new("abc") }.should_not raise_error(StandardError, "abc")
41
- end
42
-
43
- it "should pass too" do
44
- proc { raise StandardError.new("abc") }.should_not raise_error(StandardError, "xyz")
45
- end
46
-
47
- end
@@ -1 +0,0 @@
1
- require File.expand_path('../../spec_helper.rb', __FILE__)
@@ -1,7 +0,0 @@
1
- describe "when passing a block to a matcher" do
2
- it "you should use {} instead of do/end" do
3
- Object.new.should satisfy do
4
- "this block is being passed to #should instead of #satisfy - use {} instead"
5
- end
6
- end
7
- end
@@ -1,43 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- class Team
4
- attr_reader :players
5
- def initialize
6
- @players = Players.new
7
- end
8
- end
9
-
10
- class Players
11
- def initialize
12
- @players = []
13
- end
14
- def size
15
- @players.size
16
- end
17
- def include? player
18
- raise "player must be a string" unless player.is_a?(String)
19
- @players.include? player
20
- end
21
- end
22
-
23
- describe "A new team" do
24
-
25
- before(:each) do
26
- @team = Team.new
27
- end
28
-
29
- it "should have 3 players (failing example)" do
30
- @team.should have(3).players
31
- end
32
-
33
- it "should include some player (failing example)" do
34
- @team.players.should include("Some Player")
35
- end
36
-
37
- it "should include 5 (failing example)" do
38
- @team.players.should include(5)
39
- end
40
-
41
- it "should have no players"
42
-
43
- end
@@ -1,7 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- describe "Something really slow" do
4
- it "should be failed by RSpec when it takes longer than --timeout" do
5
- sleep(2)
6
- end
7
- end
@@ -1,12 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
- require 'spec/runner/formatter/progress_bar_formatter'
3
-
4
- # Example of a formatter with custom bactrace printing. Run me with:
5
- # ruby bin/spec examples/failing -r examples/passing/custom_formatter.rb -f CustomFormatter
6
- class CustomFormatter < Spec::Runner::Formatter::ProgressBarFormatter
7
- def backtrace_line(line)
8
- line.gsub(/([^:]*\.rb):(\d*)/) do
9
- "<a href=\"file://#{File.expand_path($1)}\">#{$1}:#{$2}</a> "
10
- end
11
- end
12
- end
@@ -1,54 +0,0 @@
1
- module AnimalSpecHelper
2
- class Eat
3
- def initialize(food)
4
- @food = food
5
- end
6
-
7
- def matches?(animal)
8
- @animal = animal
9
- @animal.eats?(@food)
10
- end
11
-
12
- def failure_message
13
- "expected #{@animal} to eat #{@food}, but it does not"
14
- end
15
-
16
- def negative_failure_message
17
- "expected #{@animal} not to eat #{@food}, but it does"
18
- end
19
- end
20
-
21
- def eat(food)
22
- Eat.new(food)
23
- end
24
- end
25
-
26
- module Animals
27
- class Animal
28
- def eats?(food)
29
- return foods_i_eat.include?(food)
30
- end
31
- end
32
-
33
- class Mouse < Animal
34
- def foods_i_eat
35
- [:cheese]
36
- end
37
- end
38
-
39
- describe Mouse do
40
- include AnimalSpecHelper
41
- before(:each) do
42
- @mouse = Animals::Mouse.new
43
- end
44
-
45
- it "should eat cheese" do
46
- @mouse.should eat(:cheese)
47
- end
48
-
49
- it "should not eat cat" do
50
- @mouse.should_not eat(:cat)
51
- end
52
- end
53
-
54
- end