Last active
December 11, 2015 03:19
-
-
Save kurotaky/4537170 to your computer and use it in GitHub Desktop.
Web-driverを使ってリモートホストのテストをするサンプル
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| source :rubygems | |
| gem 'rspec' | |
| gem 'capybara' | |
| gem 'rake' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -*- coding: utf-8 -*- | |
| require 'spec_helper' | |
| describe "システム:ログイン" do | |
| before do | |
| visit 'http://example.com/' | |
| end | |
| context "ログインページ" do | |
| it 'ログイン失敗' do | |
| fill_in 'account', :with => 'kurotaky' | |
| fill_in 'password', :with => 'wrongpassword' | |
| click_on 'LOGIN' | |
| end | |
| it 'ログイン成功してメインページが表示されること' do | |
| fill_in 'account', :with => 'kurotaky' | |
| fill_in 'password', :with => 'password' | |
| click_on 'LOGIN' | |
| page.should have_content('メインページ') | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'capybara/rspec' | |
| require 'selenium-webdriver' | |
| Capybara.run_server = false | |
| Capybara.app_host = 'http://example.com/' | |
| Capybara.default_selector = :css | |
| Capybara.default_driver = :selenium | |
| RSpec.configure do |config| | |
| config.include Capybara::DSL | |
| end | |
| def login_as_staff | |
| visit 'http://example.com/' | |
| fill_in 'account', :with => 'kurotaky' | |
| fill_in 'password', :with => 'password' | |
| click_on 'LOGIN' | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment