【文件属性】:
文件名称:rspec-dom-testing:使用RSpec for Rails 5进行DOM测试
文件大小:10KB
文件格式:ZIP
更新时间:2021-05-25 23:51:08
Ruby
RSpec DOM测试
将宝石移植到RSpec中,包括一些电池。
问题
Rails 5不推荐使用控制器测试,而倾向于集成测试。 在Rails 4和5,你可以写在期待assigns和render_template ,如:
get :index
expect ( assings ( :posts ) . size ) . to eq 2
expect ( assings ( :posts ) ) . to include post
expect ( response ) . to render_template ( "_post" )
在Rails 5中,您不能访问内部变量或模板,因为它是控制器的私有逻辑。
取而代之的是,现在您必须检查响应正文中是否有匹配的内容,例如:
get :index
expect ( response . body ) . to include "Pos
【文件预览】:
rspec-dom-testing-master
----.gitignore(87B)
----rspec-dom-testing.gemspec(1KB)
----bin()
--------setup(115B)
--------console(342B)
--------rake(364B)
--------rspec(372B)
----.travis.yml(71B)
----LICENSE.txt(1KB)
----spec()
--------rspec-dom-testing()
--------spec_helper.rb(118B)
----README.md(2KB)
----lib()
--------rspec-dom-testing.rb(37B)
--------rspec-dom-testing()
----Gemfile(113B)
----Rakefile(145B)