cornucopia 0.1.40 → 0.1.41

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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/cornucopia.gemspec +1 -1
  4. data/lib/cornucopia.rb +7 -0
  5. data/lib/cornucopia/capybara/finder_diagnostics.rb +10 -6
  6. data/lib/cornucopia/capybara/finder_extensions.rb +24 -15
  7. data/lib/cornucopia/capybara/install_extensions.rb +44 -0
  8. data/lib/cornucopia/capybara/matcher_extensions.rb +33 -21
  9. data/lib/cornucopia/capybara/page_diagnostics.rb +44 -1
  10. data/lib/cornucopia/capybara/selectable_values.rb +47 -0
  11. data/lib/cornucopia/capybara/synchronizable.rb +24 -0
  12. data/lib/cornucopia/cucumber_hooks.rb +6 -3
  13. data/lib/cornucopia/rspec_hooks.rb +5 -4
  14. data/lib/cornucopia/site_prism/element_extensions.rb +16 -2
  15. data/lib/cornucopia/site_prism/install_extensions.rb +18 -0
  16. data/lib/cornucopia/site_prism/page_application.rb +3 -1
  17. data/lib/cornucopia/site_prism/section_extensions.rb +23 -0
  18. data/lib/cornucopia/spinach_hooks.rb +6 -3
  19. data/lib/cornucopia/util/configuration.rb +14 -6
  20. data/lib/cornucopia/util/configured_report.rb +3 -1
  21. data/lib/cornucopia/util/file_asset.rb +3 -1
  22. data/lib/cornucopia/util/generic_settings.rb +3 -1
  23. data/lib/cornucopia/util/log_capture.rb +4 -2
  24. data/lib/cornucopia/util/pretty_formatter.rb +4 -2
  25. data/lib/cornucopia/util/report_builder.rb +9 -6
  26. data/lib/cornucopia/util/report_formatters.rb +3 -1
  27. data/lib/cornucopia/util/report_table.rb +4 -2
  28. data/lib/cornucopia/util/test_helper.rb +8 -2
  29. data/lib/cornucopia/version.rb +2 -2
  30. data/spec/dummy/app/controllers/application_controller.rb +2 -0
  31. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  32. data/spec/dummy/config/application.rb +2 -0
  33. data/spec/dummy/config/boot.rb +2 -0
  34. data/spec/dummy/config/environment.rb +2 -0
  35. data/spec/dummy/config/environments/development.rb +2 -0
  36. data/spec/dummy/config/environments/production.rb +2 -0
  37. data/spec/dummy/config/environments/test.rb +2 -0
  38. data/spec/dummy/config/initializers/backtrace_silencers.rb +2 -0
  39. data/spec/dummy/config/initializers/filter_parameter_logging.rb +2 -0
  40. data/spec/dummy/config/initializers/inflections.rb +2 -0
  41. data/spec/dummy/config/initializers/mime_types.rb +2 -0
  42. data/spec/dummy/config/initializers/secret_token.rb +2 -0
  43. data/spec/dummy/config/initializers/session_store.rb +2 -0
  44. data/spec/dummy/config/initializers/wrap_parameters.rb +2 -0
  45. data/spec/dummy/config/routes.rb +2 -0
  46. data/spec/dummy/db/schema.rb +2 -0
  47. data/spec/dummy/features/support/env.rb +2 -0
  48. data/spec/lib/capybara/finder_diagnostics_spec.rb +68 -58
  49. data/spec/lib/capybara/finder_extensions_spec.rb +13 -6
  50. data/spec/lib/capybara/matcher_extensions_spec.rb +2 -0
  51. data/spec/lib/capybara/page_diagnostics_spec.rb +2 -0
  52. data/spec/lib/site_prism/element_extensions_spec.rb +2 -0
  53. data/spec/lib/site_prism/page_application_spec.rb +2 -0
  54. data/spec/lib/util/configuration_spec.rb +2 -0
  55. data/spec/lib/util/configured_report_spec.rb +2 -0
  56. data/spec/lib/util/file_asset_spec.rb +2 -0
  57. data/spec/lib/util/generic_settings_spec.rb +2 -0
  58. data/spec/lib/util/log_capture_spec.rb +2 -0
  59. data/spec/lib/util/pretty_formatter_spec.rb +29 -27
  60. data/spec/lib/util/report_builder_spec.rb +5 -3
  61. data/spec/lib/util/report_formatters_spec.rb +2 -0
  62. data/spec/lib/util/report_table_exception_spec.rb +2 -0
  63. data/spec/lib/util/report_table_spec.rb +4 -2
  64. data/spec/lib/util/test_helper_spec.rb +2 -0
  65. data/spec/pages/cornucopia_report_app.rb +2 -0
  66. data/spec/pages/cornucopia_report_pages/cornucopia_report_holder_page.rb +2 -0
  67. data/spec/pages/cornucopia_report_pages/cornucopia_report_test_contents_page.rb +2 -0
  68. data/spec/pages/cornucopia_report_pages/index_page.rb +2 -0
  69. data/spec/pages/google/email_page.rb +2 -0
  70. data/spec/pages/google/login_page.rb +2 -0
  71. data/spec/rails_helper.rb +2 -0
  72. data/spec/sample_report.rb +2 -0
  73. data/spec/spec_helper.rb +2 -0
  74. metadata +11 -9
  75. data/lib/cornucopia/capybara/install_finder_extensions.rb +0 -105
  76. data/lib/cornucopia/capybara/install_matcher_extensions.rb +0 -43
  77. data/lib/cornucopia/site_prism/install_element_extensions.rb +0 -54
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require ::File.expand_path("../cornucopia", File.dirname(__FILE__))
2
4
  require "singleton"
3
5
 
4
- 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
- load ::File.expand_path("site_prism/install_element_extensions.rb", File.dirname(__FILE__))
6
+ load ::File.expand_path("capybara/install_extensions.rb", File.dirname(__FILE__))
7
+ load ::File.expand_path("site_prism/install_extensions.rb", File.dirname(__FILE__))
7
8
 
8
9
  module Cornucopia
9
10
  class RSpecHelper
@@ -138,4 +139,4 @@ RSpec.configure do |config|
138
139
 
139
140
  puts "Cornucopia::Hook::after test time: #{time}" if Cornucopia::Util::Configuration.benchmark
140
141
  end
141
- end
142
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support/concern'
2
4
 
3
5
  module Cornucopia
@@ -5,6 +7,20 @@ module Cornucopia
5
7
  module ElementExtensions
6
8
  extend ActiveSupport::Concern
7
9
 
10
+ included do
11
+ ::Capybara::Session::DSL_METHODS.each do |method|
12
+ alias_method "__cornucopia_orig_#{method}".to_sym, method
13
+
14
+ define_method method do |*args, &block|
15
+ if @__corunucopia_base_node
16
+ @__corunucopia_base_node.send method, *args, &block
17
+ else
18
+ send "__cornucopia_orig_#{method}", *args, &block
19
+ end
20
+ end
21
+ end
22
+ end
23
+
8
24
  module ClassMethods
9
25
  # patterned_elements defines a set of elements where the find pattern is based on the
10
26
  # name that will be used for the element.
@@ -277,5 +293,3 @@ module Cornucopia
277
293
  end
278
294
  end
279
295
  end
280
-
281
- load ::File.expand_path("install_element_extensions.rb", File.dirname(__FILE__))
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ if Object.const_defined?("SitePrism") &&
4
+ ::SitePrism.const_defined?("Page")
5
+ unless SitePrism::Page.included_modules.include?(Cornucopia::SitePrism::ElementExtensions)
6
+ SitePrism::Page.include Cornucopia::SitePrism::ElementExtensions
7
+ end
8
+ end
9
+
10
+ if Object.const_defined?("SitePrism") &&
11
+ ::SitePrism.const_defined?("Section")
12
+ unless SitePrism::Section.included_modules.include?(Cornucopia::SitePrism::ElementExtensions)
13
+ SitePrism::Section.include Cornucopia::SitePrism::ElementExtensions
14
+ end
15
+ unless SitePrism::Section.included_modules.include?(Cornucopia::SitePrism::SectionExtensions)
16
+ SitePrism::Section.include Cornucopia::SitePrism::SectionExtensions
17
+ end
18
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Cornucopia
2
4
  module SitePrism
3
5
  # PageApplication is a class used to fetch page objects and memoize them
@@ -123,4 +125,4 @@ module Cornucopia
123
125
  end
124
126
  end
125
127
  end
126
- end
128
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/concern'
4
+
5
+ module Cornucopia
6
+ module SitePrism
7
+ module SectionExtensions
8
+ extend ActiveSupport::Concern
9
+
10
+ included do |base|
11
+ base.class_exec do
12
+ alias :__cornucopia_orig_initialize :initialize
13
+
14
+ def initialize(*args)
15
+ __cornucopia_orig_initialize(*args)
16
+
17
+ self.owner_node = args[0].owner_node
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,6 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require ::File.expand_path("../cornucopia", File.dirname(__FILE__))
2
- load ::File.expand_path("capybara/install_finder_extensions.rb", File.dirname(__FILE__))
3
- load ::File.expand_path("site_prism/install_element_extensions.rb", File.dirname(__FILE__))
4
+
5
+ load ::File.expand_path("capybara/install_extensions.rb", File.dirname(__FILE__))
6
+ load ::File.expand_path("site_prism/install_extensions.rb", File.dirname(__FILE__))
4
7
 
5
8
  Spinach.hooks.around_scenario do |scenario_data, step_definitions, &block|
6
9
  test_name = Cornucopia::Util::TestHelper.spinach_name(scenario_data)
@@ -68,4 +71,4 @@ Spinach.hooks.after_run do |status|
68
71
  Cornucopia::Util::ReportBuilder.current_report.close
69
72
  end
70
73
 
71
- Cornucopia::Util::ReportBuilder.new_report "spinach_report"
74
+ Cornucopia::Util::ReportBuilder.new_report "spinach_report"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "singleton"
2
4
  require ::File.expand_path('configured_report', File.dirname(__FILE__))
3
5
  require ::File.expand_path('generic_settings', File.dirname(__FILE__))
@@ -85,7 +87,9 @@ module Cornucopia
85
87
  :example__example_group_instance__controller___request,
86
88
  :example__example_group_instance__controller___response,
87
89
  :example__example_group_instance__controller___routes,
90
+ :example__example_group_instance__request__filtered_env,
88
91
  :example__example_group_instance__routes,
92
+ :example__example_group_instance___routes,
89
93
  "example__example_group_instance__request__env__action_dispatch.routes",
90
94
  "example__example_group_instance__request__env__action_controller.instance",
91
95
  ],
@@ -94,7 +98,11 @@ module Cornucopia
94
98
  min_fields: [
95
99
  {
96
100
  report_element: :scenario__feature__title,
97
- report_options: { label: "feature" }
101
+ report_options: { label: "feature", ignore_missing: true }
102
+ },
103
+ {
104
+ report_element: :scenario__feature__name,
105
+ report_options: { label: "feature", ignore_missing: true }
98
106
  },
99
107
  {
100
108
  report_element: :scenario__feature__location,
@@ -121,7 +129,10 @@ module Cornucopia
121
129
  # :scenario__feature__comment,
122
130
  :scenario__feature__keyword,
123
131
  :scenario__feature__description,
124
- :scenario__feature__gherkin_statement,
132
+ {
133
+ report_element: :scenario__feature__gherkin_statement,
134
+ report_options: { ignore_missing: true }
135
+ },
125
136
  :scenario__feature__tags,
126
137
  # :scenario__current_visitor__configuration,
127
138
  :cucumber,
@@ -259,11 +270,8 @@ module Cornucopia
259
270
  ],
260
271
  exclude_fields: [
261
272
  :capybara__page_url,
262
- :capybara__title,
263
273
  :capybara__screen_shot,
264
- :capybara__page_url,
265
274
  :capybara__title,
266
- :capybara__screen_shot,
267
275
  :capybara__options,
268
276
  :capybara__report,
269
277
  :capybara__table,
@@ -740,4 +748,4 @@ module Cornucopia
740
748
  end
741
749
  end
742
750
  end
743
- end
751
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require ::File.expand_path('report_builder', File.dirname(__FILE__))
2
4
  require ::File.expand_path('report_table', File.dirname(__FILE__))
3
5
  require ::File.expand_path('log_capture', File.dirname(__FILE__))
@@ -558,4 +560,4 @@ module Cornucopia
558
560
  end
559
561
  end
560
562
  end
561
- end
563
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "singleton"
2
4
 
3
5
  module Cornucopia
@@ -63,4 +65,4 @@ module Cornucopia
63
65
  end
64
66
  end
65
67
  end
66
- end
68
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Cornucopia
2
4
  module Util
3
5
  # This is a stupid little settings class
@@ -34,4 +36,4 @@ module Cornucopia
34
36
  end
35
37
  end
36
38
  end
37
- end
39
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # require ::File.expand_path('configuration', File.dirname(__FILE__))
2
4
  require ::File.expand_path('report_builder', File.dirname(__FILE__))
3
5
 
@@ -88,7 +90,7 @@ module Cornucopia
88
90
 
89
91
  num_lines = options[:num_lines] || Cornucopia::Util::Configuration.num_lines
90
92
  num_lines = Cornucopia::Util::Configuration.num_lines if num_lines <= 0
91
- log_buffer = ""
93
+ log_buffer = "".dup
92
94
  file_size = File.size(log_file_name)
93
95
 
94
96
  File.open(log_file_name) do |log_file|
@@ -130,4 +132,4 @@ module Cornucopia
130
132
  end
131
133
  end
132
134
  end
133
- end
135
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Cornucopia
2
4
  module Util
3
5
  class PrettyFormatter
@@ -38,7 +40,7 @@ module Cornucopia
38
40
  @current_pos = 0
39
41
  @start_pos = 0
40
42
  @unknown_string_len = @unknown_string.length
41
- @formatted_string = ""
43
+ @formatted_string = "".dup
42
44
 
43
45
  while @current_pos < @unknown_string_len
44
46
  case @current_state
@@ -577,4 +579,4 @@ module Cornucopia
577
579
  end
578
580
  end
579
581
  end
580
- end
582
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "timeout"
2
4
  require ::File.expand_path('file_asset', File.dirname(__FILE__))
3
5
  require ::File.expand_path('pretty_formatter', File.dirname(__FILE__))
@@ -87,10 +89,11 @@ module Cornucopia
87
89
  begin
88
90
  timeout_length = Cornucopia::Util::Configuration.print_timeout_min
89
91
  if Object.const_defined?("Capybara")
90
- timeout_length = [timeout_length, ::Capybara.default_wait_time].max
92
+ default_time = ::Capybara.respond_to?(:default_max_wait_time) ? ::Capybara.default_max_wait_time : ::Capybara.default_wait_time
93
+ timeout_length = [timeout_length, default_time].max
91
94
  end
92
95
  if Object.const_defined?("Rails")
93
- timeout_length = [timeout_length, 60 * 60].max if Rails.env.development?
96
+ timeout_length = [timeout_length, 30].max if Rails.env.development?
94
97
  end
95
98
 
96
99
  Timeout::timeout(timeout_length) do
@@ -559,7 +562,7 @@ module Cornucopia
559
562
  open_report_test_contents_file do |write_file|
560
563
  write_file.write "<div class=\"cornucopia-section #{((@section_number += 1) % 2) == 1 ? "cornucopia-even" : "cornucopia-odd"}\">\n"
561
564
  write_file.write "<p class=\"cornucopia-section-label\">#{Cornucopia::Util::ReportBuilder.escape_string(section_text)}</p>\n".
562
- force_encoding("UTF-8")
565
+ dup.force_encoding("UTF-8")
563
566
  end
564
567
  block.yield self
565
568
  ensure
@@ -571,7 +574,7 @@ module Cornucopia
571
574
  end
572
575
 
573
576
  def within_hidden_table(options={}, &block)
574
- table_pre = "<div class=\"cornucopia-show-hide-section\">\n"
577
+ table_pre = "<div class=\"cornucopia-show-hide-section\">\n".dup
575
578
  table_pre << " <div class=\"cornucopia-table\">\n"
576
579
  table_pre << " <div class=\"cornucopia-row\">\n"
577
580
  table_pre << " <div class=\"cornucopia-cell-data\">\n"
@@ -582,7 +585,7 @@ module Cornucopia
582
585
  table_pre << " <div class=\"cornucopia-additional-details hidden\">\n"
583
586
  table_pre = table_pre.html_safe
584
587
 
585
- table_post = " </div>\n"
588
+ table_post = " </div>\n".dup
586
589
  table_post << "</div>\n"
587
590
  table_post = table_post.html_safe
588
591
 
@@ -690,4 +693,4 @@ module Cornucopia
690
693
  end
691
694
  end
692
695
  end
693
- end
696
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require ::File.expand_path('report_builder', File.dirname(__FILE__))
2
4
 
3
5
  module Cornucopia
@@ -8,4 +10,4 @@ module Cornucopia
8
10
  end
9
11
  end
10
12
  end
11
- end
13
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require ::File.expand_path('file_asset', File.dirname(__FILE__))
2
4
  # require ::File.expand_path('report_builder', File.dirname(__FILE__))
3
5
 
@@ -60,7 +62,7 @@ module Cornucopia
60
62
  # suppress_blank_table - If set, then when a nested table is to be written to the parent table, the
61
63
  # nested table will not be output if it is empty.
62
64
  def initialize(options = {}, &block)
63
- @full_table = ""
65
+ @full_table = "".dup
64
66
  @table_closed = false
65
67
  @options = options
66
68
 
@@ -192,4 +194,4 @@ module Cornucopia
192
194
  end
193
195
  end
194
196
  end
195
- end
197
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "singleton"
2
4
 
3
5
  module Cornucopia
@@ -10,7 +12,11 @@ module Cornucopia
10
12
  def cucumber_name(scenario)
11
13
  report_name = "Unknown"
12
14
  if scenario.respond_to?(:feature)
13
- report_name = "#{scenario.feature.title}:#{scenario.title}"
15
+ if scenario.feature.respond_to?(:name)
16
+ report_name = "#{scenario.feature.name}:#{scenario.name}"
17
+ else
18
+ report_name = "#{scenario.feature.title}:#{scenario.title}"
19
+ end
14
20
  elsif scenario.respond_to?(:line)
15
21
  report_name = "Line - #{scenario.line}"
16
22
  end
@@ -50,4 +56,4 @@ module Cornucopia
50
56
  end
51
57
  end
52
58
  end
53
- end
59
+ end
@@ -1,3 +1,3 @@
1
1
  module Cornucopia
2
- VERSION = "0.1.40"
3
- end
2
+ VERSION = "0.1.41"
3
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class ApplicationController < ActionController::Base
2
4
  # Prevent CSRF attacks by raising an exception.
3
5
  # For APIs, you may want to use :null_session instead.
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ApplicationHelper
2
4
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.expand_path('../boot', __FILE__)
2
4
 
3
5
  # Pick the frameworks you want:
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Set up gems listed in the Gemfile.
2
4
  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Load the Rails application.
2
4
  require File.expand_path('../application', __FILE__)
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Dummy::Application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb.
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Dummy::Application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb.
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Dummy::Application.configure do
2
4
  # Settings specified here will take precedence over those in config/application.rb.
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Be sure to restart your server when you modify this file.
2
4
 
3
5
  # Configure sensitive parameters which will be filtered from the log file.