Skip to content

Commit

Permalink
Refactor booking and parking slot specs to simplify attribute handlin…
Browse files Browse the repository at this point in the history
…g and ensure accurate test conditions
  • Loading branch information
binos30 committed Jan 25, 2025
1 parent 3b2499a commit 0793138
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
7 changes: 1 addition & 6 deletions spec/requests/api/v1/bookings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@
# sticking to rails and rspec-rails APIs to keep things simple and stable.

RSpec.describe "/api/v1/bookings", type: :request do
# This should return the minimal set of attributes required to create a valid
# Booking. As you add validations to Booking, be sure to
# adjust the attributes here as well.
let(:valid_attributes) { { vehicle_type: VehicleType::TYPES[:small], plate_number: "ABC123" } }

describe "GET /index" do
before do
create(:booking)
Expand All @@ -32,7 +27,7 @@
end

describe "GET /show" do
let!(:booking) { create(:booking, **valid_attributes) }
let!(:booking) { create(:booking, vehicle_type: :small) }

before { get api_v1_booking_url(booking) }

Expand Down
7 changes: 2 additions & 5 deletions spec/requests/api/v1/parking_slots_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,16 @@
# sticking to rails and rspec-rails APIs to keep things simple and stable.

RSpec.describe "/api/v1/parking_slots", type: :request do
let!(:parking_lot) { create :parking_lot }

describe "GET /index" do
before do
ParkingSlot.destroy_all
create_pair(:parking_slot, parking_lot:)
create(:parking_lot, slots_count: 3)
get api_v1_parking_slots_url
end

it "renders a successful response" do
expect(response).to have_http_status(:success)
parking_slots = response.parsed_body
expect(parking_slots.size).to eq(2)
expect(parking_slots.size).to eq(3)
end
end
end

0 comments on commit 0793138

Please sign in to comment.