2013-04-25 39 views

Trả lời

19

Giải pháp đạt được bằng cách sửa đổi tệp zeus.json của bạn để bao gồm một lệnh giao diện điều khiển mới sẽ chạy trong môi trường thử nghiệm mà tôi đã gọi là test_console.

Dưới đây là toàn bộ zeus.json tập tin của tôi, các bit có liên quan chỉ là một phần bắt đầu với "test_console":

{ 
    "command": "ruby -rubygems -r./custom_plan -eZeus.go", 

    "plan": { 
    "boot": { 
     "default_bundle": { 
     "development_environment": { 
      "prerake": {"rake": []}, 
      "runner": ["r"], 
      "console": ["c"], 
      "server": ["s"], 
      "generate": ["g"], 
      "destroy": ["d"], 
      "dbconsole": [] 
     }, 
     "test_environment": { 
      "cucumber_environment": {"cucumber": []}, 
      "test_helper": {"test": ["rspec", "testrb"]}, 
      "test_console": ["tc"] 
     } 
     } 
    } 
    } 
} 

Để kích hoạt test_console tuy nhiên, bạn sẽ cần phải tạo ra một kế hoạch tùy chỉnh trong custom_plan của bạn rb tập tin như sau:

require 'zeus/rails' 

class CustomPlan < Zeus::Rails 
    def default_bundle_with_test_env 
    ::Rails.env = 'test' 
    ENV['RAILS_ENV'] = 'test' 
    default_bundle 
    end 

    def test_console 
    console 
    end 
end 

Zeus.plan = CustomPlan.new 

Lưu ý default_bundle_with_test_env là cần thiết, như là phương pháp test_console được định nghĩa ở trên trong tệp zeus.json của bạn.

Cuối cùng, chạy: zeus test_console hoặc zeus tc

Các vấn đề liên quan