@@ -45,20 +45,6 @@ def capture_stdout
4545 example_group . run
4646 expect ( example . exception ) . to be_nil
4747 end
48-
49- it "returns false for pending_fixed? if not pending fixed" do
50- example = example_group . example { fail }
51- example_group . run
52- expect ( example . exception ) . not_to be_pending_fixed
53- end
54-
55- it "returns true for pending_fixed? if pending fixed" do
56- example = example_group . example do
57- pending ( "fixed" ) { }
58- end
59- example_group . run
60- expect ( example . exception ) . to be_pending_fixed
61- end
6248 end
6349
6450 describe "when there is an explicit description" do
@@ -345,6 +331,22 @@ def run_and_capture_reported_message(group)
345331 message = run_and_capture_reported_message ( group )
346332 expect ( message ) . to be_nil
347333 end
334+
335+ it "leaves a raised exception unmodified (GH-1103)" do
336+ # set the backtrace, otherwise MRI will build a whole new object,
337+ # and thus mess with our expectations. Rubinius and JRuby are not
338+ # affected.
339+ exception = StandardError . new
340+ exception . set_backtrace ( [ ] )
341+
342+ group = RSpec ::Core ::ExampleGroup . describe do
343+ example { raise exception . freeze }
344+ end
345+ group . run
346+
347+ actual = group . examples . first . metadata [ :execution_result ] [ :exception ]
348+ expect ( actual . __id__ ) . to eq ( exception . __id__ )
349+ end
348350 end
349351 end
350352
@@ -370,6 +372,30 @@ def run_and_capture_reported_message(group)
370372 group . run
371373 expect ( blah ) . to be ( :success )
372374 end
375+
376+ context "with a block" do
377+ it "sets the example to pending if block fails" do
378+ group = RSpec ::Core ::ExampleGroup . describe do
379+ example do
380+ pending { expect ( 1 ) . to eq ( 2 ) }
381+ end
382+ end
383+ group . run
384+ expect ( group . examples . first . metadata [ :execution_result ] [ :status ] ) . to eq ( 'pending' )
385+ expect ( group . examples . first . metadata [ :execution_result ] [ :pending_fixed ] ) . to eq ( false )
386+ end
387+
388+ it "fails if block is fixed, i.e. does not raise" do
389+ group = RSpec ::Core ::ExampleGroup . describe do
390+ example do
391+ pending { }
392+ end
393+ end
394+ group . run
395+ expect ( group . examples . first . metadata [ :execution_result ] [ :status ] ) . to eq ( 'failed' )
396+ expect ( group . examples . first . metadata [ :execution_result ] [ :pending_fixed ] ) . to eq ( true )
397+ end
398+ end
373399 end
374400
375401 context "in before(:each)" do
0 commit comments