How do I run specs for the activeadmin gem - ruby-on-rails

I am trying to run the specs for a local clone of the activeadmin gems current master.
I am using ruby 2.2.2 and have bundled successfully.
When I try to run one of the specs like so:
bundle exec rspec spec/unit/filters/humanized_spec.rb
I am getting the following error:
The git source https://github.com/jruby/activerecord-jdbc-adapter is not yet checked out. Please run `bundle install` before trying to start your application
Coverage report generated for RSpec to /Users/aljoscha/gem/activeadmin/coverage. 0.0 / 0.0 LOC (100.0%) covered.
/Users/aljoscha/gem/activeadmin/spec/rails_helper.rb:13:in `require': cannot load such file -- active_record (LoadError)
from /Users/aljoscha/gem/activeadmin/spec/rails_helper.rb:13:in `<top (required)>'
from /Users/aljoscha/gem/activeadmin/spec/unit/filters/humanized_spec.rb:1:in `require'
from /Users/aljoscha/gem/activeadmin/spec/unit/filters/humanized_spec.rb:1:in `<top (required)>'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `load'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `block in load_spec_files'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `each'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `load_spec_files'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:100:in `setup'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:86:in `run'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:71:in `run'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:45:in `invoke'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/gems/rspec-core-3.5.4/exe/rspec:4:in `<top (required)>'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/bin/rspec:22:in `load'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/bin/rspec:22:in `<main>'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `eval'
from /Users/aljoscha/.rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `<main>'
which I cannot make sense of.
Especially since activerecord-jdbc-adapter is not even in the Gemfile.
What am I missing?

Try prepending your command with bundle exec:
bundle exec rspec spec/unit/filters/humanized_spec.rb
It looks like you have a local version discrepancy causing issues.
If not, did you follow all of the steps listed on their contributing readme?
If you are still stuck, you may be experiencing an issue with bundler itself. First, try updating bundler then reinstalling gems and attempt to run rspec. If that doesn't work you may need to delete the bundle cache folder and start over.

I'm going to re-answer to emphasize how to test a gem using appraisal as mentioned in CONTIBUTING:
bundle exec appraisal install
bundle exec appraisal rails_50 rspec spec/unit/filters/humanized_spec.rb
Thank you for your interest in Active Admin.

Related

"bundle-exec-jekyll-serve" causes LoadError

I am a novice programmer trying to use a Jekyll theme for my Github blog. This is my first time using it... and I'm having problems with bundle exec jekyll serve command.
(FYI, I'm using Windows OS.)
Here's the output:
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/html.rb:10:in `require': cannot load such file -- rexml/parsers/baseparser (LoadError)
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/html.rb:10:in `<top (required)>'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown/html.rb:10:in `require'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown/html.rb:10:in `<top (required)>'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown/paragraph.rb:14:in `require'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown/paragraph.rb:14:in `<top (required)>'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown.rb:345:in `require'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown.rb:345:in `<class:Kramdown>'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown.rb:60:in `<module:Parser>'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown.rb:19:in `<module:Kramdown>'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown.rb:17:in `<top (required)>'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.8.6/lib/jekyll/converters/smartypants.rb:3:in `require'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.8.6/lib/jekyll/converters/smartypants.rb:3:in `<top (required)>'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.8.6/lib/jekyll.rb:13:in `require'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.8.6/lib/jekyll.rb:13:in `block in require_all'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.8.6/lib/jekyll.rb:12:in `each'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.8.6/lib/jekyll.rb:12:in `require_all'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.8.6/lib/jekyll.rb:194:in `<top (required)>'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.8.6/exe/jekyll:8:in `require'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/jekyll-3.8.6/exe/jekyll:8:in `<top (required)>'
from C:/Ruby30-x64/bin/jekyll:25:in `load'
from C:/Ruby30-x64/bin/jekyll:25:in `<main>'
I tried these 4 different solutions:
1.
bundle add webrick
But had the same error
(referenced bundle exec jekyll serve: cannot load such file)
gem install jekyll github-pages
gem install jekyll
gem install jekyll-feed
bundle update
But had the same error
3.
gem install webrick
gem install jekyll -mentions
Then added
group :jekyll_plugins do
gem "jekyll-mentions", "1.6.0"
gem "webrick"
end
to my gemfile, then
bundle install
But had the same error
(referenced https://github.com/jekyll/jekyll/issues/8523)
bundle add sdbm
bundle add webrick
bundle add net-telnet
bundle add xmlrpc
But had the same error.
Is there any way I can fix this situation?
From what I understand, Ruby moves all stdlib parts into gems, some are "default gems", as in, they are normally installed with Ruby and don't need a reference in your Gemfile, but some are "bundled gems" which also are installed with Ruby, but need a reference in Gemfile. The problem stems from a fact, that with every Ruby release, some "default gems" become "bundled gems".
Such a situation happened with webrick in the past.
In your case it's most likely that you need rexml, which just became a "bundled gem" in Ruby 3.0: https://stdgems.org/rexml/
All this about a theory, but a solution is pretty simple. You just need to do
bundle add rexml
and then bundle install.

Rails console in production: NameError: uninitialized constant

I have a rails app (rails 5). In development, everything work, when i use
rails console
And enter an instruction, for example User.all , it's working.
In production, my app work perfectly, no problems, no errors, but when i use rails console production and enter for example User.all i have an error :
NameError: uninitialized constant User
from (irb):2
from /home/alexandre/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/console.rb:65:in `start'
from /home/alexandre/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/console_helper.rb:9:in `start'
from /home/alexandre/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:78:in `console'
from /home/alexandre/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /home/alexandre/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
from /home/alexandre/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from /home/alexandre/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
from /home/alexandre/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from /home/alexandre/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
from /home/alexandre/tcheen/bin/rails:9:in `<top (required)>'
from /home/alexandre/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/commands/rails.rb:6:in `load'
from /home/alexandre/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/commands/rails.rb:6:in `call'
from /home/alexandre/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/command_wrapper.rb:38:in `call'
from /home/alexandre/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:191:in `block in serve'
from /home/alexandre/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:161:in `fork'
from /home/alexandre/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:161:in `serve'
from /home/alexandre/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:131:in `block in run'
from /home/alexandre/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:125:in `loop'
from /home/alexandre/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:125:in `run'
from /home/alexandre/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/application/boot.rb:19:in `<top (required)>'
from /home/alexandre/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/alexandre/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
I have the same problem with all my classes, but i repeat, the application work perfectly.
I develop on Mac OS and the app run in production on debian 8.
My models are correctly named i verified.
Thanks
I had this problem and realized it happened after I made a tweak to one of my job files.
What fixed it was restarting the spring loader. Just run
spring stop
Then the next time you run the rails console it should load things as normal.
I had this same issue, rewolf's answer above solved it for me temporarily.
Just to add to his answer:
After stopping the spring gem by running the command below
spring stop
You can also fix this issue permanently by upspringing (removing the spring gem from) your bin/ executables:
bin/spring binstub --remove --all
Or
spring binstub --remove --all
You can now run the command below to get into rails console in production
rails c --environment=production
Also, to avoid this from occurring in subsequent occasions endeavour to make sure that the spring gem is only present in development and test groups in your Gemfile.
Moreso, when you're in production make sure you always provide the --without development test argument to the bundle install command
bundle install --without development test
and not the usual or common
bundle install
Please note: As an indication, whenever you run the command rails c or rails console and you see the output below:
Running via Spring preloader in process 26651
WARNING: Spring is running in production. To fix this make sure the spring gem is only present in development and test groups in your Gemfile and make sure you always use bundle install --without development test in production
It's an indication that the spring gem is running in your production environment, and it should be stopped or removed entirely from your bin executables.
That's all.
I hope this helps

Unable to run Rake tasks, ci_reporter dependency missing

I am unable to any rake tasks within my Rails project. Any attempt to do so results in the following error, stating that it cannot locate an rspec file for ci_reporter:
rake aborted!
LoadError: cannot load such file -- ci/reporter/rake/rspec
/Users/blake/.rvm/gems/ruby-2.0.0-p643/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
/Users/blake/.rvm/gems/ruby-2.0.0-p643/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `block in require'
/Users/blake/.rvm/gems/ruby-2.0.0-p643/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/blake/.rvm/gems/ruby-2.0.0-p643/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
/Users/blake/workspaces/ruby/minestatus/Rakefile:6:in `<top (required)>'
/Users/blake/.rvm/gems/ruby-2.0.0-p643/bin/ruby_executable_hooks:15:in `eval'
I have made the following attempts to reset my environment to a working state:
Installing the newest ci_reporter gem from github
Deleting Gemfile.lock and re-running bundle install
Reinstalling Ruby 2.0.0 using rvm
Unfortunately none of the above things have helped me solve this issue. I am able to run rake tasks in other Rails projects, but not in this one. Rake tasks used to run just fine, and I'm not sure what changes I could've made to break things. Does anyone have an idea of what I can do to get rake tasks to run properly again?

You have already activated minitest 5.5.1, but your Gemfile requires minitest 4.7.5

rails server doesn't work with me, when I run rails s -p 3005, I got the following error:
Please report a bug if this causes problems.
/home/badrit-user/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:33:in `block in setup': You have already activated minitest 5.5.1, but your Gemfile requires minitest 4.7.5. Using bundle exec may solve this. (Gem::LoadError)
from /home/badrit-user/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/runtime.rb:19:in `setup'
from /home/badrit-user/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler.rb:120:in `setup'
from /home/badrit-user/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/setup.rb:7:in `<top (required)>'
from /home/badrit-user/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `require'
from /home/badrit-user/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `rescue in require'
from /home/badrit-user/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35:in `require'
from /home/badrit-user/work/seeloz_mobile/config/boot.rb:4:in `<top (required)>'
from /home/badrit-user/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:106:in `require'
from /home/badrit-user/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:106:in `require'
from /home/badrit-user/.rvm/gems/ruby-2.0.0-p247#seeloz_mobile/gems/railties-4.1.8/lib/rails/app_rails_loader.rb:42:in `block in exec_app_rails'
from /home/badrit-user/.rvm/gems/ruby-2.0.0-p247#seeloz_mobile/gems/railties-4.1.8/lib/rails/app_rails_loader.rb:32:in `loop'
from /home/badrit-user/.rvm/gems/ruby-2.0.0-p247#seeloz_mobile/gems/railties-4.1.8/lib/rails/app_rails_loader.rb:32:in `exec_app_rails'
from /home/badrit-user/.rvm/gems/ruby-2.0.0-p247#seeloz_mobile/gems/railties-4.1.8/lib/rails/cli.rb:5:in `<top (required)>'
from /home/badrit-user/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:58:in `require'
from /home/badrit-user/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:58:in `require'
from /home/badrit-user/.rvm/gems/ruby-2.0.0-p247#seeloz_mobile/gems/railties-4.1.8/bin/rails:9:in `<top (required)>'
from /home/badrit-user/.rvm/gems/ruby-2.0.0-p247#seeloz_mobile/bin/rails:23:in `load'
from /home/badrit-user/.rvm/gems/ruby-2.0.0-p247#seeloz_mobile/bin/rails:23:in `<main>'
And I checked my Gemfile.lock, I have already minitest (4.7.5).
It's weird, If I run this bundle exec rails s -p 3005, it's working, so Why this occurred ?
What's the solution to fix this issue ? (to run it using rails s)
as you can see from error message Using bundle exec may solve this.
bundle exec rails s -p 3005
It's weird, If I run this bundle exec rails s -p 3005, it's working,
so Why this occurred ?
Running a command with bundle exec at begin, launch gem what installed with a Gemfile from app directory, without bundle exec it is run gem what installed in to the system. As you can see you have success installed minitest 5.5.1 in system and minitest 4.7.5 in the Gemfile.
Ref
If you’re not using bundler’s binstubs with RVM integration yet, you should give it a try!
This means you don’t have to type bundle exec ever again.
Setup:
One time, run chmod +x $rvm_path/hooks/after_cd_bundler
Once for each project, run bundle install -—binstubs

rails console on openshift

I deployed my rails application to openshift it works well but I cannot run 'rails console' on production server. It gives me this error. How can I solve this? I tried to update rubygems but it also gives permission denied error and I couldn't make it too.
rails c error:
Warning: You're using Rubygems 1.8.24 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better startup performance.
/opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in `require': cannot load such file -- bundler/setup (LoadError)
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
from /var/lib/openshift/5429e72a500446dfee000197/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/spring-1.1.3/lib/spring/commands.rb:33:in `<module:Spring>'
from /var/lib/openshift/5429e72a500446dfee000197/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/spring-1.1.3/lib/spring/commands.rb:4:in `<top (required)>'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
from /var/lib/openshift/5429e72a500446dfee000197/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/spring-1.1.3/lib/spring/application.rb:77:in `preload'
from /var/lib/openshift/5429e72a500446dfee000197/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/spring-1.1.3/lib/spring/application.rb:140:in `serve'
from /var/lib/openshift/5429e72a500446dfee000197/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/spring-1.1.3/lib/spring/application.rb:128:in `block in run'
from /var/lib/openshift/5429e72a500446dfee000197/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/spring-1.1.3/lib/spring/application.rb:122:in `loop'
from /var/lib/openshift/5429e72a500446dfee000197/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/spring-1.1.3/lib/spring/application.rb:122:in `run'
from /var/lib/openshift/5429e72a500446dfee000197/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/spring-1.1.3/lib/spring/application/boot.rb:18:in `<top (required)>'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
from -e:1:in `<main>'
rubygems-update error:
[appname.rhcloud.com repo]\> update_rubygems
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /opt/rh/ruby193/root/usr/local/share/ruby
I ran into the same issue, try running it like this:
RAILS_ENV=production bundle exec rails console
Also make sure you are running it in ~/app-root/repo when you run it
To update rubygems:
gem update --system
If that doesn't solve the problem try Spring's suggestion and run:
gem pristine --all
The problem is that there are multiple bundle executables and the system is using the wrong one.
Locate the correct bundle executable. In my case it was located at ~/.gem/bin/bundle.
If you can't find it, install it gem install bundler.
Then run ~/.gem/bin/bundle exec rails console production inside ~/app-root/repo
I couldn't get any of the gem install or bundle exec solutions to work while running the 4.1.4 Rails cartridge on OpenShift. My solution was running RAILS_ENV=production bin/rails c in app-root/repo.

Resources