0

Rspec 2.14.2 を使用して、Rails 4.0 アプリのリクエスト仕様を作成しています。これらのテストを実行しようとすると、正しく動作しますが、コマンド ラインで次の非推奨の警告が表示されます。

DEPRECATION WARNING: ActionController::Integration is deprecated and will be removed, use ActionDispatch::Integration instead. 

私が言ったように、仕様は完全に機能し、この非推奨警告に対処するものをオンラインで見つけることができないため、私の仕様コードに問題があると推測されます。私のスペックファイルは次のとおりです

require 'spec_helper'

describe "Authenticating" do

  it "should create a new authentication" do
    expect {
      visit "/auth/developer"
    }.to change { Authentication.count }.by(1)
  end

  it "should create a new user" do
    expect {
      visit "/auth/developer"
    }.to change { User.count }.by(1)
  end

  it "should create a new device" do
    expect {
      visit "/auth/developer"
    }.to change { Device.count }.by(1)

    Device.last.registration_id.should_not be_nil
  end

  describe "with an existing user and authentication" do

    before do
      @test_user.authentications.create(:provider => "developer", :uid => "my@email.com")
    end

    it "shouldn't create a new authentication" do
      expect {
        visit "/auth/developer"
      }.not_to change { Authentication.count }.by(1)
    end

    it "shouldn't create a new user" do
      expect {
        visit "/auth/developer"
      }.not_to change { Authentication.count }.by(1)
    end

    it "should create a new device" do
      expect {
        visit "/auth/developer"
      }.to change { Device.count }.by(1)

      @test_user.devices.last.registration_id.should_not be_nil
    end

  end

end

もちろん、非推奨の警告はテストの実際の機能には影響しませんが、 を実行するたびに警告が表示されるのは非常に煩わしいのでrspec spec、本当に削除したいと思っています。

ありがとう!

4

3 に答える 3

1

Webratを使用していると思われます。答えは、Webrat から離れて Capybara に移行することです

現在、Webrat は 1 年近く更新されていません。

伝えられるところによると、それはGemfileを編集するのと同じくらい簡単です。ただし、現実的には、受け入れ仕様のかなりの部分を書き直さなければならない可能性があります (私が現在やらなければならないことです)。

あなたが Webrat に慣れている場合、gem 内の問題のあるコードはここにあるようです。いつでも修正して、プル リクエストを送信できます。

しかし、より更新された Capybara gem に移行することは、長期的にはより良い考えのようです。

于 2013-12-21T00:26:34.380 に答える
0

Webrat を使用していますか? その場合は、代わりに gemfile を Capybara に置き換えてみてください。これを行う場合は、次を spec_helper.rb の RSpec.configure ブロックの任意の場所に追加してください:

config.include Capybara::DSL

少なくとも、それが私にとって警告がなくなった理由です... M. HartlのRailsチュートリアルソースを詳しく調べているときに上記の行を取得しました。

于 2013-11-15T19:29:42.267 に答える