【问题标题】:Segmentation Fault when testing Sequel Model with Rspec使用 Rspec 测试 Sequel 模型时出现分段错误
【发布时间】:2014-05-23 19:47:11
【问题描述】:

我只是这样做

require 'spec_helper'

describe 'Donor' do
  it "does something" do
    d = Donor.new
    d.name = 'ABC'
  end
end

而且失败得很惨:

$> bundle exec rspec spec/tombamento/donor_spec.rb 2>&1 | head
/home/nerde/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/sequel-4.10.0/lib/sequel/model/base.rb:2094: [BUG] Segmentation fault at 0x00000000000018
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0020 p:0129 s:0090 e:000089 METHOD /home/nerde/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/sequel-4.10.0/lib/sequel/model/base.rb:2094
c:0019 p:0011 s:0084 e:000083 METHOD /home/nerde/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/sequel-4.10.0/lib/sequel/model/base.rb:1171
c:0018 p:0014 s:0076 e:000074 METHOD /home/nerde/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/sequel-4.10.0/lib/sequel/model/base.rb:850
c:0017 p:0026 s:0071 e:000069 BLOCK  /media/shared/home/git/unila/tombamento/spec/tombamento/donor_spec.rb:6 [FINISH]
...

我在 Sequel gem 中找到了跟踪点的行:

begin
  model.db.typecast_value(col_schema[:type], value)
rescue InvalidValue

调用model方法时出现问题。我使用了debugger 上面的行,我可以毫无错误地调用model

   2093          begin
   2094            debugger
=> 2095            model.db.typecast_value(col_schema[:type], value)
   2096          rescue InvalidValue
   2097            raise_on_typecast_failure ? raise : value
   2098          end
   2099        end
(rdb:1) model
Donor
(rdb:1) model.db.typecast_value(col_schema[:type], value)
"ABC"

我也可以在控制台中成功运行这段代码,但是在运行规范时它失败了。

感谢您的帮助。

【问题讨论】:

    标签: ruby rspec sequel


    【解决方案1】:

    重新安装 Ruby 解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-27
      • 2015-10-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多