I added the following lines to my spec_helper.rb file
require 'clearance/testing'
require 'clearance/shoulda_macros'
config.include Clearance::Shoulda::Helpers
But I'm getting the following error:
~/.rvm/gems/ruby-1.8.7-p357/gems/activesupport-3.0.10/lib/active_support/dependencies.rb
:239:in `require': no such file to load -- clearance/shoulda_macros (LoadError)
Running Ruby 1.8.7, Rails 3.0.9 with the latest Shoulda, Clearance, and RSpec-rails gems installed.
Any ideas?
Related
When I try running the rspec file of a task of my ruby application by using the command
rspec /Users/priyanshu.sahoo/Desktop/Fk/ltl-worker/spec/tasks/four_kites_common/background_job/tasks/calculate_auto_delivery_appointment_time_task_spec.rb
I get this error.
An error occurred while loading spec_helper. - Did you mean?
rspec ./spec/spec_helper.rb Failure/Error: require 'simplecov' LoadError: cannot load such file -- simplecov
#./spec/spec_helper.rb:1:in `<top (required)>' No examples found.
This is my first time working with a rails application. Can anyone help me resolve this?
I am using ruby 2.7.5p203, rails 4.2.11.1
I am trying to use the twitter-text-rb (https://github.com/twitter/twitter-text-rb) in my Rails 3 app.
I installed it using bundler and my gemfile - seemingly successfully - but when I try and include its autolink function in my Application Helper, like this:
require 'twitter-text'
module ApplicationHelper
include Twitter::Autolink
end
I get this error in the browser when I try to load the root of the app:
Routing Error
uninitialized constant Twitter::Autolink Try running rake routes for
more information on available routes.
I've followed these Troubleshooting Questions within the Ruby Gems manual but it doesn't seem to be either of the two likely issues that they suggest under "Why does require 'some_gem' fail?".
Here's the extract from when I followed their instructions from the root of my app using terminal:
manager$ gem list twitter-text
*** LOCAL GEMS ***
twitter-text (1.5.0)
manager$ ruby -rubygems -e 'require "twitter-text"'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:60:in `gem_original_require': no such file to load -- twitter-text (LoadError)
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:60:in `require'
from -e:1
manager$ gem contents --no-prefix twitter-text | grep lib
lib/twitter-text.rb
lib/twitter-text/autolink.rb
lib/twitter-text/deprecation.rb
lib/twitter-text/extractor.rb
lib/twitter-text/hit_highlighter.rb
lib/twitter-text/regex.rb
lib/twitter-text/rewriter.rb
lib/twitter-text/unicode.rb
lib/twitter-text/validation.rb
manager$ ruby -rubygems -e 'require "twitter-text"'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:60:in `gem_original_require': no such file to load -- twitter-text (LoadError)
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:60:in `require'
from -e:1
manager$ which ruby
/usr/bin/ruby
manager$ gem env | grep 'RUBY EXECUTABLE'
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
I'm using and handful of other gems in the app and haven't run into similar problems before.
I'm at a loss as what to try next. I'm pretty new to Ruby/Rails (and programming in general for that matter!) so any help would be much appreciated.
thanks,
Matt
I've now got this gem working and removed the Load Error (although I can't say for sure what went right).
I installed RVM and tried my app and the twitter_gem using Ruby 1.9.2 and Rails 3.2.3. I was previously using the system default Ruby - 1.8.7 - and Rails 3.2.3. The gem was loaded correctly and worked perfectly.
So it seems like the problem was with the gem working on the earlier version of Ruby or RVM's gemsets helped the app to load the gem correctly.
I have an app build on 1.8.7 and I'm trying to start it on a system with 1.9.3
When I run script/server, I'm getting:
/usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- test/unit/error (LoadError)
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
My server script looks like this:
#!/usr/bin/env ruby
require File.expand_path('../../config/boot', __FILE__)
require 'commands/server
What am I missing?
Thanks
Thomas
You don't add the origin path of your test. Add in your script to improve the LOAD_PATH
#!/usr/bin/env ruby
$: << File.dirname(__FILE__) + '../..'
require File.expand_path('../../config/boot', __FILE__)
require 'commands/server
In my case, this error was due to I was trying to run a Rails 2.1.1 application with Ruby 2.0.0. I solved it by changing to Ruby 1.8.6, which was the one supported by Rails 2.1.1.
If you want to upgrade your Ruby version, you'll probably need to upgrade your Rails application as well. (Check this post for info about Ruby-Rails compatibility.)
I solved by removing the ../ path in the file /var/www/redmine-2.6.0/config/boot.rb
# Before
require File.expand_path('../../config/boot', __FILE__)
# After
require File.expand_path('../config/boot', __FILE__)
I hope it helps.
Marcos Rogerio
I have an application using Rails 2.3.4 which I'm trying to run. No matter how I start it, by using script/console or script/ferret_server, it always boils down to the same error:
uninitialized constant Gem
When I search online, I only find people who has a similar problem finding something inside of the Gem class. But in my case, Gem is just not there at all.
I am running Ruby on Ubuntu. I tried using the version of Ruby that came with APT and a more recent one with RVM. Nothing helped.
Any idea how what can be causing thing and how to fix it? Thanks in advance!
Some extra details, as requested by commenters:
Output of ruby -v:
ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2011.03
Output of gem -v:
1.8.6
Calling ruby script/console outputs a similar error (edited):
Loading development environment (Rails 2.3.4)
/var/www/sites/example.com/releases/20110726061310/config/environment.rb:12:NameError: uninitialized constant Gem
/usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/irb/init.rb:254:in `require': no such file to load -- console_app (LoadError)
from /usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/irb/init.rb:254:in `load_modules'
from /usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/irb/init.rb:252:in `each'
from /usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/irb/init.rb:252:in `load_modules'
from /usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/irb/init.rb:21:in `setup'
from /usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/irb.rb:54:in `start'
from /usr/local/rvm/rubies/ree-1.8.7-2011.03/bin/irb:17
I'm trying to call Ferret Server to allow Passenger to connect to it, with the command:
ruby --debug script/ferret_server -e production start
Outputs the following error:
Exception `NameError' at ./script/../vendor/plugins/acts_as_ferret/lib/../../../../config/environment.rb:12 - uninitialized constant Gem
uninitialized constant Gem
Alternatively, calling bundle exec ruby --debug script/ferret_server -e production start outputs the following error:
superclass mismatch for class GemDependency
Please note that I added the following right above the Rails::Initializer.run do |config| line in config/environment.rb:
require 'thread'
if Gem::VERSION >= "1.3.6"
module Rails
class GemDependency
def requirement
r = super
(r == Gem::Requirement.default) ? nil : r
end
end
end
end
require File.join(File.dirname(__FILE__), 'boot')
Remove the lines mentioned above gives uninitialized constant Rails errors instead.
Try putting:
require 'rubygems'
Just after require 'thread'
I have installed both shoulda and factory_girl, I can run shoulda just fine, but when I add this:
require 'factory_girl'
Factory.define :user do |u|
u.mail 'test#example.com'
u.pass 'secret'
end
to my test/test_helper.rb I'm getting this error:
/test/test_helper.rb:1:in `require': no such file to load -- factory_girl (LoadError)
when I execute rake test:units
I have installed both gems using:
sudo gem install thoughtbot-shoulda --source=http://gems.github.com
sudo gem install thoughtbot-factory_girl --source=http://gems.github.com
and can see both of them being installed fine.
And by the way, this works fine as well:
script/console
Loading development environment (Rails 2.3.8)
require 'factory_girl'
=> []
so requiring the gems seems to be working
Couple things to check:
Don't use --source=http://gems.github.com anymore. This has been deprecated in favor for gemcutter.org
Don't use "thoughtbot-gem_name" - again this was deprecated by gemcutter.org. Just do sudo gem install factory_girl shoulda
Make sure you have config.gem 'factory_girl' in your config/environments/test.rb file.
if you are using spork, make sure to restart it. Took me a few moments to realize that.