Running RSPEC in Ruby + Rails - ruby-on-rails

I am trying to run rspec in my rails app using the spec command- but I get the following error:
`require': cannot load such file -- spec/rails/example/helper_example_group_helper (LoadError)
I have had to deal already with missing 'helper' files, but it seems this one is not even in my app but in rails itself..
If I go ahead and create a helper_example_group_helper.rb file, then the error will appear regarding some other missing helper file inside Rails, ad infinitum.
The full log trace: http://pastie.org/pastes/3295692/text
The full gem list: http://pastie.org/pastes/3296070/text
I am running:
Ruby 1.9.3-p0
Rails 2.3.14
rspec 1.2.9 (gem)
rspec-rails 1.2.9 (gem)
Any help would be greatly appreciated!
Thanks

An old question but it's an issue I hit recently while upgrading a rails app. This issue is specific to Rails 2.3.x and ruby 1.9.3. There's a google groups thread about it here:
https://groups.google.com/forum/#!msg/rubyonrails-core/gb5woRkmDlk/iQ2G7jjNWKkJ%5B1-25%5D
The workaround is to add a file to config/initializers with the following:
MissingSourceFile::REGEXPS.push([/^cannot load such file -- (.+)$/i, 1])

Related

Rails 5.2 on Heroku - missing coffee_script

I have been using Rails 5.2 from the 5-2-stable branch of Rails to use ActiveStorage, now I am updating a bunch of apps to use the released version again. As mentioned in this issue the rails versions from Github all requires coffee_script. Now I want to remove coffee.
I cannot recreate this in my local environment or on CI, but when deploying to Heroku it fails with:
LoadError: cannot load such file -- coffee_script
/tmp/build_2b0eaffa6f7fd662e3233ac5b4de6d62/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
I cannot find any mention of coffee in my code.
Could this be a caching issue on Herkou or similar? Any clues are welcome.
Failing gemfile
https://github.com/fsek/voting/blob/50d063d16ae8d323f0cfe57e5bb6b4299c592019/Gemfile
Working gemfile (separate project, can be deployed)
https://github.com/pensionsupplysning/web/blob/cb256668640e38af4b59e8cf23fbfa939728abb7/Gemfile
Add the gem coffee-rails to your project or migrate to sprockets 4.x and make sure you follow this migration guide: https://github.com/rails/sprockets/blob/master/UPGRADING.md#manifestjs

Installing rspec-rails failing (trying to update to rails 4.0/ruby 2.0)

I am getting the following error message in the console after running
rails generate rspec:install
C:RailsInstaller\Ruby2.0.0\lib\ruby\gems\2.0.0\gems\sqlite3-1.3.7-x86-mingw32/lib/sqlite3.rb:6:in 'require' : cannot load such file -- sqlite3/sqlite3_native (LoadError)
followed by several more messages saying similar things, but instead of 'require', there are other messages like 'block', 'each', 'block in require', etc.
Any suggestions as to how to get this installed?
Thanks!
According to this bug report, this a problem with C compiling in Ruby 2.0.0. Try switching to Ruby 1.9.3

Rails not launching web page

I have just started to learn Ruby on Rails and in going through a tutorial I am not able to launch the rails project because of the following error.
-e:4:in `load': no such file to load -- script/server (LoadError)
from -e:4:in `<main>'
I have installed Ruby 1.9.2 and using RadRails as the IDE for creating and executing the Rails project. Any suggestions?
Most likely your tutorial refers to Rails 2 (for which given command works), while you're using Rails 3.
I'm not sure how exactly you start server in Rails 3 (edit see answer by jdl), but take my adice: find another tutorial. Otherwise, you'll have to create such questions here several times a day :)
If you just installed the latest Rails the the command has changed (as of Rails 3) to:
$ ./script/rails server
I think the best way to start a server in Rails 3 is to run this command from the root of the project:
rails server
You should have the rails executable in your path if you've installed the Rails 3 gem.

Rails gem error while trying to upgrade rails project to rails 3

While trying to upgrade rails project from rails 2.3.5 to rails 3.0.3 i get following error:-
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/site_ruby/1.8/rubygems.rb:230:in
activate': can't activate rails (=
2.3.5, runtime) for [], already activated rails-3.0.3 for []
(Gem::LoadError) from
/opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:35:in
require' from
./script/../config/boot.rb:54:in
load_initializer' from
./script/../config/boot.rb:38:inrun'
from ./script/../config/boot.rb:11:in
boot!' from
./script/../config/boot.rb:109 from
script/server:2:inrequire' from
script/server:2
The application is using ruby-enterprise-1.8.7. Can any one point out why rails 2.3.5 is being loaded, even though rails 3.0.3 is specified.
Thanks in advance,
Anubhaw
How did you upgrade? It looks like your config/boot.rb is unchanged, which means it will attempt to load Rails 2.3.5. There are significant changes in the files in the config directory between Rails 2 and 3.
In my experience it's easier to create a new Rails 3 application, and copy all functionality (models, controllers, views, tests, ...) to this new application. It'll save you trouble and can be done very quickly.

Errors when Generating Devise Views

I am developing a rails 3 application and I am using Devise for authentication. Everything seems to be working just fine, but when I try to generate the views using rails generate devise:views, I get a bunch of errors like this:
/Library/Ruby/Gems/1.8/gems/bundler-1.0.2/lib/bundler/shared_helpers.rb:2:in `require': no such file to load -- rubygems (LoadError)
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.2/lib/bundler/shared_helpers.rb:2
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.2/lib/bundler/setup.rb:1:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.2/lib/bundler/setup.rb:1
My default template engine is HAMl and I have the hpricot gem installed (as it says to do on the Devise github page).
Any ideas?
Thanks
Give it a shot with bundle exec:
bundle exec rails g devise:views
It turns out that it had something to do with my gems being stored in a different location than ruby. I'm not sure why it suddenly became a problem with that particular command. But re-installing rubygems seemed to do the trick.

Resources