Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sample_app
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nguyen Hoang Mai Phuong
sample_app
Commits
466f3ee9
Commit
466f3ee9
authored
Jun 03, 2021
by
Nguyen Hoang Mai Phuong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Complete advanced testing setup
parent
42348eae
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
10 deletions
+81
-10
Guardfile
+73
-0
test/test_helper.rb
+8
-10
No files found.
Guardfile
0 → 100644
View file @
466f3ee9
require
'active_support/core_ext/string'
# Defines the matching rules for Guard.
guard
:minitest
,
spring:
"bin/rails test"
,
all_on_start:
false
do
watch
(
%r{^test/(.*)/?(.*)_test
\.
rb$}
)
watch
(
'test/test_helper.rb'
)
{
'test'
}
watch
(
'config/routes.rb'
)
{
interface_tests
}
watch
(
%r{app/views/layouts/*}
)
{
interface_tests
}
watch
(
%r{^app/models/(.*?)
\.
rb$}
)
do
|
matches
|
[
"test/models/
#{
matches
[
1
]
}
_test.rb"
,
"test/integration/microposts_interface_test.rb"
]
end
watch
(
%r{^test/fixtures/(.*?)
\.
yml$}
)
do
|
matches
|
"test/models/
#{
matches
[
1
].
singularize
}
_test.rb"
end
watch
(
%r{^app/mailers/(.*?)
\.
rb$}
)
do
|
matches
|
"test/mailers/
#{
matches
[
1
]
}
_test.rb"
end
watch
(
%r{^app/views/(.*)_mailer/.*$}
)
do
|
matches
|
"test/mailers/
#{
matches
[
1
]
}
_mailer_test.rb"
end
watch
(
%r{^app/controllers/(.*?)_controller
\.
rb$}
)
do
|
matches
|
resource_tests
(
matches
[
1
])
end
watch
(
%r{^app/views/([^/]*?)/.*
\.
html
\.
erb$}
)
do
|
matches
|
[
"test/controllers/
#{
matches
[
1
]
}
_controller_test.rb"
]
+
integration_tests
(
matches
[
1
])
end
watch
(
%r{^app/helpers/(.*?)_helper
\.
rb$}
)
do
|
matches
|
integration_tests
(
matches
[
1
])
end
watch
(
'app/views/layouts/application.html.erb'
)
do
'test/integration/site_layout_test.rb'
end
watch
(
'app/helpers/sessions_helper.rb'
)
do
integration_tests
<<
'test/helpers/sessions_helper_test.rb'
end
watch
(
'app/controllers/sessions_controller.rb'
)
do
[
'test/controllers/sessions_controller_test.rb'
,
'test/integration/users_login_test.rb'
]
end
watch
(
'app/controllers/account_activations_controller.rb'
)
do
'test/integration/users_signup_test.rb'
end
watch
(
%r{app/views/users/*}
)
do
resource_tests
(
'users'
)
+
[
'test/integration/microposts_interface_test.rb'
]
end
end
# Returns the integration tests corresponding to the given resource.
def
integration_tests
(
resource
=
:all
)
if
resource
==
:all
Dir
[
"test/integration/*"
]
else
Dir
[
"test/integration/
#{
resource
}
_*.rb"
]
end
end
# Returns all tests that hit the interface.
def
interface_tests
integration_tests
<<
"test/controllers"
end
# Returns the controller tests corresponding to the given resource.
def
controller_test
(
resource
)
"test/controllers/
#{
resource
}
_controller_test.rb"
end
# Returns all tests for the given resource.
def
resource_tests
(
resource
)
integration_tests
(
resource
)
<<
controller_test
(
resource
)
end
\ No newline at end of file
test/test_helper.rb
View file @
466f3ee9
ENV
[
'RAILS_ENV'
]
||=
'test'
ENV
[
'RAILS_ENV'
]
||=
'test'
require_relative
"../config/environment"
require_relative
'../config/environment'
require
"rails/test_help"
require
'rails/test_help'
require
"minitest/reporters"
require
"minitest/reporters"
Minitest
::
Reporters
.
use!
Minitest
::
Reporters
.
use!
class
ActiveSupport
::
TestCase
class
ActiveSupport
::
TestCase
# Run tests in parallel with specified workers
# Run tests in parallel with specified workers
parallelize
(
workers: :number_of_processors
)
parallelize
(
workers: :number_of_processors
)
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures
:all
fixtures
:all
# Add more helper methods to be used by all tests here...
# Add more helper methods to be used by all tests here...
end
end
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment