我将一个应用升级到了Rails 6.1.0 (从6.0.3.3升级到Rails 6.1.0,方法是创建一个新的纯api应用,添加RSpec,然后手动复制所需的文件)。 当我运行RSpec时,我看到以下警告: DEPRECATION WARNING: connection_config is deprecated and will be removed from Rails 6.2 (Use
connection_db_config instead) (called from <top (required)> at
[...app/models/application_reco
我的测试文件中有:
controller.request.stub referer: 'bla'
这将生成弃用警告:
Using `stub` from rspec-mocks' old `:should` syntax without explicitly enabling the syntax is deprecated. Use the new `:expect` syntax or explicitly enable `:should` instead.
在控制器规格中设置request.referrer的正确方法是什么?提前谢谢。
我正在尝试理解弃用警告:
DEPRECATION WARNING: Initialization autoloaded the constants
ActionText::ContentHelper and ActionText::TagHelper.
Being able to do this is deprecated. Autoloading during initialization is
going
to be an error condition in future versions of Rails.
Reloading does not reboot the appli
我有一个控制器操作来排队发送一封电子邮件。我为该控制器操作编写了一个测试,在运行这些测试时,我收到了一个不推荐的警告:
弃用警告:使用DeliveryJob发送邮件和参数化::Delivery作业是不推荐的,将在Rails 6.1中删除。请改用MailDeliveryJob。
主计长:
def send_email
SubscriptionMailer.with(user_id: @user.id).send_welcome_email.deliver_later
end
SubscriptionMailer:
class SubscriptionMailer < Ap
当我运行rspec时收到以下警告:-
DEPRECATION WARNING: Using positional arguments in functional tests has been deprecated,
in favor of keyword arguments, and will be removed in Rails 5.1.
Deprecated style:
get :show, { id: 1 }, nil, { notice: "This is a flash message" }
New keyword style:
get :show, para
当我运行rspec时,当我使用Draper的be_decorated助手时,会收到一个弃用警告:
DEPRECATION WARNING: `named_routes.helpers` is deprecated, please use `route_defined?(route_name)` to see if a named route was defined.
我在用:
rspec 3.0.0
rspec-核心3.0.0
rspec-预期3.0.0
rspec-模拟3.0.0
rspec-rails 3.0.2
在运行rspec测试时,我将收到以下弃用警告
DEPRECATION WARNING: to_prepare is deprecated and will be removed from Rails 5.1 (use ActiveSupport::Reloader.to_prepare instead) (called from <top (required)> at /Users/Chris/Sites/golf_mentor/config/environment.rb:5)
我的environment.rb第5行
Rails.application.initialize!
如何
在即将升级到5.1的Rails 5.0.7应用程序中,我们希望将所有(许多)不推荐的警告都捕获到一个文件中。
RSpec3.9提供了一个非常清楚的示例,说明如何向文本文件发送推荐:
但这不管用:
# spec/spec_helper.rb
RSpec.configure do |config|
config.deprecation_stream = File.open('deprecations.txt', 'w')
end
当我运行一个没有警告的规范时(上面的代码),stdout会显示一堆:DEPRECATION WARNING: uniq is dep
假设您有一个参数化类和一个不推荐的构造函数,以及一个调用此构造函数的User类。在下面的示例中,使用菱形操作符,javac (Version11.0.11)不会产生弃用警告:
class DepTester<T> {
T t;
@Deprecated
public DepTester(T t) {
this.t = t;
}
}
class User {
DepTester<String> tester = new DepTester<>("This does not produce a w
我刚刚将一个项目升级到Rails 5.1.0,我看到了这个弃用警告。
DEPRECATION WARNING: The behavior of `attribute_changed?`
inside of after callbacks will be changing in the next version of Rails.
The new return value will reflect the behavior of calling the method
after `save` returned (e.g. the opposite of what it returns now
我用rails 6和haml-rails和rspec开始了一个简单的项目,我的基本测试在一个基本的get上失败了:home指向一个简单的haml模板-我真的不知道这是一个haml-rails,haml还是rspec的问题。 我得到的错误 # rspec spec/controllers/static_pages_controller_spec.rb
DEPRECATION WARNING: Single arity template handlers are deprecated. Template handlers must
now accept two parameters, the
在我的Rails应用程序中,运行guard init rspec时会收到此警告
Warning: you have a Gemfile, but you're not using bundler or
RUBYGEMS_GEMDEPS
14:54:15 - INFO - Writing new Guardfile to
/home/ubuntu/railsprojects/sillyfish/Guardfile 14:54:16 - INFO - rspec
guard added to Guardfile, feel free to edit it
我不明白它为什么会出现。无视这个警
我正在尝试使用。@Deprecated文档指出:“编译器在非推荐代码中使用或重写不推荐的程序元素时发出警告”。我认为这应该触发它,但它没有。javac版本的1.7.0_09和编译使用而不是使用-Xlint和-deprecation。
public class TestAnnotations {
public static void main(String[] args)
{
TestAnnotations theApp = new TestAnnotations();
theApp.thisIsDeprecated();
}
@Depreca