Skip to content

Instantly share code, notes, and snippets.

@kurotaky
Last active December 11, 2015 03:19
Show Gist options
  • Select an option

  • Save kurotaky/4537170 to your computer and use it in GitHub Desktop.

Select an option

Save kurotaky/4537170 to your computer and use it in GitHub Desktop.
Web-driverを使ってリモートホストのテストをするサンプル
source :rubygems
gem 'rspec'
gem 'capybara'
gem 'rake'
-*- 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
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