2017-08-09 32 views
0

我使用rspec来测试我的模型,应该序列化一个json。 顺便说一句,这是在我的控制台显示错误rspec主动记录测试序列化错误

这是我的RSpec 需要“rails_helper”

RSpec.describe Image, type: :model do 
    it { should belong_to :user } 
    it { should serialize(:path) } 
end 

这是我的形象模型

class Image < ApplicationRecord 
    belongs_to :user 
    attr_accessor :imagepath_data 
    serialize :path, JSON 
    mount_uploader :path, ImageUploader 
end 

当我运行捆绑高管RSPEC其抛一个错误

Image should serialize :path 
Failure/Error: it { should serialize(:path) } 

NoMethodError: 
    undefined method `cast_type' for #<ActiveRecord::ConnectionAdapters::PostgreSQLColumn:0x000000064a81d8> 

任何人都可以解决是

+0

看起来这是在GitHub上的已知问题一个[PR](https://github.com/thoughtbot/shoulda-matchers/拉/ 965)15天前合并到他们的轨道5分支...看起来像宝石的最后一次更新是〜30天前,所以可能必须手工应用该补丁 –

回答