Skip to content

Instantly share code, notes, and snippets.

@robertbrook
Created November 12, 2009 12:24
Show Gist options
  • Save robertbrook/232858 to your computer and use it in GitHub Desktop.
Save robertbrook/232858 to your computer and use it in GitHub Desktop.
describe HansardReference, 'when creating a reference' do
# checking matches #
it 'should match date in "27 October 2003, Official Report, column 55W"' do
should_match '27 October 2003, Official Report, column 55W'
end
it 'should match on "10 February 2004, Official Report, columns 1293–98W"' do
should_match '10 February 2004, Official Report, columns 1293–98W'
end
it 'should match on "15 January 1986, c. 580"' do
should_match '15 January 1986, c. 580'
end
# checking identifies house #
it 'should not identify house from "15 January 1986, c. 580"' do
should_match_house '15 January 1986, c. 580', nil
end
it 'should identify house from "hc deb 12 December 2005 c1090"' do
should_match_house 'hc deb 2 December 2005 c1090', :commons
end
it 'should identify house from "HC Deb 12 December 2005 c1090"' do
should_match_house 'HC Deb 2 December 2005 c1090', :commons
end
# checking identifies date #
it 'should match date in "15 January 1986, c. 580"' do
should_match_date '15 January 1986, c. 580', '1986-01-15'
end
it 'should match date in "HC Deb 12 December 2005 c1090"' do
should_match_date 'HC Deb 2 December 2005 c1090', '2005-12-02'
end
it 'should match date in "HL Deb 20 July 2005 c111WA"' do
should_match_date 'HL Deb 20 July 2005 c111WA', '2005-07-20'
end
# checking identifies volume #
it 'should not identify volume from "15 January 1986, c. 580"' do
should_match_volume '15 January 1986, c. 580', nil
end
it 'should not identify volume from "HC Deb 12 December 2005 c1090"' do
should_match_volume 'HC Deb 2 December 2005 c1090', nil
end
it 'should not identify volume from "HC Deb 12 December 2005 cc1090-4"' do
should_match_volume 'HC Deb 12 December 2005 cc1090-4', nil
end
# checking identifies column #
it 'should identify column from "15 January 1986, c. 580"' do
should_match_column '15 January 1986, c. 580', 580
end
it 'should identify column from "HC Deb 12 December 2005 c1090"' do
should_match_column 'HC Deb 2 December 2005 c1090', 1090
end
# checking identifies column #
it 'should identify column from "15 January 1986, c. 580"' do
should_match_end_column '15 January 1986, c. 580', nil
end
it 'should identify column from "HC Deb 12 December 2005 c1090"' do
should_match_end_column 'HC Deb 2 December 2005 c1090', nil
end
# checking identifies series #
it 'should not identify series from "15 January 1986, c. 580"' do
should_match_series '15 January 1986, c. 580', nil
end
it 'should not identify series from "HC Deb 12 December 2005 c1090"' do
should_match_series 'HC Deb 2 December 2005 c1090', nil
end
it 'should not identify series from "HC Deb 12 December 2005 cc1090-4"' do
should_match_series 'HC Deb 12 December 2005 cc1090-4', nil
end
# checking identifies written statement #
it 'should identify whether written statement from "HC Deb 12 December 2005 c1090"' do
should_identify_written_statement 'HC Deb 2 December 2005 c1090', false
end
it 'should identify whether written statement from "HC Deb 12 December 2005 cc1090-4"' do
should_identify_written_statement 'HC Deb 12 December 2005 cc1090-4', false
end
# checking identifies written answer #
it 'should not identitfy as written answer "HC Deb 18 Oct 1971 c343"' do
should_identify_written_answer 'HC Deb 18 Oct 1971 c343', false
end
it 'should identify whether written answer from "HC Deb 12 December 2005 c1090"' do
should_identify_written_answer 'HC Deb 2 December 2005 c1090', false
end
it 'should identify whether written answer from "HC Deb 12 December 2005 cc1090-4"' do
should_identify_written_answer 'HC Deb 12 December 2005 cc1090-4', false
end
it 'should not create reference from "random text"' do
HansardReference.create_from('random text').should be_nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment