# RSpec Results

Mocker
  should be able to call mock()
  should fail when expected message not received

      Mock 'poke me' expected :poke with (any args) once, but received it 0 times

      ./failing_examples/mocking_example.rb:13
      /Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50
      /Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46 :in `chdir'
      /Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46

      11  it "should fail when expected message not received" do
      12    mock = mock("poke me")
      13    mock.should_receive(:poke)
      14  end
      15

  should fail when messages are received out of order

      Mock 'one two three' received :three out of order

      ./failing_examples/mocking_example.rb:22
      /Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50
      /Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46 :in `chdir'
      /Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46

      20    mock.should_receive(:three).ordered
      21    mock.one
      22    mock.three
      23    mock.two
      24  end

  should get yelled at when sending unexpected messages

      Mock 'don't talk to me' expected :any_message_at_all with (no args) 0 times, but received it once

      ./failing_examples/mocking_example.rb:29
      /Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50
      /Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46 :in `chdir'
      /Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46

      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

  has a bug we need to fix

      Expected pending 'here is the bug' to fail. No Error was raised.

      ./failing_examples/mocking_example.rb:33
      /Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50
      /Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46 :in `chdir'
      /Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46

      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")

Running specs with --diff
  should print diff of different strings

      expected: "RSpec is a\nbehaviour driven development\nframework for Ruby\n",
           got: "RSpec is a\nbehavior driven development\nframework for Ruby\n" (using ==)
      Diff:
      @@ -1,4 +1,4 @@
       RSpec is a
      -behaviour driven development
      +behavior driven development
       framework for Ruby

      ./failing_examples/diffing_spec.rb:13
      /Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50
      /Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46 :in `chdir'
      /Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46

      11framework for Ruby
      12EOF
      13    usa.should == uk
      14  end

  should print diff of different objects' pretty representation

      expected <Animal
      name=bob,
      species=tortoise
      >
      , got <Animal
      name=bob,
      species=giraffe
      >
       (using .eql?)
      Diff:
      @@ -1,5 +1,5 @@
       <Animal
       name=bob,
      -species=tortoise
      +species=giraffe
       >

      ./failing_examples/diffing_spec.rb:34
      /Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:50
      /Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46 :in `chdir'
      /Users/david/projects/ruby/rspec/rspec/spec/spec/runner/formatter/spec_mate_formatter_spec.rb:46

      32    expected = Animal.new "bob", "giraffe"
      33    actual   = Animal.new "bob", "tortoise"
      34    expected.should eql(actual)
      35  end
      36end

A consumer of a stub
  should be able to stub methods on any Object

A stubbed method on a class
  should return the stubbed value
  should revert to the original method after each spec
  can stub! and mock the same message

A mock
  can stub!
  can stub! and mock
  can stub! and mock the same message

pending example (using pending method)
  should be reported as "PENDING: for some reason" (PENDING: for some reason)

pending example (with no block)
  should be reported as "PENDING: Not Yet Implemented" (PENDING: Not Yet Implemented)

pending example (with block for pending)
  should have a failing block, passed to pending, reported as "PENDING: for some reason" (PENDING: for some reason)