RSpec Code Examples

 

 

pending spec with no implementation
is pending (PENDING: Not Yet Implemented)
pending command with block format
with content that would fail
is pending (PENDING: No reason given)
with content that would pass
fails
RSpec::Core::PendingExampleFixedError
16  context "with content that would pass" do
17    it "fails" do
18      pending do
19        1.should eq(1)
20      end
passing spec
passes
failing spec
fails
expected: 2
     got: 1

(compared using ==)
31describe "failing spec" do
32  it "fails" do
33    1.should eq(2)
34  end
35end
a failing spec with odd backtraces
fails with a backtrace that has no file
foo
(erb):1:in `<main>'
./spec/rspec/core/resources/formatter_specs.rb:41 :in `block (2 levels) in <top (required)>'
./spec/rspec/core/formatters/text_mate_formatter_spec.rb:24 :in `block (2 levels) in <module:Formatters>'
./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47 :in `block (5 levels) in <module:Formatters>'
./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47 :in `open'
./spec/rspec/core/formatters/text_mate_formatter_spec.rb:47 :in `block (4 levels) in <module:Formatters>'
./spec/rspec/core/formatters/text_mate_formatter_spec.rb:46 :in `chdir'
./spec/rspec/core/formatters/text_mate_formatter_spec.rb:46 :in `block (3 levels) in <module:Formatters>'
-1# Couldn't get snippet for (erb)
fails with a backtrace containing an erb file
Exception
/foo.html.erb:1 :in `<main>': foo (RuntimeError)
-1# Couldn't get snippet for /foo.html.erb