我应该使用Selenium还是Jasmine来测试RSpec的视图文件? [英] Should I use Selenium or Jasmine in order to test view files with RSpec?
问题描述
我正在使用Ruby on Rails 3.2.2,cucumber-rails-1.3.0,rspec-rails-2.8.1和capybara-1.1.2以及Selenium驱动程序。收到我的上一个问题的答案后我有一个疑问:我应该使用Selenium ruby-gem还是Jasmine ruby-gem来测试RSpec的视图文件?如果是的话,因为我已经在使用Selenium了测试使用Cucumber的视图文件的JavaScript,为什么(当使用RSpec测试时)我应该使用Jasmine而不是Selenium吗?也就是说,为什么要使用两个具有相同目的的红宝石并制作相同的东西?
I am using Ruby on Rails 3.2.2, cucumber-rails-1.3.0, rspec-rails-2.8.1 and capybara-1.1.2 with the Selenium driver. After receiving the answer to a my previous question I had a doubt: should I use the Selenium ruby-gem or the Jasmine ruby-gem in order to test view files with RSpec? If so, since I am already using Selenium in order to test JavaScript for view files with Cucumber, why (when testing with RSpec) should I use Jasmine instead of Selenium? That is, why to use two ruby-gems that have the same purpose and make the same things?
一般来说,实际上,你如何建议测试使用RSpec查看文件? ...但是,使用RSpec测试视图文件是正确的方法还是应该使用Cucumber测试?
推荐答案
我更喜欢使用selenium服务器,firefox中的selenium IDE记录和rspec的selenium客户端。
I prefer to use selenium server, the selenium IDE in firefox to record and selenium client for rspec.
selenium_helper.rb
selenium_helper.rb
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path(File.join(File.dirname(__FILE__),'../..','config','environment'))
require 'spec/autorun'
require 'spec/rails'
require 'factory_girl'
require 'rspec/instafail'
require "selenium/client"
Spec::Runner.configure do |config|
end
rspec_tester_file_spec.rb
rspec_tester_file_spec.rb
require "selenium/selenium_helper"
require "selenium/modules/loginator"
describe "tester" do
attr_reader :selenium_driver
alias :page :selenium_driver
before(:all) do
@verification_errors = []
@selenium_driver = Selenium::Client::Driver.new \
:host => "localhost",
:port => 4444,
:browser => "*firefox",
:url => "http://localhost:3000",
:timeout_in_second => 60
end
before(:each) do
@selenium_driver.start_new_browser_session
end
append_after(:each) do
@selenium_driver.close_current_browser_session
end
it "login and then try to search for stuff" do
@login.run_login(page)
page.click "link=CSR"
page.wait_for_page_to_load "30000"
page.type "id=isq_Name", "john smith"
page.click "css=input[type=\"submit\"]"
page.wait_for_page_to_load "30000"
page.is_text_present("Update")
page.is_text_present("Date")
page.is_text_present("PIN")
page.is_text_present("Name")
end
这篇关于我应该使用Selenium还是Jasmine来测试RSpec的视图文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!