rspec-core 2.0.0.a1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. data/.document +5 -0
  2. data/.gitignore +7 -0
  3. data/.treasure_map.rb +23 -0
  4. data/License.txt +22 -0
  5. data/README.markdown +9 -0
  6. data/Rakefile +76 -0
  7. data/TODO.markdown +16 -0
  8. data/VERSION +1 -0
  9. data/VERSION.yml +5 -0
  10. data/bin/rspec +12 -0
  11. data/cucumber.yml +2 -0
  12. data/example_specs/failing/README.txt +7 -0
  13. data/example_specs/failing/diffing_spec.rb +36 -0
  14. data/example_specs/failing/failing_implicit_docstrings_example.rb +19 -0
  15. data/example_specs/failing/failure_in_after.rb +10 -0
  16. data/example_specs/failing/failure_in_before.rb +10 -0
  17. data/example_specs/failing/mocking_example.rb +40 -0
  18. data/example_specs/failing/mocking_with_flexmock.rb +26 -0
  19. data/example_specs/failing/mocking_with_mocha.rb +25 -0
  20. data/example_specs/failing/mocking_with_rr.rb +27 -0
  21. data/example_specs/failing/partial_mock_example.rb +20 -0
  22. data/example_specs/failing/pending_example.rb +9 -0
  23. data/example_specs/failing/predicate_example.rb +34 -0
  24. data/example_specs/failing/raising_example.rb +47 -0
  25. data/example_specs/failing/spec_helper.rb +3 -0
  26. data/example_specs/failing/syntax_error_example.rb +7 -0
  27. data/example_specs/failing/team_spec.rb +44 -0
  28. data/example_specs/failing/timeout_behaviour.rb +7 -0
  29. data/example_specs/passing/custom_formatter.rb +12 -0
  30. data/example_specs/passing/custom_matchers.rb +54 -0
  31. data/example_specs/passing/dynamic_spec.rb +9 -0
  32. data/example_specs/passing/file_accessor.rb +19 -0
  33. data/example_specs/passing/file_accessor_spec.rb +38 -0
  34. data/example_specs/passing/filtered_formatter.rb +18 -0
  35. data/example_specs/passing/filtered_formatter_example.rb +31 -0
  36. data/example_specs/passing/greeter_spec.rb +31 -0
  37. data/example_specs/passing/helper_method_example.rb +14 -0
  38. data/example_specs/passing/implicit_docstrings_example.rb +18 -0
  39. data/example_specs/passing/io_processor.rb +8 -0
  40. data/example_specs/passing/io_processor_spec.rb +21 -0
  41. data/example_specs/passing/mocking_example.rb +27 -0
  42. data/example_specs/passing/multi_threaded_example_group_runner.rb +26 -0
  43. data/example_specs/passing/nested_classes_example.rb +36 -0
  44. data/example_specs/passing/options_example.rb +31 -0
  45. data/example_specs/passing/options_formatter.rb +20 -0
  46. data/example_specs/passing/partial_mock_example.rb +29 -0
  47. data/example_specs/passing/pending_example.rb +20 -0
  48. data/example_specs/passing/predicate_example.rb +27 -0
  49. data/example_specs/passing/shared_example_group_example.rb +81 -0
  50. data/example_specs/passing/shared_stack_examples.rb +36 -0
  51. data/example_specs/passing/simple_matcher_example.rb +31 -0
  52. data/example_specs/passing/spec_helper.rb +14 -0
  53. data/example_specs/passing/stack.rb +36 -0
  54. data/example_specs/passing/stack_spec.rb +64 -0
  55. data/example_specs/passing/stack_spec_with_nested_example_groups.rb +67 -0
  56. data/example_specs/passing/stubbing_example.rb +69 -0
  57. data/example_specs/passing/yielding_example.rb +33 -0
  58. data/example_specs/ruby1.9.compatibility/access_to_constants_spec.rb +85 -0
  59. data/features-pending/command_line/line_number_option.feature +56 -0
  60. data/features-pending/command_line/line_number_option_with_example_with_no_name.feature +22 -0
  61. data/features-pending/example_groups/example_group_with_should_methods.feature +29 -0
  62. data/features-pending/example_groups/implicit_docstrings.feature +59 -0
  63. data/features-pending/example_groups/nested_groups.feature +32 -0
  64. data/features-pending/expectations/expect_change.feature +65 -0
  65. data/features-pending/expectations/expect_error.feature +44 -0
  66. data/features-pending/extensions/custom_example_group.feature +19 -0
  67. data/features-pending/formatters/custom_formatter.feature +30 -0
  68. data/features-pending/heckle/heckle.feature +56 -0
  69. data/features-pending/interop/examples_and_tests_together.feature +80 -0
  70. data/features-pending/interop/rspec_output.feature +25 -0
  71. data/features-pending/interop/test_but_not_test_unit.feature +26 -0
  72. data/features-pending/interop/test_case_with_should_methods.feature +46 -0
  73. data/features-pending/matchers/define_diffable_matcher.feature +26 -0
  74. data/features-pending/matchers/define_matcher.feature +179 -0
  75. data/features-pending/matchers/define_matcher_with_fluent_interface.feature +27 -0
  76. data/features-pending/mocks/mix_stubs_and_mocks.feature +22 -0
  77. data/features-pending/mocks/stub_implementation.feature +26 -0
  78. data/features-pending/pending/pending_examples.feature +81 -0
  79. data/features-pending/runner/specify_line_number.feature +32 -0
  80. data/features/before_and_after_blocks/before_and_after_blocks.feature +169 -0
  81. data/features/expectations/customized_message.feature +54 -0
  82. data/features/matchers/define_matcher_outside_rspec.feature +39 -0
  83. data/features/mock_framework_integration/use_flexmock.feature +23 -0
  84. data/features/mock_framework_integration/use_mocha.feature +23 -0
  85. data/features/mock_framework_integration/use_rr.feature +23 -0
  86. data/features/mock_framework_integration/use_rspec.feature +23 -0
  87. data/features/step_definitions/running_rspec_steps.rb +35 -0
  88. data/features/subject/explicit_subject.feature +31 -0
  89. data/features/subject/implicit_subject.feature +31 -0
  90. data/features/support/env.rb +82 -0
  91. data/features/support/matchers/smart_match.rb +14 -0
  92. data/lib/rspec/autorun.rb +2 -0
  93. data/lib/rspec/core.rb +38 -0
  94. data/lib/rspec/core/backward_compatibility.rb +9 -0
  95. data/lib/rspec/core/command_line_options.rb +60 -0
  96. data/lib/rspec/core/configuration.rb +222 -0
  97. data/lib/rspec/core/deprecation.rb +47 -0
  98. data/lib/rspec/core/example.rb +113 -0
  99. data/lib/rspec/core/example_group.rb +239 -0
  100. data/lib/rspec/core/example_group_subject.rb +77 -0
  101. data/lib/rspec/core/formatters.rb +16 -0
  102. data/lib/rspec/core/formatters/base_formatter.rb +123 -0
  103. data/lib/rspec/core/formatters/base_text_formatter.rb +139 -0
  104. data/lib/rspec/core/formatters/documentation_formatter.rb +84 -0
  105. data/lib/rspec/core/formatters/progress_formatter.rb +36 -0
  106. data/lib/rspec/core/kernel_extensions.rb +15 -0
  107. data/lib/rspec/core/mocking/with_absolutely_nothing.rb +13 -0
  108. data/lib/rspec/core/mocking/with_flexmock.rb +25 -0
  109. data/lib/rspec/core/mocking/with_mocha.rb +22 -0
  110. data/lib/rspec/core/mocking/with_rr.rb +26 -0
  111. data/lib/rspec/core/mocking/with_rspec.rb +21 -0
  112. data/lib/rspec/core/rake_task.rb +88 -0
  113. data/lib/rspec/core/runner.rb +66 -0
  114. data/lib/rspec/core/shared_behaviour.rb +41 -0
  115. data/lib/rspec/core/shared_behaviour_kernel_extensions.rb +31 -0
  116. data/lib/rspec/core/version.rb +16 -0
  117. data/lib/rspec/core/world.rb +105 -0
  118. data/rspec-core.gemspec +204 -0
  119. data/script/console +8 -0
  120. data/spec/resources/example_classes.rb +67 -0
  121. data/spec/rspec/core/command_line_options_spec.rb +63 -0
  122. data/spec/rspec/core/configuration_spec.rb +171 -0
  123. data/spec/rspec/core/example_group_spec.rb +351 -0
  124. data/spec/rspec/core/example_group_subject_spec.rb +67 -0
  125. data/spec/rspec/core/example_spec.rb +67 -0
  126. data/spec/rspec/core/formatters/base_formatter_spec.rb +105 -0
  127. data/spec/rspec/core/formatters/documentation_formatter_spec.rb +5 -0
  128. data/spec/rspec/core/formatters/progress_formatter_spec.rb +29 -0
  129. data/spec/rspec/core/kernel_extensions_spec.rb +13 -0
  130. data/spec/rspec/core/mocha_spec.rb +29 -0
  131. data/spec/rspec/core/resources/a_bar.rb +0 -0
  132. data/spec/rspec/core/resources/a_foo.rb +0 -0
  133. data/spec/rspec/core/resources/a_spec.rb +1 -0
  134. data/spec/rspec/core/resources/custom_example_group_runner.rb +14 -0
  135. data/spec/rspec/core/resources/example_classes.rb +67 -0
  136. data/spec/rspec/core/resources/utf8_encoded.rb +8 -0
  137. data/spec/rspec/core/runner_spec.rb +34 -0
  138. data/spec/rspec/core/shared_behaviour_spec.rb +185 -0
  139. data/spec/rspec/core/world_spec.rb +167 -0
  140. data/spec/rspec/core_spec.rb +35 -0
  141. data/spec/ruby_forker.rb +13 -0
  142. data/spec/spec_helper.rb +72 -0
  143. metadata +219 -0
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,7 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage*
4
+ rdoc
5
+ pkg
6
+ tmp
7
+ tags
@@ -0,0 +1,23 @@
1
+ Beholder.runner = 'clear; ruby -Ilib -Ispec'
2
+
3
+ map_for(:rspec_core) do |m|
4
+
5
+ m.watch 'lib', 'spec', 'example_specs'
6
+
7
+ m.add_mapping %r%example_specs/(.*)_spec\.rb% do |match|
8
+ ["example_specs/#{match[1]}_spec.rb"]
9
+ end
10
+
11
+ m.add_mapping %r%spec/(.*)_spec\.rb% do |match|
12
+ ["spec/#{match[1]}_spec.rb"]
13
+ end
14
+
15
+ m.add_mapping %r%spec/spec_helper\.rb% do |match|
16
+ Dir["spec/**/*_spec.rb"]
17
+ end
18
+
19
+ m.add_mapping %r%lib/(.*)\.rb% do |match|
20
+ tests_matching match[1]
21
+ end
22
+
23
+ end
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2009 David Chelimsky, Chad Humphries
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,9 @@
1
+ # RSpec Core
2
+
3
+ See README.markdown at [http://github.com/rspec/meta](http://github.com/rspec/meta)
4
+
5
+
6
+ #### Also see
7
+
8
+ * [http://github.com/rspec/expectations](http://github.com/rspec/expectations)
9
+ * [http://github.com/rspec/mocks](http://github.com/rspec/mocks)
@@ -0,0 +1,76 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'yaml'
4
+
5
+ $:.unshift 'lib'
6
+
7
+ require 'rake/rdoctask'
8
+ require 'rspec/core/rake_task'
9
+ require 'cucumber/rake/task'
10
+
11
+ begin
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ gem.name = "rspec-core"
15
+ gem.summary = "RSpec Core"
16
+ gem.description = 'RSpec Core'
17
+ gem.email = "dchelimsky@gmail.com;chad.humphries@gmail.com"
18
+ gem.homepage = "http://github.com/rspec/core"
19
+ gem.authors = ["David Chelimsky", "Chad Humphries"]
20
+ gem.add_development_dependency('rspec-expectations', '>= 2.0.0.a1')
21
+ gem.add_development_dependency('rspec-mocks', '>= 2.0.0.a1')
22
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
23
+ end
24
+ rescue LoadError
25
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
26
+ end
27
+
28
+ Rspec::Core::RakeTask.new :spec do |t|
29
+ t.ruby_opts = %[-Ilib -Ispec]
30
+ t.pattern = "spec/**/*_spec.rb"
31
+ end
32
+
33
+ task :cleanup_rcov_files do
34
+ rm_rf 'coverage.data'
35
+ end
36
+
37
+ desc "Run all examples using rcov"
38
+ Rspec::Core::RakeTask.new :rcov => :cleanup_rcov_files do |t|
39
+ t.rcov = true
40
+ t.rcov_opts = %[-Ilib -Ispec --exclude "mocks,expectations,gems/*,spec/resources,spec/lib,spec/spec_helper.rb,db/*,/Library/Ruby/*,config/*"]
41
+ t.rcov_opts << %[--no-html --aggregate coverage.data]
42
+ t.pattern = "spec/**/*_spec.rb"
43
+ end
44
+
45
+ if RUBY_VERSION == '1.9.1'
46
+ Cucumber::Rake::Task.new :features do |t|
47
+ t.cucumber_opts = %w{--format progress}
48
+ end
49
+
50
+ task :default => [:spec, :features]
51
+ else
52
+ Cucumber::Rake::Task.new :features do |t|
53
+ t.rcov = true
54
+ t.rcov_opts = %[-Ilib -Ispec --exclude "mocks,expectations,gems/*,features,spec/ruby_forker,spec/rspec,spec/resources,spec/lib,spec/spec_helper.rb,db/*,/Library/Ruby/*,config/*"]
55
+ t.rcov_opts << %[--text-report --sort coverage --aggregate coverage.data]
56
+ t.cucumber_opts = %w{--format progress}
57
+ end
58
+
59
+ task :default => [:rcov, :features]
60
+ end
61
+
62
+
63
+ Rake::RDocTask.new do |rdoc|
64
+ if File.exist?('VERSION.yml')
65
+ config = YAML.load(File.read('VERSION.yml'))
66
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
67
+ else
68
+ version = ""
69
+ end
70
+
71
+ rdoc.rdoc_dir = 'rdoc'
72
+ rdoc.title = "rspec-core #{version}"
73
+ rdoc.rdoc_files.include('README*')
74
+ rdoc.rdoc_files.include('lib/**/*.rb')
75
+ end
76
+
@@ -0,0 +1,16 @@
1
+ ### RSpec Core
2
+
3
+ * support the following concepts from rspec-1.2.x
4
+ * run options
5
+ * from command line
6
+ * in rake task definitions
7
+ * formatters
8
+ * Ensure context works everywhere describe does
9
+ * For self testing
10
+ ** shared example groups should not be merged into the real 'world'
11
+ * make sure all behaviour refs are now examplegroup
12
+
13
+ ### Maxwell
14
+
15
+ * need to figure out how maxwell will allow us to mix all the rails testing
16
+ facilities with rspec when working with rails.
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 2.0.0.a1
@@ -0,0 +1,5 @@
1
+ ---
2
+ :major: 2
3
+ :minor: 0
4
+ :patch: 0
5
+ :build: a1
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ # Temporary, until things are actually gems
3
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '/../../expectations/lib'))
4
+ require 'rspec/expectations'
5
+
6
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '/../../mocks/lib'))
7
+ require 'rspec/mocks'
8
+
9
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
10
+ require 'rspec/autorun'
11
+
12
+ Rspec::Core::ExampleGroup.send(:include, Rspec::Matchers)
@@ -0,0 +1,2 @@
1
+ default: features -r features -t ~wip
2
+ wip: features -r features -t wip
@@ -0,0 +1,7 @@
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/spec ./*.rb
@@ -0,0 +1,36 @@
1
+ describe "Running specs with --diff" do
2
+ it "should print diff of different strings" do
3
+ uk = <<-EOF
4
+ RSpec is a
5
+ behaviour driven development
6
+ framework for Ruby
7
+ EOF
8
+ usa = <<-EOF
9
+ RSpec is a
10
+ behavior driven development
11
+ framework for Ruby
12
+ EOF
13
+ usa.should == uk
14
+ end
15
+
16
+ class Animal
17
+ def initialize(name,species)
18
+ @name,@species = name,species
19
+ end
20
+
21
+ def inspect
22
+ <<-EOA
23
+ <Animal
24
+ name=#{@name},
25
+ species=#{@species}
26
+ >
27
+ EOA
28
+ end
29
+ end
30
+
31
+ it "should print diff of different objects' pretty representation" do
32
+ expected = Animal.new "bob", "giraffe"
33
+ actual = Animal.new "bob", "tortoise"
34
+ expected.should eql(actual)
35
+ end
36
+ end
@@ -0,0 +1,19 @@
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
@@ -0,0 +1,10 @@
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
@@ -0,0 +1,10 @@
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
@@ -0,0 +1,40 @@
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
@@ -0,0 +1,26 @@
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
@@ -0,0 +1,25 @@
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
@@ -0,0 +1,27 @@
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
@@ -0,0 +1,20 @@
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
@@ -0,0 +1,9 @@
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
@@ -0,0 +1,34 @@
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