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 n.nnnns
RSpec::Core::Pending::PendingExampleFixedError
./spec/rspec/core/resources/formatter_specs.rb:18
./spec/rspec/core/formatters/html_formatter_spec.rb:32:in `generated_html'
./spec/rspec/core/formatters/html_formatter_spec.rb:54
./spec/rspec/core/formatters/html_formatter_spec.rb:54:in `open'
./spec/rspec/core/formatters/html_formatter_spec.rb:54
./spec/rspec/core/formatters/html_formatter_spec.rb:53:in `chdir'
./spec/rspec/core/formatters/html_formatter_spec.rb:53
16  context "with content that would pass" do
17    it "fails" do
18      pending do
19        expect(1).to eq(1)
20      end
passing spec
passesn.nnnns
failing spec
fails n.nnnns
expected: 2
     got: 1

(compared using ==)
./spec/rspec/core/resources/formatter_specs.rb:33
./spec/rspec/core/formatters/html_formatter_spec.rb:32:in `generated_html'
./spec/rspec/core/formatters/html_formatter_spec.rb:54
./spec/rspec/core/formatters/html_formatter_spec.rb:54:in `open'
./spec/rspec/core/formatters/html_formatter_spec.rb:54
./spec/rspec/core/formatters/html_formatter_spec.rb:53:in `chdir'
./spec/rspec/core/formatters/html_formatter_spec.rb:53
31describe "failing spec" do
32  it "fails" do
33    expect(1).to eq(2)
34  end
35end
a failing spec with odd backtraces
fails with a backtrace that has no file n.nnnns
foo
(erb):1
-1# Couldn't get snippet for (erb)
fails with a backtrace containing an erb file n.nnnns
Exception
/foo.html.erb:1:in `
': foo (RuntimeError)
-1# Couldn't get snippet for /foo.html.erb