-
Notifications
You must be signed in to change notification settings - Fork 20
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
Rspec rubocop #4524
base: main
Are you sure you want to change the base?
Rspec rubocop #4524
Conversation
7e96a5e
to
4604572
Compare
ac9e058
to
8fab2f4
Compare
c71e2b1
to
ca01601
Compare
ca01601
to
ca83948
Compare
- This is the "include dangerous autocorrects" version, and indeed some of these changes break tests. I will fix in the following commits.
ca83948
to
0f69853
Compare
cc90ef8
to
20e057c
Compare
- will be used in the following commits, allows us to include expectations in methods that would otherwise appear erroneously to have no expectations, fooling rubocop - But is also a more consistent call.
- One lint (RSpec/SubjectStub) is disabled in two classes rather than being fixed, because fixing it really requires a rethink about the actual classes, and this set of commits is scoped to just making the lint pass. We should revisit how these two classes work later (especially the call out to mtime in ics_renderer)
20e057c
to
eee8251
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good. I've added some inline comments, but they are quite small.
@@ -1,5 +1,5 @@ | |||
RSpec.describe GetInvolved do | |||
let(:consultation_1) do | |||
let(:consultation_closing_november) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are much nicer names!
spec/requests/places_spec.rb
Outdated
end | ||
end | ||
|
||
context "with invalid postcode" do | ||
it "shows location error" do | ||
post "/slug", params: { postcode: invalid_postcode } | ||
|
||
expect(LocationError.new(PlacesManagerResponse::INVALID_POSTCODE).postcode_error).to eq(@controller.view_assigns["location_error"].postcode_error) | ||
expect(LocationError.new(PlacesManagerResponse::INVALID_POSTCODE).postcode_error).to eq(describecontroller.view_assigns["location_error"].postcode_error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo? Should this be controller
rather than describecontroller
?
@@ -37,29 +38,31 @@ | |||
end | |||
|
|||
context "with a protocol-relative redirect" do | |||
let(:referer) { "//protocol-relative-path" } | |||
let(:redirect_path) { referer } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think redirect_path
is needed for this test if it's just a copy of referrer. However, I think that might be out of scope for these changes.
@@ -128,11 +131,11 @@ | |||
get "/sign-in/callback", params: { code: "code123", state: "state123", _ga: underscore_ga } | |||
|
|||
expect(response).to have_http_status(:redirect) | |||
assert_includes(@response.redirect_url, underscore_ga) | |||
assert_includes(response.redirect_url, underscore_ga) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't assert_includes
Minitest?
Should it be expect(response.redirect_url).to include(underscore_ga)
?
spec/requests/sessions_spec.rb
Outdated
@@ -142,10 +145,10 @@ | |||
get "/sign-in/callback", params: { code: "code123", state: "state123" } | |||
|
|||
expect(response).to have_http_status(:redirect) | |||
assert_includes(@response.redirect_url, @redirect_path) | |||
assert_includes(response.redirect_url, @redirect_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here and below about using assert_includes
end | ||
end | ||
|
||
context "with CSV containing CRLF line terminators" do | ||
subject { described_class.new(@crlf_csv).csv_rows } | ||
let(:csv) { "header 1,header 2,header 3\ncontent 1,content 2,content 3\n".gsub(/\n/, "\r\n") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just set this to "header 1,header 2,header 3\ncontent 1,content 2,content 3\r\n
?
"kind" => "outcome", | ||
"slug" => "outcome-1", | ||
"title" => "Outcome 1", | ||
"body" => "<p>This is outcome 1</p>", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's strange that Outcome 1 is duplicated. Perhaps it can be deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So has this file has been renamed from "spec/unit/strategy_spec.rb"? If so, I'd expect to see a corresponding deleted file.
# Stop the checker putting it's jaunty message to stdout | ||
around do |ex| | ||
original_stdout = $stdout | ||
$stdout = File.open(File::NULL, "w") | ||
ex.run | ||
$stdout = original_stdout | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for removing this! I too want to see the error if the test fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! This deletion should be fixed up to the previous commit.
What
During the rspec conversion, we missed that rubocop-govuk has an opt-in rspec lint ruleset, which wasn't turned on (because previously there was no rspec). This PR turns on that setting, and fixes the many cops that were triggered.
Why
We should adhere to our standards, especially as Frontend is the candidate for merging the other frontend apps.