LoginSignup
4
4

More than 5 years have passed since last update.

PaperTrailをrspecで確認する

Last updated at Posted at 2016-10-07

paperTrailの挙動をrspecで確認しようとしたらうまくうごかなくてはまったのでメモ。
普通に書くとPaperTrail動かないっす。

rails_helper.rbにライブラリを追加

rails_helper.rb
# spec/rails_helper.rb
ENV["RAILS_ENV"] ||= 'test'
require 'spec_helper'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
...
require 'paper_trail/frameworks/rspec' #<-これを追加

テストをwith_versioningのブロックでかこむ

test_spec.rb
RSpec.describe V1::Admin::VersionsController, autodoc: true do

  describe "GET #index" do
    with_versioning do
      it "normal" do
        get "v1/admin/versions"
        expect(last_response.status).to eq(200)
      end
    end
  end

end

以上

参考

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4