Skip to content
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

Ensure regions cannot be modified outside gem #180

Merged
merged 1 commit into from
Jan 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/carmen/region.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def name
end

def subregions
@subregions ||= load_subregions
@subregions ||= load_subregions.freeze
end

def subregions?
Expand Down
17 changes: 14 additions & 3 deletions spec/carmen/country_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@

describe Carmen::Country do

it "provides access to all countries" do
countries = Carmen::Country.all
countries.size.must_equal 3
describe "all" do
before do
@countries = countries = Carmen::Country.all
end

it "provides access to all countries" do
@countries.size.must_equal 3
end

it "denies modification of countries" do
assert_raises RuntimeError do
@countries.clear
end
end
end

describe "API for finding countries by name" do
Expand Down
10 changes: 10 additions & 0 deletions spec/carmen/region_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@
end

describe "subregions" do
it "is frozen" do
subregions = Carmen::Country.coded('OC').subregions

assert_raises RuntimeError do
subregions.clear
end
end
end

describe "subregion" do
before do
@london = @airstrip_one.subregions.first
end
Expand Down