Skip to content

Commit

Permalink
Add rubocop-rspec
Browse files Browse the repository at this point in the history
  • Loading branch information
maxjacobson committed May 22, 2024
1 parent a45173d commit 19df608
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 25 deletions.
16 changes: 16 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ inherit_from: .rubocop_todo.yml

require:
- rubocop-rails
- rubocop-rspec
- rubocop-rspec_rails

AllCops:
Exclude:
Expand All @@ -14,5 +16,19 @@ AllCops:
Metrics:
Enabled: false

RSpec/ContextWording:
Prefixes:
- and
- when

RSpec/ExampleLength:
Enabled: false

RSpec/MultipleExpectations:
Enabled: false

RSpec/NestedGroups:
Enabled: false

Style/StringLiterals:
EnforcedStyle: double_quotes
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ group :development do
gem "listen"
gem "rubocop"
gem "rubocop-rails"
gem "rubocop-rspec"
gem "rubocop-rspec_rails"
end

group :test do
Expand Down
13 changes: 13 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,22 @@ GEM
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.3)
parser (>= 3.3.1.0)
rubocop-capybara (2.20.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.25.1)
rubocop (~> 1.41)
rubocop-rails (2.25.0)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rspec (2.29.2)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
rubocop-rspec_rails (~> 2.28)
rubocop-rspec_rails (2.28.3)
rubocop (~> 1.40)
ruby-progressbar (1.13.0)
stringio (3.1.0)
strscan (3.1.0)
Expand Down Expand Up @@ -323,6 +334,8 @@ DEPENDENCIES
rspec-rails
rubocop
rubocop-rails
rubocop-rspec
rubocop-rspec_rails
sucker_punch
vite_rails
webmock
Expand Down
6 changes: 3 additions & 3 deletions spec/models/episode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
RSpec.describe Episode do
let(:show) { Show.create!(title: "Not Dead Yet", tmdb_tv_id: 42) }
let(:season) { Season.create!(show:, tmdb_id: 42, name: "Season 1", season_number: 1, episode_count: 1) }
let(:episode) { Episode.create!(season:, air_date:, name: "Pilot", tmdb_id: 42, episode_number: 1) }
let(:episode) { described_class.create!(season:, air_date:, name: "Pilot", tmdb_id: 42, episode_number: 1) }

describe "#available?" do
context "when there is an air_date" do
Expand All @@ -29,7 +29,7 @@
let(:air_date) { 3.days.from_now.to_date }

it "returns false" do
expect(episode).to_not be_available
expect(episode).not_to be_available
end
end
end
Expand All @@ -38,7 +38,7 @@
let(:air_date) { nil }

it "returns false" do
expect(episode).to_not be_available
expect(episode).not_to be_available
end
end
end
Expand Down
36 changes: 18 additions & 18 deletions spec/models/season_review_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
human = Human.create!(handle: "marc", email: "marc@example.com")
show = Show.create!(title: "Home Economics", tmdb_tv_id: 1)
season = Season.create!(show:, name: "Season 1", season_number: 1, episode_count: 10, tmdb_id: 1)
review = SeasonReview.create!(author: human, season:, viewing: 1, body: "Not bad", visibility: "anybody")
review = described_class.create!(author: human, season:, viewing: 1, body: "Not bad", visibility: "anybody")

other_human = Human.create!(handle: "Ashley", email: "ashley@example.com")

expect(SeasonReview.viewable_by(other_human)).to include(review)
expect(described_class.viewable_by(other_human)).to include(review)
end
end

Expand All @@ -23,9 +23,9 @@
human = Human.create!(handle: "marc", email: "marc@example.com")
show = Show.create!(title: "Home Economics", tmdb_tv_id: 1)
season = Season.create!(show:, name: "Season 1", season_number: 1, episode_count: 10, tmdb_id: 1)
review = SeasonReview.create!(author: human, season:, viewing: 1, body: "Not bad", visibility: "anybody")
review = described_class.create!(author: human, season:, viewing: 1, body: "Not bad", visibility: "anybody")

expect(SeasonReview.viewable_by(nil)).to include(review)
expect(described_class.viewable_by(nil)).to include(review)
end
end
end
Expand All @@ -36,9 +36,9 @@
human = Human.create!(handle: "marc", email: "marc@example.com")
show = Show.create!(title: "Home Economics", tmdb_tv_id: 1)
season = Season.create!(show:, name: "Season 1", season_number: 1, episode_count: 10, tmdb_id: 1)
review = SeasonReview.create!(author: human, season:, viewing: 1, body: "Not bad", visibility: "myself")
review = described_class.create!(author: human, season:, viewing: 1, body: "Not bad", visibility: "myself")

expect(SeasonReview.viewable_by(human)).to include(review)
expect(described_class.viewable_by(human)).to include(review)
end
end

Expand All @@ -47,10 +47,10 @@
human = Human.create!(handle: "marc", email: "marc@example.com")
show = Show.create!(title: "Home Economics", tmdb_tv_id: 1)
season = Season.create!(show:, name: "Season 1", season_number: 1, episode_count: 10, tmdb_id: 1)
review = SeasonReview.create!(author: human, season:, viewing: 1, body: "Not bad", visibility: "myself")
review = described_class.create!(author: human, season:, viewing: 1, body: "Not bad", visibility: "myself")
other_human = Human.create!(handle: "Ashley", email: "ashley@example.com")

expect(SeasonReview.viewable_by(other_human)).not_to include(review)
expect(described_class.viewable_by(other_human)).not_to include(review)
end
end

Expand All @@ -59,9 +59,9 @@
human = Human.create!(handle: "marc", email: "marc@example.com")
show = Show.create!(title: "Home Economics", tmdb_tv_id: 1)
season = Season.create!(show:, name: "Season 1", season_number: 1, episode_count: 10, tmdb_id: 1)
review = SeasonReview.create!(author: human, season:, viewing: 1, body: "Not bad", visibility: "myself")
review = described_class.create!(author: human, season:, viewing: 1, body: "Not bad", visibility: "myself")

expect(SeasonReview.viewable_by(nil)).not_to include(review)
expect(described_class.viewable_by(nil)).not_to include(review)
end
end
end
Expand All @@ -72,13 +72,13 @@
human = Human.create!(handle: "marc", email: "marc@example.com")
show = Show.create!(title: "Home Economics", tmdb_tv_id: 1)
season = Season.create!(show:, name: "Season 1", season_number: 1, episode_count: 10, tmdb_id: 1)
review = SeasonReview.create!(author: human, season:, viewing: 1, body: "Not bad", visibility: "mutuals")
review = described_class.create!(author: human, season:, viewing: 1, body: "Not bad", visibility: "mutuals")
other_human = Human.create!(handle: "ashley", email: "ashley@example.com")

Follow.create!(follower_id: human.id, followee_id: other_human.id)
Follow.create!(follower_id: other_human.id, followee_id: human.id)

expect(SeasonReview.viewable_by(other_human)).to include(review)
expect(described_class.viewable_by(other_human)).to include(review)
end
end

Expand All @@ -87,12 +87,12 @@
human = Human.create!(handle: "marc", email: "marc@example.com")
show = Show.create!(title: "Home Economics", tmdb_tv_id: 1)
season = Season.create!(show:, name: "Season 1", season_number: 1, episode_count: 10, tmdb_id: 1)
review = SeasonReview.create!(author: human, season:, viewing: 1, body: "Not bad", visibility: "mutuals")
review = described_class.create!(author: human, season:, viewing: 1, body: "Not bad", visibility: "mutuals")
other_human = Human.create!(handle: "ashley", email: "ashley@example.com")

Follow.create!(follower_id: other_human.id, followee_id: human.id)

expect(SeasonReview.viewable_by(other_human)).not_to include(review)
expect(described_class.viewable_by(other_human)).not_to include(review)
end
end

Expand All @@ -101,12 +101,12 @@
human = Human.create!(handle: "marc", email: "marc@example.com")
show = Show.create!(title: "Home Economics", tmdb_tv_id: 1)
season = Season.create!(show:, name: "Season 1", season_number: 1, episode_count: 10, tmdb_id: 1)
review = SeasonReview.create!(author: human, season:, viewing: 1, body: "Not bad", visibility: "mutuals")
review = described_class.create!(author: human, season:, viewing: 1, body: "Not bad", visibility: "mutuals")
other_human = Human.create!(handle: "ashley", email: "ashley@example.com")

Follow.create!(follower_id: human.id, followee_id: other_human.id)

expect(SeasonReview.viewable_by(other_human)).not_to include(review)
expect(described_class.viewable_by(other_human)).not_to include(review)
end
end

Expand All @@ -115,9 +115,9 @@
human = Human.create!(handle: "marc", email: "marc@example.com")
show = Show.create!(title: "Home Economics", tmdb_tv_id: 1)
season = Season.create!(show:, name: "Season 1", season_number: 1, episode_count: 10, tmdb_id: 1)
review = SeasonReview.create!(author: human, season:, viewing: 1, body: "Not bad", visibility: "mutuals")
review = described_class.create!(author: human, season:, viewing: 1, body: "Not bad", visibility: "mutuals")

expect(SeasonReview.viewable_by(nil)).not_to include(review)
expect(described_class.viewable_by(nil)).not_to include(review)
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/services/refresh_episodes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
tmdb_poster_path: "/ctTaOOAg9iZtvVBOyH2UE5ifBHg.jpg"
)

RefreshEpisodes.call(show, season)
described_class.call(show, season)

expect(request).to have_been_requested
expect(season.episodes.count).to be 3
Expand Down Expand Up @@ -76,7 +76,7 @@
episode_number: 3
)

RefreshEpisodes.call(show, season)
described_class.call(show, season)

expect(request).to have_been_requested
expect(season.episodes.count).to be 3
Expand Down Expand Up @@ -120,7 +120,7 @@
episode_number: 2
)

RefreshEpisodes.call(show, season)
described_class.call(show, season)

expect(request).to have_been_requested
expect(season.episodes.count).to be 3
Expand Down Expand Up @@ -170,7 +170,7 @@
episode_number: 3
)

RefreshEpisodes.call(show, season)
described_class.call(show, season)

expect(request).to have_been_requested
expect(season.episodes.count).to be 3
Expand Down

0 comments on commit 19df608

Please sign in to comment.