dchelimsky (owner)

Revisions

gist: 103147 Download_button fork
public
Public Clone URL: git://gist.github.com/103147.git
Embed All Files: show embed
failing_examples.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# excerpted from spec/spec/matchers/raise_error_spec.rb
 
  it "passes the error to the block" do
    error = nil
    lambda { non_existent_method }.should raise_error {|e|
      error = e
    }
    error.should be_an_instance_of(NameError)
  end
 
  it "should fail if named error is raised" do
    lambda {
      lambda { non_existent_method }.should_not raise_error(NameError)
    }.should fail_with(/expected no NameError, got #<NameError: undefined/)
  end
 
failures.txt #
1
2
3
4
5
6
7
8
9
10
1)
'should raise_error {|err| ... } passes the error to the block' FAILED
expected #<NoMethodError: undefined method `non_existent_method' for #<Spec::Example::ExampleGroup::Subclass_158:0xc08873>> to be an instance of NameError
/Users/david/projects/ruby/rspec-dev/example_rails_app/vendor/plugins/rspec/spec/spec/matchers/raise_error_spec.rb:29:
 
2)
'should_not raise_error(NamedError) should fail if named error is raised' FAILED
expected Spec::Expectations::ExpectationNotMetError with message matching /expected no NameError, got #<NameError: undefined/, got #<Spec::Expectations::ExpectationNotMetError: expected no NameError, got #<NoMethodError: undefined method `non_existent_method' for #<Spec::Example::ExampleGroup::Subclass_163:0x2774a4>>>
/Users/david/projects/ruby/rspec-dev/example_rails_app/vendor/plugins/rspec/spec/spec/matchers/raise_error_spec.rb:120: