Comments (10)
bundle exec rake
is roughly the same as bin/rake
, and has the same error:
RAILS_ENV=test KNAPSACK_PRO_RSPEC_SPLIT_BY_TEST_EXAMPLES=true bundle exec rake knapsack_pro:rspec
rake aborted!
NameError: uninitialized constant RSpec::Core::Version
/opt/rbenv/versions/2.7.2/bin/bundle:23:in `load'
/opt/rbenv/versions/2.7.2/bin/bundle:23:in `<main>'
Tasks: TOP => knapsack_pro:rspec
(See full trace by running task with --trace)
The rake loading stuff faster is a carefully designed bit of rails. :-)
This particular knapsack rake task gear would be loading in a parent process of the rspec spec_helper or rails_helper so those probably wouldn't have any effect either.
Maybe adding require 'rspec/core/version' inside of the method fast_and_slow_test_files_to_run right before RSpec::Core::Version::STRING check would be enough to fix the issue.
Yeah, that's what I was thinking! 👍
from knapsack_pro-ruby.
Another alternative which avoids requiring the file would be to look at the loaded spec version, which bundle exec ...
(or require "bundler/setup"
) sets up long before anything within the gem is required:
if adapter_class == KnapsackPro::Adapters::RSpecAdapter && KnapsackPro::Config::Env.rspec_split_by_test_examples?
unless Gem.loaded_specs["rspec-core"].version >= Gem::Version.new('3.3.0')
from knapsack_pro-ruby.
Thanks @ArturT!
from knapsack_pro-ruby.
A workaround is to insert a rake task dependency which requires the file:
sj26/knapsack-test@rspec-core-version-error...rspec-core-version-workaround
A fix is probably to add the require immediately before the usage within lib/knapsack_pro/base_allocator_builder.rb
from knapsack_pro-ruby.
Most likely you have not set RAILS_ENV=test and rspec is not loaded.
from knapsack_pro-ruby.
You can also ensure RSpec is in the test
and development
group in your Gemfile.
from knapsack_pro-ruby.
RAILS_ENV is set to test:
https://github.com/sj26/knapsack-test/blob/rspec-core-version-error/.buildkite/pipeline.yml#L16
rspec is in the test and development groups:
https://github.com/sj26/knapsack-test/blob/rspec-core-version-error/Gemfile#L8-L14
Are you expecting rails rake to have called Bundler.require
? It doesn't, on purpose, so that invoking rake is quick. If you want to load all gems and the rails environment then your take rask needs to depend on the environment
task. (In this case I don't think it should, the rspec child process should do that.)
from knapsack_pro-ruby.
That's interesting. You basically use knapsack_pro in a way that's not the default approach documented in README. Most people just use bundler:
bundle exec rake knapsack_pro:rspec
You use bin/rake
to load stuff faster and load Rails environment only if RSpec config (like spec_helper.rb or rails_helper.rb) decides to do it. I could imagine someone could have tests that don't depend on Rails environment and then the user doesn't have to load Rails environment so using bin/rake
makes more sense than bundle exec
because bin/rake
is faster.
Anyway. I didn't think about it before so I never covered the bin/rake
approach in the documentation that's why you encounter the issue.
from knapsack_pro-ruby.
Maybe adding require 'rspec/core/version'
inside of the method fast_and_slow_test_files_to_run
right before RSpec::Core::Version::STRING
check would be enough to fix the issue. I need to ensure we load rspec only when someone is running RSpec test runner.
from knapsack_pro-ruby.
I've released knapsack_pro 2.18.1 with a fix.
PR: #151
from knapsack_pro-ruby.
Related Issues (20)
- Lots of failures with rolify gem after 4.1 -> 5.0 bump HOT 12
- Docs need to specify ENV var to detect CI provider HOT 1
- Fail gracefully when there's no git HOT 8
- Running `git fetch --shallow-since` to fetch commit author log causes hang on Buildkite runners HOT 12
- rspec-core conflict HOT 4
- Running queue mode locally for troubleshooting with a small subset of tests, but with multiple batches HOT 6
- Does `rake knapsack_pro:rspec_test_example_detector` need to run if there aren't any slow specs? HOT 2
- Slow test analysis runs even when there's no slow tests HOT 2
- Disable example_status_persistence_file_path HOT 3
- Create a replication command on failed node HOT 2
- Incompatibility with rspec --options on 6.0+ HOT 11
- NoMethodError: undefined method `rspec_is_quitting' HOT 2
- NoMethodError: undefined method `rspec_is_quitting' for RSpec::Core::World HOT 1
- After upgrading to minitest 5.22.0 I get error status even if all test pass HOT 8
- NoMethodError: undefined method `keys' for nil HOT 20
- Failing RSpec tests on ~>7.0.0 HOT 9
- DataDog dropping RSpec tests with the knapsack_pro 7.x gem in Queue Mode HOT 1
- Knapsack v7 ignores run options defined in spec_helpers. HOT 3
- Ruby 3.3 support? HOT 3
- Simplecov doesnt work with Knapsack Pro 7.4 and minitest HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from knapsack_pro-ruby.