File flickr_photos_importer_spec.rb
has 316 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'rails_helper'
describe FlickrPhotosImporter do
it { is_expected.to be_retryable true }
it { is_expected.to be_unique }
Do not use expect
in before
hook Open
expect(FlickRaw::Flickr).to receive_message_chain('new.people.getPublicPhotos').and_raise StandardError
- Exclude checks
Prefer using verifying doubles over normal doubles. Open
let(:flickr_user_client) { double('Flickr client for user call') }
- Exclude checks
Add an empty line after subject
. Open
end
- Exclude checks
Prefer allow
over expect
when configuring a response. Open
expect(flickr_group_client).to receive_message_chain('groups.pools.getPhotos').and_return(no_results)
- Exclude checks
Prefer allow
over expect
when configuring a response. Open
expect(FlickRaw::Flickr).to receive_message_chain('new.people.getPublicPhotos').and_raise StandardError
- Exclude checks
Prefer using verifying doubles over normal doubles. Open
and_yield(double(FlickrProfile, id: 'def', profile_type: 'group'))
- Exclude checks
Do not use Time.now
without zone. Use one of Time.zone.now
, Time.current
, Time.now.in_time_zone
, Time.now.utc
, Time.now.getlocal
, Time.now.xmlschema
, Time.now.iso8601
, Time.now.jisx0301
, Time.now.rfc3339
, Time.now.httpdate
, Time.now.to_i
, Time.now.to_f
instead. Open
photo1 = Hashie::Mash.new(id: 'photo1', owner: 'owner1', tags: '', title: 'title1', description: 'desc 1', datetaken: Time.now.strftime('%Y-%m-%d %H:%M:%S'), views: 100, url_o: 'http://photo1', url_q: 'http://photo_thumbnail1', dateupload: Time.now.to_i)
- Read upRead up
- Exclude checks
This cop checks for the use of Time methods without zone.
Built on top of Ruby on Rails style guide (https://github.com/rubocop-hq/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/
Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.
When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.
Example: EnforcedStyle: strict
# `strict` means that `Time` should be used with `zone`.
# bad
Time.now
Time.parse('2015-03-02 19:05:37')
# bad
Time.current
Time.at(timestamp).in_time_zone
# good
Time.zone.now
Time.zone.parse('2015-03-02 19:05:37')
Example: EnforcedStyle: flexible (default)
# `flexible` allows usage of `in_time_zone` instead of `zone`.
# bad
Time.now
Time.parse('2015-03-02 19:05:37')
# good
Time.zone.now
Time.zone.parse('2015-03-02 19:05:37')
# good
Time.current
Time.at(timestamp).in_time_zone
Prefer have_received
for setting message expectations. Setup Rails.logger
as a spy using allow
or instance_spy
. Open
expect(Rails.logger).to receive(:warn)
- Exclude checks
Prefer using verifying doubles over normal doubles. Open
let(:flickr_group_client) { double('Flickr client for group call') }
- Exclude checks
Do not use Time.now
without zone. Use one of Time.zone.now
, Time.current
, Time.now.in_time_zone
, Time.now.utc
, Time.now.getlocal
, Time.now.xmlschema
, Time.now.iso8601
, Time.now.jisx0301
, Time.now.rfc3339
, Time.now.httpdate
, Time.now.to_i
, Time.now.to_f
instead. Open
photo3 = Hashie::Mash.new(id: 'photo3', owner: 'owner3', tags: '', title: 'title3', description: 'desc 3', datetaken: Time.now.strftime('%Y-%m-%d %H:%M:%S'), views: 300, url_o: 'http://photo3', url_q: 'http://photo_thumbnail3', dateupload: Time.now.to_i)
- Read upRead up
- Exclude checks
This cop checks for the use of Time methods without zone.
Built on top of Ruby on Rails style guide (https://github.com/rubocop-hq/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/
Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.
When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.
Example: EnforcedStyle: strict
# `strict` means that `Time` should be used with `zone`.
# bad
Time.now
Time.parse('2015-03-02 19:05:37')
# bad
Time.current
Time.at(timestamp).in_time_zone
# good
Time.zone.now
Time.zone.parse('2015-03-02 19:05:37')
Example: EnforcedStyle: flexible (default)
# `flexible` allows usage of `in_time_zone` instead of `zone`.
# bad
Time.now
Time.parse('2015-03-02 19:05:37')
# good
Time.zone.now
Time.zone.parse('2015-03-02 19:05:37')
# good
Time.current
Time.at(timestamp).in_time_zone
Add an empty line after the last let
. Open
let(:no_results) { [] }
- Exclude checks
Do not use Time.now
without zone. Use one of Time.zone.now
, Time.current
, Time.now.in_time_zone
, Time.now.utc
, Time.now.getlocal
, Time.now.xmlschema
, Time.now.iso8601
, Time.now.jisx0301
, Time.now.rfc3339
, Time.now.httpdate
, Time.now.to_i
, Time.now.to_f
instead. Open
photo2 = Hashie::Mash.new(id: 'photo2', owner: 'owner2', tags: '', title: 'title2', description: 'desc 2', datetaken: Time.now.strftime('%Y-%m-%d %H:%M:%S'), views: 200, url_o: 'http://photo2', url_q: 'http://photo_thumbnail2', dateupload: Time.now.to_i)
- Read upRead up
- Exclude checks
This cop checks for the use of Time methods without zone.
Built on top of Ruby on Rails style guide (https://github.com/rubocop-hq/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/
Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.
When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.
Example: EnforcedStyle: strict
# `strict` means that `Time` should be used with `zone`.
# bad
Time.now
Time.parse('2015-03-02 19:05:37')
# bad
Time.current
Time.at(timestamp).in_time_zone
# good
Time.zone.now
Time.zone.parse('2015-03-02 19:05:37')
Example: EnforcedStyle: flexible (default)
# `flexible` allows usage of `in_time_zone` instead of `zone`.
# bad
Time.now
Time.parse('2015-03-02 19:05:37')
# good
Time.zone.now
Time.zone.parse('2015-03-02 19:05:37')
# good
Time.current
Time.at(timestamp).in_time_zone
Prefer allow
over expect
when configuring a response. Open
expect(flickr_user_client).to receive_message_chain('people.getPublicPhotos').and_return(no_results)
- Exclude checks
Prefer using verifying doubles over normal doubles. Open
and_yield(double(FlickrProfile, id: 'abc', profile_type: 'user')).
- Exclude checks
Prefer have_received
for setting message expectations. Setup Rails.logger
as a spy using allow
or instance_spy
. Open
expect(Rails.logger).to receive(:warn)
- Exclude checks