Skip to content

Commit cb70bad

Browse files
authored
Replace regex rspec test.
1 parent 5128dec commit cb70bad

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

spec/requests/admin/users_requests_spec.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
before do
1010
sign_in(super_admin)
1111
AddRoleService.call(user_id: user.id, resource_type: Role::PARTNER, resource_id: partner.id)
12+
create(:organization, name: "Pawnee")
13+
create(:organization, name: "SF Diaper")
14+
create(:organization, name: "Second City")
1215
end
1316

1417
describe "GET #index" do
@@ -238,14 +241,12 @@
238241
end
239242
end
240243
describe "Validate Order of returned organization list" do
241-
let!(:pawnee_organization) { create(:organization, id: 2, name: "Pawnee") }
242-
let!(:sf_diaper_organization) { create(:organization, id: 3, name: "SF Diaper") }
243-
let!(:second_city_organization) { create(:organization, id: 4, name: "Second City") }
244-
245244
it "Should sort display resource in human alphabetical order" do
246245
get "/admin/users/resource_ids?resource_type=org_admin"
247-
puts response.body
248-
expect(response.body).to match(/{"results":\[{"id":\d+,"text":"Org ABC"},{"id":\d+,"text":"Pawnee"},{"id":\d+,"text":"Second City"},{"id":\d+,"text":"SF Diaper"}]}/)
246+
body_json = JSON.parse(response.body)
247+
expect(body_json["results"].length).to be(4)
248+
text_list = body_json["results"].map { |obj| obj["text"] }
249+
expect(text_list).to match_array(["Org ABC", "Pawnee", "SF Diaper", "Second City"])
249250
end
250251
end
251252
end

0 commit comments

Comments
 (0)