Skip to content

Commit ac65577

Browse files
author
Alistair Davidson
committed
cleaner syntax for choosing a random nation & region in the Local Authority factory, and should_not be_persisted in local_authority_spec
1 parent 071ef4b commit ac65577

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

spec/factories/local_authorities.rb

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,8 @@
3131
gias_code { Array(0..9).sample(3).join }
3232
official_name { [Faker::Address.city, "Council"].join(" ") }
3333
short_name { [Faker::Address.city] }
34-
region do
35-
[
36-
"Yorkshire and The Humber",
37-
"West Midlands",
38-
"East Midlands",
39-
"Northern Ireland",
40-
"South East",
41-
"Wales",
42-
nil,
43-
"East of England",
44-
"Scotland",
45-
"North East",
46-
"North West",
47-
"South West",
48-
"London"
49-
].sample
50-
end
51-
nation { "England" }
34+
region { LocalAuthority.regions.keys.sample }
35+
nation { LocalAuthority.nations.keys.sample }
5236
gov_uk_slug do
5337
["/", Faker::Address.city.downcase.gsub(/[^A-Z]+/i, "-")].join
5438
end

spec/models/local_authority_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
end
4848

4949
describe "the result" do
50-
it "is not saved" do
51-
expect(result.persisted?).to be(false)
52-
end
50+
subject{ result }
51+
52+
it { should_not be_persisted }
5353

5454
it "has the expected attributes" do
5555
expect(result).to have_attributes(

0 commit comments

Comments
 (0)