Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

課題16 system spec作成 #1

Open
wants to merge 33 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
12b3ba1
Feature: vendor/bundleをgit ignore
denkikairo Oct 8, 2019
0368f16
テスト途中
denkikairo Oct 8, 2019
5cdccb6
Feature: user, task system spec
denkikairo Oct 8, 2019
ff6cc19
Merge branch 'develop' into system_spec
denkikairo Oct 8, 2019
ab8c137
Feature: 別ユーザーがコメント閲覧した時の異常系
denkikairo Oct 8, 2019
32ee76e
Fix: rocket hash
denkikairo Oct 10, 2019
3da662d
Fix: 異常系のコメントの一つを修正
denkikairo Oct 10, 2019
41293f3
Fix: update時、編集した内容の項目が画面上に表示されることを確認
denkikairo Oct 10, 2019
ccd2617
Fix: delete時、該当レコードが存在しないことを確認
denkikairo Oct 10, 2019
11763b9
Feature: user updateのテスト
denkikairo Oct 10, 2019
5e68254
Fix: task new時、indexに表示されることを確認
denkikairo Oct 10, 2019
55e477e
Fix: task_specの最初のキャプションのミスを修正
denkikairo Oct 10, 2019
dad025a
Fix: loginにリダイレクトした時、current_pathの確認
denkikairo Oct 10, 2019
a83845b
Fix: taskのcreateでlet!ではなくlet使用
denkikairo Oct 10, 2019
188182c
Fix: pathをlogin_pathと記述
denkikairo Oct 10, 2019
1abf20a
Fix: user_specのdescribe, context修正
denkikairo Oct 10, 2019
6f05688
Fix: describe, contextのコメント変更
denkikairo Oct 10, 2019
b6aad56
Fix: letをプロジェクトの一番上にまとめる
denkikairo Oct 11, 2019
2c28e93
Fix: letをまとめる、task newでletを使わない
denkikairo Oct 11, 2019
1963ba0
Add helper user_form_button
yuji91 Oct 11, 2019
c9a5817
Merge branch 'develop' into system_spec
denkikairo Oct 11, 2019
6c0a437
Fix: SignupをSubmitに変更
denkikairo Oct 11, 2019
de465ac
Fix: 登録済みアドレスのユーザー作成、編集が失敗するテスト追加
denkikairo Oct 15, 2019
eba18d2
Feature: fdescribe, fcontextなどを有効化
denkikairo Oct 15, 2019
626f40d
Feature: headless chromeの設定ファイル
denkikairo Oct 15, 2019
6602a65
Fix: letとdescribeの間を一行開ける
denkikairo Oct 15, 2019
f19a61f
Fix: spec_helperの一部をコメントアウト
denkikairo Oct 15, 2019
6e82187
Add forbid invalid access for user edit, update, destroy
yuji91 Oct 15, 2019
4fdc5be
Merge remote-tracking branch 'origin/develop' into develop
yuji91 Oct 15, 2019
84405e6
Merge remote-tracking branch 'origin/develop' into develop
yuji91 Oct 15, 2019
909949a
Merge remote-tracking branch 'upstream/develop' into system_spec
denkikairo Oct 15, 2019
83639dc
Feature: 他のユーザーの編集ページにアクセスできない
denkikairo Oct 15, 2019
aa52084
Fix: userのSubmitボタンをSignup, Updateボタンに変更
denkikairo Oct 15, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

/public/assets
.byebug_history
/vendor/bundle

# Ignore master key for decrypting credentials and more.
/config/master.key
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ gem 'sorcery'

group :development, :test do
gem 'byebug', platforms: %i[mri mingw x64_mingw]
gem 'rspec-rails'
gem 'capybara'
gem 'webdrivers'
gem 'factory_bot_rails'
end

group :development do
Expand Down
50 changes: 50 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ GEM
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
arel (9.0.0)
ast (2.4.0)
bcrypt (3.1.13)
Expand All @@ -56,6 +58,15 @@ GEM
msgpack (~> 1.0)
builder (3.2.3)
byebug (11.0.1)
capybara (3.29.0)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (~> 1.5)
xpath (~> 3.2)
childprocess (3.0.0)
code_analyzer (0.4.8)
sexp_processor
coderay (1.1.2)
Expand All @@ -69,9 +80,15 @@ GEM
concurrent-ruby (1.1.5)
crass (1.0.4)
debug_inspector (0.0.3)
diff-lcs (1.3)
erubi (1.9.0)
erubis (2.7.0)
execjs (2.7.0)
factory_bot (5.1.1)
activesupport (>= 4.2.0)
factory_bot_rails (5.1.1)
factory_bot (~> 5.1.0)
railties (>= 4.2.0)
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
ffi (1.11.1)
Expand Down Expand Up @@ -126,6 +143,7 @@ GEM
yard (~> 0.9.11)
pry-rails (0.3.9)
pry (>= 0.10.4)
public_suffix (4.0.1)
puma (3.12.1)
rack (2.0.7)
rack-test (1.1.0)
Expand Down Expand Up @@ -167,7 +185,25 @@ GEM
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
ffi (~> 1.0)
regexp_parser (1.6.0)
require_all (2.0.0)
rspec-core (3.8.2)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-rails (3.8.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.3)
rubocop (0.74.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
Expand All @@ -177,6 +213,7 @@ GEM
unicode-display_width (>= 1.4.0, < 1.7)
ruby-progressbar (1.10.1)
ruby_dep (1.5.0)
rubyzip (1.3.0)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
Expand All @@ -188,6 +225,9 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
selenium-webdriver (3.142.6)
childprocess (>= 0.5, < 4.0)
rubyzip (>= 1.2.2)
sexp_processor (4.13.0)
sorcery (0.14.0)
bcrypt (~> 3.1)
Expand Down Expand Up @@ -218,9 +258,15 @@ GEM
activemodel (>= 5.0)
bindex (>= 0.4.0)
railties (>= 5.0)
webdrivers (4.1.2)
nokogiri (~> 1.6)
rubyzip (~> 1.0)
selenium-webdriver (>= 3.0, < 4.0)
websocket-driver (0.7.1)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4)
xpath (3.2.0)
nokogiri (~> 1.8)
yard (0.9.20)

PLATFORMS
Expand All @@ -231,14 +277,17 @@ DEPENDENCIES
binding_of_caller
bootsnap (>= 1.1.0)
byebug
capybara
coffee-rails (~> 4.2)
factory_bot_rails
listen (>= 3.0.5, < 3.2)
pry-byebug
pry-doc
pry-rails
puma (~> 3.11)
rails (~> 5.2.3)
rails_best_practices
rspec-rails
rubocop
sass-rails (~> 5.0)
sorcery
Expand All @@ -248,6 +297,7 @@ DEPENDENCIES
tzinfo-data
uglifier (>= 1.3.0)
web-console (>= 3.3.0)
webdrivers

RUBY VERSION
ruby 2.6.4p104
Expand Down
8 changes: 8 additions & 0 deletions spec/factories/task.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FactoryBot.define do
factory :task do
title { "title" }
content { "content" }
status { 0 }
deadline { '2019/10/9 11:11' }
end
end
7 changes: 7 additions & 0 deletions spec/factories/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FactoryBot.define do
factory :user do
email { "[email protected]" }
password { "password" }
password_confirmation { "password" }
end
end
62 changes: 62 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
require 'spec_helper'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point!

# Requires supporting ruby files with custom matchers and macros, etc, in
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
# run as spec files by default. This means that files in spec/support that end
# in _spec.rb will both be required and run as specs, causing the specs to be
# run twice. It is recommended that you do not name files matching this glob to
# end with _spec.rb. You can configure this pattern with the --pattern
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
#
# The following line is provided for convenience purposes. It has the downside
# of increasing the boot-up time by auto-requiring all files in the support
# directory. Alternatively, in the individual `*_spec.rb` files, manually
# require only the support files necessary.
#
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }

# Checks for pending migrations and applies them before tests are run.
# If you are not using ActiveRecord, you can remove these lines.
begin
ActiveRecord::Migration.maintain_test_schema!
rescue ActiveRecord::PendingMigrationError => e
puts e.to_s.strip
exit 1
end
RSpec.configure do |config|
config.include FactoryBot::Syntax::Methods
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"

# 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
# instead of true.
config.use_transactional_fixtures = true

# RSpec Rails can automatically mix in different behaviours to your tests
# based on their file location, for example enabling you to call `get` and
# `post` in specs under `spec/controllers`.
#
# You can disable this behaviour by removing the line below, and instead
# explicitly tag your specs with their type, e.g.:
#
# RSpec.describe UsersController, :type => :controller do
# # ...
# end
#
# The different available types are documented in the features, such as in
# https://relishapp.com/rspec/rspec-rails/docs
config.infer_spec_type_from_file_location!

# Filter lines from Rails gems in backtraces.
config.filter_rails_from_backtrace!
# arbitrary gems may also be filtered via:
# config.filter_gems_from_backtrace("gem name")
end
96 changes: 96 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause
# this file to always be loaded, without a need to explicitly require it in any
# files.
#
# Given that it is always loaded, you are encouraged to keep this file as
# light-weight as possible. Requiring heavyweight dependencies from this file
# will add to the boot time of your test suite on EVERY test run, even for an
# individual file that may not need all of that loaded. Instead, consider making
# a separate helper file that requires the additional dependencies and performs
# the additional setup, and require it from the spec files that actually need
# it.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer.
config.expect_with :rspec do |expectations|
# This option will default to `true` in RSpec 4. It makes the `description`
# and `failure_message` of custom matchers include text for helper methods
# defined using `chain`, e.g.:
# be_bigger_than(2).and_smaller_than(4).description
# # => "be bigger than 2 and smaller than 4"
# ...rather than:
# # => "be bigger than 2"
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end

# rspec-mocks config goes here. You can use an alternate test double
# library (such as bogus or mocha) by changing the `mock_with` option here.
config.mock_with :rspec do |mocks|
# Prevents you from mocking or stubbing a method that does not exist on
# a real object. This is generally recommended, and will default to
# `true` in RSpec 4.
mocks.verify_partial_doubles = true
end

# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
# have no way to turn it off -- the option exists only for backwards
# compatibility in RSpec 3). It causes shared context metadata to be
# inherited by the metadata hash of host groups and examples, rather than
# triggering implicit auto-inclusion in groups with matching metadata.
config.shared_context_metadata_behavior = :apply_to_host_groups

# The settings below are suggested to provide a good initial experience
# with RSpec, but feel free to customize to your heart's content.
=begin
# This allows you to limit a spec run to individual examples or groups
# you care about by tagging them with `:focus` metadata. When nothing
# is tagged with `:focus`, all examples get run. RSpec also provides
# aliases for `it`, `describe`, and `context` that include `:focus`
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
config.filter_run_when_matching :focus
Copy link
Contributor

@yuji91 yuji91 Oct 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config.filter_run_when_matching :focus を有効化すると fit でそのテストケースにforcusして実行できます。

また config.filter_run :focus を記載すると fit をつけないテストケースは実行されなくなります。(何もつけなければ、何も実行されなくなってしまいます)

# Allows RSpec to persist some state between runs in order to support
# the `--only-failures` and `--next-failure` CLI options. We recommend
# you configure your source control system to ignore this file.
config.example_status_persistence_file_path = "spec/examples.txt"
# Limits the available syntax to the non-monkey patched syntax that is
# recommended. For more details, see:
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
config.disable_monkey_patching!
# Many RSpec users commonly either run the entire suite or an individual
# file, and it's useful to allow more verbose output when running an
# individual spec file.
if config.files_to_run.one?
# Use the documentation formatter for detailed output,
# unless a formatter has already been configured
# (e.g. via a command-line flag).
config.default_formatter = "doc"
end
# Print the 10 slowest examples and example groups at the
# end of the spec run, to help surface which specs are running
# particularly slow.
config.profile_examples = 10
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = :random
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config.order = :random を有効化すると実行するテストケースの順番をランダムにできます。
(今回は対応不要です。)

# Seed global randomization in this process using the `--seed` CLI option.
# Setting this allows you to use `--seed` to deterministically reproduce
# test failures related to randomization by passing the same `--seed` value
# as the one that triggered the failure.
Kernel.srand config.seed
=end
end
6 changes: 6 additions & 0 deletions spec/support/utilities.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def login_as(user)
visit login_path
fill_in 'email', with: user.email
fill_in 'password', with: 'password'
click_button 'Login'
end
Loading