代码之家  ›  专栏  ›  技术社区  ›  brainfck

黄瓜替代固定器

  •  2
  • brainfck  · 技术社区  · 16 年前

    有趣的是,我用FixtureReplacement创建的数据无法从测试中访问。

    我为selenium添加了一个自己的rails环境,并为增强的selenium功能使用了自己的配置文件。 我的selenium配置文件设置为:

    Webrat.configure do |config|
      config.mode = :selenium
      config.application_environment = :selenium
    end
    
    Cucumber::Rails::World.use_transactional_fixtures = false
    
    require "database_cleaner"
    
    # Clean the database once when starting
    DatabaseCleaner.clean_with :truncation
    DatabaseCleaner.strategy = :truncation
    
    Before do
      DatabaseCleaner.start
      include FixtureReplacement
    end
    
    After do
      DatabaseCleaner.clean
    end
    
    # this is necessary to have webrat "wait_for" the response body to be available
    # when writing steps that match against the response body returned by selenium
    World(Webrat::Selenium::Matchers)
    

    我正在使用以下功能运行selenium功能:

    RAILS_ENV=selenium cucumber -p selenium features/enhanced/test.feature
    

    顺致敬意,

    2 回复  |  直到 16 年前
        1
  •  1
  •   Rodreegez    16 年前

    Before do
      require 'database_cleaner'
      require 'database_cleaner/cucumber'
      DatabaseCleaner.strategy = :truncation
    end
    

    使用Factory Girl时,这适用于我。

        2
  •  1
  •   Community Mohan Dere    9 年前

    以下内容修复了它: Cucumber + selenium fails randomly

    推荐文章