Skip to content

pending and skip do not work in tests that include the reactor context #7

Open
@rdubya

Description

@rdubya

When trying to use skip or pending inside of examples, the examples do not function as expected. skip results in the call being ignored and the test appearing that it has passed and pending throws an exception. The following script should be able to be used to reproduce:

require 'async/rspec'

RSpec.describe 'test pending and skip' do
	include_context Async::RSpec::Reactor

	it 'should show as pending if skipped' do
		skip 'this should be skipped'
		expect(true).to be false
	end

	it 'should show as pending if pending is called' do
		pending 'this is pending'
		expect(true).to be false
	end
end

When I run it I get the following output:

test pending and skip
  should show as pending if skipped
  should show as pending if pending is called (FAILED - 1)

Failures:

  1) test pending and skip should show as pending if pending is called
     Failure/Error: pending 'this is pending'

     RuntimeError:
       `pending` may not be used outside of examples, such as in before(:context). Maybe you want `skip`?
     # /Users/rdubya/.rvm/gems/jruby-9.1.17.0/gems/rspec-core-3.8.0/lib/rspec/core/pending.rb:94:in `pending'
     # ./spec/test_spec.rb:107:in `block in (root)'
     # org/jruby/RubyBasicObject.java:1728:in `instance_exec'
     # /Users/rdubya/.rvm/gems/jruby-9.1.17.0/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:254:in `block in run'
     # /Users/rdubya/.rvm/gems/jruby-9.1.17.0/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:500:in `block in with_around_and_singleton_context_hooks'
     # /Users/rdubya/.rvm/gems/jruby-9.1.17.0/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:457:in `block in with_around_example_hooks'
     # /Users/rdubya/.rvm/gems/jruby-9.1.17.0/gems/rspec-core-3.8.0/lib/rspec/core/hooks.rb:464:in `block in run'
     # /Users/rdubya/.rvm/gems/jruby-9.1.17.0/gems/rspec-core-3.8.0/lib/rspec/core/hooks.rb:604:in `block in run_around_example_hooks_for'
     # /Users/rdubya/.rvm/gems/jruby-9.1.17.0/gems/rspec-core-3.8.0/lib/rspec/core/example.rb:342:in `call'
     # /Users/rdubya/.rvm/gems/jruby-9.1.17.0/gems/async-rspec-1.12.0/lib/async/rspec/reactor.rb:55:in `block in run_example'
     # /Users/rdubya/.rvm/gems/jruby-9.1.17.0/gems/async-1.15.1/lib/async/task.rb:199:in `block in make_fiber'

Finished in 0.1073 seconds (files took 2.97 seconds to load)
2 examples, 1 failure

Failed examples:

rspec ./spec/test_spec.rb:106 # test pending and skip should show as pending if pending is called

This was ran in the context of a full test suite so there is potentially something else at play, but the basic issue seems to be that RSpec.current_example is nil so it can't be flagged like it should be. The current example is stored on the thread so I'm guessing it has something to do with how the example is being ran in a different thread, but haven't tracked down exactly where the break is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions