現在、次の状況をテストする必要があるシナリオがあります。
- テキストフィールドに学校名を入力した場合。
- 次に、そのサブドメインのURLに移動する必要があります
例えば。xyz大学をテキストフィールドに入力すると、xz.lvh.me:3000になります。xyz大学の短縮名はデータベースに保存されているxzです。
ホームページ.feature機能:ホームページ大学のフィールドを確認する必要があります
Scenario Outline: Fill up universities
When i fillup university name "<name>"
Then it should go to their login page "<subdomain>"
Examples:
| name | subdomain |
| sp College | sp |
ホームページ.rb
When /^i fillup university name "([^"]*)"$/ do |name|
visit @@url
choose('institution_category_school')
fill_in "search_institution_name", :with => name
click_button "Go"
end
Then /^it should go to their login page "([^"]*)"$/ do |subdomain|
#so i need to check that produced url == "#{subdomain}.lvh.me:3000/"
end
以下は私の設定ファイルです。support / env.rb
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
require 'rspec'
Capybara.run_server = false
Capybara.default_driver = :selenium
Capybara.default_selector = :css
module Helpers
def without_resynchronize
page.driver.options[:resynchronize] = false
yield
page.driver.options[:resynchronize] = true
end
end
World(Capybara::DSL, Helpers)
@@url= "http://lvh.me:3000/"
Rails 3.1.1、キュウリ1.1.4、rspec2.8.0を使用