Created
June 6, 2013 13:09
-
-
Save yoshitsugu/5721374 to your computer and use it in GitHub Desktop.
rspec + capybara で 非RailsのWebアプリをテスト ref: http://qiita.com/yoshitsugu/items/76e62ebff2ac244020a1
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 "https://rubygems.org" | |
gem "rspec" | |
gem "capybara-mechanize" , "1.0.1" |
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
# 設定 | |
# encoding: utf-8 | |
require 'capybara/mechanize' | |
require 'capybara/rspec' | |
# ref: http://stackoverflow.com/questions/18616683/why-do-i-get-including-capybaradsl-in-the-global-scope-is-not-recommended | |
RSpec.configure do |config| | |
config.include Capybara::DSL, :type => :feature | |
end | |
Capybara.app = "myapp" | |
Capybara.default_driver = :mechanize | |
Capybara.app_host = 'http://myapp.com' | |
Capybara.run_server = false |
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 File.dirname(__FILE__)+'/spec_helper' | |
describe 'テスト', :js => true do | |
it 'トップページ' do | |
visit "/" | |
page.should have_content("TOP PAGE") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment