diveintocode-corp / rails_exam01_bugfix Goto Github PK
View Code? Open in Web Editor NEWSample App includes EasyBugs for beginner of Ruby on Rails (Level 1 BugFix)
Sample App includes EasyBugs for beginner of Ruby on Rails (Level 1 BugFix)
[参考URL] https://blog.jnito.com/entry/2018/03/12/053153
※ 2017年10月にRspec 3.7でリリースされた様です。
http://rspec.info/ja/blog/2017/10/rspec-3-7-has-been-released/
手順1. gem rspec-rails を追加し、rails generate rspec:install
でファイルを初期化
[参考URL] https://github.com/rspec/rspec-rails
手順2. SystemSpecは rails generate
非対応なので、手動でファイルを生成する
[参考URL] https://everydayrails.com/2018/01/08/rspec-3.7-system-tests.html
手順3. テスト実行時に発生する警告への対応
selenium-webdriverとchromedriver-helperのgemは実行時に警告が出る。
SeleniumHQ/selenium#7125
webdriversに統合されたので入れ替える。
https://stackoverflow.com/questions/55970418/capyabra-selenium-chrome-driver-settings
手順4. テスト実行時に使用するwebdriverの設定を追加
(rails_helperに記載すると、どこに設定があるのか分かりづらい。
spec/support以下を読み込む様にして、別途設定を定義したファイルを作成する)
・driven_by(:selenium_chrome)
--> テスト実行時にブラウザが起動されます。byebugやsleepで停止して画面の要素を確認できます。
・driven_by(:selenium_chrome_headless)
--> ブラウザを起動せずにテストが実施されます。
手順5. その他の設定を追加
・focus: trueの設定を入れる
https://kossy-web-engineer.hatenablog.com/entry/2019/01/16/071517
・specの実行結果をドキュメント形式で出力する設定を .rspec
に追加
https://shinkufencer.hateblo.jp/entry/2019/01/21/233000
.rspec -format
手順6. FactoryBotを使用するためgemを追加
・rails consoleでも動作確認できるように、gemfileでは :testだけでなく :developmentにも定義
・rails_helperに config.include FactoryBot::Syntax::Methods
を追加
(FactoryBot.build(:blog)
を build(:blog)
と省略して記載できる様にした)
[詰まったところ]
・EverydayRailsのSystemSpecのサンプルコードに誤りがあった
https://everydayrails.com/2018/01/08/rspec-3.7-system-tests.html
RSpec.system
だと NoMethodError: systemになるので、RSpec.describe
で使用すること
require 'rails_helper'
RSpec.describe "Test name", type: :system do
it "does something" do
# ... your test
end
end
・specの実行結果をドキュメント形式で出力する .rspec
が見当たらない
--> .gitignore
で管理対象外になっていたので、新規作成して対応
・railsの公式Rubocop設定(20190602時点)
https://github.com/rails/rails/blob/master/.rubocop.yml
--> [注意点1] Error: The Layout/FirstParameterIndentation
cop has been renamed to Layout/IndentFirstArgument
が発生するので1点Renameする必要あり
--> [注意点2] performanceを検証しないのであれば require: rubocop-performance
を削除する必要あり
--> rubocop実行時の結果の差分は、下記のfrozen_string_literalのチェックくらいだった。
(詳しくは未検証)
・# frozen_string_literal: true
のチェックを入れるべきか?
https://teratail.com/questions/74592
入れた方が良いという意見もあるが、入れないことでクリティカルな問題になるとは思えないし、内容の複雑さが増してしまうことから今回は導入しない。(方がいいのかな、という個人的意見です。)
現状: bundle install実行時に "gem rubocop-rails" が推奨される
https://github.com/toshimaru/rubocop-rails
--> 下記に移管した旨がREADMEに記載されている
https://github.com/toshimaru/rubocop-rails_config
--> 下記の内容を記載する必要がある
inherit_gem:
rubocop-rails_config:
- config/rails.yml
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.