运行rspec时出现Cassandra错误

时间:2016-05-24 23:19:54

标签: ruby-on-rails ruby rspec

blau08@BLAU08:~/Documents/Ruby/fieldfacts_api$ rspec
/home/blau08/.rvm/gems/ruby-2.1.2/gems/cequel-1.5.0/lib/cequel/record/railtie.rb:56:in `configuration': undefined method `deep_symbolize_keys' for nil:NilClass (NoMethodError)
from /home/blau08/.rvm/gems/ruby-2.1.2/gems/cequel-1.5.0/lib/cequel/record/railtie.rb:18:in `block in <class:Railtie>'
from /home/blau08/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/initializable.rb:30:in `instance_exec'
from /home/blau08/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/initializable.rb:30:in `run'
from /home/blau08/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/blau08/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
from /home/blau08/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
from /home/blau08/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
from /home/blau08/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
from /home/blau08/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each'
from /home/blau08/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `call'
from /home/blau08/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
from /home/blau08/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
from /home/blau08/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
from /home/blau08/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/initializable.rb:54:in `run_initializers'
from /home/blau08/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/application.rb:300:in `initialize!'
from /home/blau08/Documents/Ruby/fieldfacts_api/config/environment.rb:5:in `<top (required)>'
from /home/blau08/Documents/Ruby/fieldfacts_api/spec/rails_helper.rb:3:in `require'
from /home/blau08/Documents/Ruby/fieldfacts_api/spec/rails_helper.rb:3:in `<top (required)>'
from /home/blau08/Documents/Ruby/fieldfacts_api/spec/controllers/topic_posts_controller_spec.rb:1:in `require'
from /home/blau08/Documents/Ruby/fieldfacts_api/spec/controllers/topic_posts_controller_spec.rb:1:in `<top (required)>'
from /home/blau08/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1361:in `load'
from /home/blau08/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1361:in `block in load_spec_files'
from /home/blau08/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1359:in `each'
from /home/blau08/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1359:in `load_spec_files'
from /home/blau08/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:106:in `setup'
from /home/blau08/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:92:in `run'
from /home/blau08/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:78:in `run'
from /home/blau08/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:45:in `invoke'
from /home/blau08/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.4.4/exe/rspec:4:in `<top (required)>'
from /home/blau08/.rvm/gems/ruby-2.1.2/bin/rspec:23:in `load'
from /home/blau08/.rvm/gems/ruby-2.1.2/bin/rspec:23:in `<main>'
from /home/blau08/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
from /home/blau08/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'

SPEC - 以防人们想看。

require 'rails_helper'

RSpec.describe TopicPost, :type => :model do
  it "checks if twitter handle exists" do
     professional_safety = TopicPost.new(topic_id: "professional_safety", pub_date: "5a612420-21e2-11e6-bdf4-0800200c9a66",     author_id: 1, id: 1, message: "test", twitter_handle: "blau")
    professional_safety.save()
    expect(TopicPost.all.count).to eq(0)
  end
end

我真的不知道如何解决这个问题。我不确定它是否是续集,rspec或宝石问题。任何人都可以帮我理解这个吗?

感谢。

1 个答案:

答案 0 :(得分:0)

你必须在config / cequel.yml中确保它包含一个像这样的测试数据库。

development:
  host: '127.0.0.1'
  port: 9042
  keyspace: fieldfacts_discovery
  max_retries: 3
  retry_delay: 0.5
  replication:
    class: SimpleStrategy
    replication_factor: 1

test:
  host: '127.0.0.1'
  port: 9042
  keyspace: fieldfacts_test

uat:
  host: '10.0.1.228'
  port: 9042
  keyspace: fieldfacts_uat
  max_retries: 3
  retry_delay: 0.5
  newrelic: false
  replication:
    class: SimpleStrategy
    replication_factor: 1