cornucopia 0.1.12 → 0.1.13
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/.gitignore +2 -1
- data/lib/cornucopia/capybara/matcher_extensions.rb +3 -1
- data/lib/cornucopia/cucumber_hooks.rb +7 -3
- data/lib/cornucopia/spinach_hooks.rb +13 -3
- data/lib/cornucopia/util/configuration.rb +1 -1
- data/lib/cornucopia/version.rb +1 -1
- data/spec/lib/capybara/finder_diagnostics_spec.rb +86 -0
- data/spec/lib/capybara/matcher_extensions_spec.rb +344 -0
- data/spec/lib/util/configuration_spec.rb +70 -0
- data/spec/lib/util/configured_report_spec.rb +19 -0
- data/spec/rails_helper.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +4 -3
- data/lib/cornucopia/factory_girl/dynamic_association.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3346fed2eb1ac7927737bf2bbbdd9fdd4c82edca
|
4
|
+
data.tar.gz: 6adeed695e6be6f05292d6327272290fe2a34b41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2a81685b388928f567d25f7fc754d4d128f0ba9c2479391ad784eb79c78800d5fc200650378c48d16195e49c69b3f7cee17ab29f48c6ca457b74f553def7bab
|
7
|
+
data.tar.gz: 462a916d48b5f1c25da256e68ae77b8dd87fd32a2a26c3074caedf2cfe167371e82dce94fa89ef9275cc966bf12fa46b7b658e7e3362b43b66ec7f364eef6f62
|
data/.gitignore
CHANGED
@@ -52,6 +52,8 @@ module Cornucopia
|
|
52
52
|
if !support_options[:__cornucopia_no_analysis] &&
|
53
53
|
(Cornucopia::Util::Configuration.analyze_selector_exceptions ||
|
54
54
|
support_options[:__cornucopia_retry_with_found])
|
55
|
+
support_options.merge!({ __cornucopia_no_analysis: true })
|
56
|
+
|
55
57
|
find_action = Cornucopia::Capybara::FinderDiagnostics::FindAction.new(self,
|
56
58
|
{},
|
57
59
|
support_options,
|
@@ -60,7 +62,7 @@ module Cornucopia
|
|
60
62
|
|
61
63
|
if find_action.perform_analysis(Cornucopia::Util::Configuration.retry_match_with_found ||
|
62
64
|
support_options[:__cornucopia_retry_with_found])
|
63
|
-
return_value = find_action.simple_run rescue nil
|
65
|
+
return_value = find_action.simple_run({ __cornucopia_no_analysis: true }) rescue nil
|
64
66
|
return_value ||= find_action.return_value
|
65
67
|
else
|
66
68
|
raise error
|
@@ -1,8 +1,5 @@
|
|
1
1
|
require ::File.expand_path("../cornucopia", File.dirname(__FILE__))
|
2
|
-
require ::File.expand_path("../cornucopia/factory_girl/dynamic_association", File.dirname(__FILE__))
|
3
|
-
|
4
2
|
load ::File.expand_path("capybara/install_finder_extensions.rb", File.dirname(__FILE__))
|
5
|
-
load ::File.expand_path("capybara/install_matcher_extensions.rb", File.dirname(__FILE__))
|
6
3
|
load ::File.expand_path("site_prism/install_element_extensions.rb", File.dirname(__FILE__))
|
7
4
|
|
8
5
|
Around do |scenario, block|
|
@@ -28,6 +25,13 @@ After do |scenario|
|
|
28
25
|
configured_report.add_report_objects scenario: scenario, cucumber: self
|
29
26
|
configured_report.generate_report(report)
|
30
27
|
end
|
28
|
+
|
29
|
+
# Cornucopia::DiagnosticsReportBuilder.current_report.within_section("Error:") do |report|
|
30
|
+
# report_generator = Cornucopia::Configuration.report_configuration(:cucumber)
|
31
|
+
#
|
32
|
+
# report_generator.add_report_objects(self: self, scenario: scenario)
|
33
|
+
# report_generator.generate_report_for_object(report, diagnostics_name: scenario.file_colon_line)
|
34
|
+
# end
|
31
35
|
end
|
32
36
|
end
|
33
37
|
|
@@ -1,8 +1,5 @@
|
|
1
1
|
require ::File.expand_path("../cornucopia", File.dirname(__FILE__))
|
2
|
-
require ::File.expand_path("../cornucopia/factory_girl/dynamic_association", File.dirname(__FILE__))
|
3
|
-
|
4
2
|
load ::File.expand_path("capybara/install_finder_extensions.rb", File.dirname(__FILE__))
|
5
|
-
load ::File.expand_path("capybara/install_matcher_extensions.rb", File.dirname(__FILE__))
|
6
3
|
load ::File.expand_path("site_prism/install_element_extensions.rb", File.dirname(__FILE__))
|
7
4
|
|
8
5
|
Spinach.hooks.before_scenario do |scenario, step_definitions|
|
@@ -42,6 +39,19 @@ def debug_failed_step(failure_description, step_data, exception, location, step_
|
|
42
39
|
|
43
40
|
configured_report.generate_report(report)
|
44
41
|
end
|
42
|
+
|
43
|
+
# Cornucopia::Util::ReportBuilder.current_report.within_section("#{failure_description}:") do |report|
|
44
|
+
# report_generator = Cornucopia::Configuration.report_configuration(:spinach)
|
45
|
+
#
|
46
|
+
# report_generator.add_report_objects(failure_description: "#{failure_description} at:, #{location[0]}:#{location[1]}",
|
47
|
+
# step_data: step_data,
|
48
|
+
# exception: exception,
|
49
|
+
# location: location,
|
50
|
+
# step_definitions: step_definitions,
|
51
|
+
# running_scenario: @running_scenario
|
52
|
+
# )
|
53
|
+
# report_generator.generate_report_for_object(report, diagnostics_name: "#{step_data.name}:#{step_data.line}")
|
54
|
+
# end
|
45
55
|
end
|
46
56
|
|
47
57
|
Spinach.hooks.after_run do |status|
|
@@ -393,7 +393,7 @@ module Cornucopia
|
|
393
393
|
|
394
394
|
# This setting is used by the Capybara utilities.
|
395
395
|
#
|
396
|
-
# When Capybara::Node.
|
396
|
+
# When Capybara::Node.analyze_selector throws an exception, if this is set, the system will try to
|
397
397
|
# use the FinderDiagnostics to output some diagnostic information about the page and the
|
398
398
|
# selector to try to assist in determining what happened.
|
399
399
|
def analyze_selector_exceptions
|
data/lib/cornucopia/version.rb
CHANGED
@@ -468,6 +468,92 @@ describe Cornucopia::Capybara::FinderDiagnostics, type: :feature do
|
|
468
468
|
end
|
469
469
|
end
|
470
470
|
|
471
|
+
it "works with assert_selector" do
|
472
|
+
# TODO: figure out why this test appears to be flakey sometimes.
|
473
|
+
begin
|
474
|
+
Cornucopia::Util::Configuration.retry_match_with_found = true
|
475
|
+
|
476
|
+
allow_any_instance_of(::Capybara::Node::Element).to receive(:outerHTML).and_return(nil)
|
477
|
+
|
478
|
+
expect(::Capybara.current_session).
|
479
|
+
to receive(:evaluate_script).at_least(1).times.and_raise(::Capybara::NotSupportedByDriverError)
|
480
|
+
expect_any_instance_of(::Selenium::WebDriver::Driver).
|
481
|
+
to receive(:execute_script).at_least(1).times.and_raise(::Capybara::NotSupportedByDriverError)
|
482
|
+
|
483
|
+
base_object = ::Capybara.current_session.find(:css, "#hidden-div", visible: false)
|
484
|
+
button = base_object.assert_selector("Still cool!", count: 1)
|
485
|
+
|
486
|
+
expect(button).to be true
|
487
|
+
|
488
|
+
report_page = CornucopiaReportApp.cornucopia_report_page
|
489
|
+
report_page.load(report_name: "cornucopia_report", base_folder: "cornucopia_report")
|
490
|
+
report_page.contents do |contents_frame|
|
491
|
+
contents_frame.errors[1].more_details.show_hide.click
|
492
|
+
expect(contents_frame.errors.length).to be == 2
|
493
|
+
expect(contents_frame.errors[1].tables[0].rows.last.labels[0].text).not_to be == "Retrying action:"
|
494
|
+
expect(contents_frame.errors[1].more_details.details.rows.last.labels[0].text).to be == "Retrying action:"
|
495
|
+
expect(contents_frame.errors[1].more_details.details.rows.last.values[0].text).to be == "Found"
|
496
|
+
end
|
497
|
+
ensure
|
498
|
+
Cornucopia::Util::Configuration.retry_match_with_found = false
|
499
|
+
end
|
500
|
+
end
|
501
|
+
|
502
|
+
it "works with assert_no_selector" do
|
503
|
+
# 621023375412314903581404663773388410917
|
504
|
+
begin
|
505
|
+
Cornucopia::Util::Configuration.retry_match_with_found = true
|
506
|
+
|
507
|
+
allow_any_instance_of(::Capybara::Node::Element).to receive(:outerHTML).and_return(nil)
|
508
|
+
|
509
|
+
allow(::Capybara.current_session).
|
510
|
+
to receive(:evaluate_script).and_raise(::Capybara::NotSupportedByDriverError)
|
511
|
+
allow_any_instance_of(::Selenium::WebDriver::Driver).
|
512
|
+
to receive(:execute_script).and_raise(::Capybara::NotSupportedByDriverError)
|
513
|
+
|
514
|
+
base_object = ::Capybara.current_session.find(:css, "#hidden-div", visible: false)
|
515
|
+
find_button = base_object.all("#hidden-cool-button", count: 1, visible: false)
|
516
|
+
empty_find_button = base_object.all("#hidden-cool-button", count: 1, visible: false)
|
517
|
+
|
518
|
+
allow_any_instance_of(::Cornucopia::Capybara::FinderDiagnostics::FindAction).
|
519
|
+
to receive(:all_elements).and_return []
|
520
|
+
allow_any_instance_of(::Cornucopia::Capybara::FinderDiagnostics::FindAction).
|
521
|
+
to receive(:all_other_elements).and_return []
|
522
|
+
allow(empty_find_button).to receive(:size).and_return 0
|
523
|
+
allow_any_instance_of(::Capybara::Node::Element).
|
524
|
+
to receive(:all).
|
525
|
+
and_call_original
|
526
|
+
allow_any_instance_of(::Capybara::Node::Element).
|
527
|
+
to receive(:all).
|
528
|
+
with("Still cool!", { count: 1 }).
|
529
|
+
and_return(find_button)
|
530
|
+
allow_any_instance_of(::Capybara::Node::Element).
|
531
|
+
to receive(:all).
|
532
|
+
with(instance_of(Symbol), "Still cool!", { visible: false, __cornucopia_no_analysis: true }).
|
533
|
+
and_return(empty_find_button)
|
534
|
+
allow_any_instance_of(::Capybara::Node::Element).
|
535
|
+
to receive(:all).
|
536
|
+
with("Still cool!", { visible: false, __cornucopia_no_analysis: true }).
|
537
|
+
and_return(empty_find_button)
|
538
|
+
|
539
|
+
button = base_object.assert_no_selector("Still cool!", count: 1)
|
540
|
+
|
541
|
+
expect(button).to be true
|
542
|
+
|
543
|
+
report_page = CornucopiaReportApp.cornucopia_report_page
|
544
|
+
report_page.load(report_name: "cornucopia_report", base_folder: "cornucopia_report")
|
545
|
+
report_page.contents do |contents_frame|
|
546
|
+
contents_frame.errors[0].more_details.show_hide.click
|
547
|
+
expect(contents_frame.errors.length).to be == 1
|
548
|
+
expect(contents_frame.errors[0].tables[0].rows.last.labels[0].text).not_to be == "Retrying action:"
|
549
|
+
expect(contents_frame.errors[0].more_details.details.rows.last.labels[0].text).to be == "Retrying action:"
|
550
|
+
expect(contents_frame.errors[0].more_details.details.rows.last.values[0].text).to be == "Not Found"
|
551
|
+
end
|
552
|
+
ensure
|
553
|
+
Cornucopia::Util::Configuration.retry_match_with_found = false
|
554
|
+
end
|
555
|
+
end
|
556
|
+
|
471
557
|
it "finds selection options using the from option" do
|
472
558
|
report = Cornucopia::Util::ReportBuilder.current_report
|
473
559
|
|
@@ -0,0 +1,344 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require ::File.expand_path("../../../lib/cornucopia/capybara/matcher_extensions", File.dirname(__FILE__))
|
3
|
+
|
4
|
+
describe Cornucopia::Capybara::MatcherExtensions, type: :feature do
|
5
|
+
# Make sure that all tests start clean and get cleaned up afterwards...
|
6
|
+
around(:example) do |example|
|
7
|
+
expect(File.directory?(Rails.root.join("cornucopia_report/"))).to be_falsey
|
8
|
+
|
9
|
+
begin
|
10
|
+
@file_name_1 = generate_report_file("report_1")
|
11
|
+
|
12
|
+
example.run
|
13
|
+
ensure
|
14
|
+
if (Cornucopia::Util::ReportBuilder.class_variable_get("@@current_report"))
|
15
|
+
Cornucopia::Util::ReportBuilder.current_report.close
|
16
|
+
end
|
17
|
+
|
18
|
+
::Capybara.current_session.driver.window_handles.each do |handle|
|
19
|
+
if handle != ::Capybara.current_session.driver.current_window_handle
|
20
|
+
::Capybara.current_session.driver.close_window(handle)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
FileUtils.rm_rf Rails.root.join("cornucopia_report/")
|
25
|
+
FileUtils.rm_rf Rails.root.join("sample_report/")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
before(:context) do
|
30
|
+
@file_name_1 = generate_report_file("report_1")
|
31
|
+
::Capybara.app = Rack::File.new File.absolute_path(File.join(File.dirname(@file_name_1), "../.."))
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#__cornucopia_assert_selector_function" do
|
35
|
+
it "should retry if a Selenium cache error is thrown" do
|
36
|
+
index_page = CornucopiaReportApp.index_page
|
37
|
+
|
38
|
+
index_page.load base_folder: "sample_report"
|
39
|
+
|
40
|
+
index_page.contents do |contents_frame|
|
41
|
+
found_elements = contents_frame.assert_selector("a", __cornucopia_no_analysis: true)
|
42
|
+
|
43
|
+
num_retries = rand(1..(Cornucopia::Util::Configuration.selenium_cache_retry_count - 1))
|
44
|
+
time_count = num_retries
|
45
|
+
num_calls = 0
|
46
|
+
|
47
|
+
allow(contents_frame.page.document).
|
48
|
+
to receive(:__cornucopia_orig_assert_selector) do |*args|
|
49
|
+
num_calls += 1
|
50
|
+
|
51
|
+
if time_count > 0
|
52
|
+
time_count -= 1
|
53
|
+
raise Selenium::WebDriver::Error::StaleElementReferenceError.new
|
54
|
+
end
|
55
|
+
|
56
|
+
expect(args).to be == ["a"]
|
57
|
+
found_elements
|
58
|
+
end
|
59
|
+
|
60
|
+
second_found = contents_frame.assert_selector("a")
|
61
|
+
|
62
|
+
allow(contents_frame.page.document).
|
63
|
+
to receive(:__cornucopia_orig_assert_selector).
|
64
|
+
and_call_original
|
65
|
+
|
66
|
+
# I realize that this is almost like testing that the stub worked, which we don't need to test.
|
67
|
+
# However, we are really testing that the results returned by the stub are passed back all the way
|
68
|
+
# Which we do need to test.
|
69
|
+
expect(second_found).to be == found_elements
|
70
|
+
expect(time_count).to be == 0
|
71
|
+
expect(num_calls).to be == num_retries + 1
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should call __cornucopia__analyze_selector if it cannot resolve the stale reference" do
|
76
|
+
index_page = CornucopiaReportApp.index_page
|
77
|
+
|
78
|
+
index_page.load base_folder: "sample_report"
|
79
|
+
|
80
|
+
index_page.contents do |contents_frame|
|
81
|
+
found_elements = contents_frame.assert_selector("a", __cornucopia_no_analysis: true)
|
82
|
+
|
83
|
+
# Because we are over riding the original call, we just stub this out
|
84
|
+
# because it cannot work properly.
|
85
|
+
expect(contents_frame.page.document).
|
86
|
+
to receive(:__cornucopia__analyze_selector).
|
87
|
+
and_return(found_elements)
|
88
|
+
|
89
|
+
allow(contents_frame.page.document).
|
90
|
+
to receive(:__cornucopia_orig_assert_selector) do |*args|
|
91
|
+
raise Selenium::WebDriver::Error::StaleElementReferenceError.new
|
92
|
+
end
|
93
|
+
|
94
|
+
second_found = contents_frame.assert_selector("a")
|
95
|
+
|
96
|
+
allow(contents_frame.page.document).
|
97
|
+
to receive(:__cornucopia_orig_assert_selector).
|
98
|
+
and_call_original
|
99
|
+
|
100
|
+
# I realize that this is almost like testing that the stub worked, which we don't need to test.
|
101
|
+
# However, we are really testing that the results returned by the stub are passed back all the way
|
102
|
+
# Which we do need to test.
|
103
|
+
expect(second_found).to be == found_elements
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should call __cornucopia__analyze_selector if an exception is thrown" do
|
108
|
+
index_page = CornucopiaReportApp.index_page
|
109
|
+
|
110
|
+
index_page.load base_folder: "sample_report"
|
111
|
+
|
112
|
+
index_page.contents do |contents_frame|
|
113
|
+
found_elements = contents_frame.assert_no_selector("notfound .report-block", __cornucopia_no_analysis: true)
|
114
|
+
|
115
|
+
# Because we are over riding the original call, we just stub this out
|
116
|
+
# because it cannot work properly.
|
117
|
+
expect(contents_frame.page.document).
|
118
|
+
to receive(:__cornucopia__analyze_selector).
|
119
|
+
and_return(found_elements)
|
120
|
+
|
121
|
+
allow(contents_frame.page.document).
|
122
|
+
to receive(:__cornucopia_orig_assert_no_selector) do |*args|
|
123
|
+
raise "This is an error"
|
124
|
+
end
|
125
|
+
|
126
|
+
second_found = contents_frame.assert_no_selector(".report-block")
|
127
|
+
|
128
|
+
allow(contents_frame.page.document).
|
129
|
+
to receive(:__cornucopia_orig_assert_no_selector).
|
130
|
+
and_call_original
|
131
|
+
|
132
|
+
# I realize that this is almost like testing that the stub worked, which we don't need to test.
|
133
|
+
# However, we are really testing that the results returned by the stub are passed back all the way
|
134
|
+
# Which we do need to test.
|
135
|
+
expect(second_found).to be == found_elements
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def get_object(object_type)
|
141
|
+
case (object_type)
|
142
|
+
when :page
|
143
|
+
::Capybara.page
|
144
|
+
|
145
|
+
when :document
|
146
|
+
::Capybara.page.document
|
147
|
+
|
148
|
+
when :body
|
149
|
+
::Capybara.page.document.find("html")
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
[:page, :document, :body].each do |object_type|
|
154
|
+
describe "#__cornucopia__analyze_selector for #{object_type}" do
|
155
|
+
it "does nothing if this is called from the analysis function" do
|
156
|
+
index_page = CornucopiaReportApp.index_page
|
157
|
+
|
158
|
+
index_page.load base_folder: "sample_report"
|
159
|
+
|
160
|
+
Cornucopia::Util::Configuration.analyze_find_exceptions = true
|
161
|
+
|
162
|
+
expect(Cornucopia::Capybara::FinderDiagnostics::FindAction).not_to receive(:new)
|
163
|
+
|
164
|
+
expect { get_object(object_type).assert_selector "boody", __cornucopia_no_analysis: true }.
|
165
|
+
to raise_error(::Capybara::ExpectationNotMet)
|
166
|
+
end
|
167
|
+
|
168
|
+
it "does nothing if this is called from the analysis function no_selector" do
|
169
|
+
index_page = CornucopiaReportApp.index_page
|
170
|
+
|
171
|
+
index_page.load base_folder: "sample_report"
|
172
|
+
|
173
|
+
Cornucopia::Util::Configuration.analyze_find_exceptions = true
|
174
|
+
|
175
|
+
expect(Cornucopia::Capybara::FinderDiagnostics::FindAction).not_to receive(:new)
|
176
|
+
|
177
|
+
expect { get_object(object_type).assert_no_selector "body", __cornucopia_no_analysis: true }.
|
178
|
+
to raise_error(::Capybara::ExpectationNotMet)
|
179
|
+
end
|
180
|
+
|
181
|
+
it "does nothing if configuration is turned off" do
|
182
|
+
begin
|
183
|
+
index_page = CornucopiaReportApp.index_page
|
184
|
+
|
185
|
+
index_page.load base_folder: "sample_report"
|
186
|
+
|
187
|
+
Cornucopia::Util::Configuration.analyze_selector_exceptions = false
|
188
|
+
|
189
|
+
expect(Cornucopia::Capybara::FinderDiagnostics::FindAction).not_to receive(:new)
|
190
|
+
|
191
|
+
expect { get_object(object_type).assert_selector "boody" }.to raise_error(::Capybara::ExpectationNotMet)
|
192
|
+
ensure
|
193
|
+
Cornucopia::Util::Configuration.analyze_selector_exceptions = true
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
it "does nothing if configuration is turned off no_selector" do
|
198
|
+
begin
|
199
|
+
index_page = CornucopiaReportApp.index_page
|
200
|
+
|
201
|
+
index_page.load base_folder: "sample_report"
|
202
|
+
|
203
|
+
Cornucopia::Util::Configuration.analyze_selector_exceptions = false
|
204
|
+
|
205
|
+
expect(Cornucopia::Capybara::FinderDiagnostics::FindAction).not_to receive(:new)
|
206
|
+
|
207
|
+
expect { get_object(object_type).assert_no_selector "body" }.to raise_error(::Capybara::ExpectationNotMet)
|
208
|
+
ensure
|
209
|
+
Cornucopia::Util::Configuration.analyze_selector_exceptions = true
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
it "calls perform analysis with values from the configuration and returns the results" do
|
214
|
+
begin
|
215
|
+
index_page = CornucopiaReportApp.index_page
|
216
|
+
|
217
|
+
index_page.load base_folder: "sample_report"
|
218
|
+
|
219
|
+
Cornucopia::Util::Configuration.analyze_selector_exceptions = true
|
220
|
+
|
221
|
+
the_obj = get_object(object_type)
|
222
|
+
stubbed_finder = Cornucopia::Capybara::FinderDiagnostics::FindAction.new(the_obj, {}, {}, "boody")
|
223
|
+
found_body = the_obj.assert_selector("body")
|
224
|
+
|
225
|
+
expect(Cornucopia::Capybara::FinderDiagnostics::FindAction).to receive(:new).and_return(stubbed_finder)
|
226
|
+
|
227
|
+
retry_found = [true, false].sample
|
228
|
+
# retry_alt = [true, false].sample
|
229
|
+
|
230
|
+
Cornucopia::Util::Configuration.retry_match_with_found = retry_found
|
231
|
+
# Cornucopia::Util::Configuration.alternate_retry = retry_alt
|
232
|
+
|
233
|
+
retry_found = retry_found || nil
|
234
|
+
# retry_alt = retry_alt || nil
|
235
|
+
|
236
|
+
expect(stubbed_finder).to receive(:perform_analysis).with(retry_found).and_return true
|
237
|
+
expect(stubbed_finder).to receive(:return_value).and_return found_body
|
238
|
+
|
239
|
+
expect(the_obj.assert_selector("boody")).to be == found_body
|
240
|
+
ensure
|
241
|
+
Cornucopia::Util::Configuration.retry_match_with_found = false
|
242
|
+
# Cornucopia::Util::Configuration.alternate_retry = false
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
it "calls perform analysis with values from the configuration and returns the results no_selector" do
|
247
|
+
begin
|
248
|
+
index_page = CornucopiaReportApp.index_page
|
249
|
+
|
250
|
+
index_page.load base_folder: "sample_report"
|
251
|
+
|
252
|
+
Cornucopia::Util::Configuration.analyze_selector_exceptions = true
|
253
|
+
|
254
|
+
the_obj = get_object(object_type)
|
255
|
+
stubbed_finder = Cornucopia::Capybara::FinderDiagnostics::FindAction.new(the_obj, {}, {}, "body")
|
256
|
+
found_body = the_obj.assert_no_selector("boody")
|
257
|
+
|
258
|
+
expect(Cornucopia::Capybara::FinderDiagnostics::FindAction).to receive(:new).and_return(stubbed_finder)
|
259
|
+
|
260
|
+
retry_found = [true, false].sample
|
261
|
+
# retry_alt = [true, false].sample
|
262
|
+
|
263
|
+
Cornucopia::Util::Configuration.retry_match_with_found = retry_found
|
264
|
+
# Cornucopia::Util::Configuration.alternate_retry = retry_alt
|
265
|
+
|
266
|
+
retry_found = retry_found || nil
|
267
|
+
# retry_alt = retry_alt || nil
|
268
|
+
|
269
|
+
expect(stubbed_finder).to receive(:perform_analysis).with(retry_found).and_return true
|
270
|
+
expect(stubbed_finder).to receive(:return_value).and_return found_body
|
271
|
+
|
272
|
+
expect(the_obj.assert_no_selector("body")).to be == found_body
|
273
|
+
ensure
|
274
|
+
Cornucopia::Util::Configuration.retry_match_with_found = false
|
275
|
+
# Cornucopia::Util::Configuration.alternate_retry = false
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
it "re-raises the last error if the analysis doesn't find anything" do
|
280
|
+
begin
|
281
|
+
index_page = CornucopiaReportApp.index_page
|
282
|
+
|
283
|
+
index_page.load base_folder: "sample_report"
|
284
|
+
|
285
|
+
Cornucopia::Util::Configuration.analyze_selector_exceptions = true
|
286
|
+
|
287
|
+
the_obj = get_object(object_type)
|
288
|
+
stubbed_finder = Cornucopia::Capybara::FinderDiagnostics::FindAction.new(the_obj, {}, {}, "boody")
|
289
|
+
# found_body = the_obj.assert_selector("boody")
|
290
|
+
|
291
|
+
expect(Cornucopia::Capybara::FinderDiagnostics::FindAction).to receive(:new).and_return(stubbed_finder)
|
292
|
+
|
293
|
+
retry_found = [true, false].sample
|
294
|
+
# retry_alt = [true, false].sample
|
295
|
+
|
296
|
+
Cornucopia::Util::Configuration.retry_match_with_found = retry_found
|
297
|
+
# Cornucopia::Util::Configuration.alternate_retry = retry_alt
|
298
|
+
|
299
|
+
retry_found = retry_found || nil
|
300
|
+
# retry_alt = retry_alt || nil
|
301
|
+
|
302
|
+
expect(stubbed_finder).to receive(:perform_analysis).with(retry_found).and_return false
|
303
|
+
|
304
|
+
expect { (the_obj.assert_selector("boody")) }.to raise_error(::Capybara::ExpectationNotMet)
|
305
|
+
ensure
|
306
|
+
Cornucopia::Util::Configuration.retry_match_with_found = false
|
307
|
+
# Cornucopia::Util::Configuration.alternate_retry = false
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
it "re-raises the last error if the analysis doesn't find anything no_selector" do
|
312
|
+
begin
|
313
|
+
index_page = CornucopiaReportApp.index_page
|
314
|
+
|
315
|
+
index_page.load base_folder: "sample_report"
|
316
|
+
|
317
|
+
Cornucopia::Util::Configuration.analyze_selector_exceptions = true
|
318
|
+
|
319
|
+
the_obj = get_object(object_type)
|
320
|
+
stubbed_finder = Cornucopia::Capybara::FinderDiagnostics::FindAction.new(the_obj, {}, {}, "body")
|
321
|
+
# found_body = the_obj.assert_no_selector("body")
|
322
|
+
|
323
|
+
expect(Cornucopia::Capybara::FinderDiagnostics::FindAction).to receive(:new).and_return(stubbed_finder)
|
324
|
+
|
325
|
+
retry_found = [true, false].sample
|
326
|
+
# retry_alt = [true, false].sample
|
327
|
+
|
328
|
+
Cornucopia::Util::Configuration.retry_match_with_found = retry_found
|
329
|
+
# Cornucopia::Util::Configuration.alternate_retry = retry_alt
|
330
|
+
|
331
|
+
retry_found = retry_found || nil
|
332
|
+
# retry_alt = retry_alt || nil
|
333
|
+
|
334
|
+
expect(stubbed_finder).to receive(:perform_analysis).with(retry_found).and_return false
|
335
|
+
|
336
|
+
expect { (the_obj.assert_no_selector("body")) }.to raise_error(::Capybara::ExpectationNotMet)
|
337
|
+
ensure
|
338
|
+
Cornucopia::Util::Configuration.retry_match_with_found = false
|
339
|
+
# Cornucopia::Util::Configuration.alternate_retry = false
|
340
|
+
end
|
341
|
+
end
|
342
|
+
end
|
343
|
+
end
|
344
|
+
end
|
@@ -199,6 +199,22 @@ describe "Cornucopia::Util::Configuration" do
|
|
199
199
|
end
|
200
200
|
end
|
201
201
|
|
202
|
+
describe "#analyze_selector_exceptions" do
|
203
|
+
it "#can read the default" do
|
204
|
+
expect(Cornucopia::Util::Configuration.analyze_selector_exceptions).to be_truthy
|
205
|
+
end
|
206
|
+
|
207
|
+
it "#can set the value" do
|
208
|
+
begin
|
209
|
+
Cornucopia::Util::Configuration.analyze_selector_exceptions = false
|
210
|
+
|
211
|
+
expect(Cornucopia::Util::Configuration.analyze_selector_exceptions).to be_falsy
|
212
|
+
ensure
|
213
|
+
Cornucopia::Util::Configuration.analyze_selector_exceptions = true
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
202
218
|
describe "#retry_with_found" do
|
203
219
|
it "#can read the default" do
|
204
220
|
expect(Cornucopia::Util::Configuration.retry_with_found).to be_falsy
|
@@ -215,6 +231,22 @@ describe "Cornucopia::Util::Configuration" do
|
|
215
231
|
end
|
216
232
|
end
|
217
233
|
|
234
|
+
describe "#retry_match_with_found" do
|
235
|
+
it "#can read the default" do
|
236
|
+
expect(Cornucopia::Util::Configuration.retry_match_with_found).to be_falsy
|
237
|
+
end
|
238
|
+
|
239
|
+
it "#can set the value" do
|
240
|
+
begin
|
241
|
+
Cornucopia::Util::Configuration.retry_match_with_found = true
|
242
|
+
|
243
|
+
expect(Cornucopia::Util::Configuration.retry_match_with_found).to be_truthy
|
244
|
+
ensure
|
245
|
+
Cornucopia::Util::Configuration.retry_match_with_found = false
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
218
250
|
describe "#auto_open_report_after_generation" do
|
219
251
|
after(:each) do
|
220
252
|
Cornucopia::Util::Configuration.class_variable_get(:@@configurations).open_report_settings = { default: false }
|
@@ -234,6 +266,44 @@ describe "Cornucopia::Util::Configuration" do
|
|
234
266
|
end
|
235
267
|
|
236
268
|
describe "#open_report_after_generation" do
|
269
|
+
after(:each) do
|
270
|
+
Cornucopia::Util::Configuration.class_variable_get(:@@configurations).open_report_settings = { default: false }
|
271
|
+
end
|
272
|
+
|
273
|
+
it "returns the default value" do
|
274
|
+
def_value = [true, false].sample
|
275
|
+
|
276
|
+
Cornucopia::Util::Configuration.auto_open_report_after_generation(def_value)
|
277
|
+
expect(Cornucopia::Util::Configuration.open_report_after_generation(Faker::Lorem.word)).to eq def_value
|
278
|
+
end
|
279
|
+
|
280
|
+
it "returns the value for a report" do
|
281
|
+
def_value = [true, false].sample
|
282
|
+
report = Faker::Lorem.word
|
283
|
+
|
284
|
+
Cornucopia::Util::Configuration.auto_open_report_after_generation(def_value)
|
285
|
+
Cornucopia::Util::Configuration.auto_open_report_after_generation(!def_value, report)
|
286
|
+
|
287
|
+
expect(Cornucopia::Util::Configuration.open_report_after_generation("#{report} not")).to eq def_value
|
288
|
+
expect(Cornucopia::Util::Configuration.open_report_after_generation(report)).to eq !def_value
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
describe "#base_folder" do
|
293
|
+
it "#can read the default" do
|
294
|
+
expect(Cornucopia::Util::Configuration.base_folder).to eq "cornucopia_report"
|
295
|
+
end
|
296
|
+
|
297
|
+
it "#can set the value" do
|
298
|
+
begin
|
299
|
+
base_value = Faker::Lorem.sentence
|
300
|
+
Cornucopia::Util::Configuration.base_folder = base_value
|
301
|
+
|
302
|
+
expect(Cornucopia::Util::Configuration.base_folder).to eq base_value
|
303
|
+
ensure
|
304
|
+
Cornucopia::Util::Configuration.base_folder = "cornucopia_report"
|
305
|
+
end
|
306
|
+
end
|
237
307
|
end
|
238
308
|
|
239
309
|
# describe "#alternate_retry" do
|
@@ -362,6 +362,25 @@ describe Cornucopia::Util::ConfiguredReport do
|
|
362
362
|
end
|
363
363
|
|
364
364
|
describe "#export_field_record" do
|
365
|
+
it "doesn't crash if there is an exception" do
|
366
|
+
string_val = "string"
|
367
|
+
|
368
|
+
Cornucopia::Util::ReportTable.new do |report_table|
|
369
|
+
allow(report_table).to receive(:write_stats).and_call_original
|
370
|
+
expect(report_table).to receive(:write_stats).with(:string_val, "string", {}).and_raise(Exception, "This is an error")
|
371
|
+
|
372
|
+
simple_report.export_field_record({ report_element: [:string_val] },
|
373
|
+
string_val,
|
374
|
+
:string_val,
|
375
|
+
report_table,
|
376
|
+
0,
|
377
|
+
report_object_set: true)
|
378
|
+
|
379
|
+
expect(report_table.full_table).to match /Configured Report Error/
|
380
|
+
expect(report_table.full_table).to match /This is an error/
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
365
384
|
it "takes a passed in parent" do
|
366
385
|
string_val = "string"
|
367
386
|
|
data/spec/rails_helper.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -58,7 +58,7 @@ require ::File.expand_path("../lib/cornucopia/util/configuration", File.dirname(
|
|
58
58
|
|
59
59
|
Capybara.default_driver = :selenium
|
60
60
|
|
61
|
-
# Cornucopia::Util::Configuration.seed =
|
61
|
+
# Cornucopia::Util::Configuration.seed = 1
|
62
62
|
RSpec.configure do |config|
|
63
63
|
config.around(:each) do |example|
|
64
64
|
@seed_value = Cornucopia::Util::Configuration.seed ||
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cornucopia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RealNobody
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -230,7 +230,6 @@ files:
|
|
230
230
|
- lib/cornucopia/capybara/matcher_extensions.rb
|
231
231
|
- lib/cornucopia/capybara/page_diagnostics.rb
|
232
232
|
- lib/cornucopia/cucumber_hooks.rb
|
233
|
-
- lib/cornucopia/factory_girl/dynamic_association.rb
|
234
233
|
- lib/cornucopia/rspec_hooks.rb
|
235
234
|
- lib/cornucopia/site_prism/element_extensions.rb
|
236
235
|
- lib/cornucopia/site_prism/install_element_extensions.rb
|
@@ -300,6 +299,7 @@ files:
|
|
300
299
|
- spec/fixtures/sample_page.html
|
301
300
|
- spec/lib/capybara/finder_diagnostics_spec.rb
|
302
301
|
- spec/lib/capybara/finder_extensions_spec.rb
|
302
|
+
- spec/lib/capybara/matcher_extensions_spec.rb
|
303
303
|
- spec/lib/capybara/page_diagnostics_spec.rb
|
304
304
|
- spec/lib/site_prism/element_extensions_spec.rb
|
305
305
|
- spec/lib/site_prism/page_application_spec.rb
|
@@ -389,6 +389,7 @@ test_files:
|
|
389
389
|
- spec/fixtures/sample_page.html
|
390
390
|
- spec/lib/capybara/finder_diagnostics_spec.rb
|
391
391
|
- spec/lib/capybara/finder_extensions_spec.rb
|
392
|
+
- spec/lib/capybara/matcher_extensions_spec.rb
|
392
393
|
- spec/lib/capybara/page_diagnostics_spec.rb
|
393
394
|
- spec/lib/site_prism/element_extensions_spec.rb
|
394
395
|
- spec/lib/site_prism/page_application_spec.rb
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module Cornucopia
|
2
|
-
module FactoryGirl
|
3
|
-
class DynamicAssociations
|
4
|
-
##
|
5
|
-
# association creates an association which allows arguments or will call a block to create the
|
6
|
-
# associated object.
|
7
|
-
#
|
8
|
-
#
|
9
|
-
def association(name, options, &block)
|
10
|
-
options
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|