cornucopia 0.1.12

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 (107) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +51 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile +16 -0
  6. data/LICENSE.TXT +22 -0
  7. data/README.md +341 -0
  8. data/Rakefile +18 -0
  9. data/cornucopia.gemspec +39 -0
  10. data/lib/cornucopia.rb +18 -0
  11. data/lib/cornucopia/capybara/finder_diagnostics.rb +536 -0
  12. data/lib/cornucopia/capybara/finder_extensions.rb +89 -0
  13. data/lib/cornucopia/capybara/install_finder_extensions.rb +105 -0
  14. data/lib/cornucopia/capybara/install_matcher_extensions.rb +39 -0
  15. data/lib/cornucopia/capybara/matcher_extensions.rb +83 -0
  16. data/lib/cornucopia/capybara/page_diagnostics.rb +228 -0
  17. data/lib/cornucopia/cucumber_hooks.rb +38 -0
  18. data/lib/cornucopia/factory_girl/dynamic_association.rb +14 -0
  19. data/lib/cornucopia/rspec_hooks.rb +37 -0
  20. data/lib/cornucopia/site_prism/element_extensions.rb +273 -0
  21. data/lib/cornucopia/site_prism/install_element_extensions.rb +23 -0
  22. data/lib/cornucopia/site_prism/page_application.rb +126 -0
  23. data/lib/cornucopia/source_files/collapse.gif +0 -0
  24. data/lib/cornucopia/source_files/cornucopia.css +162 -0
  25. data/lib/cornucopia/source_files/expand.gif +0 -0
  26. data/lib/cornucopia/source_files/index_base.html +10 -0
  27. data/lib/cornucopia/source_files/index_contents.html +2 -0
  28. data/lib/cornucopia/source_files/more_info.js +87 -0
  29. data/lib/cornucopia/source_files/report_base.html +10 -0
  30. data/lib/cornucopia/source_files/report_contents.html +3 -0
  31. data/lib/cornucopia/spinach_hooks.rb +51 -0
  32. data/lib/cornucopia/util/configuration.rb +493 -0
  33. data/lib/cornucopia/util/configured_report.rb +520 -0
  34. data/lib/cornucopia/util/file_asset.rb +46 -0
  35. data/lib/cornucopia/util/generic_settings.rb +37 -0
  36. data/lib/cornucopia/util/log_capture.rb +97 -0
  37. data/lib/cornucopia/util/pretty_formatter.rb +580 -0
  38. data/lib/cornucopia/util/report_builder.rb +474 -0
  39. data/lib/cornucopia/util/report_formatters.rb +11 -0
  40. data/lib/cornucopia/util/report_table.rb +195 -0
  41. data/lib/cornucopia/version.rb +3 -0
  42. data/lib/tasks/cornucopia_tasks.rake +4 -0
  43. data/spec/dummy/README.rdoc +28 -0
  44. data/spec/dummy/Rakefile +6 -0
  45. data/spec/dummy/app/assets/images/.keep +0 -0
  46. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  47. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  48. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  49. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  50. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  51. data/spec/dummy/app/mailers/.keep +0 -0
  52. data/spec/dummy/app/models/.keep +0 -0
  53. data/spec/dummy/app/models/concerns/.keep +0 -0
  54. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  55. data/spec/dummy/bin/bundle +3 -0
  56. data/spec/dummy/bin/rails +4 -0
  57. data/spec/dummy/bin/rake +4 -0
  58. data/spec/dummy/config.ru +4 -0
  59. data/spec/dummy/config/application.rb +27 -0
  60. data/spec/dummy/config/boot.rb +5 -0
  61. data/spec/dummy/config/cucumber.yml +8 -0
  62. data/spec/dummy/config/database.yml +37 -0
  63. data/spec/dummy/config/environment.rb +5 -0
  64. data/spec/dummy/config/environments/development.rb +29 -0
  65. data/spec/dummy/config/environments/production.rb +80 -0
  66. data/spec/dummy/config/environments/test.rb +36 -0
  67. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  68. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  69. data/spec/dummy/config/initializers/inflections.rb +16 -0
  70. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  71. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  72. data/spec/dummy/config/initializers/session_store.rb +3 -0
  73. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  74. data/spec/dummy/config/locales/en.yml +23 -0
  75. data/spec/dummy/config/routes.rb +56 -0
  76. data/spec/dummy/db/schema.rb +16 -0
  77. data/spec/dummy/features/support/env.rb +66 -0
  78. data/spec/dummy/lib/assets/.keep +0 -0
  79. data/spec/dummy/lib/tasks/cucumber.rake +65 -0
  80. data/spec/dummy/public/404.html +58 -0
  81. data/spec/dummy/public/422.html +58 -0
  82. data/spec/dummy/public/500.html +57 -0
  83. data/spec/dummy/public/favicon.ico +0 -0
  84. data/spec/dummy/script/cucumber +10 -0
  85. data/spec/fixtures/sample_page.html +150 -0
  86. data/spec/lib/capybara/finder_diagnostics_spec.rb +517 -0
  87. data/spec/lib/capybara/finder_extensions_spec.rb +328 -0
  88. data/spec/lib/capybara/page_diagnostics_spec.rb +277 -0
  89. data/spec/lib/site_prism/element_extensions_spec.rb +290 -0
  90. data/spec/lib/site_prism/page_application_spec.rb +81 -0
  91. data/spec/lib/util/configuration_spec.rb +254 -0
  92. data/spec/lib/util/configured_report_spec.rb +1058 -0
  93. data/spec/lib/util/file_asset_spec.rb +86 -0
  94. data/spec/lib/util/generic_settings_spec.rb +48 -0
  95. data/spec/lib/util/log_capture_spec.rb +151 -0
  96. data/spec/lib/util/pretty_formatter_spec.rb +694 -0
  97. data/spec/lib/util/report_builder_spec.rb +983 -0
  98. data/spec/lib/util/report_formatters_spec.rb +13 -0
  99. data/spec/lib/util/report_table_exception_spec.rb +21 -0
  100. data/spec/lib/util/report_table_spec.rb +319 -0
  101. data/spec/pages/cornucopia_report_app.rb +10 -0
  102. data/spec/pages/google/email_page.rb +22 -0
  103. data/spec/pages/google/login_page.rb +25 -0
  104. data/spec/rails_helper.rb +43 -0
  105. data/spec/sample_report.rb +45 -0
  106. data/spec/spec_helper.rb +81 -0
  107. metadata +410 -0
@@ -0,0 +1,11 @@
1
+ require ::File.expand_path('report_builder', File.dirname(__FILE__))
2
+
3
+ module Cornucopia
4
+ module Util
5
+ class CucumberFormatter
6
+ def self.format_location(value)
7
+ Cornucopia::Util::ReportBuilder.pretty_format("#{value.file}:#{value.line}")
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,195 @@
1
+ require ::File.expand_path('file_asset', File.dirname(__FILE__))
2
+ require ::File.expand_path('report_builder', File.dirname(__FILE__))
3
+
4
+ module Cornucopia
5
+ module Util
6
+ class ReportTable
7
+ class ReportTableException < Exception
8
+ attr_accessor :error
9
+
10
+ def initialize(error)
11
+ @error = error
12
+ end
13
+
14
+ def to_s
15
+ @error.to_s
16
+ end
17
+
18
+ def backtrace
19
+ @error.backtrace
20
+ end
21
+ end
22
+
23
+ attr_reader :full_table
24
+
25
+ # Usage Example:
26
+ #
27
+ # ReportTable.new do |report_table|
28
+ # report_table.write_stats("label", "value")
29
+ #
30
+ # ReportTable.new(table_prefix: more_info_prefix_text,
31
+ # table_postfix: more_info_postfix_text,
32
+ # nested_table: report_table) do |more_info_block|
33
+ # ReportTable.new(nested_table: more_info_block) do |more_info_table|
34
+ # more_info_table.write_stats("label", "value")
35
+ #
36
+ # ReportTable.new(report_table: is_sub_table? nil : more_info_table,
37
+ # nested_table: more_info_table) do |sub_table|
38
+ # sub_table.write_stats("label", "value")
39
+ # end
40
+ # end
41
+ # end
42
+ # end
43
+
44
+ # options
45
+ # table_prefix - The value to open the table with.
46
+ # Default: <div class="cornucopia-table">
47
+ # table_postfix - The value to output when closing the table.
48
+ # Default: </div>
49
+ # report_table - The table that all table cells are to be output
50
+ # to.
51
+ # If set, this table will effectively not do anything.
52
+ # Default: nil
53
+ # nested_table - If this table is nested inside of another table, this will ensure
54
+ # that the nested table is written, even in case of an exception.
55
+ # nested_table_label - The label that the nested table is to be output with.
56
+ # nested_table_options - The options that the nested table is to be output with.
57
+ # Default: { prevent_shrink: true, exclude_code_block: true, do_not_pretty_print: true }
58
+ # not_a_table - If set, then write_stats simply appends the value to the "table"
59
+ # Default: false
60
+ # suppress_blank_table - If set, then when a nested table is to be written to the parent table, the
61
+ # nested table will not be output if it is empty.
62
+ def initialize(options = {}, &block)
63
+ @full_table = ""
64
+ @table_closed = false
65
+ @options = options
66
+
67
+ @options.delete_if { |key, value| value.blank? }
68
+ @options.reverse_merge!({
69
+ table_prefix: "<div class=\"cornucopia-table\">\n",
70
+ table_postfix: "</div>\n",
71
+ report_table: self,
72
+ nested_table: nil,
73
+ nested_table_label: nil,
74
+ nested_table_options: { prevent_shrink: true,
75
+ exclude_code_block: true,
76
+ do_not_pretty_print: true }
77
+ })
78
+
79
+ @options[:report_table] ||= self
80
+
81
+ begin
82
+ open_table
83
+
84
+ block.yield(@options[:report_table]) if block
85
+ rescue ReportTableException => table_error
86
+ if @options[:nested_table]
87
+ raise table_error
88
+ else
89
+ raise table_error.error
90
+ end
91
+ rescue Exception => error
92
+ error_report = "".html_safe
93
+ error_report << error.to_s + "\n"
94
+ error_report << error.class.name + "\n"
95
+ error_report << error.class.name + "\n"
96
+ error_report << Cornucopia::Util::ReportBuilder.pretty_format(error.backtrace)
97
+
98
+ @options[:report_table].write_stats "<strong>Exception while building table</strong>".html_safe, error_report
99
+
100
+ raise(ReportTableException.new(error))
101
+ ensure
102
+ close_table
103
+ end
104
+ end
105
+
106
+ def open_table
107
+ @full_table << @options[:table_prefix] if @options[:table_prefix] && @options[:report_table] == self
108
+ @table_start = @full_table.clone
109
+ end
110
+
111
+ def close_table
112
+ empty_table = @table_start == @full_table
113
+
114
+ @full_table << @options[:table_postfix] if @options[:table_postfix] && @options[:report_table] == self
115
+ @full_table = @full_table.html_safe
116
+
117
+ if @options[:nested_table] && @options[:report_table] != @options[:nested_table]
118
+ if !@options[:suppress_blank_table] || !empty_table
119
+ @options[:nested_table].write_stats(@options[:nested_table_label],
120
+ @options[:report_table].full_table,
121
+ @options[:nested_table_options])
122
+ end
123
+ else
124
+ unless !@options[:suppress_blank_table] || !empty_table
125
+ @full_table = "".html_safe
126
+ end
127
+ end
128
+
129
+ @table_closed = true
130
+ end
131
+
132
+ # Writes information to the table.
133
+ #
134
+ # Parameters:
135
+ # label - The label for the information.
136
+ # Should be short. Will be made bold and the cell will be shrunk.
137
+ # value - The value for the information.
138
+ # If the value is very wide, the cell will expand to show it.
139
+ # If the value is very tall, an expansion option will be provided, and the
140
+ # cell will truncate the value otherwise.
141
+ #
142
+ # options:
143
+ # prevent_shrink - If set, the cell will not be truncated if it is too tall, instead the cell will show
144
+ # the full contents.
145
+ # default - false
146
+ # exclude_code_block - If set, then the <pre><code> tags will not be added to the output
147
+ # default: false
148
+ # do_not_pretty_print - If set, then the value will only be escaped.
149
+ # If not, then it will be pretty formatted.
150
+ # default: false
151
+ def write_stats label, value, options = {}
152
+ raise Exception.new("The table is closed, you may not add more rows to it") if @table_closed
153
+
154
+ if options[:format]
155
+ print_value = options[:format].call(value)
156
+ elsif options[:format_function] && options[:format_object]
157
+ print_value = options[:format_object].send(options[:format_function], value)
158
+ elsif options[:do_not_pretty_print]
159
+ print_value = Cornucopia::Util::ReportBuilder.escape_string(value)
160
+ else
161
+ print_value = Cornucopia::Util::ReportBuilder.pretty_format(value)
162
+ end
163
+ label = Cornucopia::Util::ReportBuilder.escape_string(label)
164
+
165
+ unless @options[:not_a_table]
166
+ @full_table << " <div class=\"cornucopia-row\">\n"
167
+ @full_table << " <div class=\"cornucopia-cell-label\">\n#{label}\n</div>\n"
168
+ @full_table << " <div class=\"cornucopia-cell-expand\">\n"
169
+ unless options[:prevent_shrink]
170
+ @full_table << " <div class=\"hidden\"><a class=\"cornucopia-cell-more-data\" href=\"#\"><img src=\"expand.gif\"></a></div>\n"
171
+ end
172
+ @full_table << " </div>\n"
173
+ @full_table << " <div class=\"cornucopia-cell-data\">\n"
174
+ unless options[:prevent_shrink]
175
+ @full_table << " <div class=\"hide-contents\">\n"
176
+ end
177
+
178
+ @full_table << "<pre><code>" unless options[:exclude_code_block]
179
+ end
180
+
181
+ @full_table << print_value
182
+
183
+ unless @options[:not_a_table]
184
+ @full_table << "</code></pre>\n" unless options[:exclude_code_block]
185
+ unless options[:prevent_shrink]
186
+ @full_table << " </div>\n"
187
+ @full_table << " <div class=\"cornucopia-cell-more hidden\"><a class=\"cornucopia-cell-more-data\" href=\"#\">more...</a></div>\n"
188
+ end
189
+ @full_table << " </div>\n"
190
+ @full_table << " </div>\n"
191
+ end
192
+ end
193
+ end
194
+ end
195
+ end
@@ -0,0 +1,3 @@
1
+ module Cornucopia
2
+ VERSION = "0.1.12"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :cornucopia do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Dummy::Application.load_tasks
File without changes
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
File without changes
File without changes
File without changes
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
6
+ <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -0,0 +1,27 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ # Pick the frameworks you want:
4
+ require "active_record/railtie"
5
+ require "action_controller/railtie"
6
+ require "action_mailer/railtie"
7
+ require "sprockets/railtie"
8
+ # require "rails/test_unit/railtie"
9
+
10
+ Bundler.require(*Rails.groups)
11
+ require "cornucopia"
12
+
13
+ module Dummy
14
+ class Application < Rails::Application
15
+ # Settings in config/environments/* take precedence over those specified here.
16
+ # Application configuration should go into files in config/initializers
17
+ # -- all .rb files in that directory are automatically loaded.
18
+
19
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
20
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
21
+ # config.time_zone = 'Central Time (US & Canada)'
22
+
23
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
24
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
25
+ # config.i18n.default_locale = :de
26
+ end
27
+ end
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,8 @@
1
+ <%
2
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
+ rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
+ std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
5
+ %>
6
+ default: <%= std_opts %> features
7
+ wip: --tags @wip:3 --wip features
8
+ rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
@@ -0,0 +1,37 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ development:
7
+ adapter: mysql2
8
+ encoding: utf8
9
+ reconnect: false
10
+ database: cornucopia_dev
11
+ pool: 5
12
+ username: root
13
+ password: lp!8288178
14
+ socket: /tmp/mysql.sock
15
+
16
+ # Warning: The database defined as "test" will be erased and
17
+ # re-generated from your development database when you run "rake".
18
+ # Do not set this db to the same as development or production.
19
+ test:
20
+ adapter: mysql2
21
+ encoding: utf8
22
+ reconnect: false
23
+ database: cornucopia_test
24
+ pool: 5
25
+ username: root
26
+ password: lp!8288178
27
+ socket: /tmp/mysql.sock
28
+
29
+ production:
30
+ adapter: mysql2
31
+ encoding: utf8
32
+ reconnect: false
33
+ database: cornucopia_production
34
+ pool: 5
35
+ username: root
36
+ password: lp!8288178
37
+ socket: /tmp/mysql.sock
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Dummy::Application.initialize!
@@ -0,0 +1,29 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports and disable caching.
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send.
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger.
20
+ config.active_support.deprecation = :log
21
+
22
+ # Raise an error on page load if there are pending migrations
23
+ config.active_record.migration_error = :page_load
24
+
25
+ # Debug mode disables concatenation and preprocessing of assets.
26
+ # This option may cause significant delays in view rendering with a large
27
+ # number of complex assets.
28
+ config.assets.debug = true
29
+ end