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
./lib/rspec/core/pending.rb:102 :in `pending'
./spec/rspec/core/resources/formatter_specs.rb:18 :in `__script__'
kernel/common/eval18.rb:45 :in `instance_eval'
./lib/rspec/core/example.rb:114 :in `run'
./lib/rspec/core/example.rb:254 :in `with_around_each_hooks'
./lib/rspec/core/example.rb:111 :in `run'
./lib/rspec/core/example_group.rb:388 :in `run_examples'
kernel/bootstrap/array18.rb:18 :in `map'
./lib/rspec/core/example_group.rb:384 :in `run_examples'
./lib/rspec/core/example_group.rb:369 :in `orig_run (run)'
./spec/spec_helper.rb:53 :in `run'
./lib/rspec/core/example_group.rb:370 :in `run'
kernel/bootstrap/array18.rb:18 :in `map'
./lib/rspec/core/example_group.rb:370 :in `orig_run (run)'
./spec/spec_helper.rb:53 :in `run'
./lib/rspec/core/command_line.rb:28 :in `run'
kernel/bootstrap/array18.rb:18 :in `map'
./lib/rspec/core/command_line.rb:28 :in `run'
./lib/rspec/core/reporter.rb:34 :in `report'
./lib/rspec/core/command_line.rb:25 :in `run'
./spec/rspec/core/formatters/text_mate_formatter_spec.rb:36 :in `Formatters'
./lib/rspec/core/let.rb:93 :in `let'
kernel/common/hash18.rb:196 :in `fetch'
./lib/rspec/core/let.rb:93 :in `let'
./spec/rspec/core/formatters/text_mate_formatter_spec.rb:58 :in `Formatters'
kernel/common/io.rb:217 :in `open'
./spec/rspec/core/formatters/text_mate_formatter_spec.rb:58 :in `Formatters'
kernel/common/dir.rb:92 :in `chdir'
./spec/rspec/core/formatters/text_mate_formatter_spec.rb:57 :in `Formatters'
kernel/common/eval18.rb:45 :in `instance_eval'
./lib/rspec/core/example.rb:114 :in `run'
./lib/rspec/core/example.rb:179 :in `run'
./spec/spec_helper.rb:102 :in `__script__'
kernel/common/eval18.rb:45 :in `instance_eval'
./spec/spec_helper.rb:59 :in `sandboxed'
./spec/spec_helper.rb:102 :in `__script__'
kernel/common/eval18.rb:106 :in `instance_exec'
./lib/rspec/core/extensions/instance_eval_with_args.rb:16 :in `instance_eval_with_args'
./lib/rspec/core/example.rb:247 :in `instance_eval_with_args'
./lib/rspec/core/hooks.rb:93 :in `run'
./lib/rspec/core/hooks.rb:91 :in `run'
./lib/rspec/core/hooks.rb:424 :in `run_hook'
./lib/rspec/core/example_group.rb:327 :in `run_around_each_hooks'
./lib/rspec/core/example.rb:256 :in `with_around_each_hooks'
./lib/rspec/core/example.rb:111 :in `run'
./lib/rspec/core/example_group.rb:388 :in `run_examples'
kernel/bootstrap/array18.rb:18 :in `map'
./lib/rspec/core/example_group.rb:384 :in `run_examples'
./lib/rspec/core/example_group.rb:369 :in `run'
./lib/rspec/core/example_group.rb:370 :in `run'
kernel/bootstrap/array18.rb:18 :in `map'
./lib/rspec/core/example_group.rb:370 :in `run'
./lib/rspec/core/command_line.rb:28 :in `run'
kernel/bootstrap/array18.rb:18 :in `map'
./lib/rspec/core/command_line.rb:28 :in `run'
./lib/rspec/core/reporter.rb:34 :in `report'
./lib/rspec/core/command_line.rb:25 :in `run'
./lib/rspec/core/runner.rb:77 :in `run'
./lib/rspec/core/runner.rb:17 :in `autorun'
kernel/loader.rb:697 :in `run_at_exits'
kernel/loader.rb:717 :in `epilogue'
kernel/loader.rb:850 :in `main'
100            teardown_mocks_for_rspec
101          end
102          raise PendingExampleFixedError.new if result
103        end
104        raise PendingDeclaredInExample.new(message)
passing spec
passesn.nnnns
failing spec
fails n.nnnns
expected: 2
     got: 1

(compared using ==)
/Users/alindeman/workspace/rspec-dev/repos/rspec-expectations/lib/rspec/expectations/fail_with.rb:33 :in `fail_with'
/Users/alindeman/workspace/rspec-dev/repos/rspec-expectations/lib/rspec/expectations/handler.rb:31 :in `handle_matcher'
/Users/alindeman/workspace/rspec-dev/repos/rspec-expectations/lib/rspec/expectations/expectation_target.rb:34 :in `to'
./spec/rspec/core/resources/formatter_specs.rb:33 :in `__script__'
kernel/common/eval18.rb:45 :in `instance_eval'
./lib/rspec/core/example.rb:114 :in `run'
./lib/rspec/core/example.rb:254 :in `with_around_each_hooks'
./lib/rspec/core/example.rb:111 :in `run'
./lib/rspec/core/example_group.rb:388 :in `run_examples'
kernel/bootstrap/array18.rb:18 :in `map'
./lib/rspec/core/example_group.rb:384 :in `run_examples'
./lib/rspec/core/example_group.rb:369 :in `orig_run (run)'
./spec/spec_helper.rb:53 :in `run'
./lib/rspec/core/command_line.rb:28 :in `run'
kernel/bootstrap/array18.rb:18 :in `map'
./lib/rspec/core/command_line.rb:28 :in `run'
./lib/rspec/core/reporter.rb:34 :in `report'
./lib/rspec/core/command_line.rb:25 :in `run'
./spec/rspec/core/formatters/text_mate_formatter_spec.rb:36 :in `Formatters'
./lib/rspec/core/let.rb:93 :in `let'
kernel/common/hash18.rb:196 :in `fetch'
./lib/rspec/core/let.rb:93 :in `let'
./spec/rspec/core/formatters/text_mate_formatter_spec.rb:58 :in `Formatters'
kernel/common/io.rb:217 :in `open'
./spec/rspec/core/formatters/text_mate_formatter_spec.rb:58 :in `Formatters'
kernel/common/dir.rb:92 :in `chdir'
./spec/rspec/core/formatters/text_mate_formatter_spec.rb:57 :in `Formatters'
kernel/common/eval18.rb:45 :in `instance_eval'
./lib/rspec/core/example.rb:114 :in `run'
./lib/rspec/core/example.rb:179 :in `run'
./spec/spec_helper.rb:102 :in `__script__'
kernel/common/eval18.rb:45 :in `instance_eval'
./spec/spec_helper.rb:59 :in `sandboxed'
./spec/spec_helper.rb:102 :in `__script__'
kernel/common/eval18.rb:106 :in `instance_exec'
./lib/rspec/core/extensions/instance_eval_with_args.rb:16 :in `instance_eval_with_args'
./lib/rspec/core/example.rb:247 :in `instance_eval_with_args'
./lib/rspec/core/hooks.rb:93 :in `run'
./lib/rspec/core/hooks.rb:91 :in `run'
./lib/rspec/core/hooks.rb:424 :in `run_hook'
./lib/rspec/core/example_group.rb:327 :in `run_around_each_hooks'
./lib/rspec/core/example.rb:256 :in `with_around_each_hooks'
./lib/rspec/core/example.rb:111 :in `run'
./lib/rspec/core/example_group.rb:388 :in `run_examples'
kernel/bootstrap/array18.rb:18 :in `map'
./lib/rspec/core/example_group.rb:384 :in `run_examples'
./lib/rspec/core/example_group.rb:369 :in `run'
./lib/rspec/core/example_group.rb:370 :in `run'
kernel/bootstrap/array18.rb:18 :in `map'
./lib/rspec/core/example_group.rb:370 :in `run'
./lib/rspec/core/command_line.rb:28 :in `run'
kernel/bootstrap/array18.rb:18 :in `map'
./lib/rspec/core/command_line.rb:28 :in `run'
./lib/rspec/core/reporter.rb:34 :in `report'
./lib/rspec/core/command_line.rb:25 :in `run'
./lib/rspec/core/runner.rb:77 :in `run'
./lib/rspec/core/runner.rb:17 :in `autorun'
kernel/loader.rb:697 :in `run_at_exits'
kernel/loader.rb:717 :in `epilogue'
kernel/loader.rb:850 :in `main'
31        end
32
33        raise(RSpec::Expectations::ExpectationNotMetError.new(message))
34      end
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/alindeman/.rvm/rubies/rbx-2.0.0-rc1/lib/18/erb.rb:719 :in `result'
./spec/rspec/core/resources/formatter_specs.rb:41 :in `__script__'
kernel/common/eval18.rb:45 :in `instance_eval'
./lib/rspec/core/example.rb:114 :in `run'
./lib/rspec/core/example.rb:254 :in `with_around_each_hooks'
./lib/rspec/core/example.rb:111 :in `run'
./lib/rspec/core/example_group.rb:388 :in `run_examples'
kernel/bootstrap/array18.rb:18 :in `map'
./lib/rspec/core/example_group.rb:384 :in `run_examples'
./lib/rspec/core/example_group.rb:369 :in `orig_run (run)'
./spec/spec_helper.rb:53 :in `run'
./lib/rspec/core/command_line.rb:28 :in `run'
kernel/bootstrap/array18.rb:18 :in `map'
./lib/rspec/core/command_line.rb:28 :in `run'
./lib/rspec/core/reporter.rb:34 :in `report'
./lib/rspec/core/command_line.rb:25 :in `run'
./spec/rspec/core/formatters/text_mate_formatter_spec.rb:36 :in `Formatters'
./lib/rspec/core/let.rb:93 :in `let'
kernel/common/hash18.rb:196 :in `fetch'
./lib/rspec/core/let.rb:93 :in `let'
./spec/rspec/core/formatters/text_mate_formatter_spec.rb:58 :in `Formatters'
kernel/common/io.rb:217 :in `open'
./spec/rspec/core/formatters/text_mate_formatter_spec.rb:58 :in `Formatters'
kernel/common/dir.rb:92 :in `chdir'
./spec/rspec/core/formatters/text_mate_formatter_spec.rb:57 :in `Formatters'
kernel/common/eval18.rb:45 :in `instance_eval'
./lib/rspec/core/example.rb:114 :in `run'
./lib/rspec/core/example.rb:179 :in `run'
./spec/spec_helper.rb:102 :in `__script__'
kernel/common/eval18.rb:45 :in `instance_eval'
./spec/spec_helper.rb:59 :in `sandboxed'
./spec/spec_helper.rb:102 :in `__script__'
kernel/common/eval18.rb:106 :in `instance_exec'
./lib/rspec/core/extensions/instance_eval_with_args.rb:16 :in `instance_eval_with_args'
./lib/rspec/core/example.rb:247 :in `instance_eval_with_args'
./lib/rspec/core/hooks.rb:93 :in `run'
./lib/rspec/core/hooks.rb:91 :in `run'
./lib/rspec/core/hooks.rb:424 :in `run_hook'
./lib/rspec/core/example_group.rb:327 :in `run_around_each_hooks'
./lib/rspec/core/example.rb:256 :in `with_around_each_hooks'
./lib/rspec/core/example.rb:111 :in `run'
./lib/rspec/core/example_group.rb:388 :in `run_examples'
kernel/bootstrap/array18.rb:18 :in `map'
./lib/rspec/core/example_group.rb:384 :in `run_examples'
./lib/rspec/core/example_group.rb:369 :in `run'
./lib/rspec/core/example_group.rb:370 :in `run'
kernel/bootstrap/array18.rb:18 :in `map'
./lib/rspec/core/example_group.rb:370 :in `run'
./lib/rspec/core/command_line.rb:28 :in `run'
kernel/bootstrap/array18.rb:18 :in `map'
./lib/rspec/core/command_line.rb:28 :in `run'
./lib/rspec/core/reporter.rb:34 :in `report'
./lib/rspec/core/command_line.rb:25 :in `run'
./lib/rspec/core/runner.rb:77 :in `run'
./lib/rspec/core/runner.rb:17 :in `autorun'
kernel/loader.rb:697 :in `run_at_exits'
kernel/loader.rb:717 :in `epilogue'
kernel/loader.rb:850 :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)
   from /lib/ruby/1.9.1/erb.rb:753 :in `eval'
-1# Couldn't get snippet for /foo.html.erb