cornucopia 0.1.13 → 0.1.14
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 +46 -6
- data/lib/cornucopia/capybara/finder_diagnostics.rb +6 -0
- data/lib/cornucopia/cucumber_hooks.rb +2 -0
- data/lib/cornucopia/rspec_hooks.rb +5 -1
- data/lib/cornucopia/spinach_hooks.rb +2 -0
- data/lib/cornucopia/util/configuration.rb +14 -0
- data/lib/cornucopia/version.rb +1 -1
- data/spec/lib/capybara/finder_diagnostics_spec.rb +1 -1
- data/spec/lib/capybara/finder_extensions_spec.rb +1 -1
- data/spec/lib/capybara/matcher_extensions_spec.rb +1 -1
- data/spec/lib/capybara/page_diagnostics_spec.rb +1 -1
- data/spec/lib/site_prism/element_extensions_spec.rb +1 -1
- data/spec/lib/site_prism/page_application_spec.rb +1 -1
- data/spec/lib/util/configuration_spec.rb +20 -1
- data/spec/lib/util/configured_report_spec.rb +1 -1
- data/spec/lib/util/file_asset_spec.rb +1 -1
- data/spec/lib/util/generic_settings_spec.rb +1 -1
- data/spec/lib/util/log_capture_spec.rb +1 -1
- data/spec/lib/util/pretty_formatter_spec.rb +1 -1
- data/spec/lib/util/report_builder_spec.rb +1 -1
- data/spec/lib/util/report_formatters_spec.rb +1 -1
- data/spec/lib/util/report_table_exception_spec.rb +1 -1
- data/spec/lib/util/report_table_spec.rb +1 -1
- data/spec/rails_helper.rb +10 -4
- data/spec/spec_helper.rb +5 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2682bd2d0aef45b217d6232d738f47f3e263a84
|
4
|
+
data.tar.gz: 6421bfd30df02f3374930bbc9fde78e96503d8a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b236913bc33aa3af05bddf15938f360e59032615891215d7e8a3f47045d50ed10a589580cfb6e9d92ba5b52cbe561326910123e116dfa46495a0c90f9aa83a7
|
7
|
+
data.tar.gz: 45552b891a827b6a5e8a7f73bbd0a172058c0121959374681167444d9ff8b86a90c6863c349eb1c52bedca07ff717c0750800a74c422b19e4b4bccef68e02ef2
|
data/README.md
CHANGED
@@ -9,11 +9,11 @@ this is just the way it is.
|
|
9
9
|
|
10
10
|
Add this line to your application's Gemfile:
|
11
11
|
|
12
|
-
gem 'cornucopia'
|
12
|
+
gem 'cornucopia'
|
13
13
|
|
14
14
|
And then execute:
|
15
15
|
|
16
|
-
$ bundle
|
16
|
+
$ bundle install
|
17
17
|
|
18
18
|
Or install it yourself as:
|
19
19
|
|
@@ -28,7 +28,7 @@ include the appropriate files.
|
|
28
28
|
|
29
29
|
#### RSPEC:
|
30
30
|
|
31
|
-
spec_helper.rb:
|
31
|
+
spec_helper.rb or rails_helper.rb depending on the version of RSpec you are using, or where you want to put it:
|
32
32
|
|
33
33
|
```
|
34
34
|
require "cornucopia/rspec_hooks"
|
@@ -125,7 +125,7 @@ Examples:
|
|
125
125
|
# element :my_element_3, :xpath, "//td[name = \"my_element_3\"]", visible: false
|
126
126
|
end
|
127
127
|
|
128
|
-
* **
|
128
|
+
* **form_elements(form_type, *elements)**
|
129
129
|
|
130
130
|
This provides a quick and easy way to define elements for the items in forms. The ids of the elements in a form
|
131
131
|
follow the simple pattern of: <form_name><element_id>. Most of the time, you want the name of the
|
@@ -177,12 +177,14 @@ Example:
|
|
177
177
|
class MySection < SitePrism::Section
|
178
178
|
id_elements :my_item_1,
|
179
179
|
:my_item_2,
|
180
|
-
:my_item_3
|
180
|
+
:my_item_3,
|
181
|
+
"my-class-name"
|
181
182
|
|
182
183
|
# instead of:
|
183
184
|
# element :my_item_1, ".my_item_1"
|
184
185
|
# element :my_item_2, ".my_item_2"
|
185
186
|
# element :my_item_3, ".my_item_3"
|
187
|
+
# element :my_class_name, ".my-class-name"
|
186
188
|
end
|
187
189
|
|
188
190
|
* **indexed_elements(pattern, *element, options = {})**
|
@@ -266,6 +268,14 @@ The configuration class contains the various configurations that are used by the
|
|
266
268
|
The seed value represents the seed value for `rand`. It is used by the testing hooks to allow tests with
|
267
269
|
randomized values to still be repeatable. This value can be set or read.
|
268
270
|
|
271
|
+
* **order_seed**
|
272
|
+
|
273
|
+
**Experimental** The order_seed value represents the seed value for the order that RSpec tests are run in if they
|
274
|
+
are run randomly. This value in the configurations actually doesn't always work as it is very dependent on when
|
275
|
+
it is set during the RSpec configuration process. The system tries, but it may be best just to do what this does
|
276
|
+
and set `RSpec.configuration.seed = <your value>` youself in spec_helper.rb. Really I've just started playing
|
277
|
+
around with it and seeing what I can do with it.
|
278
|
+
|
269
279
|
* **grab_logs**
|
270
280
|
|
271
281
|
Indicates if the `Cornucopia::Util::LogCapture` class will capture any log files or not.
|
@@ -321,6 +331,20 @@ The configuration class contains the various configurations that are used by the
|
|
321
331
|
literally hours to print out using `pretty_inspect`. (I suspect an infinite loop.) This value prevents that by
|
322
332
|
interrupting a printout which takes too long.
|
323
333
|
|
334
|
+
* **auto_open_report_after_generation**
|
335
|
+
|
336
|
+
This allows you to tell the system to open a report with errors in it after the report is closed/finished. If
|
337
|
+
you do not specify a type of report the value you specify will be the default value used for any report that is
|
338
|
+
generated.
|
339
|
+
|
340
|
+
* And more...
|
341
|
+
|
342
|
+
There are more configurations. They are commented in the configuraiton.rb file. If I didn't include them here,
|
343
|
+
then I probably thought that they were well commented in the file, or that they weren't important enough to put
|
344
|
+
here, or that they shouldn't be used normally, or (hopefully not) I just forgot to update the readme.
|
345
|
+
|
346
|
+
If I forgot one and you think it should be here, let me know.
|
347
|
+
|
324
348
|
#### ConfiguredReport
|
325
349
|
|
326
350
|
The `Cornucopia::Util::ConfiguredReport` class allows you to configure what information is exported to generated
|
@@ -338,4 +362,20 @@ report files.
|
|
338
362
|
|
339
363
|
ReportBuilder - delayed reports
|
340
364
|
@delayed_reports = { key: { report_name: "", report_table: ReportTable.new do || end} }
|
341
|
-
finder diagnostics - within sub-report. delayed_report?
|
365
|
+
finder diagnostics - within sub-report. delayed_report?
|
366
|
+
ReportBuilder - reports by test with multiple sub-reports
|
367
|
+
Instead of delayed reports?
|
368
|
+
ReportBuilder - reformat and styling of report?
|
369
|
+
ReportBuilder - Each test in separate files so we can create a report with a list of failed tests in case there are a
|
370
|
+
lot of them.
|
371
|
+
Instead of delayed reports?
|
372
|
+
Hooks to add stuff to reports
|
373
|
+
Add own section to report for test
|
374
|
+
Option/way to make new section a more-details section
|
375
|
+
SitePrism override section, element, sections and elements command to allow parameters to be passed in as additional
|
376
|
+
options.
|
377
|
+
functions to override:
|
378
|
+
main function (name)
|
379
|
+
has_
|
380
|
+
???
|
381
|
+
Make configuration a singleton
|
@@ -79,6 +79,12 @@ module Cornucopia
|
|
79
79
|
class FindAction
|
80
80
|
@@diagnosed_finders = {}
|
81
81
|
|
82
|
+
# Clears the class variable @@diagnosed_finders between tests if called.
|
83
|
+
# This is done so that finder analysis is called at least once per test.
|
84
|
+
def self.start_test
|
85
|
+
@@diagnosed_finders = {}
|
86
|
+
end
|
87
|
+
|
82
88
|
attr_accessor :return_value
|
83
89
|
attr_accessor :support_options
|
84
90
|
|
@@ -4,6 +4,8 @@ load ::File.expand_path("capybara/install_matcher_extensions.rb", File.dirname(_
|
|
4
4
|
load ::File.expand_path("site_prism/install_element_extensions.rb", File.dirname(__FILE__))
|
5
5
|
|
6
6
|
RSpec.configure do |config|
|
7
|
+
config.seed = Cornucopia::Util::Configuration.order_seed if Cornucopia::Util::Configuration.order_seed
|
8
|
+
|
7
9
|
config.before(:suite) do |*args|
|
8
10
|
Cornucopia::Util::ReportBuilder.new_report("rspec_report")
|
9
11
|
end
|
@@ -18,6 +20,8 @@ RSpec.configure do |config|
|
|
18
20
|
|
19
21
|
srand(@seed_value)
|
20
22
|
|
23
|
+
Cornucopia::Capybara::FinderDiagnostics::FindAction.start_test
|
24
|
+
|
21
25
|
example.run
|
22
26
|
|
23
27
|
test_example = example.example if example.respond_to?(:example)
|
@@ -29,7 +33,7 @@ RSpec.configure do |config|
|
|
29
33
|
within_section("Test Error: #{test_example.full_description}") do |report|
|
30
34
|
configured_report = Cornucopia::Util::Configuration.report_configuration :rspec
|
31
35
|
|
32
|
-
configured_report.add_report_objects example: test_example
|
36
|
+
configured_report.add_report_objects example: test_example, rspec: RSpec
|
33
37
|
configured_report.generate_report(report)
|
34
38
|
end
|
35
39
|
end
|
@@ -8,6 +8,8 @@ Spinach.hooks.before_scenario do |scenario, step_definitions|
|
|
8
8
|
100000000000000000000000000000000000000 + rand(899999999999999999999999999999999999999)
|
9
9
|
|
10
10
|
scenario.instance_variable_set :@seed_value, seed_value
|
11
|
+
|
12
|
+
Cornucopia::Capybara::FinderDiagnostics::FindAction.start_test
|
11
13
|
end
|
12
14
|
|
13
15
|
Spinach.hooks.after_scenario do |scenario, step_definitions|
|
@@ -6,6 +6,7 @@ module Cornucopia
|
|
6
6
|
module Util
|
7
7
|
class Configuration
|
8
8
|
@@configurations = Cornucopia::Util::GenericSettings.new
|
9
|
+
@@configurations.order_seed = nil
|
9
10
|
@@configurations.rand_seed = nil
|
10
11
|
@@configurations.user_log_files = {}
|
11
12
|
@@configurations.default_num_lines = 500
|
@@ -34,6 +35,7 @@ module Cornucopia
|
|
34
35
|
:example,
|
35
36
|
:example__example_group_instance,
|
36
37
|
:example__metadata__caller,
|
38
|
+
:rspec__configuration__seed,
|
37
39
|
:logs,
|
38
40
|
:capybara_page_diagnostics
|
39
41
|
],
|
@@ -268,6 +270,18 @@ module Cornucopia
|
|
268
270
|
@@configurations.rand_seed
|
269
271
|
end
|
270
272
|
|
273
|
+
# order_seed is the seed value used to set the order that randomly ordered tests are run in.
|
274
|
+
# This is provided as a convenience method. I think it is easier to set this in rails_helper than it is to
|
275
|
+
# set it on the command line. This also provides a uniform method to do it.
|
276
|
+
def order_seed=(value)
|
277
|
+
@@configurations.order_seed = value
|
278
|
+
RSpec.configuration.seed = value if value
|
279
|
+
end
|
280
|
+
|
281
|
+
def order_seed
|
282
|
+
@@configurations.order_seed
|
283
|
+
end
|
284
|
+
|
271
285
|
# grab_logs indicates if the system should try to automatically grab a tail of
|
272
286
|
# the log file if outputing a diagnostics report.
|
273
287
|
#
|
data/lib/cornucopia/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require "
|
1
|
+
require "rails_helper"
|
2
2
|
require ::File.expand_path("../../../lib/cornucopia/util/report_builder", File.dirname(__FILE__))
|
3
3
|
require ::File.expand_path("../../../lib/cornucopia/capybara/page_diagnostics", File.dirname(__FILE__))
|
4
4
|
require ::File.expand_path("../../../lib/cornucopia/capybara/finder_diagnostics", File.dirname(__FILE__))
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require "
|
1
|
+
require "rails_helper"
|
2
2
|
require 'rack/file'
|
3
3
|
require ::File.expand_path("../../../lib/cornucopia/util/report_builder", File.dirname(__FILE__))
|
4
4
|
require ::File.expand_path("../../../lib/cornucopia/capybara/page_diagnostics", File.dirname(__FILE__))
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require "
|
1
|
+
require "rails_helper"
|
2
2
|
require ::File.expand_path("../../../lib/cornucopia/util/configuration", File.dirname(__FILE__))
|
3
3
|
|
4
4
|
describe "Cornucopia::Util::Configuration" do
|
@@ -18,6 +18,25 @@ describe "Cornucopia::Util::Configuration" do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
it "has a default order_seed value" do
|
22
|
+
expect(Cornucopia::Util::Configuration.order_seed).not_to be
|
23
|
+
end
|
24
|
+
|
25
|
+
it "can set the order_seed value" do
|
26
|
+
config_seed = RSpec.configuration.seed
|
27
|
+
begin
|
28
|
+
seed_value = rand(0..999999999999999999999999999)
|
29
|
+
|
30
|
+
Cornucopia::Util::Configuration.order_seed = seed_value
|
31
|
+
|
32
|
+
expect(Cornucopia::Util::Configuration.order_seed).to be == seed_value
|
33
|
+
expect(RSpec.configuration.seed).to be == seed_value
|
34
|
+
ensure
|
35
|
+
RSpec.configuration.seed = config_seed
|
36
|
+
Cornucopia::Util::Configuration.order_seed = nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
21
40
|
describe "log files" do
|
22
41
|
it "grabs logs by default" do
|
23
42
|
expect(Cornucopia::Util::Configuration.grab_logs).to be_truthy
|
data/spec/rails_helper.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
-
ENV["RAILS_ENV"] ||= 'test'
|
3
|
-
require
|
4
|
-
require File.expand_path("../../config/environment", __FILE__)
|
2
|
+
ENV["RAILS_ENV"] ||= 'test'
|
3
|
+
require "spec_helper"
|
4
|
+
# require File.expand_path("../../config/environment", __FILE__)
|
5
5
|
require 'rspec/rails'
|
6
6
|
|
7
7
|
# Requires supporting ruby files with custom matchers and macros, etc, in
|
@@ -19,7 +19,7 @@ ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
|
|
19
19
|
|
20
20
|
RSpec.configure do |config|
|
21
21
|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
22
|
-
config.fixture_path
|
22
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
23
23
|
|
24
24
|
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
25
25
|
# examples within a transaction, remove the following line or assign false
|
@@ -40,4 +40,10 @@ RSpec.configure do |config|
|
|
40
40
|
# The different available types are documented in the features, such as in
|
41
41
|
# https://relishapp.com/rspec/rspec-rails/docs
|
42
42
|
config.infer_spec_type_from_file_location!
|
43
|
+
|
44
|
+
config.before(:each) do
|
45
|
+
Cornucopia::Capybara::FinderDiagnostics::FindAction.start_test
|
46
|
+
|
47
|
+
expect(Cornucopia::Capybara::FinderDiagnostics::FindAction.class_variable_get(:@@diagnosed_finders)).to be_blank
|
48
|
+
end
|
43
49
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -59,17 +59,19 @@ require ::File.expand_path("../lib/cornucopia/util/configuration", File.dirname(
|
|
59
59
|
Capybara.default_driver = :selenium
|
60
60
|
|
61
61
|
# Cornucopia::Util::Configuration.seed = 1
|
62
|
+
# Cornucopia::Util::Configuration.order_seed = 1
|
63
|
+
|
62
64
|
RSpec.configure do |config|
|
63
65
|
config.around(:each) do |example|
|
64
|
-
@
|
66
|
+
@test_seed_value = Cornucopia::Util::Configuration.seed ||
|
65
67
|
100000000000000000000000000000000000000 + rand(899999999999999999999999999999999999999)
|
66
68
|
|
67
|
-
srand(@
|
69
|
+
srand(@test_seed_value)
|
68
70
|
|
69
71
|
example.run
|
70
72
|
|
71
73
|
if (example.exception)
|
72
|
-
puts("random seed for testing was: #{@
|
74
|
+
puts("random seed for testing was: #{@test_seed_value}")
|
73
75
|
end
|
74
76
|
end
|
75
77
|
end
|
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.14
|
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-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|