2012-07-26 4 views
1

저는 Ruby에 익숙하지 않아 뭔가를 알아 내는데 도움이 필요했습니다. 나는이 오류를 2 일 동안 지속했습니다. 나는 모든 것이 완벽하게 작동 할 연결 문제를 안다면 알아. 도와주세요.Errno :: ECONNREFUSED : 연결이 거부되었습니다 - connect (2) test_helper.rb

#의 test_helper.rb
$LOAD_PATH<< File.expand_path(__FILE__) 
ENV["RAILS_ENV"] = "test" 
require File.expand_path('../../config/environment', __FILE__) 
Rails.env='test' 
require 'rails/test_help' 
require 'action_view/test_case' 
require 'factory_girl' 
require 'capybara/rails' 
require 'capybara/dsl' 
require 'factories' 

DatabaseCleaner.strategy = :truncation 

class ActiveSupport::TestCase 
    # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. 
    # 
    # Note: You'll currently still have to declare fixtures explicitly in integration tests 
    # -- they do not yet inherit this setting 
    fixtures :all 

    include Devise::TestHelpers 


end 

class ActionController::TestCase 
    setup do 
    DatabaseCleaner.start 
    end 

    teardown do 
    DatabaseCleaner.clean  # Truncate the database 
    end 
end 


class ActionDispatch::IntegrationTest 
    # Make the Capybara DSL available in all integration tests 
    include Capybara::DSL 
    include Warden::Test::Helpers 
    include Capybara::RSpecMatchers 
    Warden.test_mode! 
    # Stop ActiveRecord from wrapping tests in transactions 
    self.use_transactional_fixtures = false 

    teardown do 
    DatabaseCleaner.clean  # Truncate the database 
    Capybara.reset_sessions! # Forget the (simulated) browser state 
    Capybara.use_default_driver # Revert Capybara.current_driver to Capybara.default_driver 
    end 

end 

class ActionController::TestCase 
    # include Devise::TestHelpers 
end 

require 'selenium-webdriver' 
module ::Selenium::WebDriver::Firefox 
    class Bridge 
    attr_accessor :speed 

    def execute(*args) 
     result = raw_execute(*args)['value'] 
     case speed 
     when :slow 
      sleep 0.3 
     when :medium 
      sleep 0.1 
     end 
     result 
    end 
    end 
end 

def set_speed(speed) 
    begin 
    page.driver.browser.send(:bridge).speed=speed 
    rescue 
    end 
end 
# 테스트/유닛/project_test.rb
require 'test_helper' 

class ProjectTest < ActiveSupport::TestCase 
    # test "the truth" do 
    # assert true 
    # end 

    setup do 
    DatabaseCleaner.start 
    @user = FactoryGirl.create(:user) 
    @company = FactoryGirl.create(:company, :name=>'MegaTesters') 
    @project = FactoryGirl.create(:project, :name=>'testProject', :budget=>100000) 
    assert @project.valid? 
    @sow = @project.contracts.create :name=>"first", :company=>@company, :type=>"Sow" 
    @invoice = @sow.invoices.create :amount=>25000 
    @payment = @invoice.payments.create :amount=>10000 

    end 

    teardown do 
    DatabaseCleaner.clean  # Truncate the database 
    end 

    test "remaining funds" do 

    end 
end 
#STACK 추적 :
bundle exec rake test:units TEST=test/unit/project_test.rb --trace 
(in /Users/higgs001/Sandbox/att-innovate/foundry_ledger) 
** Invoke test:units (first_time) 
** Invoke test:prepare (first_time) 
** Invoke db:test:prepare (first_time) 
** Invoke db:abort_if_pending_migrations (first_time) 
** Invoke environment (first_time) 
** Execute environment 
** Execute db:abort_if_pending_migrations 
** Execute db:test:prepare 
** Invoke db:test:load (first_time) 
** Invoke db:test:purge (first_time) 
** Invoke environment 
** Execute db:test:purge 
** Execute db:test:load 
** Invoke db:test:load_schema (first_time) 
** Invoke db:test:purge 
** Execute db:test:load_schema 
** Invoke db:schema:load (first_time) 
** Invoke environment 
** Execute db:schema:load 
NOTICE: CREATE TABLE will create implicit sequence "assignments_id_seq" for serial column "assignments.id" 
NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index "assignments_pkey" for table "assignments" 
NOTICE: CREATE TABLE will create implicit sequence "attachments_id_seq" for serial column "attachments.id" 
NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index "attachments_pkey" for table "attachments" 
NOTICE: CREATE TABLE will create implicit sequence "companies_id_seq" for serial column "companies.id" 
NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index "companies_pkey" for table "companies" 
NOTICE: CREATE TABLE will create implicit sequence "contracts_id_seq" for serial column "contracts.id" 
NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index "contracts_pkey" for table "contracts" 
NOTICE: CREATE TABLE will create implicit sequence "fundings_id_seq" for serial column "fundings.id" 
NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index "fundings_pkey" for table "fundings" 
NOTICE: CREATE TABLE will create implicit sequence "invoices_id_seq" for serial column "invoices.id" 
NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index "invoices_pkey" for table "invoices" 
NOTICE: CREATE TABLE will create implicit sequence "lockers_id_seq" for serial column "lockers.id" 
NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index "lockers_pkey" for table "lockers" 
NOTICE: CREATE TABLE will create implicit sequence "pages_id_seq" for serial column "pages.id" 
NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index "pages_pkey" for table "pages" 
NOTICE: CREATE TABLE will create implicit sequence "payments_id_seq" for serial column "payments.id" 
NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index "payments_pkey" for table "payments" 
NOTICE: CREATE TABLE will create implicit sequence "projects_id_seq" for serial column "projects.id" 
NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index "projects_pkey" for table "projects" 
NOTICE: CREATE TABLE will create implicit sequence "queue_classic_jobs_id_seq" for serial column "queue_classic_jobs.id" 
NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index "queue_classic_jobs_pkey" for table "queue_classic_jobs" 
NOTICE: CREATE TABLE will create implicit sequence "users_id_seq" for serial column "users.id" 
NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index "users_pkey" for table "users" 
NOTICE: CREATE TABLE will create implicit sequence "versions_id_seq" for serial column "versions.id" 
NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index "versions_pkey" for table "versions" 
** Execute test:prepare 
** Execute test:units 
Run options: --seed 14051 

# Running tests: 

E 

Finished tests in 0.802822s, 1.2456 tests/s, 0.0000 assertions/s. 

    1) Error: 
test_remaining_funds(ProjectTest): 
Errno::ECONNREFUSED: Connection refused - connect(2) 
    /Users/higgs001/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/http.rb:644:in `initialize' 
    /Users/higgs001/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/http.rb:644:in `open' 
    /Users/higgs001/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/http.rb:644:in `block in connect' 
    /Users/higgs001/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/timeout.rb:44:in `timeout' 
    /Users/higgs001/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/timeout.rb:89:in `timeout' 
    /Users/higgs001/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/http.rb:644:in `connect' 
    /Users/higgs001/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/http.rb:637:in `do_start' 
    /Users/higgs001/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/http.rb:626:in `start' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/rest-client-1.6.7/lib/restclient/request.rb:172:in `transmit' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/rest-client-1.6.7/lib/restclient/request.rb:64:in `execute' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/rest-client-1.6.7/lib/restclient/request.rb:33:in `execute' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/rest-client-1.6.7/lib/restclient.rb:72:in `post' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/tire-0.4.2/lib/tire/http/client.rb:19:in `post' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/tire-0.4.2/lib/tire/index.rb:80:in `store' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/tire-0.4.2/lib/tire/model/search.rb:134:in `block in update_index' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:403:in `_run__2302947893627650000__update_elasticsearch_index__985824136385614657__callbacks' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:405:in `__run_callback' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:385:in `_run_update_elasticsearch_index_callbacks' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/tire-0.4.2/lib/tire/model/search.rb:130:in `update_index' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/tire-0.4.2/lib/tire/model/callbacks.rb:21:in `block in included' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:471:in `_run__2302947893627650000__save__985824136385614657__callbacks' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:405:in `__run_callback' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:385:in `_run_save_callbacks' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:81:in `run_callbacks' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.6/lib/active_record/callbacks.rb:264:in `create_or_update' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.6/lib/active_record/persistence.rb:104:in `save!' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.6/lib/active_record/validations.rb:56:in `save!' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.6/lib/active_record/attribute_methods/dirty.rb:33:in `save!' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.6/lib/active_record/transactions.rb:246:in `block in save!' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.6/lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.6/lib/active_record/transactions.rb:208:in `transaction' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.6/lib/active_record/transactions.rb:293:in `with_transaction_returning_status' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/activerecord-3.2.6/lib/active_record/transactions.rb:246:in `save!' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/factory_girl-3.5.0/lib/factory_girl/configuration.rb:18:in `block in initialize' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/factory_girl-3.5.0/lib/factory_girl/evaluation.rb:15:in `[]' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/factory_girl-3.5.0/lib/factory_girl/evaluation.rb:15:in `create' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/factory_girl-3.5.0/lib/factory_girl/strategy/create.rb:12:in `block in result' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/factory_girl-3.5.0/lib/factory_girl/strategy/create.rb:9:in `tap' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/factory_girl-3.5.0/lib/factory_girl/strategy/create.rb:9:in `result' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/factory_girl-3.5.0/lib/factory_girl/factory.rb:42:in `run' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/factory_girl-3.5.0/lib/factory_girl/factory_runner.rb:23:in `block in run' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.6/lib/active_support/notifications.rb:125:in `instrument' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/factory_girl-3.5.0/lib/factory_girl/factory_runner.rb:22:in `run' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/factory_girl-3.5.0/lib/factory_girl/strategy_syntax_method_registrar.rb:19:in `block in define_singular_strategy_method' 
    /Users/higgs001/Sandbox/att-innovate/foundry_ledger/test/unit/project_test.rb:11:in `block in <class:ProjectTest>' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:429:in `_run__3361187329649106861__setup__985824136385614657__callbacks' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:405:in `__run_callback' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:385:in `_run_setup_callbacks' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:81:in `run_callbacks' 
    /Users/higgs001/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.6/lib/active_support/testing/setup_and_teardown.rb:35:in `run' 

1 tests, 0 assertions, 0 failures, 1 errors, 0 skips 
rake aborted! 
Command failed with status (1): [/Users/higgs001/.rvm/rubies/ruby-1.9.2-p32...] 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/file_utils.rb:53:in `block in create_shell_runner' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `call' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `sh' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `sh' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/file_utils.rb:82:in `ruby' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `ruby' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/testtask.rb:99:in `block (2 levels) in define' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:60:in `verbose' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/testtask.rb:98:in `block in define' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain' 
/Users/higgs001/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run' 
/Users/higgs001/.rvm/gems/[email protected]/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>' 
/Users/higgs001/.rvm/gems/[email protected]/bin/rake:19:in `load' 
/Users/higgs001/.rvm/gems/[email protected]/bin/rake:19:in `<main>' 
/Users/higgs001/.rvm/gems/ruby-1.9.2-p320/bin/ruby_noexec_wrapper:14:in `eval' 
/Users/higgs001/.rvm/gems/ruby-1.9.2-p320/bin/ruby_noexec_wrapper:14:in `<main>' 
Tasks: TOP => test:units  

답변

-1

ElasticSearch 구성 할 필요가있다. Lee Hambley에게 감사드립니다.

+0

이렇게하면 도움이되었습니다. 내 이마에 "L"이 있다는 뜻인가요 L : / –

1

조금 일반적인 답변입니다. localhost에 SMTP 서버가 없으므로 동일한 오류가 발생했습니다. RSpec은 단지 FactoryGirl.create (: user)의 줄에 Errno::ECONNREFUSED: Connection refused - Connection refused을 표시합니다. 조금 혼란 스럽지만 rspec을 실행하면 --backtrace을 추가하면 정확히 무슨 일이 발생하는지 알 수 있습니다.

관련 문제