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

Refactor RSpec for AnnotateModels (1) #726

Merged

Conversation

nard-tech
Copy link
Collaborator

I refactored and structuralized RSpec test cases of AnnotateModels for readability and scalability because it was too complex to read.

cf. #718
In this PR, I refactored test cases of some methods in AnnotateModels.
I will refactor test cases of other methods in another PR.

Copy link
Collaborator

@drwl drwl left a comment

Choose a reason for hiding this comment

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

Looks good. Can clean up typos in future commit

(@model_file_name, @file_content) = write_model 'user.rb', <<-EOS
class User < ActiveRecord::Base
end
(@model_file_name, @file_content) = write_model 'user.rb', <<~EOS
Copy link
Collaborator

Choose a reason for hiding this comment

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

I looked up what the differences are in the doc string <<- vs <<~. Learning something new 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

cf. https://www.rubyguides.com/2018/11/ruby-heredoc/

I like <<~ because it makes code more clean.
When using VS Code, both strings indented with <<~ and that of <<- can be collapsed, but the latter looks bad.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep the <<~ does look more clean. I think that it may have not existed when that spec was written but now it does 😊

end
end

context 'without additional_file_patterns' do
context 'when additional_file_patterns is not specified is the options' do
Copy link
Collaborator

Choose a reason for hiding this comment

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

Some typos here, but we can clean that up in a later commit :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, I fixed it in #731.

end
end

context 'without additional_file_patterns' do
context 'when additional_file_patterns is not specified is the options' do
Copy link
Collaborator

Choose a reason for hiding this comment

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

Another typo here

@drwl drwl merged commit 87b51c2 into ctran:develop Jan 19, 2020
@nard-tech nard-tech deleted the feature/refactor_annotate_models/rspec/clean_v1 branch January 20, 2020 11:38
vfonic pushed a commit to vfonic/annotate_models that referenced this pull request May 8, 2020
I refactored and structuralized RSpec test cases of AnnotateModels for readability and scalability because it was too complex to read.

cf. ctran#718 
In this PR, I refactored test cases of some methods in `AnnotateModels`.
I will refactor test cases of other methods in another PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants