From f1797b4868a01a27cefef53416da0acca47cac7f Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Tue, 28 Aug 2012 13:43:56 +0100 Subject: Add headings and by_heading accessors to PublicBodyCategories to allow easier access to headings and to tags associated with a particular heading. --- spec/lib/public_body_categories_spec.rb | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 spec/lib/public_body_categories_spec.rb (limited to 'spec/lib') diff --git a/spec/lib/public_body_categories_spec.rb b/spec/lib/public_body_categories_spec.rb new file mode 100644 index 000000000..e53d9a028 --- /dev/null +++ b/spec/lib/public_body_categories_spec.rb @@ -0,0 +1,42 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe PublicBodyCategories do + + before do + load_test_categories + end + + describe 'when asked for categories with headings' do + + it 'should return a list of headings as plain strings, each followed by n tag specifications as + lists in the form: + ["tag_to_use_as_category", "Sub category title", "Instance description"]' do + expected_categories = ["Local and regional", ["local_council", + "Local councils", + "a local council"], + "Miscellaneous", ["other", + "Miscellaneous", + "miscellaneous"]] + PublicBodyCategories::get().with_headings().should == expected_categories + end + + end + + describe 'when asked for headings' do + + it 'should return a list of headings' do + PublicBodyCategories::get().headings().should == ['Local and regional', 'Miscellaneous'] + end + + end + + describe 'when asked for tags by headings' do + + it 'should return a hash of tags keyed by heading' do + PublicBodyCategories::get().by_heading().should == {'Local and regional' => ['local_council'], + 'Miscellaneous' => ['other']} + end + + end + +end \ No newline at end of file -- cgit v1.2.3