惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed

博客园 - Tachikoma

用Ruby实现 Web Service Server ,并用Ruby发送 HTTP请求 Web Service Android 使用 Ksoap2 出现的低级错误... - Tachikoma Cygwin中通过RJB在Ruby下调用ICTCLAS(JAVA) ICTCLAS4J 的编译脚本 Ruby Sandbox 实现运行客户代码 - Tachikoma Ruby在使用MongoDB时,对Cursor的重新包装 ruby 下使用 ICTCLAS(JAVA) RJB 在windows下的一些安装事项 Ruby手工测试正确,rcov测试失败的解决 在dell dimension 5150 上安装 leopard 手记 Rails测试中清空数据表/载入空fixtures RDoc 解决同名module 与 Class的问题 C 实用的 e-editor 的bundle Best of Ruby Quiz - Animal Quiz Best of Ruby Quiz - GEDCOM Parser Best of Ruby Quiz - MadLib - Tachikoma 使用selenium-on-rails的一些讨论 3]assertXpathCount的使用 使用selenium-on-rails的一些讨论 2]清理缓存 - Tachikoma - 博客园 关于 rails ActiveRecord 属性 以及 foreign_key 不直接用数据库项目 时的一些讨论
使用selenium-on-rails的一些讨论 [0,1]
Tachikoma · 2008-04-27 · via 博客园 - Tachikoma

这两天搞了一下selenium-on-rails, 作了一些讨论

0. 建议单独建立一个环境 selenium,用法见doc
0.1. 可以另开一个数据库用于selenium测试,但一般会用test库,以及测试夹具,但是有些只适合selenium测试的夹具,为了不影响其他测试,需要把这些夹具单独存放并保证不影响其他测试
举个例子[源自doc],建立空的夹具文件放在test/fixtures/blank下,然后http://localhost:3000/selenium/setup?fixtures=blank/* [可能需要转义一下],就会装载blank下的所有夹具,实际效果是讲数据库表清空

1. 关于测试夹具 fixtures 装入无效
有时会存在莫名其妙的无效问题,举个例子

open "/selenium/setup?fixtures=blank/*"
open 
"/selenium/setup?fixtures=all"  # => 这一行会失效

有时候第一行也可能直接失效
查看selenium-on-rails的源代码

 1#selenium-on-rails/lib/selenium-on-rails/fixture_loader.rb
 2
 3  def load_fixtures fixtures_param
 4    available = nil
 5    fixtures = fixtures_param.split(/\s*,\s*/).collect do |f|
 6      fixture_set = File.dirname f
 7      fixture_set = '' if fixture_set == '.'
 8      fixture = File.basename f
 9      if fixture == 'all'
10        available ||= available_fixtures
11        available[fixture_set]
12      else
13        f
14      end
15    end
16    fixtures.flatten!
17    fixtures.reject! {|f| f.blank? }
18
19    if fixtures.any?
20      # Fixtures.reset_cache  ## tachikmoma add
21      Fixtures.create_fixtures fixtures_path, fixtures
22    end
23    fixtures
24  end

第20行是我人为加入的,去掉其注释后问题可解决
原理:
在console里作了一下实验

 Fixtures.create_fixtures(File.join(RAILS_ROOT,"test/fixtures"),"teachers")  
#
=> 这句会成功

Fixtures.create_fixtures(File.join(RAILS_ROOT,
"test/fixtures"),"blank/teachers")
#
=> 这句和上句输出一样,并未把库清空

下面

Fixtures.create_fixtures(File.join(RAILS_ROOT,"test/fixtures"),"teachers")  
#
=> 这句会成功

Fixtures.reset_cache
#
=> 清空fixtures缓存,rails为了保证fixtures加载速度,启用了缓存机制

Fixtures.create_fixtures(File.join(RAILS_ROOT,
"test/fixtures"),"blank/teachers")
#
=> 清空库