From the continuation of the last time. I've reached the point where it works for the time being, so let's push it to Github.
Select New repository.
Then create it with an appropriate name. If you don't want others to see the source code, go to Private. If there is no problem, go to Public.
Cloud9 includes git by default, so you can use the git command as it is.
$ git add -A
$ git commit -m 'initial commit'
$ git remote add origin https://github.com/{YOUR_ACCOUNT}/{YOUR_REPOSITORY}.git
$ git branch -M master
$ git push -u origin master
The YOUR_ part of the above command is written in the repository you just created, so please refer to it.
With the above support, you will be asked for your Github user ID and password each time you push.
$ ssh-keygen -t rsa
Make a key pair by hitting the Enter key repeatedly.
$ cat ~/.ssh/id_rsa.pub
The character string displayed in is the public key, so copy it.
Go to Github and change from your icon on the upper right to "Settings" → "SSH and GPG keys" → "New SSH key". Give the title an easy-to-understand one, paste the public key to the key, and save it.
However, you should still be asked for your ID path when pushing.
$ git remote set-url origin [email protected]:{YOUR_ACCOUNT}/{YOUR_REPOSITORY}.git
If so, it's OK. This will prevent you from being asked for your ID path each time you push or pull.
Reference: Procedure for ssh connection on GitHub ~ From generation of public / private key ~
This time we will implement the test using RSpec, so delete the test directory for minitest.
$ git rm -r test/
First, let's insert rubocop that will perform static analysis. This is because it is a gem that checks the coding standards, but if you put it in later, a lot of indications that violate the coding standards will come out and you will not be able to handle it.
Gemfile
...
+ gem 'rubocop-rails'
...
Installation
$ bundle
yml:.rubocop.yml
AllCops:
Exclude:
- bin/*
- db/schema.rb
#Japanese comment permission
AsciiComments:
Enabled: false
#Unified to double quotes
StringLiterals:
EnforcedStyle: double_quotes
Place it in your application's root directory (/ home / ec2-user / environment / bbs). Don't forget to put a dot at the beginning of the file name.
$ rubocop -a
When executed, it spits out about 40 errors, but almost all should be the following errors.
C: Style/FrozenStringLiteralComment: Missing frozen string literal comment.
this is
Add to the first line of each Ruby file
+ # frozen_string_literal: true
+
This is OK. What it means is that strings are mutable by default in Ruby, but it may cause unintended problems, so it's a good idea to freeze it to make it immutable. In Ruby3, it is decided that it will be immutable by default, so if you include this description in preparation for that, the character string in the file will be immutable.
It's like that.
If you don't want to open dozens of files, edit and save them ...
#At the beginning of the Gemfile# frozen_string_literal:Add true
$ sed -i '1s/^/# frozen_string_literal: true\n\n/' Gemfile
You can add to the beginning of the file by doing like. If you specify like db / *, you can also batch directories (a little dangerous).
If you have no children, you can disable this check with rubocop within the scope of the tutorial. In that case
diff:.rubocop.yml
...
+ Style/FrozenStringLiteralComment:
+ Enabled: false
Please add. However, as mentioned above, it will be immutable by default from Ruby3, so if you start creating new applications in the future, you should include it.
All you have to do is eliminate the following error.
C: Style/Documentation: Missing top-level class documentation comment.
app/mailers/application_mailer.rb app/models/application_record.rb config/application.rb It should have occurred in the 3 files of, but it is an error that appears when there is no documentation of the class.
config/application.rb
module Bbs
+ #
+ #setting file
+ #
class Application < Rails::Application
Let's add a comment before the class definition like.
Fix everything,
Inspecting 26 files
..........................
26 files inspected, no offenses detected
It is OK if the error disappears like.
→ Build a bulletin board API with authentication authorization with Rails 6 # 3 RSpec, FactoryBot is introduced and a post model is created [To the serial table of contents]