undefined method `home' for Dir:Class - shapado

I follow the shapado install with http://gitorious.org/shapado/shapado/blobs/master/README,
and when I execute rake bootstrap RAILS_ENV=development,it will generate some warnings and errors
DEPRECATION WARNING: The InstanceMethods module inside ActiveSupport::Concern will be no longer included automatically. Please define instance methods directly in Mongoid::Criteria instead. (called from include at /usr/lib/ruby/gems/1.8/bundler/gems/mongoid_ext-edcb64748380/lib/mongoid_ext/criteria_ext.rb:15)
rake aborted!
undefined method `home' for Dir:Class
I am a newbie to ror,I am on the ubuntu-server 11.10 platform,so I don't know how resolve it

I solved it:
to get rid of the DEPRECATION WARNING,just comment the code in criteria_ext.rb:15 as its instruction
module InstanceMethods
end
my ubuntu11.10 will first my install 1.8.7,when I execute ruby -v,it will show me that the current ruby version is 1.8.7,so it is sure that Dir.home method is not exist in 1.8.7,so I remove the default ruby in /usr/bin/ruby, then execute rvm --default use 1.9.3-p125
it's not related with the shapado,it's only the ruby version of my mistaken

Related

`rake spec` fails with no error message

OS X Mavericks
Ruby 1.8.7
Rails 2.3.18
Rspec 1.3.2
Rspec-rails 1.3.4
Output of rake spec
$ rake spec
(in /Users/timosand/Dropbox/Development/epassi)
Please install RDoc 2.4.2+ to generate documentation.
DEPRECATION WARNING: Rake tasks in vendor/plugins/annotate_models/tasks, vendor/plugins/barcode_generator/tasks, vendor/plugins/crypted_authentication/tasks, vendor/plugins/oauth-plugin/tasks, vendor/plugins/tarantula/tasks, and vendor/plugins/ym4r_gm/tasks are deprecated. Use lib/tasks instead. (called from /usr/local/var/rbenv/versions/1.8.7-p375/lib/ruby/gems/1.8/gems/rails-2.3.18/lib/tasks/rails.rb:10)
DEPRECATION WARNING: ActiveSupport::Dependencies.load_paths is deprecated, please use autoload_paths instead. (called from /usr/local/var/rbenv/versions/1.8.7-p375/lib/ruby/gems/1.8/gems/carrierwave-0.4.10/lib/carrierwave.rb:84)
/Users/timosand/Dropbox/Development/epassi/config/initializers/oauth_consumers.rb:7: warning: already initialized constant VERSION
/Users/timosand/Dropbox/Development/epassi/lib/spreadsheet/format.rb:21: warning: already initialized constant COLORS
I have 45 spec files
$ find spec -name '*_spec.rb' | wc -l
45
I've added p __FILE_ to each spec and every filename gets printed. Still the actual tests are not run.
Any advice on how to solve this?
Here is my spec_helper.rb and one controller spec as an example

Updating from Rails 3.2.0 to 3.2.8 caused uninitialized constant Addressable

In a project I was given a task to update all gems to stable. We were using rails 3.2.0 and some other gems. After updating to version 3.2.8 all tests crushed and I wa to fix them, the last error is ActionView::Template::Error: uninitialized constant Addressable. I have a file with
module URIHelpers
class << self
...
def parse_url(url)
Addressable.URI.heuristic_parse(url)
end
...
end
end
When calling URIHelpers.parse_url(url) I'm getting the above error. Where could be a error?
I've got an answer by myself :) I was to add
require 'addressable/uri'
at the begging of the file. Before the update it was required somewhere in dependent gems and after it was out and i needed to add it to gemfile by myself and require it by hand.

CanCan ruby on rails error

I'm just starting a new project in Rails and I wanted to add some CanCan roles checking to app. What have I done:
1. Installed proper gem
2. Included in gemfile "cancan"
3. Created ability class
4. In my ApplicationController - added "check_authorization"
But still, I get
undefined local variable or method `authorize_resource' for ApplicationController:Class
or
undefined local variable or method `check_authorization' for ApplicationController:Class
error.
Somebody got any ideas what can be the reason why?
My cancan version is 1.6.7.
Gem version is 1.9.1
As the author #Animattronic said, restart your Rails server.

Rails 3 - How do I get Rspec spec/ & autotest to work?

I was all setup with Rspec and Autotest before I updated to Rails 3.
When running rspec spec/ I'm getting:
* spec/spec.opts is deprecated.
* please use ./.rspec or ~/.rspec instead.
I tried changed spec.opts to spec.rspec and running rspec spec/ again. But now I get a whole mess of warnings:
DEPRECATION WARNING: Use toplevel init.rb; rails/init.rb is deprecated:
DEPRECATION WARNING: reset_javascript_include_default is deprecated. Please manipulate config.action_view.javascript_expansions[:defaults] directly.
DEPRECATION WARNING: RAILS_ENV is deprecated. Please use ::Rails.env.
DEPRECATION WARNING: Use toplevel init.rb; rails/init.rb is deprecated:
DEPRECATION WARNING: You are using the old router DSL which will be removed in Rails 3.1. Please check how to update your routes file at: http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/.
Autotest isn't working either. I'm getting:
.rvm/rubies/ruby-1.9.2-p0/bin/ruby -I.:lib:test -rubygems -e "['test/unit', 'spec/integration/layout_links_spec.rb', 'test/unit/color_test.rb', 'test/functional/products_controller_test.rb', 'spec/integration/users_spec.rb', 'test/functional/colors_controller_test.rb', 'test/unit/product_test.rb', 'test/unit/helpers/products_helper_test.rb', 'test/unit/helpers/colors_helper_test.rb'].each { |f| require f }" | .rvm/gems/ruby-1.9.2-p0/gems/autotest-4.3.2/bin/unit_diff -u
:29:in require': no such file to load -- spec_helper (LoadError)
from <internal:lib/rubygems/custom_require>:29:inrequire'
from spec/integration/layout_links_spec.rb:1:in <top (required)>'
from <internal:lib/rubygems/custom_require>:29:inrequire'
from :29:in require'
from -e:1:inblock in '
from -e:1:in each'
from -e:1:in'
Any ideas?
The deprecation warnings are because of your upgrade to Rails 3, not because of RSpec. Rails 3 has a very different architecture, and the API has also changed significantly. Have you run your project through the rails_upgrade plugin? Also, check out the Rails 3 Release Notes for help on fixing the parts of your application that rely on deprecated functionality.
The second issue is probably because ruby 1.9.2 no longer puts the current directory on the load path. You'll need to manually include spec/ into the load path from your spec.opts.

Installing Mocha 0.9.7 in a Rails 2.3.3 project

I installed the Mocha 0.9.7 Rails plug-in using:
$ script/plugin install git://github.com/floehopper/mocha.git
(Just followed instruction in http://mocha.rubyforge.org/)
Then, I have the following set-up defined in my functional test
def setup
#controller.expects(:logged_in?).returns(true)
#controller.expects(:admin_user?).returns(true)
end
Running the test generates the ff. error:
NameError: uninitialized constant Mocha::Mockery::ImpersonatingName
/test/functional/xxxx_controller_test.rb:x:in `setup'
Before that, I see the ff. error at the top of the test log:
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/test_case.rb:12: warning: already initialized constant Mocha
This has led me to believe that I have an old version of Mocha somewhere in Ruby's or Rails' path. The problem is I can't find it.
Is my guess correct? If so, where is this old version of Mocha? Alternatively, how can I found out where it is?
According to http://selfamusementpark.com/blog/2009/07/30/rails233mochaconfusion/, my guess is not correct. The problem really is that Mocha is being loaded before the testing framework which is not what the former expects. The solution is to edit RAILS_ROOT/vendor/plugin/mocha/init.rb to comment out the ff. line:
require 'mocha'
Then, Mocha will have to be explicitly required in the test files or helpers to ensure that the testing framework will have been loaded beforehand.

Resources