Commit bb5cb4f7 by tady

passed capybara, polterguist, move to mysql

parent e9de798b
...@@ -20,3 +20,5 @@ ...@@ -20,3 +20,5 @@
/coverage/.* /coverage/.*
*.bk *.bk
/db/*.sql
...@@ -26,6 +26,8 @@ gem 'coffee-rails' ...@@ -26,6 +26,8 @@ gem 'coffee-rails'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder' gem 'jbuilder'
gem 'i18n_generators'
group :doc do group :doc do
# bundle exec rake doc:rails generates the API under doc/api. # bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false gem 'sdoc', require: false
...@@ -45,6 +47,9 @@ end ...@@ -45,6 +47,9 @@ end
# gem 'bootstrap-sass-rails' # gem 'bootstrap-sass-rails'
gem 'mysql2'
gem 'sqlite3'
gem 'devise' gem 'devise'
gem 'omniauth-google-oauth2' gem 'omniauth-google-oauth2'
...@@ -57,8 +62,6 @@ gem 'coderay' ...@@ -57,8 +62,6 @@ gem 'coderay'
group :development do group :development do
# Use sqlite3 as the database for Active Record # Use sqlite3 as the database for Active Record
gem 'sqlite3'
gem 'better_errors' gem 'better_errors'
gem 'binding_of_caller' gem 'binding_of_caller'
...@@ -74,24 +77,25 @@ group :development do ...@@ -74,24 +77,25 @@ group :development do
# rubocop # rubocop
gem 'rubocop' gem 'rubocop'
gem 'guard-rubocop' gem 'guard-rubocop'
end
group :development, :test do
gem 'rspec-rails'
gem 'guard-rspec' gem 'guard-rspec'
gem 'guard-spring' gem 'guard-spring'
gem 'factory_girl_rails'
gem 'spring' gem 'spring'
end end
# group :test do group :development, :test do
# gem 'email_spec' gem 'rspec-rails'
# end
# gem 'database_cleaner'
gem 'database_rewinder'
end
# group :production do group :test do
# gem 'rails_12factor' gem 'factory_girl_rails'
# gem 'pg' gem 'capybara'
# end gem 'launchy'
gem 'poltergeist'
gem 'coveralls', :require => false
end
# tree structure # tree structure
gem 'ancestry' gem 'ancestry'
...@@ -106,7 +110,3 @@ gem 'nokogiri' ...@@ -106,7 +110,3 @@ gem 'nokogiri'
gem 'premailer' gem 'premailer'
gem 'faraday' gem 'faraday'
group :test do
gem 'coveralls', :require => false
end
...@@ -54,8 +54,15 @@ GEM ...@@ -54,8 +54,15 @@ GEM
binding_of_caller (0.7.2) binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1) debug_inspector (>= 0.0.1)
builder (3.1.4) builder (3.1.4)
capybara (2.1.0)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
celluloid (0.15.2) celluloid (0.15.2)
timers (~> 1.1.0) timers (~> 1.1.0)
cliver (0.2.2)
coderay (1.1.0) coderay (1.1.0)
coffee-rails (4.0.1) coffee-rails (4.0.1)
coffee-script (>= 2.2.0) coffee-script (>= 2.2.0)
...@@ -73,6 +80,7 @@ GEM ...@@ -73,6 +80,7 @@ GEM
css_parser (1.3.5) css_parser (1.3.5)
addressable addressable
daemons (1.1.9) daemons (1.1.9)
database_rewinder (0.0.2)
debug_inspector (0.0.2) debug_inspector (0.0.2)
devise (3.2.2) devise (3.2.2)
bcrypt-ruby (~> 3.0) bcrypt-ruby (~> 3.0)
...@@ -82,6 +90,8 @@ GEM ...@@ -82,6 +90,8 @@ GEM
warden (~> 1.2.3) warden (~> 1.2.3)
diff-lcs (1.2.5) diff-lcs (1.2.5)
docile (1.1.1) docile (1.1.1)
domain_name (0.5.15)
unf (>= 0.0.5, < 1.0.0)
erubis (2.7.0) erubis (2.7.0)
eventmachine (1.0.3) eventmachine (1.0.3)
execjs (2.0.2) execjs (2.0.2)
...@@ -114,14 +124,21 @@ GEM ...@@ -114,14 +124,21 @@ GEM
hashie (2.0.5) hashie (2.0.5)
hike (1.2.3) hike (1.2.3)
htmlentities (4.3.1) htmlentities (4.3.1)
http-cookie (1.0.2)
domain_name (~> 0.5)
httpauth (0.2.0) httpauth (0.2.0)
i18n (0.6.9) i18n (0.6.9)
i18n_generators (1.2.1)
mechanize
rails (>= 3.0.0)
jbuilder (2.0.1) jbuilder (2.0.1)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
multi_json (>= 1.2.0) multi_json (>= 1.2.0)
json (1.8.1) json (1.8.1)
jwt (0.1.8) jwt (0.1.8)
multi_json (>= 1.5) multi_json (>= 1.5)
launchy (2.4.0)
addressable (~> 2.3)
listen (2.4.0) listen (2.4.0)
celluloid (>= 0.15.2) celluloid (>= 0.15.2)
rb-fsevent (>= 0.9.3) rb-fsevent (>= 0.9.3)
...@@ -130,14 +147,27 @@ GEM ...@@ -130,14 +147,27 @@ GEM
mail (2.5.4) mail (2.5.4)
mime-types (~> 1.16) mime-types (~> 1.16)
treetop (~> 1.4.8) treetop (~> 1.4.8)
mechanize (2.7.2)
domain_name (~> 0.5, >= 0.5.1)
http-cookie (~> 1.0.0)
mime-types (~> 1.17, >= 1.17.2)
net-http-digest_auth (~> 1.1, >= 1.1.1)
net-http-persistent (~> 2.5, >= 2.5.2)
nokogiri (~> 1.4)
ntlm-http (~> 0.1, >= 0.1.1)
webrobots (>= 0.0.9, < 0.2)
method_source (0.8.2) method_source (0.8.2)
mime-types (1.25.1) mime-types (1.25.1)
mini_portile (0.5.2) mini_portile (0.5.2)
minitest (4.7.5) minitest (4.7.5)
multi_json (1.8.2) multi_json (1.8.2)
multipart-post (1.2.0) multipart-post (1.2.0)
mysql2 (0.3.14)
net-http-digest_auth (1.4)
net-http-persistent (2.9)
nokogiri (1.6.1) nokogiri (1.6.1)
mini_portile (~> 0.5.0) mini_portile (~> 0.5.0)
ntlm-http (0.1.1)
oauth (0.4.7) oauth (0.4.7)
oauth2 (0.8.1) oauth2 (0.8.1)
faraday (~> 0.8) faraday (~> 0.8)
...@@ -158,6 +188,11 @@ GEM ...@@ -158,6 +188,11 @@ GEM
parser (2.0.0) parser (2.0.0)
ast (~> 1.1) ast (~> 1.1)
slop (~> 3.4, >= 3.4.5) slop (~> 3.4, >= 3.4.5)
poltergeist (1.4.1)
capybara (~> 2.1.0)
cliver (~> 0.2.1)
multi_json (~> 1.0)
websocket-driver (>= 0.2.0)
polyglot (0.3.3) polyglot (0.3.3)
powerpack (0.0.9) powerpack (0.0.9)
premailer (1.7.9) premailer (1.7.9)
...@@ -259,8 +294,15 @@ GEM ...@@ -259,8 +294,15 @@ GEM
uglifier (2.4.0) uglifier (2.4.0)
execjs (>= 0.3.0) execjs (>= 0.3.0)
json (>= 1.8.0) json (>= 1.8.0)
unf (0.1.3)
unf_ext
unf_ext (0.0.6)
warden (1.2.3) warden (1.2.3)
rack (>= 1.0) rack (>= 1.0)
webrobots (0.1.1)
websocket-driver (0.3.0)
xpath (2.0.0)
nokogiri (~> 1.3)
PLATFORMS PLATFORMS
ruby ruby
...@@ -270,19 +312,25 @@ DEPENDENCIES ...@@ -270,19 +312,25 @@ DEPENDENCIES
ancestry ancestry
better_errors better_errors
binding_of_caller binding_of_caller
capybara
coderay coderay
coffee-rails coffee-rails
coveralls coveralls
database_rewinder
devise devise
factory_girl_rails factory_girl_rails
faraday faraday
guard-rspec guard-rspec
guard-rubocop guard-rubocop
guard-spring guard-spring
i18n_generators
jbuilder jbuilder
launchy
mail mail
mysql2
nokogiri nokogiri
omniauth-google-oauth2 omniauth-google-oauth2
poltergeist
premailer premailer
pry-rails pry-rails
rack-mini-profiler rack-mini-profiler
......
...@@ -13,15 +13,15 @@ class Post < ActiveRecord::Base ...@@ -13,15 +13,15 @@ class Post < ActiveRecord::Base
query_list.each do |_query| query_list.each do |_query|
case _query case _query
when /^id:(.+)/ when /^id:(.+)/
_where_list = _where_list.where('id = ?', Regexp.last_match[1]) _where_list = _where_list.where(id: Regexp.last_match[1])
when /^title:(.+)/ when /^title:(.+)/
_where_list = _where_list.where('title LIKE ?', "%#{Regexp.last_match[1]}%") _where_list = _where_list.where('title LIKE ?', "%#{Regexp.last_match[1]}%")
when /^body:(.+)/ when /^body:(.+)/
_where_list = _where_list.where('body LIKE ?', "%#{Regexp.last_match[1]}%") _where_list = _where_list.where('body LIKE ?', "%#{Regexp.last_match[1]}%")
when /^@(.+)/ when /^@(.+)/
_where_list = _where_list.where('users.name = ?', Regexp.last_match[1]) _where_list = _where_list.where(users: { name: Regexp.last_match[1] })
when /^#(.+)/ when /^#(.+)/
_where_list = _where_list.where('tags.name = ?', Regexp.last_match[1]) _where_list = _where_list.where(tags: { name: Regexp.last_match[1] })
when /^date:(\d+)-(\d+)-(\d+)/ when /^date:(\d+)-(\d+)-(\d+)/
_date = Time.new(Regexp.last_match[1], Regexp.last_match[2], Regexp.last_match[3]) _date = Time.new(Regexp.last_match[1], Regexp.last_match[2], Regexp.last_match[3])
_where_list = _where_list.where('updated_at > ? AND updated_at < ?', _date, _date + 1.day) _where_list = _where_list.where('updated_at > ? AND updated_at < ?', _date, _date + 1.day)
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<div class="col-xs-12 col-sm-6 col-md-8"> <div class="col-xs-12 col-sm-6 col-md-8">
<div id="list_post"> <div id="list_post">
<p style="color:#aaa;font-size:30px">&lt;-- Select a post...</p> <p id="posts-placeholder" style="color:#aaa;font-size:30px">&lt;-- Select a post...</p>
</div> </div>
</div><!--/span--> </div><!--/span-->
......
#! /usr/bin/env python
import sys
def main():
print "SET sql_mode='NO_BACKSLASH_ESCAPES';"
lines = sys.stdin.read().splitlines()
for line in lines:
processLine(line)
def processLine(line):
if (
line.startswith("PRAGMA") or
line.startswith("BEGIN TRANSACTION;") or
line.startswith("COMMIT;") or
line.startswith("DELETE FROM sqlite_sequence;") or
line.startswith("INSERT INTO \"sqlite_sequence\"")
):
return
line = line.replace("AUTOINCREMENT", "AUTO_INCREMENT")
line = line.replace("DEFAULT 't'", "DEFAULT '1'")
line = line.replace("DEFAULT 'f'", "DEFAULT '0'")
line = line.replace(",'t'", ",'1'")
line = line.replace(",'f'", ",'0'")
in_string = False
newLine = ''
for c in line:
if not in_string:
if c == "'":
in_string = True
elif c == '"':
newLine = newLine + '`'
continue
elif c == "'":
in_string = False
newLine = newLine + c
print newLine
if __name__ == "__main__":
main()
...@@ -20,7 +20,8 @@ module Rendezvous ...@@ -20,7 +20,8 @@ module Rendezvous
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
config.i18n.default_locale = :ja I18n.enforce_available_locales = true
config.i18n.default_locale = 'ja'
# config.action_mailer.delivery_method = :action_gmailer # config.action_mailer.delivery_method = :action_gmailer
config.action_mailer.smtp_settings = { config.action_mailer.smtp_settings = {
......
...@@ -4,19 +4,32 @@ ...@@ -4,19 +4,32 @@
# Ensure the SQLite 3 gem is defined in your Gemfile # Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3' # gem 'sqlite3'
development: development:
adapter: sqlite3 adapter: mysql2
database: db/development.sqlite3 encoding: utf8
reconnect: false
database: rendezvous_development
pool: 5 pool: 5
timeout: 5000 username: <%= ENV['DB_DEVELOPMENT_USER'] %>
password: <%= ENV['DB_DEVELOPMENT_PASS'] %>
host: localhost
# Warning: The database defined as "test" will be erased and # Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake". # re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production. # Do not set this db to the same as development or production.
# test:
# adapter: sqlite3
# database: db/test.sqlite3
# pool: 5
# timeout: 5000
test: test:
adapter: sqlite3 adapter: mysql2
database: db/test.sqlite3 encoding: utf8
reconnect: false
database: rendezvous_test
pool: 5 pool: 5
timeout: 5000 username: <%= ENV['DB_TEST_USER'] %>
password: <%= ENV['DB_TEST_PASS'] %>
host: localhost
production: production:
adapter: sqlite3 adapter: sqlite3
......
ja:
date:
abbr_day_names:
-
-
-
-
-
-
-
abbr_month_names:
-
- 1月
- 2月
- 3月
- 4月
- 5月
- 6月
- 7月
- 8月
- 9月
- 10月
- 11月
- 12月
day_names:
- 日曜日
- 月曜日
- 火曜日
- 水曜日
- 木曜日
- 金曜日
- 土曜日
formats:
default: ! '%Y/%m/%d'
long: ! '%Y年%m月%d日(%a)'
short: ! '%m/%d'
month_names:
-
- 1月
- 2月
- 3月
- 4月
- 5月
- 6月
- 7月
- 8月
- 9月
- 10月
- 11月
- 12月
order:
- :year
- :month
- :day
datetime:
distance_in_words:
about_x_hours:
one: 約1時間
other: 約%{count}時間
about_x_months:
one: 約1ヶ月
other: 約%{count}ヶ月
about_x_years:
one: 約1年
other: 約%{count}年
almost_x_years:
one: 1年弱
other: ! '%{count}年弱'
half_a_minute: 30秒前後
less_than_x_minutes:
one: 1分以内
other: ! '%{count}分未満'
less_than_x_seconds:
one: 1秒以内
other: ! '%{count}秒未満'
over_x_years:
one: 1年以上
other: ! '%{count}年以上'
x_days:
one: 1日
other: ! '%{count}日'
x_minutes:
one: 1分
other: ! '%{count}分'
x_months:
one: 1ヶ月
other: ! '%{count}ヶ月'
x_seconds:
one: 1秒
other: ! '%{count}秒'
prompts:
day:
hour:
minute:
month:
second:
year:
errors: &errors
format: ! '%{attribute}%{message}'
messages:
accepted: を受諾してください。
blank: を入力してください。
present: は入力しないでください。
confirmation: と%{attribute}の入力が一致しません。
empty: を入力してください。
equal_to: は%{count}にしてください。
even: は偶数にしてください。
exclusion: は予約されています。
greater_than: は%{count}より大きい値にしてください。
greater_than_or_equal_to: は%{count}以上の値にしてください。
inclusion: は一覧にありません。
invalid: は不正な値です。
less_than: は%{count}より小さい値にしてください。
less_than_or_equal_to: は%{count}以下の値にしてください。
not_a_number: は数値で入力してください。
not_an_integer: は整数で入力してください。
odd: は奇数にしてください。
record_invalid: バリデーションに失敗しました。 %{errors}
restrict_dependent_destroy: ! '%{record}が存在しているので削除できません。'
taken: はすでに存在します。
too_long: は%{count}文字以内で入力してください。
too_short: は%{count}文字以上で入力してください。
wrong_length: は%{count}文字で入力してください。
other_than: "は%{count}以外の値にしてください。"
template:
body: 次の項目を確認してください。
header:
one: ! '%{model}にエラーが発生しました。'
other: ! '%{model}に%{count}個のエラーが発生しました。'
helpers:
select:
prompt: 選択してください。
submit:
create: 登録する
submit: 保存する
update: 更新する
number:
currency:
format:
delimiter: ! ','
format: ! '%n%u'
precision: 0
separator: .
significant: false
strip_insignificant_zeros: false
unit:
format:
delimiter: ! ','
precision: 3
separator: .
significant: false
strip_insignificant_zeros: false
human:
decimal_units:
format: ! '%n %u'
units:
billion: 十億
million: 百万
quadrillion: 千兆
thousand:
trillion:
unit: ''
format:
delimiter: ''
precision: 3
significant: true
strip_insignificant_zeros: true
storage_units:
format: ! '%n%u'
units:
byte: バイト
gb: ギガバイト
kb: キロバイト
mb: メガバイト
tb: テラバイト
percentage:
format:
delimiter: ''
format: "%n%"
precision:
format:
delimiter: ''
support:
array:
last_word_connector:
two_words_connector:
words_connector:
time:
am: 午前
formats:
default: ! '%Y/%m/%d %H:%M:%S'
long: ! '%Y年%m月%d日(%a) %H時%M分%S秒 %z'
short: ! '%y/%m/%d %H:%M'
pm: 午後
# remove these aliases after 'activemodel' and 'activerecord' namespaces are removed from Rails repository
activemodel:
errors:
<<: *errors
activerecord:
errors:
<<: *errors
devise:
confirmations:
confirmed: アカウントを登録しました。
send_instructions: 登録方法を数分以内にメールでご連絡します。
send_paranoid_instructions: メールアドレスが登録されていれば、数分以内にアカウントを確認する方法が記載されているメールが届きます。
failure:
already_authenticated: 既にログインしています。
inactive: アカウントが有効化されていません。
invalid: メールアドレスまたはパスワードが違います。
last_attempt: あと一回間違えるとアカウントが凍結されます。
locked: アカウントが凍結されています。
not_found_in_database: メールアドレスまたはパスワードが違います。
timeout: セッションがタイムアウトしました。もう一度ログインしてください。
unauthenticated: 続けるにはログインまたはアカウントを登録してください。
unconfirmed: 本登録を行ってください。
mailer:
confirmation_instructions:
subject: アカウントの登録方法
reset_password_instructions:
subject: パスワードの再設定
unlock_instructions:
subject: アカウントの凍結解除
omniauth_callbacks:
failure: 「%{reason}」のため、%{kind}による認証ができませんでした。
success: '%{kind}による認証に成功しました。'
passwords:
no_token: パスワード再設定のメール以外からこのページへアクセスする事はできません。もしパスワード再設定のメールに記載されたリンクをクリックしてこのページへ訪れた場合、不完全なURLのリンクをクリックしていないか確認してください。メーラーによっては、リンクのURLが途中で切れる可能性があります。
send_instructions: パスワードの再設定方法を数分以内にメールでご連絡します。
send_paranoid_instructions: メールアドレスが登録されていれば、数分以内にパスワード再設定のメールが届きます。
updated: パスワードを変更し、ログインしました。
updated_not_active: パスワードを変更しました。
registrations:
destroyed: アカウントを削除しました。またのご利用をお待ちしております。
signed_up: アカウント登録を受け付けました。
signed_up_but_inactive: 登録に成功しました。しかし、アカウントが有効になっていないためログインできません。
signed_up_but_locked: 登録に成功しました。しかし、アカウントがロックされているためログインできません。
signed_up_but_unconfirmed: アカウント確認のリンクが入っているメールを送りました。 メール内のリンクでアカウントを有効にしてください。
update_needs_confirmation: アカウント情報を変更しました。しかし、メールアドレスを確認する必要があります。メール内のリンクで新しいメールアドレスを確認してください。
updated: アカウント情報を更新しました。
sessions:
signed_in: ログインしました。
signed_out: ログアウトしました。
unlocks:
send_instructions: アカウントの凍結解除方法を数分以内にメールでご連絡します。
send_paranoid_instructions: アカウントが登録されていれば、数分以内にアカウントの凍結解除方法が登録しているアドレスに届きます。
unlocked: アカウントを凍結解除しました。続けるにはログインしてください。
errors:
messages:
already_confirmed: は既に登録済みです
confirmation_period_expired: は%{period}以内に確認が必要です。もう一度要求してください。
expired: は期限が切れたため、新しく取得する必要があります
not_found: は見つかりませんでした
not_locked: は凍結されていません
not_saved: '%{count}個のエラーにより%{resource}を保存することができませんでした。'
ja:
activerecord:
models:
post: post #g
post_tag: post_tag #g
tag: tag #g
user: user #g
attributes:
post:
author: :activerecord.models.author #g
body: body #g
post_tags: post_tags #g
tags: tags #g
title: title #g
post_tag:
post: :activerecord.models.post #g
tag: :activerecord.models.tag #g
tag:
ancestry: ancestry #g
name: name #g
post_tags: post_tags #g
posts: posts #g
user:
current_sign_in_at: current_sign_in_at #g
current_sign_in_ip: current_sign_in_ip #g
email: email #g
encrypted_password: encrypted_password #g
google_auth_token: google_auth_token #g
google_refresh_token: google_refresh_token #g
google_token_expires_at: google_token_expires_at #g
image_url: image_url #g
last_sign_in_at: last_sign_in_at #g
last_sign_in_ip: last_sign_in_ip #g
name: name #g
posts: posts #g
remember_created_at: remember_created_at #g
reset_password_sent_at: reset_password_sent_at #g
reset_password_token: reset_password_token #g
require 'spec_helper'
include Warden::Test::Helpers
Warden.test_mode!
describe 'Request via js', js: true do
let(:user) { FactoryGirl.create(:login_user_1) }
before do
@post1 = Post.create title: 'ruby rspec', body: 'This is first espec test: ruby', author_id: user.id
@post2 = Post.create title: 'php test', body: 'PHP is very easy', author_id: user.id
@post3 = Post.create title: 'java java...', body: 'Java is not ruby...', author_id: user.id
end
before :each do
login_as user, scope: :user
visit '/posts'
end
it 'show placeholder' do
page.save_screenshot(Rails.root.join('tmp', 'screenshots', "a-#{Time.now.strftime('%Y-%m-%d %H%M%S')}.png"))
expect(page.find('#posts-placeholder').text).to include('Select a post')
end
it 'click post and show' do
find('.post-list:nth-child(3)').click
page.save_screenshot(Rails.root.join('tmp', 'screenshots', "b-#{Time.now.strftime('%Y-%m-%d %H%M%S')}.png"))
expect(page.find('#list_post div.title a').text).to include('java java...')
end
after :each do
page.driver.reset!
Warden.test_reset!
end
end
...@@ -3,19 +3,18 @@ require 'spec_helper' ...@@ -3,19 +3,18 @@ require 'spec_helper'
describe User do describe User do
describe 'Instance method' do describe 'Instance method' do
before :each do
@alice = create(:alice) let(:alice) { create(:alice) }
@bob = create(:bob) let(:bob) { create(:bob) }
end
describe '#google_oauth_token_expired?' do describe '#google_oauth_token_expired?' do
it 'not expired' do it 'not expired' do
expect(@alice.google_oauth_token_expired?).to be_false expect(alice.google_oauth_token_expired?).to be_false
end end
it 'expired' do it 'expired' do
expect(@bob.google_oauth_token_expired?).to be_true expect(bob.google_oauth_token_expired?).to be_true
end end
end end
......
...@@ -10,6 +10,19 @@ require 'rspec/autorun' ...@@ -10,6 +10,19 @@ require 'rspec/autorun'
# require 'email_spec' # require 'email_spec'
require 'factory_girl' require 'factory_girl'
require 'capybara'
require 'capybara/rspec'
## Setting for polterguist.
require 'capybara/poltergeist'
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, timeout: 10)
end
Capybara.javascript_driver = :poltergeist
# Set capybara wait time (default: 2)
Capybara.default_wait_time = 5
# Requires supporting ruby files with custom matchers and macros, etc, # Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories. # in spec/support/ and its subdirectories.
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
...@@ -33,7 +46,7 @@ RSpec.configure do |config| ...@@ -33,7 +46,7 @@ RSpec.configure do |config|
# If you're not using ActiveRecord, or you'd prefer not to run each of your # If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false # examples within a transaction, remove the following line or assign false
# instead of true. # instead of true.
config.use_transactional_fixtures = true config.use_transactional_fixtures = false
# If true, the base class of anonymous controllers will be inferred # If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of # automatically. This will be the default behavior in future versions of
...@@ -54,4 +67,17 @@ RSpec.configure do |config| ...@@ -54,4 +67,17 @@ RSpec.configure do |config|
config.before(:all) do config.before(:all) do
FactoryGirl.reload FactoryGirl.reload
end end
config.include Capybara::DSL
config.before :suite do
DatabaseRewinder.clean_all
end
# config.before :each do
# end
config.after :each do
DatabaseRewinder.clean
end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment