Rails 3.2.3 uygulamasından bir dizi modeli ayıklamaya çalışıyorum, böylece uygulamalar arasında paylaşılan bir arabirim olarak kullanılabilirler. Bir gemide ActiveRecord modellerini test etmek?
bir modüle modeli taşındı ve ben gemfile içine RSpec ploppedmodule InviteInterface
class Invite < ActiveRecord::Base
belongs_to :user
end
def to_json; end;
def from_json; end;
end
lib/invite_interface/invite.rb içine koyun, başarıyla çalışan var, şu spec yarattı:
require 'spec_helper'
describe InviteInterface::EncounterSurvey do
it 'should belong to user' do
subject.should respond_to(:user)
end
end
Maalesef, etkin kayıt/rspec etkin bir bağlantı istediği için modelde rspec çalıştıramıyorum.
1) InviteInterface::Invite should belong to encounter survey set
Failure/Error: subject.should respond_to(:user)
ActiveRecord::ConnectionNotEstablished:
ActiveRecord::ConnectionNotEstablished
# /Users/justin/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:398:in `retrieve_connection'
# /Users/justin/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
# /Users/justin/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in `connection'
# /Users/justin/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/model_schema.rb:228:in `columns'
# /Users/justin/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/model_schema.rb:243:in `column_defaults'
ActiveRecord'ın bir DB bağlantısı aramasını nasıl engellerim?
sayesinde Yuri, ben sonuçta bu, harika özellikle –
benim için çalıştı. aşağıdan seçenek ile: veritabanı => ': bellek:' – ghayes
@juwiley deneyiminizden yola çıkarak minitest veya rspec kullanmalıyım. –