Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use RSpec example block argument instead of the global RSpec.current_example. This allows to run tests with the async-rspec gem. #117

Merged
merged 9 commits into from
Aug 5, 2021

Conversation

ArturT
Copy link
Member

@ArturT ArturT commented Jul 30, 2021

Use RSpec example from RSpec each hook instead of global RSpec.current_example. It allows running tests with async-rspec gem.

Related

#116

details

I noticed when I downgrade RSpec to 2.x version in the example repo https://github.com/KnapsackPro/rails-app-with-knapsack then we can't record tests due to bug:

rails-app-with-knapsack rspec-current-example-group! ruby-3.0.1
$ KNAPSACK_GENERATE_REPORT=true bundle exec rspec spec
Knapsack report generator started!
/Users/artur/.rvm/gems/ruby-3.0.1/gems/rspec-core-2.99.2/lib/rspec/core/hooks.rb:512:in `extract_scope_from': You must explicitly give a scope (:each, :all, or :suite) when using symbols as metadata for a hook. (ArgumentError)
	from /Users/artur/.rvm/gems/ruby-3.0.1/gems/rspec-core-2.99.2/lib/rspec/core/hooks.rb:505:in `scope_and_options_from'
	from /Users/artur/.rvm/gems/ruby-3.0.1/gems/rspec-core-2.99.2/lib/rspec/core/hooks.rb:483:in `register_hook'
	from /Users/artur/.rvm/gems/ruby-3.0.1/gems/rspec-core-2.99.2/lib/rspec/core/hooks.rb:328:in `prepend_before'
	from /Users/artur/Documents/github/knapsack-pro/knapsack/lib/knapsack/adapters/rspec_adapter.rb:9:in `block in bind_time_tracker'
	from /Users/artur/.rvm/gems/ruby-3.0.1/gems/rspec-core-2.99.2/lib/rspec/core.rb:154:in `configure'
	from /Users/artur/Documents/github/knapsack-pro/knapsack/lib/knapsack/adapters/rspec_adapter.rb:8:in `bind_time_tracker'
	from /Users/artur/Documents/github/knapsack-pro/knapsack/lib/knapsack/adapters/base_adapter.rb:19:in `bind'
	from /Users/artur/Documents/github/knapsack-pro/knapsack/lib/knapsack/adapters/base_adapter.rb:10:in `bind'
	from /Users/artur/Documents/github/knapsack-pro/rails-app-with-knapsack/spec/spec_helper.rb:8:in `<top (required)>'
	from /Users/artur/Documents/github/knapsack-pro/rails-app-with-knapsack/spec/rails_helper.rb:3:in `require'
	from /Users/artur/Documents/github/knapsack-pro/rails-app-with-knapsack/spec/rails_helper.rb:3:in `<top (required)>'
	from /Users/artur/.rvm/gems/ruby-3.0.1/gems/rspec-core-2.99.2/lib/rspec/core/configuration.rb:1036:in `require'
	from /Users/artur/.rvm/gems/ruby-3.0.1/gems/rspec-core-2.99.2/lib/rspec/core/configuration.rb:1036:in `block in setup_load_path_and_require'
	from /Users/artur/.rvm/gems/ruby-3.0.1/gems/rspec-core-2.99.2/lib/rspec/core/configuration.rb:1036:in `each'
	from /Users/artur/.rvm/gems/ruby-3.0.1/gems/rspec-core-2.99.2/lib/rspec/core/configuration.rb:1036:in `setup_load_path_and_require'
	from /Users/artur/.rvm/gems/ruby-3.0.1/gems/rspec-core-2.99.2/lib/rspec/core/configuration_options.rb:25:in `configure'
	from /Users/artur/.rvm/gems/ruby-3.0.1/gems/rspec-core-2.99.2/lib/rspec/core/command_line.rb:17:in `run'
	from /Users/artur/.rvm/gems/ruby-3.0.1/gems/rspec-core-2.99.2/lib/rspec/core/runner.rb:103:in `run'
	from /Users/artur/.rvm/gems/ruby-3.0.1/gems/rspec-core-2.99.2/lib/rspec/core/runner.rb:17:in `block in autorun'

It looks like we introduced breaking change for RSpec 2.x when we added context hook in PR #107

changes

  • As part of this PR we drop support for RSpec 2.x
  • we added support for async-rspec gem

@ArturT ArturT changed the title Use RSpec example from RSpec each hook instead of global RSpec.current_example. This allows running tests with async-rspec gem. Use RSpec example from RSpec each hook instead of global RSpec.current_example. It allows running tests with async-rspec gem. Jul 30, 2021
Copy link
Member

@shadre shadre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose to add similar lingo changes as in the correspondend PR from knapsack_pro

@ArturT ArturT changed the title Use RSpec example from RSpec each hook instead of global RSpec.current_example. It allows running tests with async-rspec gem. Use RSpec example block argument instead of the global RSpec.current_example. This allows to run tests with the async-rspec gem. Aug 5, 2021
@ArturT ArturT merged commit 2290374 into master Aug 5, 2021
@ArturT ArturT deleted the rspec-current-example-group branch August 5, 2021 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants