Тестирование мультидоменного приложения Rails 3 с помощью Capybara

Я хочу протестировать свое мультидоменное приложение RoR3.

Вот мой test_helper.rb

ENV["RAILS_ENV"] = "test"

require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'capybara/rails'
require 'blueprints'

class ActiveSupport::TestCase

end

class ActionDispatch::IntegrationTest
  include Capybara

  def host
    "http://#{subdomain}.lvh.me:3000"
  end

  def subdomain
    @subdomain ? @subdomain : 'demostore'
  end

  def visit(url)
    super("http://#{subdomain}.lvh.me:3000#{url}")
  end
end

И мой тест интеграции:

require 'test_helper'

class ProductsTest < ActionDispatch::IntegrationTest

  def setup
    @subdomain = 'demostore'
    # creating stuff
  end

  def teardown
    # deleting stuff
  end

  test "user views product list" do
    visit('/')
    assert page.has_css?('ul.product-listing')
    assert page.has_xpath?("//ul[@class='product-listing']/li", :count => 12)
  end

  test "user views product page" do
    product = Product.first

    visit('/')
    find(:xpath, "//ul[@class='product-listing']/li/a[1]").click
    save_and_open_page
  end

end

И я уверен, что ссылка существует. Возникла проблема с щелчком и заполнением.

click_link('Existent link title')

тоже не работает.

Думаю, у стандартного драйвера Capybara Rack :: Test могут быть проблемы с этим мультидоменным материалом?

9
задан dreake 18 January 2011 в 02:29
поделиться