cornucopia 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -13
- data/lib/cornucopia/cucumber_hooks.rb +3 -1
- data/lib/cornucopia/rspec_hooks.rb +12 -9
- data/lib/cornucopia/source_files/cornucopia.css +73 -2
- data/lib/cornucopia/source_files/report.js +17 -0
- data/lib/cornucopia/source_files/report_holder.html +22 -0
- data/lib/cornucopia/spinach_hooks.rb +6 -0
- data/lib/cornucopia/util/configured_report.rb +9 -23
- data/lib/cornucopia/util/file_asset.rb +8 -0
- data/lib/cornucopia/util/report_builder.rb +155 -10
- data/lib/cornucopia/version.rb +1 -1
- data/spec/lib/capybara/finder_diagnostics_spec.rb +288 -233
- data/spec/lib/capybara/page_diagnostics_spec.rb +7 -7
- data/spec/lib/util/configured_report_spec.rb +3 -3
- data/spec/lib/util/log_capture_spec.rb +3 -3
- data/spec/lib/util/report_builder_spec.rb +398 -50
- metadata +4 -2
@@ -57,7 +57,7 @@ describe Cornucopia::Capybara::PageDiagnostics, type: :feature do
|
|
57
57
|
|
58
58
|
report.close
|
59
59
|
|
60
|
-
report_text = File.read(report.
|
60
|
+
report_text = File.read(report.report_test_contents_page_name)
|
61
61
|
expect(report_text).not_to match /No Errors to report/
|
62
62
|
expect(report_text).to match /\>Page Dump:\</
|
63
63
|
expect(report_text).to match /\>\npage_url\n\</
|
@@ -92,7 +92,7 @@ describe Cornucopia::Capybara::PageDiagnostics, type: :feature do
|
|
92
92
|
|
93
93
|
report.close
|
94
94
|
|
95
|
-
report_text = File.read(report.
|
95
|
+
report_text = File.read(report.report_test_contents_page_name)
|
96
96
|
expect(report_text).not_to match /No Errors to report/
|
97
97
|
expect(report_text).not_to match /\>\noptions\n\</
|
98
98
|
expect(report_text).not_to match /\>\nreport\n\</
|
@@ -131,7 +131,7 @@ describe Cornucopia::Capybara::PageDiagnostics, type: :feature do
|
|
131
131
|
|
132
132
|
report.close
|
133
133
|
|
134
|
-
report_text = File.read(report.
|
134
|
+
report_text = File.read(report.report_test_contents_page_name)
|
135
135
|
expect(report_text).not_to match /No Errors to report/
|
136
136
|
expect(report_text).not_to match /\>\noptions\n\</
|
137
137
|
expect(report_text).not_to match /\>\nreport\n\</
|
@@ -171,7 +171,7 @@ describe Cornucopia::Capybara::PageDiagnostics, type: :feature do
|
|
171
171
|
Cornucopia::Capybara::PageDiagnostics.dump_details(report: report)
|
172
172
|
report.close
|
173
173
|
|
174
|
-
report_text = File.read(report.
|
174
|
+
report_text = File.read(report.report_test_contents_page_name)
|
175
175
|
expect(report_text).not_to match /No Errors to report/
|
176
176
|
expect(report_text).not_to match /\>\noptions\n\</
|
177
177
|
expect(report_text).not_to match /\>\nreport\n\</
|
@@ -209,7 +209,7 @@ describe Cornucopia::Capybara::PageDiagnostics, type: :feature do
|
|
209
209
|
|
210
210
|
report.close
|
211
211
|
|
212
|
-
report_text = File.read(report.
|
212
|
+
report_text = File.read(report.report_test_contents_page_name)
|
213
213
|
expect(report_text).not_to match /No Errors to report/
|
214
214
|
expect(report_text.scan(/\>Super cool report dump:\</).length).to be == 1
|
215
215
|
end
|
@@ -233,7 +233,7 @@ describe Cornucopia::Capybara::PageDiagnostics, type: :feature do
|
|
233
233
|
|
234
234
|
report.close
|
235
235
|
|
236
|
-
report_text = File.read(report.
|
236
|
+
report_text = File.read(report.report_test_contents_page_name)
|
237
237
|
expect(report_text).not_to match /No Errors to report/
|
238
238
|
expect(report_text.scan(/\>Super cool report dump:\</).length).to be == 1
|
239
239
|
expect(report_text).to match /Could not save screen_shot./
|
@@ -255,7 +255,7 @@ describe Cornucopia::Capybara::PageDiagnostics, type: :feature do
|
|
255
255
|
|
256
256
|
report.close
|
257
257
|
|
258
|
-
report_text = File.read(report.
|
258
|
+
report_text = File.read(report.report_test_contents_page_name)
|
259
259
|
expect(report_text).not_to match /No Errors to report/
|
260
260
|
expect(report_text).to match /\>an existing section\</
|
261
261
|
expect(report_text).to match /\>\nsomething\n\</
|
@@ -831,7 +831,7 @@ describe Cornucopia::Util::ConfiguredReport do
|
|
831
831
|
|
832
832
|
builder.generate_report(report)
|
833
833
|
|
834
|
-
full_table = File.read(report.
|
834
|
+
full_table = File.read(report.report_test_contents_page_name)
|
835
835
|
|
836
836
|
expect(full_table).not_to match(/\"cornucopia-show-hide-section\"/)
|
837
837
|
expect(full_table).to match(/\>\ntest\n\</)
|
@@ -863,7 +863,7 @@ describe Cornucopia::Util::ConfiguredReport do
|
|
863
863
|
table.write_stats("Something_Extra", "A value")
|
864
864
|
end
|
865
865
|
|
866
|
-
full_table = File.read(report.
|
866
|
+
full_table = File.read(report.report_test_contents_page_name)
|
867
867
|
|
868
868
|
expect(full_table).to match(/\"cornucopia-show-hide-section\"/)
|
869
869
|
expect(full_table).to match(/\>\ntest\n\</)
|
@@ -897,7 +897,7 @@ describe Cornucopia::Util::ConfiguredReport do
|
|
897
897
|
|
898
898
|
builder.generate_report(report)
|
899
899
|
|
900
|
-
full_table = File.read(report.
|
900
|
+
full_table = File.read(report.report_test_contents_page_name)
|
901
901
|
|
902
902
|
expect(full_table).to match(/\"cornucopia-show-hide-section\"/)
|
903
903
|
expect(full_table).to match(/\>\ntest\n\</)
|
@@ -105,7 +105,7 @@ describe Cornucopia::Util::LogCapture do
|
|
105
105
|
|
106
106
|
Cornucopia::Util::LogCapture.capture_logs(nil)
|
107
107
|
|
108
|
-
report_data = File.read(Rails.root.join("cornucopia_report/cornucopia_report/report_contents.html"))
|
108
|
+
report_data = File.read(Rails.root.join("cornucopia_report/cornucopia_report/test_1/report_contents.html"))
|
109
109
|
expect(report_data).to match /#{lines[-500..-1].join("\n")}/
|
110
110
|
expect(report_data).to_not match /#{lines[-501..-1].join("\n")}/
|
111
111
|
end
|
@@ -124,7 +124,7 @@ describe Cornucopia::Util::LogCapture do
|
|
124
124
|
expect(Rails).to receive(:root).at_least(1).and_return(new_root)
|
125
125
|
Cornucopia::Util::LogCapture.capture_logs(nil)
|
126
126
|
|
127
|
-
report_data = File.read(File.join(new_root, "cornucopia_report/cornucopia_report/report_contents.html"))
|
127
|
+
report_data = File.read(File.join(new_root, "cornucopia_report/cornucopia_report/test_1/report_contents.html"))
|
128
128
|
expect(report_data).to match /#{lines[-500..-1].join("\n")}/
|
129
129
|
expect(report_data).to_not match /#{lines[-501..-1].join("\n")}/
|
130
130
|
end
|
@@ -143,7 +143,7 @@ describe Cornucopia::Util::LogCapture do
|
|
143
143
|
|
144
144
|
Cornucopia::Util::LogCapture.capture_logs(nil)
|
145
145
|
|
146
|
-
report_data = File.read(Rails.root.join("cornucopia_report/cornucopia_report/report_contents.html"))
|
146
|
+
report_data = File.read(Rails.root.join("cornucopia_report/cornucopia_report/test_1/report_contents.html"))
|
147
147
|
expect(report_data).to match /#{lines[-500..-1].join("\n")}/
|
148
148
|
expect(report_data).to_not match /#{lines[-501..-1].join("\n")}/
|
149
149
|
end
|
@@ -430,6 +430,11 @@ describe Cornucopia::Util::ReportBuilder do
|
|
430
430
|
to be == File.join(report_folder, "index.html").to_s
|
431
431
|
end
|
432
432
|
|
433
|
+
it "returns the #report_test_base_page_name" do
|
434
|
+
expect(send(report_settings[:report]).report_test_base_page_name).
|
435
|
+
to be == File.join(report_folder, "test_1/index.html").to_s
|
436
|
+
end
|
437
|
+
|
433
438
|
it "returns the #index_base_page_name" do
|
434
439
|
expect(send(report_settings[:report]).index_base_page_name).to be == File.join(index_folder, "index.html").to_s
|
435
440
|
end
|
@@ -439,6 +444,11 @@ describe Cornucopia::Util::ReportBuilder do
|
|
439
444
|
to be == File.join(report_folder, "report_contents.html").to_s
|
440
445
|
end
|
441
446
|
|
447
|
+
it "returns the #report_test_contents_page_name" do
|
448
|
+
expect(send(report_settings[:report]).report_test_contents_page_name).
|
449
|
+
to be == File.join(report_folder, "test_1/report_contents.html").to_s
|
450
|
+
end
|
451
|
+
|
442
452
|
it "returns the #index_contents_page_name" do
|
443
453
|
expect(send(report_settings[:report]).index_contents_page_name).
|
444
454
|
to be == File.join(index_folder, "report_contents.html").to_s
|
@@ -624,7 +634,7 @@ describe Cornucopia::Util::ReportBuilder do
|
|
624
634
|
end
|
625
635
|
|
626
636
|
groups.each do |other_group_name, other_group_indexes|
|
627
|
-
if
|
637
|
+
if other_group_name != group_name
|
628
638
|
expect((group_indexes.min < other_group_indexes.min && group_indexes.max < other_group_indexes.min) ||
|
629
639
|
(group_indexes.min > other_group_indexes.max && group_indexes.max > other_group_indexes.max)).
|
630
640
|
to be_truthy
|
@@ -642,6 +652,102 @@ describe Cornucopia::Util::ReportBuilder do
|
|
642
652
|
end
|
643
653
|
end
|
644
654
|
|
655
|
+
describe "#rebuild_report_holder_page" do
|
656
|
+
it "intializes report files" do
|
657
|
+
current_report = send(report_settings[:report])
|
658
|
+
|
659
|
+
expect(current_report).to receive(:initialize_report_files).and_call_original
|
660
|
+
|
661
|
+
current_report.rebuild_report_holder_page
|
662
|
+
|
663
|
+
expect(File.exists?(File.join(report_folder, "index.html"))).to be_truthy
|
664
|
+
expect(File.exists?(File.join(report_folder, "report.js"))).to be_truthy
|
665
|
+
expect(File.exists?(File.join(report_folder, "cornucopia.css"))).to be_truthy
|
666
|
+
end
|
667
|
+
|
668
|
+
it "creates the report folder" do
|
669
|
+
current_report = send(report_settings[:report])
|
670
|
+
|
671
|
+
current_report.rebuild_report_holder_page
|
672
|
+
|
673
|
+
expect(File.directory?(report_folder)).to be_truthy
|
674
|
+
end
|
675
|
+
|
676
|
+
it "builds the holder file" do
|
677
|
+
current_report = send(report_settings[:report])
|
678
|
+
|
679
|
+
test_names = []
|
680
|
+
report_body = "".html_safe
|
681
|
+
|
682
|
+
rand(1..5).times do
|
683
|
+
test_name = Faker::Lorem.sentence
|
684
|
+
test_names << test_name
|
685
|
+
|
686
|
+
current_report.instance_variable_set(:@test_name, test_name)
|
687
|
+
current_report.instance_variable_set(:@test_list_item, nil)
|
688
|
+
|
689
|
+
report_body += current_report.test_list_item
|
690
|
+
end
|
691
|
+
|
692
|
+
current_report.instance_variable_set(:@report_body, report_body)
|
693
|
+
|
694
|
+
current_report.rebuild_report_holder_page
|
695
|
+
|
696
|
+
report_page = Capybara::Node::Simple.new(File.read(File.join(report_folder, "index.html")))
|
697
|
+
|
698
|
+
expect(report_page.all(".coruncopia-report-link").length).to eq(test_names.length)
|
699
|
+
expect(report_page.find("#report-display-document")).to be
|
700
|
+
|
701
|
+
test_names.each_with_index do |test_name, test_index|
|
702
|
+
expect(report_page.all(".coruncopia-report-link")[test_index].text).to eq(test_name)
|
703
|
+
end
|
704
|
+
end
|
705
|
+
end
|
706
|
+
|
707
|
+
describe "#test_list_item" do
|
708
|
+
it "is html_safe?" do
|
709
|
+
current_report = send(report_settings[:report])
|
710
|
+
|
711
|
+
expect(current_report.test_list_item).to be_html_safe
|
712
|
+
end
|
713
|
+
|
714
|
+
it "creates a list item" do
|
715
|
+
current_report = send(report_settings[:report])
|
716
|
+
|
717
|
+
list_item = current_report.test_list_item
|
718
|
+
expect(list_item).to match /\<a class=\"coruncopia-report-link\"/
|
719
|
+
expect(list_item).to match /\<li\>/
|
720
|
+
expect(list_item).to match /\<\/li\>/
|
721
|
+
end
|
722
|
+
end
|
723
|
+
|
724
|
+
describe "#initialize_report_test_files" do
|
725
|
+
it "should create the report test folder" do
|
726
|
+
current_report = send(report_settings[:report])
|
727
|
+
|
728
|
+
FileUtils.mkdir_p current_report.index_folder_name
|
729
|
+
current_report.rebuild_index_page
|
730
|
+
|
731
|
+
post_file = File.read(File.join(current_report.index_folder_name, "report_contents.html"))
|
732
|
+
expect(post_file).not_to match /\>#{report_settings[:sub_folder]}\</
|
733
|
+
|
734
|
+
current_report.initialize_report_test_files
|
735
|
+
|
736
|
+
test_report_folder = current_report.report_test_folder_name
|
737
|
+
expect(File.exists?(test_report_folder)).to be_truthy
|
738
|
+
|
739
|
+
post_file = File.read(File.join(current_report.index_folder_name, "report_contents.html"))
|
740
|
+
expect(post_file).to match /\>#{report_settings[:sub_folder]}\</
|
741
|
+
|
742
|
+
expect(File.exists?(File.join(test_report_folder, "index.html"))).to be_truthy
|
743
|
+
expect(File.exists?(File.join(test_report_folder, "report_contents.html"))).to be_truthy
|
744
|
+
expect(File.exists?(File.join(test_report_folder, "collapse.gif"))).to be_truthy
|
745
|
+
expect(File.exists?(File.join(test_report_folder, "expand.gif"))).to be_truthy
|
746
|
+
expect(File.exists?(File.join(test_report_folder, "more_info.js"))).to be_truthy
|
747
|
+
expect(File.exists?(File.join(test_report_folder, "cornucopia.css"))).to be_truthy
|
748
|
+
end
|
749
|
+
end
|
750
|
+
|
645
751
|
describe "#initialize_report_files" do
|
646
752
|
it "should create the report folder" do
|
647
753
|
current_report = send(report_settings[:report])
|
@@ -654,18 +760,42 @@ describe Cornucopia::Util::ReportBuilder do
|
|
654
760
|
|
655
761
|
current_report.initialize_report_files
|
656
762
|
|
657
|
-
|
658
|
-
expect(File.exists?(
|
763
|
+
test_report_folder = current_report.report_folder_name
|
764
|
+
expect(File.exists?(test_report_folder)).to be_truthy
|
659
765
|
|
660
766
|
post_file = File.read(File.join(current_report.index_folder_name, "report_contents.html"))
|
661
767
|
expect(post_file).to match /\>#{report_settings[:sub_folder]}\</
|
662
768
|
|
663
|
-
expect(File.exists?(File.join(
|
664
|
-
expect(File.exists?(File.join(
|
665
|
-
expect(File.exists?(File.join(
|
666
|
-
|
667
|
-
|
668
|
-
|
769
|
+
expect(File.exists?(File.join(test_report_folder, "index.html"))).to be_truthy
|
770
|
+
expect(File.exists?(File.join(test_report_folder, "report.js"))).to be_truthy
|
771
|
+
expect(File.exists?(File.join(test_report_folder, "cornucopia.css"))).to be_truthy
|
772
|
+
end
|
773
|
+
end
|
774
|
+
|
775
|
+
describe "#initialize_basic_report_files" do
|
776
|
+
it "should create the report folder" do
|
777
|
+
current_report = send(report_settings[:report])
|
778
|
+
|
779
|
+
FileUtils.mkdir_p current_report.index_folder_name
|
780
|
+
current_report.rebuild_index_page
|
781
|
+
|
782
|
+
post_file = File.read(File.join(current_report.index_folder_name, "report_contents.html"))
|
783
|
+
expect(post_file).not_to match /\>#{report_settings[:sub_folder]}\</
|
784
|
+
|
785
|
+
current_report.initialize_basic_report_files
|
786
|
+
|
787
|
+
test_report_folder = current_report.report_folder_name
|
788
|
+
expect(File.exists?(test_report_folder)).to be_truthy
|
789
|
+
|
790
|
+
post_file = File.read(File.join(current_report.index_folder_name, "report_contents.html"))
|
791
|
+
expect(post_file).to match /\>#{report_settings[:sub_folder]}\</
|
792
|
+
|
793
|
+
expect(File.exists?(File.join(test_report_folder, "index.html"))).to be_truthy
|
794
|
+
expect(File.exists?(File.join(test_report_folder, "report_contents.html"))).to be_truthy
|
795
|
+
expect(File.exists?(File.join(test_report_folder, "collapse.gif"))).to be_truthy
|
796
|
+
expect(File.exists?(File.join(test_report_folder, "expand.gif"))).to be_truthy
|
797
|
+
expect(File.exists?(File.join(test_report_folder, "more_info.js"))).to be_truthy
|
798
|
+
expect(File.exists?(File.join(test_report_folder, "cornucopia.css"))).to be_truthy
|
669
799
|
end
|
670
800
|
end
|
671
801
|
|
@@ -683,10 +813,35 @@ describe Cornucopia::Util::ReportBuilder do
|
|
683
813
|
end
|
684
814
|
end
|
685
815
|
|
816
|
+
describe "#report_test_folder_name" do
|
817
|
+
it "calls report_folder_name" do
|
818
|
+
current_report = send(report_settings[:report])
|
819
|
+
|
820
|
+
expect(current_report).to receive(:report_folder_name).and_call_original
|
821
|
+
|
822
|
+
expect(current_report.report_test_folder_name.to_s).to be == Rails.root.join(report_settings[:index_folder],
|
823
|
+
report_settings[:sub_folder]).to_s + "/test_1"
|
824
|
+
|
825
|
+
expect(File.exists?(current_report.report_test_contents_page_name)).to be_falsey
|
826
|
+
end
|
827
|
+
|
828
|
+
it "gets a different folder inside within_table" do
|
829
|
+
current_report = send(report_settings[:report])
|
830
|
+
|
831
|
+
expect(current_report.report_test_folder_name.to_s).to be == Rails.root.join(report_settings[:index_folder],
|
832
|
+
report_settings[:sub_folder]).to_s + "/test_1"
|
833
|
+
|
834
|
+
current_report.within_test(Faker::Lorem.sentence) do
|
835
|
+
expect(current_report.report_test_folder_name.to_s).to be == Rails.root.join(report_settings[:index_folder],
|
836
|
+
report_settings[:sub_folder]).to_s + "/test_2"
|
837
|
+
end
|
838
|
+
end
|
839
|
+
end
|
840
|
+
|
686
841
|
describe "#open_report_contents_file" do
|
687
842
|
it "initializes the report_contents file" do
|
688
843
|
current_report = send(report_settings[:report])
|
689
|
-
expect(current_report).to receive(:
|
844
|
+
expect(current_report).to receive(:initialize_basic_report_files).and_call_original
|
690
845
|
write_contents = Faker::Lorem.paragraphs(rand(5..8)).join("\n\n")
|
691
846
|
|
692
847
|
current_report.open_report_contents_file do |writer|
|
@@ -700,6 +855,23 @@ describe Cornucopia::Util::ReportBuilder do
|
|
700
855
|
end
|
701
856
|
end
|
702
857
|
|
858
|
+
describe "#open_report_test_contents_file" do
|
859
|
+
it "initializes the report_contents file" do
|
860
|
+
current_report = send(report_settings[:report])
|
861
|
+
expect(current_report).to receive(:initialize_report_test_files).and_call_original
|
862
|
+
write_contents = Faker::Lorem.paragraphs(rand(5..8)).join("\n\n")
|
863
|
+
|
864
|
+
current_report.open_report_test_contents_file do |writer|
|
865
|
+
writer.write(write_contents)
|
866
|
+
end
|
867
|
+
|
868
|
+
write_contents = "".html_safe + write_contents
|
869
|
+
|
870
|
+
post_data = File.read(current_report.report_test_contents_page_name)
|
871
|
+
expect(post_data).to match /#{write_contents}/
|
872
|
+
end
|
873
|
+
end
|
874
|
+
|
703
875
|
describe "#close" do
|
704
876
|
it "should create an empty report if nothing was reported" do
|
705
877
|
current_report = send(report_settings[:report])
|
@@ -733,7 +905,7 @@ describe Cornucopia::Util::ReportBuilder do
|
|
733
905
|
|
734
906
|
current_report.close
|
735
907
|
|
736
|
-
post_data = File.read(current_report.
|
908
|
+
post_data = File.read(current_report.report_test_contents_page_name)
|
737
909
|
expect(post_data).not_to match /No errors to report/i
|
738
910
|
|
739
911
|
expect(Cornucopia::Util::ReportBuilder.class_variable_get("@@current_report")).not_to be
|
@@ -752,13 +924,189 @@ describe Cornucopia::Util::ReportBuilder do
|
|
752
924
|
|
753
925
|
current_report.close
|
754
926
|
|
755
|
-
post_data = File.read(current_report.
|
927
|
+
post_data = File.read(current_report.report_test_contents_page_name)
|
756
928
|
expect(post_data).not_to match /No errors to report/i
|
757
929
|
|
758
930
|
expect(Cornucopia::Util::ReportBuilder.class_variable_get("@@current_report")).not_to be
|
759
931
|
end
|
760
932
|
end
|
761
933
|
|
934
|
+
describe "#within_test" do
|
935
|
+
let(:test_names) do
|
936
|
+
rand(3..5).times.map do
|
937
|
+
Faker::Lorem.sentence
|
938
|
+
end
|
939
|
+
end
|
940
|
+
let(:section_names) do
|
941
|
+
test_names.length.times.map do
|
942
|
+
Faker::Lorem.sentence
|
943
|
+
end
|
944
|
+
end
|
945
|
+
|
946
|
+
it "starts a test with a specific name" do
|
947
|
+
current_report = send(report_settings[:report])
|
948
|
+
|
949
|
+
current_report.within_test(test_names[0]) do
|
950
|
+
current_report.within_section(section_names[0]) do |report_section|
|
951
|
+
report_section.within_table do |report_table|
|
952
|
+
report_table.write_stats(Faker::Lorem.word, Faker::Lorem.sentence)
|
953
|
+
end
|
954
|
+
end
|
955
|
+
end
|
956
|
+
|
957
|
+
current_report.close
|
958
|
+
|
959
|
+
report_page = Capybara::Node::Simple.new(File.read(current_report.report_base_page_name))
|
960
|
+
|
961
|
+
expect(report_page.all(".coruncopia-report-link").length).to eq 1
|
962
|
+
expect(report_page.all(".coruncopia-report-link")[0].text).to eq test_names[0]
|
963
|
+
expect(report_page.all(".coruncopia-report-link")[0]["href"]).to eq "test_1/index.html"
|
964
|
+
end
|
965
|
+
|
966
|
+
it "doesn't output anything if nothing is written to a section or table" do
|
967
|
+
current_report = send(report_settings[:report])
|
968
|
+
|
969
|
+
current_report.within_test(test_names[0]) do
|
970
|
+
end
|
971
|
+
|
972
|
+
current_report.close
|
973
|
+
|
974
|
+
report_page = Capybara::Node::Simple.new(File.read(current_report.report_contents_page_name))
|
975
|
+
|
976
|
+
expect(report_page.all(".cornucopia-no-errors").length).to eq 1
|
977
|
+
expect(report_page.all(".cornucopia-no-errors")[0].text).to eq "No Errors to report"
|
978
|
+
end
|
979
|
+
|
980
|
+
it "outputs multiple tests" do
|
981
|
+
current_report = send(report_settings[:report])
|
982
|
+
|
983
|
+
test_names.each_with_index do |test_name, test_index|
|
984
|
+
current_report.within_test(test_name) do
|
985
|
+
current_report.within_section(section_names[test_index]) do |report_section|
|
986
|
+
report_section.within_table do |report_table|
|
987
|
+
report_table.write_stats(Faker::Lorem.word, Faker::Lorem.sentence)
|
988
|
+
end
|
989
|
+
end
|
990
|
+
end
|
991
|
+
end
|
992
|
+
|
993
|
+
current_report.close
|
994
|
+
|
995
|
+
report_page = Capybara::Node::Simple.new(File.read(current_report.report_base_page_name))
|
996
|
+
|
997
|
+
expect(report_page.all(".coruncopia-report-link").length).to eq test_names.length
|
998
|
+
|
999
|
+
test_names.each_with_index do |test_name, test_index|
|
1000
|
+
expect(report_page.all(".coruncopia-report-link")[test_index].text).to eq test_name
|
1001
|
+
expect(report_page.all(".coruncopia-report-link")[test_index]["href"]).to eq "test_#{test_index + 1}/index.html"
|
1002
|
+
end
|
1003
|
+
end
|
1004
|
+
|
1005
|
+
it "handles a test within a test as an independent test" do
|
1006
|
+
current_report = send(report_settings[:report])
|
1007
|
+
|
1008
|
+
current_report.within_test(test_names[0]) do
|
1009
|
+
current_report.within_section(section_names[0]) do |report_section|
|
1010
|
+
report_section.within_table do |report_table|
|
1011
|
+
report_table.write_stats(Faker::Lorem.word, Faker::Lorem.sentence)
|
1012
|
+
current_report.within_test(test_names[1]) do
|
1013
|
+
current_report.within_section(section_names[1]) do |report_section|
|
1014
|
+
report_section.within_table do |report_table|
|
1015
|
+
report_table.write_stats(Faker::Lorem.word, Faker::Lorem.sentence)
|
1016
|
+
end
|
1017
|
+
end
|
1018
|
+
end
|
1019
|
+
end
|
1020
|
+
end
|
1021
|
+
end
|
1022
|
+
|
1023
|
+
current_report.close
|
1024
|
+
|
1025
|
+
report_page = Capybara::Node::Simple.new(File.read(current_report.report_base_page_name))
|
1026
|
+
|
1027
|
+
expect(report_page.all(".coruncopia-report-link").length).to eq 2
|
1028
|
+
expect(report_page.all(".coruncopia-report-link")[0].text).to eq test_names[0]
|
1029
|
+
expect(report_page.all(".coruncopia-report-link")[0]["href"]).to eq "test_1/index.html"
|
1030
|
+
expect(report_page.all(".coruncopia-report-link")[1].text).to eq test_names[1]
|
1031
|
+
expect(report_page.all(".coruncopia-report-link")[1]["href"]).to eq "test_2/index.html"
|
1032
|
+
|
1033
|
+
report_page = Capybara::Node::Simple.new(File.read(File.join(current_report.report_folder_name, "test_1/report_contents.html")))
|
1034
|
+
expect(report_page.all(".cornucopia-section-label").length).to eq 1
|
1035
|
+
expect(report_page.all(".cornucopia-section-label")[0].text).to eq section_names[0]
|
1036
|
+
|
1037
|
+
report_page = Capybara::Node::Simple.new(File.read(File.join(current_report.report_folder_name, "test_2/report_contents.html")))
|
1038
|
+
expect(report_page.all(".cornucopia-section-label").length).to eq 1
|
1039
|
+
expect(report_page.all(".cornucopia-section-label")[0].text).to eq section_names[1]
|
1040
|
+
end
|
1041
|
+
|
1042
|
+
it "restores to the old test if a test within a test" do
|
1043
|
+
current_report = send(report_settings[:report])
|
1044
|
+
|
1045
|
+
current_report.within_test(test_names[0]) do
|
1046
|
+
current_report.within_section(section_names[0]) do |report_section|
|
1047
|
+
report_section.within_table do |report_table|
|
1048
|
+
report_table.write_stats(Faker::Lorem.word, Faker::Lorem.sentence)
|
1049
|
+
current_report.within_test(test_names[1]) do
|
1050
|
+
current_report.within_section(section_names[1]) do |report_section|
|
1051
|
+
report_section.within_table do |report_table|
|
1052
|
+
report_table.write_stats(Faker::Lorem.word, Faker::Lorem.sentence)
|
1053
|
+
end
|
1054
|
+
end
|
1055
|
+
end
|
1056
|
+
end
|
1057
|
+
end
|
1058
|
+
|
1059
|
+
current_report.within_section(section_names[2]) do |report_section|
|
1060
|
+
report_section.within_table do |report_table|
|
1061
|
+
report_table.write_stats(Faker::Lorem.word, Faker::Lorem.sentence)
|
1062
|
+
end
|
1063
|
+
end
|
1064
|
+
end
|
1065
|
+
|
1066
|
+
current_report.close
|
1067
|
+
|
1068
|
+
report_page = Capybara::Node::Simple.new(File.read(current_report.report_base_page_name))
|
1069
|
+
|
1070
|
+
expect(report_page.all(".coruncopia-report-link").length).to eq 2
|
1071
|
+
expect(report_page.all(".coruncopia-report-link")[0].text).to eq test_names[0]
|
1072
|
+
expect(report_page.all(".coruncopia-report-link")[0]["href"]).to eq "test_1/index.html"
|
1073
|
+
expect(report_page.all(".coruncopia-report-link")[1].text).to eq test_names[1]
|
1074
|
+
expect(report_page.all(".coruncopia-report-link")[1]["href"]).to eq "test_2/index.html"
|
1075
|
+
|
1076
|
+
report_page = Capybara::Node::Simple.new(File.read(File.join(current_report.report_folder_name, "test_1/report_contents.html")))
|
1077
|
+
expect(report_page.all(".cornucopia-section-label").length).to eq 2
|
1078
|
+
expect(report_page.all(".cornucopia-section-label")[0].text).to eq section_names[0]
|
1079
|
+
expect(report_page.all(".cornucopia-section-label")[1].text).to eq section_names[2]
|
1080
|
+
end
|
1081
|
+
|
1082
|
+
it "numbers tests based on the tests that actually output something" do
|
1083
|
+
current_report = send(report_settings[:report])
|
1084
|
+
|
1085
|
+
test_names.each_with_index do |test_name, test_index|
|
1086
|
+
if test_index == 0 || test_index == test_names.length - 1
|
1087
|
+
current_report.within_test(test_name) do
|
1088
|
+
current_report.within_section(section_names[test_index]) do |report_section|
|
1089
|
+
report_section.within_table do |report_table|
|
1090
|
+
report_table.write_stats(Faker::Lorem.word, Faker::Lorem.sentence)
|
1091
|
+
end
|
1092
|
+
end
|
1093
|
+
end
|
1094
|
+
end
|
1095
|
+
end
|
1096
|
+
|
1097
|
+
current_report.close
|
1098
|
+
|
1099
|
+
report_page = Capybara::Node::Simple.new(File.read(current_report.report_base_page_name))
|
1100
|
+
|
1101
|
+
expect(report_page.all(".coruncopia-report-link").length).to eq 2
|
1102
|
+
|
1103
|
+
expect(report_page.all(".coruncopia-report-link")[0].text).to eq test_names[0]
|
1104
|
+
expect(report_page.all(".coruncopia-report-link")[0]["href"]).to eq "test_1/index.html"
|
1105
|
+
expect(report_page.all(".coruncopia-report-link")[1].text).to eq test_names[-1]
|
1106
|
+
expect(report_page.all(".coruncopia-report-link")[1]["href"]).to eq "test_2/index.html"
|
1107
|
+
end
|
1108
|
+
end
|
1109
|
+
|
762
1110
|
describe "#within_section" do
|
763
1111
|
it "should output passed in text to the report file" do
|
764
1112
|
current_report = send(report_settings[:report])
|
@@ -770,7 +1118,7 @@ describe Cornucopia::Util::ReportBuilder do
|
|
770
1118
|
expect(report_object.is_a?(Cornucopia::Util::ReportBuilder)).to be_truthy
|
771
1119
|
end
|
772
1120
|
|
773
|
-
post_data = File.read(current_report.
|
1121
|
+
post_data = File.read(current_report.report_test_contents_page_name)
|
774
1122
|
expect(post_data).to match /\>#{section_name}\</i
|
775
1123
|
end
|
776
1124
|
|
@@ -787,8 +1135,8 @@ describe Cornucopia::Util::ReportBuilder do
|
|
787
1135
|
end
|
788
1136
|
end.to raise_exception
|
789
1137
|
|
790
|
-
post_data = File.read(current_report.
|
791
|
-
expect(post_data[-1 * "\<\/div\>\n".length..-1]).to be == "\<\/div\>\n"
|
1138
|
+
post_data = File.read(current_report.report_test_contents_page_name)
|
1139
|
+
expect(post_data[-1 * "\<\/div\>\n<div class=\"cornucopia-end-section\" />\n".length..-1]).to be == "\<\/div\>\n<div class=\"cornucopia-end-section\" />\n"
|
792
1140
|
end
|
793
1141
|
end
|
794
1142
|
|
@@ -806,8 +1154,8 @@ describe Cornucopia::Util::ReportBuilder do
|
|
806
1154
|
end
|
807
1155
|
end
|
808
1156
|
|
809
|
-
post_data = File.read(current_report.
|
810
|
-
expect(post_data[-1 * "\<\/div\>\n".length..-1]).to be == "\<\/div\>\n"
|
1157
|
+
post_data = File.read(current_report.report_test_contents_page_name)
|
1158
|
+
expect(post_data[-1 * "\<\/div\>\n<div class=\"cornucopia-end-section\" />\n".length..-1]).to be == "\<\/div\>\n<div class=\"cornucopia-end-section\" />\n"
|
811
1159
|
expect(post_data).to match /\>\n#{table_label}\n\</
|
812
1160
|
expect(post_data).to match /\>#{table_data}\</
|
813
1161
|
end
|
@@ -828,8 +1176,8 @@ describe Cornucopia::Util::ReportBuilder do
|
|
828
1176
|
end
|
829
1177
|
end.to raise_exception
|
830
1178
|
|
831
|
-
post_data = File.read(current_report.
|
832
|
-
expect(post_data[-1 * "\<\/div\>\n".length..-1]).to be == "\<\/div\>\n"
|
1179
|
+
post_data = File.read(current_report.report_test_contents_page_name)
|
1180
|
+
expect(post_data[-1 * "\<\/div\>\n<div class=\"cornucopia-end-section\" />\n".length..-1]).to be == "\<\/div\>\n<div class=\"cornucopia-end-section\" />\n"
|
833
1181
|
expect(post_data).to match /\>\n#{table_label}\n\</
|
834
1182
|
expect(post_data).to match /\>#{table_data}\</
|
835
1183
|
expect(post_data).to match /This is an exception/
|
@@ -847,13 +1195,13 @@ describe Cornucopia::Util::ReportBuilder do
|
|
847
1195
|
sub_table.write_stats "stat", "value"
|
848
1196
|
end
|
849
1197
|
|
850
|
-
mid_data = File.read(current_report.
|
1198
|
+
mid_data = File.read(current_report.report_test_contents_page_name)
|
851
1199
|
end
|
852
1200
|
end
|
853
1201
|
|
854
1202
|
current_report.close
|
855
1203
|
|
856
|
-
post_data = File.read(current_report.
|
1204
|
+
post_data = File.read(current_report.report_test_contents_page_name)
|
857
1205
|
|
858
1206
|
expect(post_data).to match /\>\nstat\n\</
|
859
1207
|
expect(mid_data).not_to match /\>\nstat\n\</
|
@@ -862,8 +1210,8 @@ describe Cornucopia::Util::ReportBuilder do
|
|
862
1210
|
|
863
1211
|
describe "#unique_folder_name" do
|
864
1212
|
it "returns the folder if there is no folder with that name" do
|
865
|
-
current_report
|
866
|
-
|
1213
|
+
current_report = send(report_settings[:report])
|
1214
|
+
test_report_folder = current_report.report_folder_name
|
867
1215
|
|
868
1216
|
new_folder = Faker::Lorem.word
|
869
1217
|
|
@@ -871,15 +1219,15 @@ describe Cornucopia::Util::ReportBuilder do
|
|
871
1219
|
end
|
872
1220
|
|
873
1221
|
it "returns a uniqe folder if there is a folder with that name" do
|
874
|
-
current_report
|
875
|
-
|
1222
|
+
current_report = send(report_settings[:report])
|
1223
|
+
test_report_folder = current_report.report_folder_name
|
876
1224
|
|
877
1225
|
new_folder = Faker::Lorem.word
|
878
1226
|
num_folders = rand(5..10)
|
879
1227
|
|
880
|
-
FileUtils.mkdir_p File.join(
|
1228
|
+
FileUtils.mkdir_p File.join(test_report_folder, new_folder)
|
881
1229
|
num_folders.times do |folder_number|
|
882
|
-
FileUtils.mkdir_p File.join(
|
1230
|
+
FileUtils.mkdir_p File.join(test_report_folder, "#{new_folder}_#{folder_number}")
|
883
1231
|
end
|
884
1232
|
|
885
1233
|
expect(current_report.unique_folder_name(new_folder)).to be == "#{new_folder}_#{num_folders}"
|
@@ -888,8 +1236,8 @@ describe Cornucopia::Util::ReportBuilder do
|
|
888
1236
|
|
889
1237
|
describe "#unique_file_name" do
|
890
1238
|
it "creates a unique file name if there are no files" do
|
891
|
-
current_report
|
892
|
-
|
1239
|
+
current_report = send(report_settings[:report])
|
1240
|
+
test_report_folder = current_report.report_folder_name
|
893
1241
|
|
894
1242
|
prefix = Faker::Lorem.word
|
895
1243
|
postfix = Faker::Lorem.word
|
@@ -898,8 +1246,8 @@ describe Cornucopia::Util::ReportBuilder do
|
|
898
1246
|
end
|
899
1247
|
|
900
1248
|
it "creates a unique file name if there are some files already" do
|
901
|
-
current_report
|
902
|
-
|
1249
|
+
current_report = send(report_settings[:report])
|
1250
|
+
test_report_folder = current_report.report_folder_name
|
903
1251
|
|
904
1252
|
prefix = Faker::Lorem.word
|
905
1253
|
postfix = Faker::Lorem.word
|
@@ -919,23 +1267,23 @@ describe Cornucopia::Util::ReportBuilder do
|
|
919
1267
|
|
920
1268
|
describe "#image_link" do
|
921
1269
|
it "moves the image file and creates an image element" do
|
922
|
-
current_report
|
923
|
-
|
1270
|
+
current_report = send(report_settings[:report])
|
1271
|
+
test_report_folder = current_report.report_folder_name
|
924
1272
|
|
925
1273
|
prefix = Faker::Lorem.word
|
926
1274
|
postfix = Faker::Lorem.word
|
927
1275
|
|
928
|
-
FileUtils.mkdir_p
|
1276
|
+
FileUtils.mkdir_p test_report_folder
|
929
1277
|
Cornucopia::Util::FileAsset.asset("cornucopia.css").
|
930
|
-
add_file(File.join(
|
1278
|
+
add_file(File.join(test_report_folder, "#{prefix}.#{postfix}"))
|
931
1279
|
|
932
|
-
expect(File.exists?(File.join(
|
933
|
-
expect(File.exists?(File.join(
|
1280
|
+
expect(File.exists?(File.join(test_report_folder, "#{prefix}.#{postfix}"))).to be_truthy
|
1281
|
+
expect(File.exists?(File.join(test_report_folder, "#{prefix}_1.#{postfix}"))).to be_falsey
|
934
1282
|
|
935
|
-
image_link = current_report.image_link(File.join(
|
1283
|
+
image_link = current_report.image_link(File.join(test_report_folder, "#{prefix}.#{postfix}"))
|
936
1284
|
|
937
|
-
expect(File.exists?(File.join(
|
938
|
-
expect(File.exists?(File.join(
|
1285
|
+
expect(File.exists?(File.join(test_report_folder, "#{prefix}.#{postfix}"))).to be_falsey
|
1286
|
+
expect(File.exists?(File.join(test_report_folder, "#{prefix}_1.#{postfix}"))).to be_truthy
|
939
1287
|
|
940
1288
|
expect(image_link).to be_html_safe
|
941
1289
|
expect(image_link).to match /^\<img/i
|
@@ -945,25 +1293,25 @@ describe Cornucopia::Util::ReportBuilder do
|
|
945
1293
|
|
946
1294
|
describe "#page_frame" do
|
947
1295
|
it "dumps the html to a file, and returns an iframe element" do
|
948
|
-
current_report
|
949
|
-
|
950
|
-
source_html
|
1296
|
+
current_report = send(report_settings[:report])
|
1297
|
+
test_report_folder = current_report.report_folder_name
|
1298
|
+
source_html = "<html>\n<body>\nThis is some & awesome text</body>\n</html>"
|
951
1299
|
|
952
|
-
FileUtils.mkdir_p
|
953
|
-
Cornucopia::Util::FileAsset.asset("cornucopia.css").add_file(File.join(
|
1300
|
+
FileUtils.mkdir_p test_report_folder
|
1301
|
+
Cornucopia::Util::FileAsset.asset("cornucopia.css").add_file(File.join(test_report_folder, "page_dump.html"))
|
954
1302
|
|
955
|
-
expect(File.exists?(File.join(
|
956
|
-
expect(File.exists?(File.join(
|
1303
|
+
expect(File.exists?(File.join(test_report_folder, "page_dump.html"))).to be_truthy
|
1304
|
+
expect(File.exists?(File.join(test_report_folder, "page_dump_1.html"))).to be_falsey
|
957
1305
|
|
958
1306
|
page_link = current_report.page_frame(source_html)
|
959
1307
|
|
960
|
-
expect(File.exists?(File.join(
|
961
|
-
expect(File.exists?(File.join(
|
1308
|
+
expect(File.exists?(File.join(test_report_folder, "page_dump.html"))).to be_truthy
|
1309
|
+
expect(File.exists?(File.join(test_report_folder, "page_dump_1.html"))).to be_truthy
|
962
1310
|
|
963
1311
|
expect(page_link).to be_html_safe
|
964
1312
|
expect(page_link).to match /\<iframe/i
|
965
1313
|
expect(page_link).to match /src=\"page_dump_1.html\"/i
|
966
|
-
expect(File.read(File.join(
|
1314
|
+
expect(File.read(File.join(test_report_folder, "page_dump_1.html"))).to be == source_html
|
967
1315
|
end
|
968
1316
|
end
|
969
1317
|
|