Closed MaksHostroushko closed 1 year ago
You did this work great! But let's add a couple of improvements
https://github.com/alinajuly/RubyHW/blob/main/HW9/blog/spec/requests/api/v1/articles_spec.rb#L5..L8 It could be better if we write variables with the same spaces I mean
let(:author) { Author.create(name: 'Sasha') } let(:article) { Article.create(title: 'Title', body: 'Body title', author_id: author.id) } let(:comment) { Comment.create(body: 'comment', author_id: author.id, article_id: article.id) } let(:id) { article.id }
Ideally, we should call factory instead of records creating manually I mean, it could be better to write let(:author) { create(:author, name: 'Sasha') } instead of Author.create(name: 'Sasha') You can use this game for this fix(but it is optional)
let(:author) { create(:author, name: 'Sasha') }
Author.create(name: 'Sasha')
https://github.com/alinajuly/RubyHW/blob/main/HW9/blog/spec/requests/api/v1/articles_spec.rb#L32.L45 Please, add spaces between it..end
it..end
https://github.com/alinajuly/RubyHW/blob/main/HW9/blog/spec/requests/api/v1/articles_spec.rb#L32.L45 I think, we should prefer symbol to string, because it's better for memory So, let's use parameter name: :id, in: :path
parameter name: :id, in: :path
https://github.com/alinajuly/RubyHW/blob/main/HW9/blog/spec/requests/api/v1/articles_spec.rb#L129..L132 We shouldn't do it manually. Our test should have a controller and return response. We need to check the response but don't write a logic For example
Thank you. Done.
You did this work great! But let's add a couple of improvements
https://github.com/alinajuly/RubyHW/blob/main/HW9/blog/spec/requests/api/v1/articles_spec.rb#L5..L8 It could be better if we write variables with the same spaces I mean
Ideally, we should call factory instead of records creating manually I mean, it could be better to write
let(:author) { create(:author, name: 'Sasha') }
instead ofAuthor.create(name: 'Sasha')
You can use this game for this fix(but it is optional)https://github.com/alinajuly/RubyHW/blob/main/HW9/blog/spec/requests/api/v1/articles_spec.rb#L32.L45 Please, add spaces between
it..end
https://github.com/alinajuly/RubyHW/blob/main/HW9/blog/spec/requests/api/v1/articles_spec.rb#L32.L45 I think, we should prefer symbol to string, because it's better for memory So, let's use
parameter name: :id, in: :path
https://github.com/alinajuly/RubyHW/blob/main/HW9/blog/spec/requests/api/v1/articles_spec.rb#L129..L132 We shouldn't do it manually. Our test should have a controller and return response. We need to check the response but don't write a logic For example