Compare commits

..

3 Commits

Author SHA1 Message Date
Daniel O'Connor
9c4238e601 Merge branch 'dev' into feature-use-test-queue 2026-04-26 02:03:56 +09:30
Daniel O'Connor
75a2ec89e0 Merge branch 'dev' into feature-use-test-queue 2026-04-24 00:02:00 +09:30
google-labs-jules[bot]
bd5769cf4f feat: Use test-queue to parallelize RSpec tests
This change introduces the `test-queue` gem to the project to enable parallel execution of the RSpec test suite. The CI configuration in `.github/workflows/ci.yml` has been updated to use a single `test-queue` command instead of multiple, sequential `rspec` commands. This will help to speed up the CI process by running tests concurrently.

The `--fail-fast` option has been removed from the RSpec command, as it is not recommended when running tests in parallel. This ensures that all tests are run, providing a complete picture of the test suite's status.
2025-11-29 03:40:46 +00:00
14 changed files with 35 additions and 40 deletions

View File

@@ -108,23 +108,5 @@ jobs:
run: bundle exec rails db:prepare
- name: Run rspec (lib)
run: bundle exec rspec spec/lib/ -fd --fail-fast
- name: Run rspec (services)
run: bundle exec rspec spec/services/ -fd --fail-fast
- name: Run rspec (models)
run: bundle exec rspec spec/models/ -fd --fail-fast
- name: Run rspec (controllers)
run: bundle exec rspec spec/controllers/ -fd --fail-fast
- name: Run rspec (views)
run: bundle exec rspec spec/views/ -fd --fail-fast
- name: Run rspec (routing)
run: bundle exec rspec spec/routing/ -fd --fail-fast
- name: Run rspec (request)
run: bundle exec rspec spec/requests/ -fd --fail-fast
- name: Run tests with test-queue
run: bundle exec test-queue rspec spec -fd

View File

@@ -76,8 +76,3 @@ Rails/SkipsModelValidations:
- 'db/migrate/20240810160538_set_default_language_for_existing_alternate_names.rb'
- 'db/migrate/20240101010102_populate_crop_fields_from_openfarm_data.rb'
- 'db/seeds.rb'
Rails/ResponseParsedBody:
Exclude:
- spec/controllers/api/v1/plantings_controller_spec.rb
- spec/requests/api/v1/members_request_spec.rb

View File

@@ -601,6 +601,21 @@ Rails/RedundantPresenceValidationOnBelongsTo:
- 'app/models/planting.rb'
- 'app/models/scientific_name.rb'
# Offense count: 16
# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/ResponseParsedBody:
Exclude:
- 'spec/controllers/api/v1/plantings_controller_spec.rb'
- 'spec/controllers/likes_controller_spec.rb'
- 'spec/requests/api/v1/activities_request_spec.rb'
- 'spec/requests/api/v1/crop_request_spec.rb'
- 'spec/requests/api/v1/gardens_request_spec.rb'
- 'spec/requests/api/v1/harvests_request_spec.rb'
- 'spec/requests/api/v1/members_request_spec.rb'
- 'spec/requests/api/v1/photos_request_spec.rb'
- 'spec/requests/api/v1/plantings_request_spec.rb'
- 'spec/requests/api/v1/seeds_request_spec.rb'
# Offense count: 9
Rails/ReversibleMigration:
Exclude:

View File

@@ -196,6 +196,7 @@ group :test do
gem 'rails-controller-testing'
gem "rspec-rebound"
gem 'selenium-webdriver'
gem 'test-queue'
gem 'timecop'
gem 'vcr'
end

View File

@@ -719,6 +719,7 @@ GEM
unicode-display_width (>= 1.1.1, < 4)
terser (1.2.7)
execjs (>= 0.3.0, < 3)
test-queue (0.11.1)
thor (1.5.0)
thread_safe (0.3.6)
tilt (2.7.0)
@@ -873,6 +874,7 @@ DEPENDENCIES
sitemap_generator
sprockets (< 4)
terser
test-queue
timecop
unicorn
validate_url

View File

@@ -3,7 +3,7 @@
require 'rails_helper'
RSpec.describe Api::V1::PlantingsController do
subject { JSON.parse(response.body) }
subject { JSON.parse response.body }
let!(:member) { create(:member) }

View File

@@ -16,7 +16,7 @@ describe LikesController do
it { expect(Like.last.likeable_id).to eq(blogpost.id) }
it { expect(Like.last.likeable_type).to eq('Post') }
it { response.parsed_body["description"] == "1 like" }
it { JSON.parse(response.body)["description"] == "1 like" }
describe "Liking someone else's post" do
it { expect(response).to have_http_status(:created) }
@@ -30,14 +30,14 @@ describe LikesController do
describe "un-liking something i liked before" do
it { expect(response).to have_http_status(:ok) }
it { response.parsed_body["description"] == "0 likes" }
it { JSON.parse(response.body)["description"] == "0 likes" }
end
describe "Deleting someone else's like" do
let(:like) { create(:like) }
it { expect(response).to have_http_status(:forbidden) }
it { response.parsed_body["error"] == "Unable to like" }
it { JSON.parse(response.body)["error"] == "Unable to like" }
end
end
end

View File

@@ -3,7 +3,7 @@
require 'rails_helper'
RSpec.describe 'Activities' do
subject { response.parsed_body }
subject { JSON.parse response.body }
let(:member) { create(:member) }
let(:token) do

View File

@@ -3,7 +3,7 @@
require 'rails_helper'
RSpec.describe 'Crops' do
subject { response.parsed_body }
subject { JSON.parse response.body }
let(:headers) { { 'Accept' => 'application/vnd.api+json' } }
let!(:crop) { create(:crop) }

View File

@@ -3,7 +3,7 @@
require 'rails_helper'
RSpec.describe 'Gardens' do
subject { response.parsed_body }
subject { JSON.parse response.body }
let(:headers) { { 'Accept' => 'application/vnd.api+json' } }
let!(:garden) { create(:garden) }

View File

@@ -3,7 +3,7 @@
require 'rails_helper'
RSpec.describe 'Harvests' do
subject { response.parsed_body }
subject { JSON.parse response.body }
let(:headers) { { 'Accept' => 'application/vnd.api+json' } }
let!(:harvest) { create(:harvest) }

View File

@@ -3,7 +3,7 @@
require 'rails_helper'
RSpec.describe 'Photos' do
subject { response.parsed_body }
subject { JSON.parse response.body }
let(:headers) { { 'Accept' => 'application/vnd.api+json' } }
let!(:photo) { create(:photo) }

View File

@@ -3,7 +3,7 @@
require 'rails_helper'
RSpec.describe 'Plantings' do
subject { response.parsed_body }
subject { JSON.parse response.body }
let(:headers) { { 'Accept' => 'application/vnd.api+json' } }
let!(:planting) { create(:planting) }
@@ -220,18 +220,18 @@ RSpec.describe 'Plantings' do
describe "#show" do
it "locates the correct member" do
get "/api/v1/plantings?filter[owner-id]=#{@member1.id}"
expect(response.parsed_body['data'][0]['id']).to eq(planting.id.to_s)
expect(JSON.parse(response.body)['data'][0]['id']).to eq(planting.id.to_s)
get "/api/v1/plantings?filter[owner-id]=#{@member2.id}"
expect(response.parsed_body['data'][0]['id']).to eq(@planting2.id.to_s)
expect(JSON.parse(response.body)['data'][0]['id']).to eq(@planting2.id.to_s)
pending "The below should be identical to the above, but aren't."
get "/api/v1/members/#{@member1.id}/plantings"
expect(response.parsed_body['data'][0]['id']).to eq(planting.id.to_s)
expect(JSON.parse(response.body)['data'][0]['id']).to eq(planting.id.to_s)
get "/api/v1/members/#{@member2.id}/plantings"
expect(response.parsed_body['data'][0]['id']).to eq(@planting2.id.to_s)
expect(JSON.parse(response.body)['data'][0]['id']).to eq(@planting2.id.to_s)
end
end
end

View File

@@ -3,7 +3,7 @@
require 'rails_helper'
RSpec.describe 'Seeds' do
subject { response.parsed_body }
subject { JSON.parse response.body }
let(:headers) { { 'Accept' => 'application/vnd.api+json' } }
let!(:seed) { create(:seed) }