开发者

rspec / rake issue - Rake::DSL global methods are clobbering my model somehow

开发者 https://www.devze.com 2023-04-06 00:25 出处:网络
I\'m working through the upgrade to 3.1, and hit a snag. I have a model (using Mongoid) that is having it\'s \'link\' method overwritten by Rake, apparently.I\'m getting this message:

I'm working through the upgrade to 3.1, and hit a snag.

I have a model (using Mongoid) that is having it's 'link' method overwritten by Rake, apparently. I'm getting this message:

WARNING: Global access to Rake DSL methods is deprecated.  Please include
...  Rake::DSL into classes and modules which use the Rake DSL methods.
WARNING: DSL method Profile#link called at /Users/jeffdeville/Documents/code/ruby/wg/app/models/profile.rb:62:in `block in eql?'

Because the method is resolving, I have no stacktrace or anything. This happens in my rspecs, but the problem does not happen in the console.

Gemfile is below.

Even if you don't know the answer, if you have any suggestions on how I'd even approach the debugging process here, that'd be fantastic.

-Jeff

source 'http://rubygems.org'

gem 'rails', "3.1.0"
gem 'rake'
gem 'mail'

gem 'compass', "~> 0.12.alpha.0"
gem 'jquery-rails'
gem 'haml-rails'
gem "html5-boilerplate"

gem 'mini_fb', :git => 'git://github.com/jeffdeville/mini_fb.git'
gem "json"
gem "bson"
gem "bson_ext"
gem 'sucker'
gem 'crack', :git => 'git://github.com/ericgj/crack.git'
gem 'hoptoad_notifier'
gem 'httparty'
gem 'facebooker2'
gem 'delayed_job'
gem 'delayed_job_mongoid'
gem 'unicorn'
gem 'hirefireapp'
gem 'mogli', :git => 'https://github.com/jeffdeville/mogli.git'
gem 'typhoeus'
gem 'koala'
gem 'foreman'
gem 'heroku'
gem 'rbing'
gem 'rmagick'
gem 'mini_magick'
gem 'aws-sdk'
gem 'mechanize'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails', "  ~> 3.1.0"
  gem 'coffee-rails', "~> 3.1.0"
  gem 'uglifier'
end

group :development, :test do
  gem 'awesome_print'
  gem 'pry'
end

group :development do
  gem 'rails3-generators'
    gem 'coffee-script'
    gem 'guard'
    gem 'guard-coffeescript'
    gem 'guard-livereload'
  gem 'guard-rspec'
  gem 'guard-spork'
  gem 'guard-bundler'
  gem 'mailcatcher'
  gem 'foreman'
end

group :test do
    gem "factory_girl_rails"
  gem 'fuubar'
  gem 'spork', '~> 0.9.0.rc'
    gem 'ruby-debug19'
    gem "rspec"
  gem "rspec-given"
    gem "rspec-rails"
  gem 'mocha'
  gem "bourne"
    gem 'webmock'
    gem 'vcr'
    gem 'jasmine'
    gem 'email_spec'
  gem 'timecop'
end

group :mac do
#  if RUBY_PLATFO开发者_JAVA技巧RM =~ /darwin/i
    gem 'rb-fsevent'
    gem 'growl'
#  end
end


I was having a similar problem when I did the following:

api_client = API::Client
api_model = 'task' #this is dynamic in reality...
api_client.send(api_model).list

Rake's Global DSL task method was clobbering the send for some reason but the call worked if I called it directly (without using send). In the end I just changed the dynamic call to an veal.

eval "api_client.#{api_model}.list"

It's slower but I'll change it back when they eventually remove the Global DSL from Rake.

HTH, YMMV ;-)

0

精彩评论

暂无评论...
验证码 换一张
取 消