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

Bump rubocop-rspec from 2.3.0 to 2.4.0 #13951

Merged
merged 4 commits into from Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions .rubocop.yml
Expand Up @@ -894,6 +894,11 @@ RSpec/ExampleLength:
Max: 15
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleLength

RSpec/IdenticalEqualityAssertion:
Description: Checks for equality assertions with identical expressions on both sides.
Enabled: true
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/IdenticalEqualityAssertion

RSpec/MessageExpectation:
Description: Checks for consistent message expectation style.
Enabled: true
Expand All @@ -909,3 +914,8 @@ RSpec/MultipleExpectations:
Enabled: true
Max: 8
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/MultipleExpectations

RSpec/Rails/AvoidSetupHook:
Description: Checks that tests use RSpec `before` hook over Rails `setup` method.
Enabled: true
StyleGuide: https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Rails/AvoidSetupHook
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -150,7 +150,7 @@ group :development, :test do
gem "rubocop", "~> 1.16", require: false # Automatic Ruby code style checking tool
gem "rubocop-performance", "~> 1.11", require: false # A collection of RuboCop cops to check for performance optimizations in Ruby code
gem "rubocop-rails", "~> 2.10", require: false # Automatic Rails code style checking tool
gem "rubocop-rspec", "~> 2.3", require: false # Code style checking for RSpec files
gem "rubocop-rspec", "~> 2.4", require: false # Code style checking for RSpec files
gem "sassc-rails", "~> 2.1.2" # Integrate SassC-Ruby into Rails
gem "spring", "~> 2.1" # Preloads your application so things like console, rake and tests run faster
gem "spring-commands-rspec", "~> 1.0" # rspec command for spring
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Expand Up @@ -664,7 +664,7 @@ GEM
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-rspec (2.3.0)
rubocop-rspec (2.4.0)
rubocop (~> 1.0)
rubocop-ast (>= 1.1.0)
ruby-next-core (0.12.0)
Expand Down Expand Up @@ -954,7 +954,7 @@ DEPENDENCIES
rubocop (~> 1.16)
rubocop-performance (~> 1.11)
rubocop-rails (~> 2.10)
rubocop-rspec (~> 2.3)
rubocop-rspec (~> 2.4)
ruby-prof (~> 1.4)
rubyzip (~> 2.3)
s3_direct_upload (~> 0.1)
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Expand Up @@ -391,7 +391,7 @@
get "/t/:tag/:timeframe", to: "stories/tagged_articles#index",
constraints: { timeframe: /latest/ }

get "/t/:tag/edit", to: "tags#edit"
get "/t/:tag/edit", to: "tags#edit", as: :edit_tag
get "/t/:tag/admin", to: "tags#admin"
patch "/tag/:id", to: "tags#update"

Expand Down
2 changes: 1 addition & 1 deletion spec/liquid_tags/comment_tag_spec.rb
Expand Up @@ -7,7 +7,7 @@
create(:comment, commentable: article, user: user, body_markdown: "TheComment")
end

setup { Liquid::Template.register_tag("comment", described_class) }
before { Liquid::Template.register_tag("comment", described_class) }

def generate_comment_tag(id_code)
Liquid::Template.parse("{% comment #{id_code} %}")
Expand Down
2 changes: 1 addition & 1 deletion spec/liquid_tags/liquid_tag_base_spec.rb
Expand Up @@ -3,7 +3,7 @@
RSpec.describe LiquidTagBase, type: :liquid_tag do
# #new and #initialize are both private methods in Liquid::Tag, which is what
# LiquidTagBase inherits from, so we treat this class as a liquid tag itself.
setup { Liquid::Template.register_tag("liquid_tag_base", described_class) }
before { Liquid::Template.register_tag("liquid_tag_base", described_class) }

context "when VALID_CONTEXTS are defined" do
before { stub_const("#{described_class}::VALID_CONTEXTS", %w[Article]) }
Expand Down
4 changes: 2 additions & 2 deletions spec/liquid_tags/medium_tag_spec.rb
@@ -1,10 +1,10 @@
require "rails_helper"

RSpec.describe MediumTag, type: :liquid_tag do
setup { Liquid::Template.register_tag("medium", described_class) }

subject { Liquid::Template.parse("{% medium #{link} %}") }

before { Liquid::Template.register_tag("medium", described_class) }

let(:stubbed_scraper) { instance_double("MediumArticleRetrievalService") }
let(:medium_link) { "https://medium.com/@edisonywh/my-ruby-journey-hooking-things-up-91d757e1c59c" }
let(:response) do
Expand Down
2 changes: 1 addition & 1 deletion spec/liquid_tags/null_tag_spec.rb
Expand Up @@ -4,7 +4,7 @@
describe "#initialize" do
tags = %w[assign capture case cycle for if ifchanged include unless]

setup { tags.each { |tag| Liquid::Template.register_tag(tag, described_class) } }
before { tags.each { |tag| Liquid::Template.register_tag(tag, described_class) } }

def generate_given_tag(tag)
Liquid::Template.parse("{% #{tag} %}")
Expand Down
2 changes: 1 addition & 1 deletion spec/liquid_tags/organization_tag_spec.rb
Expand Up @@ -3,7 +3,7 @@
RSpec.describe OrganizationTag, type: :liquid_tag do
let(:organization) { create(:organization) }

setup { Liquid::Template.register_tag("organization", described_class) }
before { Liquid::Template.register_tag("organization", described_class) }

def generate_user_tag(id_code)
Liquid::Template.parse("{% organization #{id_code} %}")
Expand Down
2 changes: 1 addition & 1 deletion spec/liquid_tags/tag_tag_spec.rb
Expand Up @@ -3,7 +3,7 @@
RSpec.describe TagTag, type: :liquid_tag do
let(:tag) { create(:tag) }

setup { Liquid::Template.register_tag("tag", described_class) }
before { Liquid::Template.register_tag("tag", described_class) }

def generate_tag_tag(id_code)
Liquid::Template.parse("{% tag #{id_code} %}")
Expand Down
2 changes: 1 addition & 1 deletion spec/liquid_tags/tweet_tag_spec.rb
Expand Up @@ -6,7 +6,7 @@
let(:name) { "DEV Community" }
let(:body) { "When GitHub goes down" }

setup { Liquid::Template.register_tag("tweet", described_class) }
before { Liquid::Template.register_tag("tweet", described_class) }

def generate_tweet_liquid_tag(id)
Liquid::Template.parse("{% tweet #{id} %}")
Expand Down
6 changes: 3 additions & 3 deletions spec/liquid_tags/user_subscription_tag_spec.rb
@@ -1,16 +1,16 @@
require "rails_helper"

RSpec.describe UserSubscriptionTag, type: :liquid_tag do
setup { Liquid::Template.register_tag("user_subscription", described_class) }

let(:subscriber) { create(:user) }
let(:author) { create(:user) }
let(:article_with_user_subscription_tag) do
create(:article, :with_user_subscription_tag_role_user, with_user_subscription_tag: true)
end

# Stub roles because adding them normally can cause flaky specs
before do
Liquid::Template.register_tag("user_subscription", described_class)

# Stub roles because adding them normally can cause flaky specs
allow(author).to receive(:has_role?).and_call_original
allow(author).to receive(:has_role?).with(:restricted_liquid_tag, LiquidTags::UserSubscriptionTag).and_return(true)
end
Expand Down
4 changes: 2 additions & 2 deletions spec/liquid_tags/user_tag_spec.rb
@@ -1,9 +1,9 @@
require "rails_helper"

RSpec.describe UserTag, type: :liquid_tag do
let(:user) { create(:user) }
let(:user) { create(:user) }

setup { Liquid::Template.register_tag("user", described_class) }
before { Liquid::Template.register_tag("user", described_class) }

def generate_user_tag(id_code)
Liquid::Template.parse("{% user #{id_code} %}")
Expand Down
23 changes: 17 additions & 6 deletions spec/system/admin/admin_updates_tag_spec.rb
Expand Up @@ -2,9 +2,12 @@

RSpec.describe "Admin updates a tag", type: :system do
let(:super_admin) { create(:user, :super_admin) }
let(:tag) { create(:tag) }
let(:bg_color_hex) { "#000000" }
let(:text_color_hex) { "#ffffff" }

context "when no colors have been choosen for the tag" do
let(:tag) { create(:tag) }

before do
sign_in super_admin
visit edit_admin_tag_path(tag.id)
Expand All @@ -15,24 +18,32 @@
end

it "defaults to black and white upon update" do
check "Supported"
check("Supported")
click_button("Update Tag")

tag.reload
expect(tag.bg_color_hex).to eq("#000000")
expect(tag.text_color_hex).to eq("#ffffff")

expect(tag.bg_color_hex).to eq(bg_color_hex)
expect(tag.text_color_hex).to eq(text_color_hex)
end
end

context "when colors have already been choosen for the tag" do
let(:tag) { create(:tag, bg_color_hex: "#0000ff", text_color_hex: "#ff0000") }

before do
sign_in super_admin
visit edit_admin_tag_path(tag)
end

it "remains the same color it was unless otherwise updated via the color picker" do
old_bg_color_hex = tag.bg_color_hex
old_text_color_hex = tag.text_color_hex

click_button("Update Tag")
expect(tag.bg_color_hex).to eq(tag.bg_color_hex)
expect(tag.text_color_hex).to eq(tag.text_color_hex)

expect(tag.reload.bg_color_hex).to eq(old_bg_color_hex)
expect(tag.reload.text_color_hex).to eq(old_text_color_hex)
end
end
end
Expand Up @@ -20,7 +20,6 @@
it "lets moderators visit /mod", js: true do
visit "/#{user.username}/#{article.slug}/mod"

expect(page).to have_content("Moderate: #{article.title}")
expect(page).to have_selector('button[data-category="thumbsdown"][data-reactable-type="Article"]')
expect(page).to have_selector('button[data-category="vomit"][data-reactable-type="Article"]')
expect(page).to have_selector('button[data-category="vomit"][data-reactable-type="User"]')
Expand Down
51 changes: 36 additions & 15 deletions spec/system/tags/user_updates_a_tag_spec.rb
Expand Up @@ -3,13 +3,16 @@
RSpec.describe "User updates a tag", type: :system do
let(:super_admin) { create(:user, :super_admin) }
let(:tag_moderator) { create(:user) }
let(:tag) { create(:tag) }
let(:bg_color_hex) { "#000000" }
let(:text_color_hex) { "#ffffff" }

describe "Update tag as a super_admin" do
let(:tag) { create(:tag) }

describe "UPDATE /t/:tag/edit as a super_admin" do
context "when no colors have been choosen for the tag" do
before do
sign_in super_admin
visit "/t/#{tag}/edit"
visit edit_tag_path(tag.name)
end

it "defaults to white text for the color picker" do
Expand All @@ -18,32 +21,42 @@

it "defaults to black and white upon update", :aggregate_failures do
click_button("SAVE CHANGES")

tag.reload
expect(tag.bg_color_hex).to eq("#000000")
expect(tag.text_color_hex).to eq("#ffffff")

expect(tag.bg_color_hex).to eq(bg_color_hex)
expect(tag.text_color_hex).to eq(text_color_hex)
end
end

context "when colors have already been choosen for the tag" do
let(:tag) { create(:tag, bg_color_hex: "#0000ff", text_color_hex: "#ff0000") }

before do
sign_in super_admin
visit "/t/#{tag}/edit"
visit edit_tag_path(tag.name)
end

it "remains the same color it was unless otherwise updated via the color picker", :aggregate_failures do
old_bg_color_hex = tag.bg_color_hex
old_text_color_hex = tag.text_color_hex

click_button("SAVE CHANGES")
expect(tag.bg_color_hex).to eq(tag.bg_color_hex)
expect(tag.text_color_hex).to eq(tag.text_color_hex)

expect(tag.reload.bg_color_hex).to eq(old_bg_color_hex)
expect(tag.reload.text_color_hex).to eq(old_text_color_hex)
end
end
end

describe "UPDATE /t/:tag/edit as a tag_moderator" do
describe "Update tag as a tag_moderator" do
let(:tag) { create(:tag) }

context "when no colors have been choosen for the tag" do
before do
tag_moderator.add_role(:tag_moderator, tag)
sign_in tag_moderator
visit "/t/#{tag}/edit"
visit edit_tag_path(tag.name)
end

it "defaults to white text for the color picker" do
Expand All @@ -52,23 +65,31 @@

it "defaults to black and white upon update", :aggregate_failures do
click_button("SAVE CHANGES")

tag.reload
expect(tag.bg_color_hex).to eq("#000000")
expect(tag.text_color_hex).to eq("#ffffff")

expect(tag.bg_color_hex).to eq(bg_color_hex)
expect(tag.text_color_hex).to eq(text_color_hex)
end
end

context "when colors have already been choosen for the tag" do
let(:tag) { create(:tag, bg_color_hex: "#0000ff", text_color_hex: "#ff0000") }

before do
tag_moderator.add_role(:tag_moderator, tag)
sign_in tag_moderator
visit "/t/#{tag}/edit"
visit edit_tag_path(tag.name)
end

it "remains the same color it was unless otherwise updated via the color picker", :aggregate_failures do
old_bg_color_hex = tag.bg_color_hex
old_text_color_hex = tag.text_color_hex

click_button("SAVE CHANGES")
expect(tag.bg_color_hex).to eq(tag.bg_color_hex)
expect(tag.text_color_hex).to eq(tag.text_color_hex)

expect(tag.reload.bg_color_hex).to eq(old_bg_color_hex)
expect(tag.reload.text_color_hex).to eq(old_text_color_hex)
end
end
end
Expand Down
Binary file removed vendor/cache/rubocop-rspec-2.3.0.gem
Binary file not shown.
Binary file added vendor/cache/rubocop-rspec-2.4.0.gem
Binary file not shown.