aboutsummaryrefslogtreecommitdiffstats
path: root/spec/lib
diff options
context:
space:
mode:
authorRobin Houston <robin.houston@gmail.com>2012-09-07 12:51:42 +0100
committerRobin Houston <robin.houston@gmail.com>2012-09-07 12:51:42 +0100
commitc690679f5e55d908a0f91b0d9b3276ae3f748b2d (patch)
treecbe46b2e859aa6f59d39a110d997274091004a24 /spec/lib
parent67a3a43cc26f8ad7218f33a13af04c3c74347866 (diff)
parentdd39dbc580b1447758a6d3b9231ce09c9b3dcdf3 (diff)
Merge branch 'wdtk' of git.mysociety.org:/data/git/public/alaveteli into wdtk
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/public_body_categories_spec.rb42
1 files changed, 42 insertions, 0 deletions
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