test/unit/report/test_base.rb in thinreports-0.7.6 vs test/unit/report/test_base.rb in thinreports-0.7.7

- old
+ new

@@ -60,10 +60,26 @@ def test_start_new_page_should_create_a_new_page_using_a_specified_layoutfile new_page = @report.start_new_page(:layout => data_file('basic_layout1.tlf')) assert_equal new_page.layout.filename, data_file('basic_layout1.tlf') end + + def test_start_new_page_with_count_option + @report.use_layout data_file('basic_layout1.tlf'), :default => true + + new_page = @report.start_new_page :count => false + assert_nil new_page.no + assert_equal @report.page_count, 0 + + new_page = @report.start_new_page :count => true + assert_equal new_page.no, 1 + assert_equal @report.page_count, 1 + + new_page = @report.start_new_page + assert_equal new_page.no, 2 + assert_equal @report.page_count, 2 + end def test_add_blank_page_should_properly_create_a_new_blank_page @report.use_layout(data_file('basic_layout1')) assert_instance_of ThinReports::Core::BlankPage, @report.add_blank_page @@ -102,10 +118,28 @@ with(:pdf, @report, {:option => :value}). and_return(flexmock(:generate => 'Success')).once assert_equal @report.generate(:option => :value), 'Success' end + + def test_generate_should_call_generate_file_method_when_filename_option_is_given + flexmock(ThinReports::Generator). + should_receive(:new). + with(:pdf, @report, {}). + and_return(flexmock(:generate_file => 'Success')).once + + assert_equal @report.generate(:filename => 'foo.pdf'), 'Success' + end + + def test_generate_file_should_warn_the_DEPRECATION_WARNING + report = create_basic_report('basic_layout1') + + out, err = capture_io do + report.generate_file(temp_file) + end + assert_match /DEPRECATION/, err + end def test_generate_file_should_properly_initialize_Generator_and_call_generate_file_method_when_type_is_specified generator = flexmock('generator') generator.should_receive(:generate_file).with('output.pdf').once @@ -182,10 +216,16 @@ def test_list_should_properly_return_shape_with_the_specified_id @report.use_layout(data_file('basic_list_layout.tlf')) assert_equal @report.list(:list).id, 'list' end + + def test_start_page_number + assert_equal @report.start_page_number, 1 + @report.start_page_number_from 10 + assert_equal @report.start_page_number, 10 + end def test_Base_create_should_finalize_report report = Report::Base.create do |r| assert_instance_of Report::Base, r end @@ -234,9 +274,16 @@ should_receive(:create). with({:layout => 'layout.tlf'}, Proc). and_return(Report::Base.new).once Report::Base.generate_file(:pdf, 'output.pdf', :report => {:layout => 'layout.tlf'}) {} + end + + def test_Base_generate_file_should_warn_the_DEPRICATION_WARNING + out, err = capture_io do + Report.generate_file(temp_file, :report => {:layout => data_file('basic_layout1')}) { start_new_page } + end + assert_match /DEPRECATION/, err end def test_Base_generate_file_should_properly_generate_file_when_type_is_omitted flexmock(Report::Base).new_instances. should_receive(:generate_file).