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:in `__script__'
kernel/common/eval19.rb:45:in `instance_eval'
./spec/support/sandboxed_mock_space.rb:33:in `run'
./spec/support/sandboxed_mock_space.rb:72:in `sandboxed'
./spec/support/sandboxed_mock_space.rb:32:in `run'
kernel/bootstrap/array19.rb:18:in `map'
kernel/bootstrap/array19.rb:18:in `map'
kernel/bootstrap/array19.rb:18:in `map'
./spec/rspec/core/formatters/html_formatter_spec.rb:37:in `Formatters'
kernel/common/hash19.rb:256:in `fetch'
./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters'
kernel/common/io.rb:217:in `open'
./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters'
kernel/common/dir.rb:92:in `chdir'
./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `Formatters'
kernel/common/eval19.rb:45:in `instance_eval'
kernel/bootstrap/proc.rb:22:in `call'
kernel/common/eval19.rb:45:in `instance_eval'
./spec/support/sandboxed_mock_space.rb:38:in `sandboxed'
kernel/common/eval19.rb:103:in `instance_exec'
kernel/bootstrap/proc.rb:22:in `call'
kernel/bootstrap/array19.rb:18:in `map'
kernel/bootstrap/array19.rb:18:in `map'
kernel/bootstrap/array19.rb:18:in `map'
kernel/bootstrap/proc.rb:22:in `call'
kernel/loader.rb:698:in `run_at_exits'
kernel/loader.rb:718:in `epilogue'
kernel/loader.rb:851:in `main'
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:in `__script__'
kernel/common/eval19.rb:45:in `instance_eval'
./spec/support/sandboxed_mock_space.rb:33:in `run'
./spec/support/sandboxed_mock_space.rb:72:in `sandboxed'
./spec/support/sandboxed_mock_space.rb:32:in `run'
kernel/bootstrap/array19.rb:18:in `map'
kernel/bootstrap/array19.rb:18:in `map'
./spec/rspec/core/formatters/html_formatter_spec.rb:37:in `Formatters'
kernel/common/hash19.rb:256:in `fetch'
./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters'
kernel/common/io.rb:217:in `open'
./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters'
kernel/common/dir.rb:92:in `chdir'
./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `Formatters'
kernel/common/eval19.rb:45:in `instance_eval'
kernel/bootstrap/proc.rb:22:in `call'
kernel/common/eval19.rb:45:in `instance_eval'
./spec/support/sandboxed_mock_space.rb:38:in `sandboxed'
kernel/common/eval19.rb:103:in `instance_exec'
kernel/bootstrap/proc.rb:22:in `call'
kernel/bootstrap/array19.rb:18:in `map'
kernel/bootstrap/array19.rb:18:in `map'
kernel/bootstrap/array19.rb:18:in `map'
kernel/bootstrap/proc.rb:22:in `call'
kernel/loader.rb:698:in `run_at_exits'
kernel/loader.rb:718:in `epilogue'
kernel/loader.rb:851:in `main'
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:in `__script__'
kernel/common/block_environment.rb:75:in `call_on_instance'
kernel/common/eval.rb:75:in `eval'
/Users/jon/.rvm/rubies/rbx-head/lib/19/erb.rb:838:in `result'
./spec/rspec/core/resources/formatter_specs.rb:41:in `__script__'
kernel/common/eval19.rb:45:in `instance_eval'
./spec/support/sandboxed_mock_space.rb:33:in `run'
./spec/support/sandboxed_mock_space.rb:72:in `sandboxed'
./spec/support/sandboxed_mock_space.rb:32:in `run'
kernel/bootstrap/array19.rb:18:in `map'
kernel/bootstrap/array19.rb:18:in `map'
./spec/rspec/core/formatters/html_formatter_spec.rb:37:in `Formatters'
kernel/common/hash19.rb:256:in `fetch'
./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters'
kernel/common/io.rb:217:in `open'
./spec/rspec/core/formatters/html_formatter_spec.rb:59:in `Formatters'
kernel/common/dir.rb:92:in `chdir'
./spec/rspec/core/formatters/html_formatter_spec.rb:58:in `Formatters'
kernel/common/eval19.rb:45:in `instance_eval'
kernel/bootstrap/proc.rb:22:in `call'
kernel/common/eval19.rb:45:in `instance_eval'
./spec/support/sandboxed_mock_space.rb:38:in `sandboxed'
kernel/common/eval19.rb:103:in `instance_exec'
kernel/bootstrap/proc.rb:22:in `call'
kernel/bootstrap/array19.rb:18:in `map'
kernel/bootstrap/array19.rb:18:in `map'
kernel/bootstrap/array19.rb:18:in `map'
kernel/bootstrap/proc.rb:22:in `call'
kernel/loader.rb:698:in `run_at_exits'
kernel/loader.rb:718:in `epilogue'
kernel/loader.rb:851:in `main'
-1# Couldn't get snippet for (erb)
fails with a backtrace containing an erb file n.nnnns
Exception
/foo.html.erb:1:in `<main>': foo (RuntimeError)
-1# Couldn't get snippet for /foo.html.erb