spec/properties/page_margins_spec.rb in openxml-docx-0.8.0 vs spec/properties/page_margins_spec.rb in openxml-docx-0.9.0

- old
+ new

@@ -4,141 +4,55 @@ include PropertyTestMacros it_should_use tag: :pgMar, name: "page_margins" for_attribute(:bottom) do - with_value(1440) do - it_should_assign_successfully - it_should_output "<w:pgMar w:bottom=\"1440\"/>" - end - - with_value(-1440) do - it_should_assign_successfully - it_should_output "<w:pgMar w:bottom=\"-1440\"/>" - end - - with_value(9832.1) do - it_should_raise_an_exception - end - - with_value(:big) do - it_should_raise_an_exception - end + values = [1440, -1440] + it_should_assign_and_output_xml values + it_should_not_allow_floats + it_should_not_allow_invalid_value end for_attribute(:footer) do - with_value(1440) do - it_should_assign_successfully - it_should_output "<w:pgMar w:footer=\"1440\"/>" - end - - with_value(-1440) do - it_should_raise_an_exception - end - - with_value(9832.1) do - it_should_raise_an_exception - end - - with_value(:big) do - it_should_raise_an_exception - end + it_should_assign_and_output_xml 1440 + it_should_not_allow_negative_numbers + it_should_not_allow_floats + it_should_not_allow_invalid_value end for_attribute(:gutter) do - with_value(1440) do - it_should_assign_successfully - it_should_output "<w:pgMar w:gutter=\"1440\"/>" - end - - with_value(-1440) do - it_should_raise_an_exception - end - - with_value(9832.1) do - it_should_raise_an_exception - end - - with_value(:big) do - it_should_raise_an_exception - end + it_should_assign_and_output_xml 1440 + it_should_not_allow_negative_numbers + it_should_not_allow_floats + it_should_not_allow_invalid_value end for_attribute(:header) do - with_value(1440) do - it_should_assign_successfully - it_should_output "<w:pgMar w:header=\"1440\"/>" - end - - with_value(-1440) do - it_should_raise_an_exception - end - - with_value(9832.1) do - it_should_raise_an_exception - end - - with_value(:big) do - it_should_raise_an_exception - end + it_should_assign_and_output_xml 1440 + it_should_not_allow_negative_numbers + it_should_not_allow_floats + it_should_not_allow_invalid_value end for_attribute(:left) do - with_value(1440) do - it_should_assign_successfully - it_should_output "<w:pgMar w:left=\"1440\"/>" - end - - with_value(-1440) do - it_should_raise_an_exception - end - - with_value(9832.1) do - it_should_raise_an_exception - end - - with_value(:big) do - it_should_raise_an_exception - end + it_should_assign_and_output_xml 1440 + it_should_not_allow_negative_numbers + it_should_not_allow_floats + it_should_not_allow_invalid_value end for_attribute(:right) do - with_value(1440) do - it_should_assign_successfully - it_should_output "<w:pgMar w:right=\"1440\"/>" - end - - with_value(-1440) do - it_should_raise_an_exception - end - - with_value(9832.1) do - it_should_raise_an_exception - end - - with_value(:big) do - it_should_raise_an_exception - end + it_should_assign_and_output_xml 1440 + it_should_not_allow_negative_numbers + it_should_not_allow_floats + it_should_not_allow_invalid_value end for_attribute(:top) do - with_value(1440) do - it_should_assign_successfully - it_should_output "<w:pgMar w:top=\"1440\"/>" - end - - with_value(-1440) do - it_should_assign_successfully - it_should_output "<w:pgMar w:top=\"-1440\"/>" - end - - with_value(9832.1) do - it_should_raise_an_exception - end - - with_value(:big) do - it_should_raise_an_exception - end + values = [1440, -1440] + it_should_assign_and_output_xml values + it_should_not_allow_floats + it_should_not_allow_invalid_value end with_no_attributes_set do it_should_output "", assign: false end