aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/gems/rspec-1.3.1/examples/failing
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2011-02-24 15:10:14 +0000
committerLouise Crow <louise.crow@gmail.com>2011-02-24 15:10:14 +0000
commit08a64f9e3139851fd65c7ba6969ee590b4afea6a (patch)
tree20c77e796002dfa95b2af3ba00ebd2f691c02fc7 /vendor/gems/rspec-1.3.1/examples/failing
parent3757bb52c0aa86b779b00428d7ebe35b30cea1ee (diff)
Adding rspec gem.
Diffstat (limited to 'vendor/gems/rspec-1.3.1/examples/failing')
-rw-r--r--vendor/gems/rspec-1.3.1/examples/failing/README.txt11
-rw-r--r--vendor/gems/rspec-1.3.1/examples/failing/diffing_spec.rb36
-rw-r--r--vendor/gems/rspec-1.3.1/examples/failing/failing_implicit_docstrings_example.rb17
-rw-r--r--vendor/gems/rspec-1.3.1/examples/failing/failure_in_after.rb10
-rw-r--r--vendor/gems/rspec-1.3.1/examples/failing/failure_in_before.rb10
-rw-r--r--vendor/gems/rspec-1.3.1/examples/failing/mocking_example.rb38
-rw-r--r--vendor/gems/rspec-1.3.1/examples/failing/mocking_with_flexmock.rb26
-rw-r--r--vendor/gems/rspec-1.3.1/examples/failing/mocking_with_mocha.rb25
-rw-r--r--vendor/gems/rspec-1.3.1/examples/failing/mocking_with_rr.rb27
-rw-r--r--vendor/gems/rspec-1.3.1/examples/failing/partial_mock_example.rb18
-rw-r--r--vendor/gems/rspec-1.3.1/examples/failing/pending_example.rb7
-rw-r--r--vendor/gems/rspec-1.3.1/examples/failing/predicate_example.rb32
-rw-r--r--vendor/gems/rspec-1.3.1/examples/failing/raising_example.rb47
-rw-r--r--vendor/gems/rspec-1.3.1/examples/failing/syntax_error_example.rb7
-rw-r--r--vendor/gems/rspec-1.3.1/examples/failing/team_spec.rb41
-rw-r--r--vendor/gems/rspec-1.3.1/examples/failing/timeout_behaviour.rb5
16 files changed, 357 insertions, 0 deletions
diff --git a/vendor/gems/rspec-1.3.1/examples/failing/README.txt b/vendor/gems/rspec-1.3.1/examples/failing/README.txt
new file mode 100644
index 000000000..7e9f49236
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/examples/failing/README.txt
@@ -0,0 +1,11 @@
+"Why have failing examples?", you might ask.
+
+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.
+
+To see the types of messages you can expect, stand in the root directory and
+run:
+
+bin/spec examples/failing/*.rb \ No newline at end of file
diff --git a/vendor/gems/rspec-1.3.1/examples/failing/diffing_spec.rb b/vendor/gems/rspec-1.3.1/examples/failing/diffing_spec.rb
new file mode 100644
index 000000000..85e13e8c0
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/examples/failing/diffing_spec.rb
@@ -0,0 +1,36 @@
+describe "Running specs with --diff" do
+ it "should print diff of different strings" do
+ uk = <<-EOF
+RSpec is a
+behaviour driven development
+framework for Ruby
+EOF
+ usa = <<-EOF
+RSpec is a
+behavior driven development
+framework for Ruby
+EOF
+ usa.should == uk
+ end
+
+ class Animal
+ def initialize(name,species)
+ @name,@species = name,species
+ end
+
+ def inspect
+ <<-EOA
+<Animal
+name=#{@name},
+species=#{@species}
+>
+ EOA
+ end
+ end
+
+ it "should print diff of different objects' pretty representation" do
+ expected = Animal.new "bob", "giraffe"
+ actual = Animal.new "bob", "tortoise"
+ expected.should eql(actual)
+ end
+end
diff --git a/vendor/gems/rspec-1.3.1/examples/failing/failing_implicit_docstrings_example.rb b/vendor/gems/rspec-1.3.1/examples/failing/failing_implicit_docstrings_example.rb
new file mode 100644
index 000000000..7b0b86614
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/examples/failing/failing_implicit_docstrings_example.rb
@@ -0,0 +1,17 @@
+# Run spec w/ -fs to see the output of this file
+
+describe "Failing examples with no descriptions" do
+
+ # description is auto-generated as "should equal(5)" based on the last #should
+ it do
+ 3.should equal(2)
+ 5.should equal(5)
+ end
+
+ it { 3.should be > 5 }
+
+ it { ["a"].should include("b") }
+
+ it { [1,2,3].should_not respond_to(:size) }
+
+end
diff --git a/vendor/gems/rspec-1.3.1/examples/failing/failure_in_after.rb b/vendor/gems/rspec-1.3.1/examples/failing/failure_in_after.rb
new file mode 100644
index 000000000..a47338aee
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/examples/failing/failure_in_after.rb
@@ -0,0 +1,10 @@
+describe "This example" do
+
+ it "should be listed as failing in after" do
+ end
+
+ after(:each) do
+ NonExistentClass.new
+ end
+
+end
diff --git a/vendor/gems/rspec-1.3.1/examples/failing/failure_in_before.rb b/vendor/gems/rspec-1.3.1/examples/failing/failure_in_before.rb
new file mode 100644
index 000000000..b0826604e
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/examples/failing/failure_in_before.rb
@@ -0,0 +1,10 @@
+describe "This example" do
+
+ before(:each) do
+ NonExistentClass.new
+ end
+
+ it "should be listed as failing in each" do
+ end
+
+end
diff --git a/vendor/gems/rspec-1.3.1/examples/failing/mocking_example.rb b/vendor/gems/rspec-1.3.1/examples/failing/mocking_example.rb
new file mode 100644
index 000000000..9c735e00b
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/examples/failing/mocking_example.rb
@@ -0,0 +1,38 @@
+describe "Mocker" do
+
+ it "should be able to call mock()" do
+ mock = mock("poke me")
+ mock.should_receive(:poke)
+ mock.poke
+ end
+
+ it "should fail when expected message not received" do
+ mock = mock("poke me")
+ mock.should_receive(:poke)
+ end
+
+ it "should fail when messages are received out of order" do
+ mock = mock("one two three")
+ mock.should_receive(:one).ordered
+ mock.should_receive(:two).ordered
+ mock.should_receive(:three).ordered
+ mock.one
+ mock.three
+ mock.two
+ end
+
+ it "should get yelled at when sending unexpected messages" do
+ mock = mock("don't talk to me")
+ mock.should_not_receive(:any_message_at_all)
+ mock.any_message_at_all
+ end
+
+ it "has a bug we need to fix" do
+ pending "here is the bug" do
+ # Actually, no. It's fixed. This will fail because it passes :-)
+ mock = mock("Bug")
+ mock.should_receive(:hello)
+ mock.hello
+ end
+ end
+end
diff --git a/vendor/gems/rspec-1.3.1/examples/failing/mocking_with_flexmock.rb b/vendor/gems/rspec-1.3.1/examples/failing/mocking_with_flexmock.rb
new file mode 100644
index 000000000..6e79ece0e
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/examples/failing/mocking_with_flexmock.rb
@@ -0,0 +1,26 @@
+# stub frameworks like to gum up Object, so this is deliberately
+# set NOT to run so that you don't accidentally run it when you
+# run this dir.
+
+# To run it, stand in this directory and say:
+#
+# RUN_FLEXMOCK_EXAMPLE=true ruby ../bin/spec mocking_with_flexmock.rb
+
+if ENV['RUN_FLEXMOCK_EXAMPLE']
+ Spec::Runner.configure do |config|
+ config.mock_with :flexmock
+ end
+
+ describe "Flexmocks" do
+ it "should fail when the expected message is received with wrong arguments" do
+ m = flexmock("now flex!")
+ m.should_receive(:msg).with("arg").once
+ m.msg("other arg")
+ end
+
+ it "should fail when the expected message is not received at all" do
+ m = flexmock("now flex!")
+ m.should_receive(:msg).with("arg").once
+ end
+ end
+end
diff --git a/vendor/gems/rspec-1.3.1/examples/failing/mocking_with_mocha.rb b/vendor/gems/rspec-1.3.1/examples/failing/mocking_with_mocha.rb
new file mode 100644
index 000000000..f14a1a3e5
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/examples/failing/mocking_with_mocha.rb
@@ -0,0 +1,25 @@
+# stub frameworks like to gum up Object, so this is deliberately
+# set NOT to run so that you don't accidentally run it when you
+# run this dir.
+
+# To run it, stand in this directory and say:
+#
+# RUN_MOCHA_EXAMPLE=true ruby ../bin/spec mocking_with_mocha.rb
+
+if ENV['RUN_MOCHA_EXAMPLE']
+ Spec::Runner.configure do |config|
+ config.mock_with :mocha
+ end
+ describe "Mocha framework" do
+ it "should should be made available by saying config.mock_with :mocha" do
+ m = mock()
+ m.expects(:msg).with("arg")
+ m.msg
+ end
+ it "should should be made available by saying config.mock_with :mocha" do
+ o = Object.new
+ o.expects(:msg).with("arg")
+ o.msg
+ end
+ end
+end
diff --git a/vendor/gems/rspec-1.3.1/examples/failing/mocking_with_rr.rb b/vendor/gems/rspec-1.3.1/examples/failing/mocking_with_rr.rb
new file mode 100644
index 000000000..0d2b4fe04
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/examples/failing/mocking_with_rr.rb
@@ -0,0 +1,27 @@
+# stub frameworks like to gum up Object, so this is deliberately
+# set NOT to run so that you don't accidentally run it when you
+# run this dir.
+
+# To run it, stand in this directory and say:
+#
+# RUN_RR_EXAMPLE=true ruby ../bin/spec mocking_with_rr.rb
+
+if ENV['RUN_RR_EXAMPLE']
+ Spec::Runner.configure do |config|
+ config.mock_with :rr
+ end
+ describe "RR framework" do
+ it "should should be made available by saying config.mock_with :rr" do
+ o = Object.new
+ mock(o).msg("arg")
+ o.msg
+ end
+ it "should should be made available by saying config.mock_with :rr" do
+ o = Object.new
+ mock(o) do |m|
+ m.msg("arg")
+ end
+ o.msg
+ end
+ end
+end
diff --git a/vendor/gems/rspec-1.3.1/examples/failing/partial_mock_example.rb b/vendor/gems/rspec-1.3.1/examples/failing/partial_mock_example.rb
new file mode 100644
index 000000000..7f8d081b1
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/examples/failing/partial_mock_example.rb
@@ -0,0 +1,18 @@
+class MockableClass
+ def self.find id
+ return :original_return
+ end
+end
+
+describe "A partial mock" do
+
+ it "should work at the class level (but fail here due to the type mismatch)" do
+ MockableClass.should_receive(:find).with(1).and_return {:stub_return}
+ MockableClass.find("1").should equal(:stub_return)
+ end
+
+ it "should revert to the original after each spec" do
+ MockableClass.find(1).should equal(:original_return)
+ end
+
+end
diff --git a/vendor/gems/rspec-1.3.1/examples/failing/pending_example.rb b/vendor/gems/rspec-1.3.1/examples/failing/pending_example.rb
new file mode 100644
index 000000000..825af2ed1
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/examples/failing/pending_example.rb
@@ -0,0 +1,7 @@
+describe "pending example (which is fixed)" do
+ it %Q|reports "FIXED ... Expected ... to fail. No Error was raised."| do
+ pending("for some reason") do
+ # success
+ end
+ end
+end
diff --git a/vendor/gems/rspec-1.3.1/examples/failing/predicate_example.rb b/vendor/gems/rspec-1.3.1/examples/failing/predicate_example.rb
new file mode 100644
index 000000000..aed8b14bd
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/examples/failing/predicate_example.rb
@@ -0,0 +1,32 @@
+class BddFramework
+ def intuitive?
+ true
+ end
+
+ def adopted_quickly?
+ #this will cause failures because it reallly SHOULD be adopted quickly
+ false
+ end
+end
+
+describe "BDD framework" do
+
+ before(:each) do
+ @bdd_framework = BddFramework.new
+ end
+
+ it "should be adopted quickly" do
+ #this will fail because it reallly SHOULD be adopted quickly
+ @bdd_framework.should be_adopted_quickly
+ end
+
+ it "should be intuitive" do
+ @bdd_framework.should be_intuitive
+ end
+
+ it "should not respond to test" do
+ #this will fail
+ @bdd_framework.test
+ end
+
+end
diff --git a/vendor/gems/rspec-1.3.1/examples/failing/raising_example.rb b/vendor/gems/rspec-1.3.1/examples/failing/raising_example.rb
new file mode 100644
index 000000000..e40b51ec8
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/examples/failing/raising_example.rb
@@ -0,0 +1,47 @@
+describe "This example" do
+
+ it "should show that a NoMethodError is raised but an Exception was expected" do
+ proc { ''.nonexistent_method }.should raise_error
+ end
+
+ it "should pass" do
+ proc { ''.nonexistent_method }.should raise_error(NoMethodError)
+ end
+
+ it "should show that a NoMethodError is raised but a SyntaxError was expected" do
+ proc { ''.nonexistent_method }.should raise_error(SyntaxError)
+ end
+
+ it "should show that nothing is raised when SyntaxError was expected" do
+ proc { }.should raise_error(SyntaxError)
+ end
+
+ it "should show that a NoMethodError is raised but a Exception was expected" do
+ proc { ''.nonexistent_method }.should_not raise_error
+ end
+
+ it "should show that a NoMethodError is raised" do
+ proc { ''.nonexistent_method }.should_not raise_error(NoMethodError)
+ end
+
+ it "should also pass" do
+ proc { ''.nonexistent_method }.should_not raise_error(SyntaxError)
+ end
+
+ it "should show that a NoMethodError is raised when nothing expected" do
+ proc { ''.nonexistent_method }.should_not raise_error(Exception)
+ end
+
+ it "should show that the wrong message was received" do
+ proc { raise StandardError.new("what is an enterprise?") }.should raise_error(StandardError, "not this")
+ end
+
+ it "should show that the unexpected error/message was thrown" do
+ proc { raise StandardError.new("abc") }.should_not raise_error(StandardError, "abc")
+ end
+
+ it "should pass too" do
+ proc { raise StandardError.new("abc") }.should_not raise_error(StandardError, "xyz")
+ end
+
+end
diff --git a/vendor/gems/rspec-1.3.1/examples/failing/syntax_error_example.rb b/vendor/gems/rspec-1.3.1/examples/failing/syntax_error_example.rb
new file mode 100644
index 000000000..c9bb90774
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/examples/failing/syntax_error_example.rb
@@ -0,0 +1,7 @@
+describe "when passing a block to a matcher" do
+ it "you should use {} instead of do/end" do
+ Object.new.should satisfy do
+ "this block is being passed to #should instead of #satisfy - use {} instead"
+ end
+ end
+end
diff --git a/vendor/gems/rspec-1.3.1/examples/failing/team_spec.rb b/vendor/gems/rspec-1.3.1/examples/failing/team_spec.rb
new file mode 100644
index 000000000..ab35b5274
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/examples/failing/team_spec.rb
@@ -0,0 +1,41 @@
+class Team
+ attr_reader :players
+ def initialize
+ @players = Players.new
+ end
+end
+
+class Players
+ def initialize
+ @players = []
+ end
+ def size
+ @players.size
+ end
+ def include? player
+ raise "player must be a string" unless player.is_a?(String)
+ @players.include? player
+ end
+end
+
+describe "A new team" do
+
+ before(:each) do
+ @team = Team.new
+ end
+
+ it "should have 3 players (failing example)" do
+ @team.should have(3).players
+ end
+
+ it "should include some player (failing example)" do
+ @team.players.should include("Some Player")
+ end
+
+ it "should include 5 (failing example)" do
+ @team.players.should include(5)
+ end
+
+ it "should have no players"
+
+end
diff --git a/vendor/gems/rspec-1.3.1/examples/failing/timeout_behaviour.rb b/vendor/gems/rspec-1.3.1/examples/failing/timeout_behaviour.rb
new file mode 100644
index 000000000..1a3615ff0
--- /dev/null
+++ b/vendor/gems/rspec-1.3.1/examples/failing/timeout_behaviour.rb
@@ -0,0 +1,5 @@
+describe "Something really slow" do
+ it "should be failed by RSpec when it takes longer than --timeout" do
+ sleep(2)
+ end
+end