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,13 @@
1
+ require 'spec_helper'
2
+ require ::File.expand_path("../../../lib/cornucopia/util/report_formatters", File.dirname(__FILE__))
3
+
4
+ describe Cornucopia::Util::CucumberFormatter do
5
+ describe "#format_location" do
6
+ it "formats the passed in object as #file.#line" do
7
+ file_location = double(:file_location, file: Faker::Lorem.sentence, line: rand(1..500))
8
+ expect(Cornucopia::Util::ReportBuilder).to receive(:pretty_format).and_call_original
9
+ expect(Cornucopia::Util::CucumberFormatter.format_location(file_location)).
10
+ to eq "#{file_location.file}:#{file_location.line}"
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+ require ::File.expand_path("../../../lib/cornucopia/util/report_table", File.dirname(__FILE__))
3
+
4
+ describe Cornucopia::Util::ReportTable::ReportTableException do
5
+ let(:inner_error) { Exception.new("This is an error") }
6
+ let(:subject) { Cornucopia::Util::ReportTable::ReportTableException.new(inner_error) }
7
+
8
+ it "returns the #error" do
9
+ expect(subject.error.to_s).to be == "This is an error"
10
+ end
11
+
12
+ it "passes the backtrace to the inner error" do
13
+ expect(inner_error).to receive(:backtrace).and_call_original
14
+ subject.backtrace
15
+ end
16
+
17
+ it "passes the to_s to the inner error" do
18
+ expect(inner_error).to receive(:to_s).and_call_original
19
+ subject.to_s
20
+ end
21
+ end
@@ -0,0 +1,319 @@
1
+ require 'spec_helper'
2
+ require ::File.expand_path("../../../lib/cornucopia/util/report_table", File.dirname(__FILE__))
3
+
4
+ describe Cornucopia::Util::ReportTable do
5
+ describe "initialize" do
6
+ it "calls open and close table around the block" do
7
+ expect_any_instance_of(Cornucopia::Util::ReportTable).to receive(:open_table).once.and_call_original
8
+ expect_any_instance_of(Cornucopia::Util::ReportTable).to receive(:close_table).once.and_call_original
9
+
10
+ report_table = Cornucopia::Util::ReportTable.new() do |report_table|
11
+ expect(report_table.is_a?(Cornucopia::Util::ReportTable)).to be_truthy
12
+ end
13
+
14
+ expect(report_table.full_table).to be == "<div class=\"cornucopia-table\">\n</div>\n"
15
+ end
16
+
17
+ it "can nest calls if necessary" do
18
+ report_table = Cornucopia::Util::ReportTable.new() do |report_table|
19
+ expect(report_table.is_a?(Cornucopia::Util::ReportTable)).to be_truthy
20
+ expect(report_table).to receive(:close_table).once.and_call_original
21
+
22
+ Cornucopia::Util::ReportTable.new(report_table: report_table) do |sub_report_table|
23
+ expect(sub_report_table).to be == report_table
24
+ expect(sub_report_table.is_a?(Cornucopia::Util::ReportTable)).to be_truthy
25
+ end
26
+ end
27
+
28
+ expect(report_table.full_table).to be == "<div class=\"cornucopia-table\">\n</div>\n"
29
+ end
30
+ end
31
+
32
+ describe "#open_table" do
33
+ it "can customize the open statement" do
34
+ report_table = Cornucopia::Util::ReportTable.new(table_prefix: "<div>\n") do |report_table|
35
+ end
36
+
37
+ expect(report_table.full_table).to be == "<div>\n</div>\n"
38
+ end
39
+ end
40
+
41
+ describe "#close_table" do
42
+ it "can customize the close statement" do
43
+ report_table = Cornucopia::Util::ReportTable.new(table_postfix: "<p>cool</p>\n</div>") do |report_table|
44
+ end
45
+
46
+ expect(report_table.full_table).to be == "<div class=\"cornucopia-table\">\n<p>cool</p>\n</div>"
47
+ expect(report_table.full_table).to be_html_safe
48
+ end
49
+ end
50
+
51
+ describe "#write_stats" do
52
+ it "raises an exception if the table is closed" do
53
+ report_table = Cornucopia::Util::ReportTable.new do |table|
54
+ end
55
+
56
+ expect do
57
+ report_table.write_stats("something", "something")
58
+ end.to raise_exception
59
+ end
60
+
61
+ it "escapes the label" do
62
+ expect(Cornucopia::Util::ReportBuilder).to receive(:escape_string).exactly(3).and_call_original
63
+
64
+ report_table = Cornucopia::Util::ReportTable.new(table_postfix: "<p>cool</p>\n</div>") do |report_table|
65
+ report_table.write_stats("&amp;", "This is some text")
66
+ end
67
+
68
+ expect(report_table.full_table).to match /\<div class=\"cornucopia-cell-label\"\>\n&amp;amp;\n\<\/div\>\n/
69
+ end
70
+
71
+ it "pretty prints the value" do
72
+ expect(Cornucopia::Util::ReportBuilder).to receive(:pretty_format).once.and_call_original
73
+
74
+ report_table = Cornucopia::Util::ReportTable.new(table_postfix: "<p>cool</p>\n</div>") do |report_table|
75
+ report_table.write_stats("This is some text", "&amp;")
76
+ end
77
+
78
+ expect(report_table.full_table).to match /\<pre\>\<code\>&amp;amp;\<\/code\>\<\/pre\>\n/
79
+ end
80
+
81
+ it "can suppress the more info block" do
82
+ expect(Cornucopia::Util::ReportBuilder).to receive(:pretty_format).once.and_call_original
83
+
84
+ report_table = Cornucopia::Util::ReportTable.new(table_postfix: "<p>cool</p>\n</div>") do |report_table|
85
+ report_table.write_stats("This is some text", "&amp;", prevent_shrink: true)
86
+ end
87
+
88
+ expect(report_table.full_table).to_not match /class=\"cornucopia-cell-more-data\"/
89
+ end
90
+
91
+ it "escapes the value if it doesn't pretty print" do
92
+ expect(Cornucopia::Util::ReportBuilder).to receive(:escape_string).twice.and_call_original
93
+
94
+ report_table = Cornucopia::Util::ReportTable.new(table_postfix: "<p>cool</p>\n</div>") do |report_table|
95
+ report_table.write_stats("This is some text", "&amp;", do_not_pretty_print: true)
96
+ end
97
+
98
+ expect(report_table.full_table).to match /\<pre\>\<code\>&amp;amp;\<\/code\>\<\/pre\>\n/
99
+ end
100
+
101
+ it "can suppress the code block" do
102
+ expect(Cornucopia::Util::ReportBuilder).to receive(:pretty_format).once.and_call_original
103
+
104
+ report_table = Cornucopia::Util::ReportTable.new(table_postfix: "<p>cool</p>\n</div>") do |report_table|
105
+ report_table.write_stats("This is some text", "&amp;", exclude_code_block: true)
106
+ end
107
+
108
+ expect(report_table.full_table).to_not match /\<pre\>\<code\>&amp;amp;\<\/code\>\<\/pre\>\n/
109
+ end
110
+
111
+ context "not_a_table" do
112
+ it "does not print the label" do
113
+ expect(Cornucopia::Util::ReportBuilder).to receive(:escape_string).exactly(3).and_call_original
114
+
115
+ report_table = Cornucopia::Util::ReportTable.new(not_a_table: true) do |report_table|
116
+ report_table.write_stats("&amp;", "This is some text")
117
+ end
118
+
119
+ expect(report_table.full_table).not_to match /\<div class=\"cornucopia-cell-label\"\>\n&amp;amp;\n\<\/div\>\n/
120
+ expect(report_table.full_table).to match /\<div class=\"cornucopia-table\"\>\nThis is some text\<\/div\>\n/
121
+ end
122
+
123
+ it "outputs the text directly" do
124
+ expect(Cornucopia::Util::ReportBuilder).to receive(:escape_string).exactly(3).and_call_original
125
+
126
+ report_table = Cornucopia::Util::ReportTable.new(not_a_table: true) do |report_table|
127
+ report_table.write_stats("&amp;", "This is some &amp; text")
128
+ end
129
+
130
+ expect(report_table.full_table).to match /\<div class=\"cornucopia-table\"\>\nThis is some &amp;amp; text\<\/div\>\n/
131
+ end
132
+ end
133
+
134
+ it "calls a lambda" do
135
+ custom_text = Faker::Lorem.sentence
136
+
137
+ report_table = Cornucopia::Util::ReportTable.new(table_postfix: "<p>cool</p>\n</div>") do |report_table|
138
+ report_table.write_stats("This is some text", "&amp;", format: ->(value) { custom_text.html_safe + value })
139
+ end
140
+
141
+ expect(report_table.full_table).to match /\<pre\>\<code\>#{"".html_safe + custom_text}&amp;amp;\<\/code\>\<\/pre\>\n/
142
+ end
143
+
144
+ it "a function on an object" do
145
+ class TestClass
146
+ def self.my_function(value)
147
+ "This is some text also.".html_safe + "&amp;"
148
+ end
149
+ end
150
+
151
+ report_table = Cornucopia::Util::ReportTable.new(table_postfix: "<p>cool</p>\n</div>") do |report_table|
152
+ report_table.write_stats("This is some text", "&amp;", format_object: TestClass, format_function: :my_function)
153
+ end
154
+
155
+ expect(report_table.full_table).to match /\<pre\>\<code\>This is some text also.&amp;amp;\<\/code\>\<\/pre\>\n/
156
+ end
157
+ end
158
+
159
+ describe "nested tables" do
160
+ let(:pre_text) { "start_div" }
161
+ let(:post_text) { "end_div" }
162
+
163
+ it "nests tables" do
164
+ nest_label = "".html_safe + Faker::Lorem.sentence
165
+ second_label = "".html_safe + Faker::Lorem.sentence
166
+ second_body = "".html_safe + Faker::Lorem.paragraphs(rand(3..5)).join("\n")
167
+
168
+ report_table = nil
169
+ Cornucopia::Util::ReportTable.new(table_prefix: pre_text,
170
+ table_postfix: post_text) do |first_table|
171
+ report_table = first_table
172
+ Cornucopia::Util::ReportTable.new(table_prefix: pre_text,
173
+ table_postfix: post_text,
174
+ nested_table: first_table,
175
+ nested_table_label: nest_label) do |second_table|
176
+ second_table.write_stats second_label, second_body
177
+ end
178
+ end
179
+
180
+ expect(report_table).to be
181
+ expect(report_table.full_table).to match /#{second_label}/
182
+ expect(report_table.full_table).to match /#{second_body}/
183
+ expect(report_table.full_table).to match /#{nest_label}/
184
+ expect(report_table.full_table.scan(/\<code\>/).length).to be == 1
185
+ expect(report_table.full_table.scan(/start_div/).length).to be == 2
186
+ expect(report_table.full_table.scan(/end_div/).length).to be == 2
187
+ expect(report_table.full_table.scan(/cornucopia-cell-more-data/).length).to be == 2
188
+ expect(report_table.full_table.scan(/cornucopia-row\"\>/).length).to be == 2
189
+ end
190
+
191
+ it "nests tables if they are not empty" do
192
+ nest_label = "".html_safe + Faker::Lorem.sentence
193
+ second_label = "".html_safe + Faker::Lorem.sentence
194
+ second_body = "".html_safe + Faker::Lorem.paragraphs(rand(3..5)).join("\n")
195
+
196
+ report_table = nil
197
+ Cornucopia::Util::ReportTable.new(table_prefix: pre_text,
198
+ table_postfix: post_text) do |first_table|
199
+ report_table = first_table
200
+ Cornucopia::Util::ReportTable.new(table_prefix: pre_text,
201
+ table_postfix: post_text,
202
+ nested_table: first_table,
203
+ nested_table_label: nest_label,
204
+ suppress_blank_table: true) do |second_table|
205
+ second_table.write_stats second_label, second_body
206
+ end
207
+ end
208
+
209
+ expect(report_table).to be
210
+ expect(report_table.full_table).to match /#{second_label}/
211
+ expect(report_table.full_table).to match /#{second_body}/
212
+ expect(report_table.full_table).to match /#{nest_label}/
213
+ expect(report_table.full_table.scan(/\<code\>/).length).to be == 1
214
+ expect(report_table.full_table.scan(/start_div/).length).to be == 2
215
+ expect(report_table.full_table.scan(/end_div/).length).to be == 2
216
+ expect(report_table.full_table.scan(/cornucopia-cell-more-data/).length).to be == 2
217
+ expect(report_table.full_table.scan(/cornucopia-row\"\>/).length).to be == 2
218
+ end
219
+
220
+ it "does not nest tables if they are empty" do
221
+ nest_label = "".html_safe + Faker::Lorem.sentence
222
+ second_label = "".html_safe + Faker::Lorem.sentence
223
+ second_body = "".html_safe + Faker::Lorem.paragraphs(rand(3..5)).join("\n")
224
+
225
+ report_table = nil
226
+ Cornucopia::Util::ReportTable.new(table_prefix: pre_text,
227
+ table_postfix: post_text) do |first_table|
228
+ report_table = first_table
229
+ Cornucopia::Util::ReportTable.new(table_prefix: pre_text,
230
+ table_postfix: post_text,
231
+ nested_table: first_table,
232
+ nested_table_label: nest_label,
233
+ suppress_blank_table: true) do |second_table|
234
+ end
235
+ end
236
+
237
+ expect(report_table).to be
238
+ expect(report_table.full_table).not_to match /#{second_label}/
239
+ expect(report_table.full_table).not_to match /#{second_body}/
240
+ expect(report_table.full_table).not_to match /#{nest_label}/
241
+ expect(report_table.full_table.scan(/\<code\>/).length).to be == 0
242
+ expect(report_table.full_table.scan(/start_div/).length).to be == 1
243
+ expect(report_table.full_table.scan(/end_div/).length).to be == 1
244
+ expect(report_table.full_table.scan(/cornucopia-cell-more-data/).length).to be == 0
245
+ expect(report_table.full_table.scan(/cornucopia-row\"\>/).length).to be == 0
246
+ end
247
+
248
+ it "nests tables even if there is an exception" do
249
+ nest_label = "".html_safe + Faker::Lorem.sentence
250
+ second_label = "".html_safe + Faker::Lorem.sentence
251
+ second_body = "".html_safe + Faker::Lorem.paragraphs(rand(3..5)).join("\n")
252
+
253
+ report_table = nil
254
+ expect do
255
+ Cornucopia::Util::ReportTable.new(table_prefix: pre_text,
256
+ table_postfix: post_text) do |first_table|
257
+ report_table = first_table
258
+ Cornucopia::Util::ReportTable.new(table_prefix: pre_text,
259
+ table_postfix: post_text,
260
+ nested_table: first_table,
261
+ nested_table_label: nest_label) do |second_table|
262
+ second_table.write_stats second_label, second_body
263
+ raise Exception.new("This is an exception")
264
+ end
265
+ end
266
+ end.to raise_error(Exception)
267
+
268
+ expect(report_table).to be
269
+ expect(report_table.full_table).to match /#{second_label}/
270
+ expect(report_table.full_table).to match /#{second_body}/
271
+ expect(report_table.full_table).to match /#{nest_label}/
272
+ expect(report_table.full_table).to match /This is an exception/
273
+ expect(report_table.full_table.scan(/This is an exception/).length).to be == 1
274
+ expect(report_table.full_table.scan(/\<code\>/).length).to be == 2
275
+ expect(report_table.full_table.scan(/start_div/).length).to be == 2
276
+ expect(report_table.full_table.scan(/end_div/).length).to be == 2
277
+ expect(report_table.full_table.scan(/cornucopia-cell-more-data/).length).to be == 4
278
+ expect(report_table.full_table.scan(/cornucopia-row\"\>/).length).to be == 3
279
+ end
280
+
281
+ it "nests tables even if there is an exception multiple levels deep" do
282
+ nest_label = "".html_safe + Faker::Lorem.sentence
283
+ second_label = "".html_safe + Faker::Lorem.sentence
284
+ second_body = "".html_safe + Faker::Lorem.paragraphs(rand(3..5)).join("\n")
285
+
286
+ report_table = nil
287
+ expect do
288
+ Cornucopia::Util::ReportTable.new(table_prefix: pre_text,
289
+ table_postfix: post_text) do |first_table|
290
+ report_table = first_table
291
+ Cornucopia::Util::ReportTable.new(table_prefix: pre_text,
292
+ table_postfix: post_text,
293
+ nested_table: first_table,
294
+ nested_table_label: nest_label) do |second_table|
295
+ Cornucopia::Util::ReportTable.new(table_prefix: pre_text,
296
+ table_postfix: post_text,
297
+ nested_table: second_table,
298
+ nested_table_label: nest_label) do |third_table|
299
+ third_table.write_stats second_label, second_body
300
+ raise Exception.new("This is an exception")
301
+ end
302
+ end
303
+ end
304
+ end.to raise_error(Exception)
305
+
306
+ expect(report_table).to be
307
+ expect(report_table.full_table).to match /#{second_label}/
308
+ expect(report_table.full_table).to match /#{second_body}/
309
+ expect(report_table.full_table).to match /#{nest_label}/
310
+ expect(report_table.full_table).to match /This is an exception/
311
+ expect(report_table.full_table.scan(/This is an exception/).length).to be == 1
312
+ expect(report_table.full_table.scan(/\<code\>/).length).to be == 2
313
+ expect(report_table.full_table.scan(/start_div/).length).to be == 3
314
+ expect(report_table.full_table.scan(/end_div/).length).to be == 3
315
+ expect(report_table.full_table.scan(/cornucopia-cell-more-data/).length).to be == 4
316
+ expect(report_table.full_table.scan(/cornucopia-row\"\>/).length).to be == 4
317
+ end
318
+ end
319
+ end
@@ -0,0 +1,10 @@
1
+ require ::File.expand_path("../../lib/cornucopia/site_prism/page_application", File.dirname(__FILE__))
2
+ require ::File.expand_path("../../lib/cornucopia/site_prism/element_extensions", File.dirname(__FILE__))
3
+
4
+ Dir[File.expand_path("**/*.rb", File.dirname(__FILE__))].each { |require_file| require require_file }
5
+
6
+ class CornucopiaReportApp < Cornucopia::SitePrism::PageApplication
7
+ def pages_module
8
+ ::CornucopiaReportPages
9
+ end
10
+ end
@@ -0,0 +1,22 @@
1
+ module GooglePages
2
+ class EmailSection < SitePrism::Section
3
+ # include GalaxyPages::SimpleElements
4
+
5
+ # indexed_elements "td:nth-child(%{element_index})",
6
+ # :left_padding,
7
+ # :select,
8
+ # :star,
9
+ # :from,
10
+ # :padding_2,
11
+ # :subject,
12
+ # :padding_3,
13
+ # :time
14
+ end
15
+
16
+ class EmailPage < SitePrism::Page
17
+ set_url "https://mail.google.com/mail/#inbox"
18
+
19
+ # sections :emails, EmailSection, "#:3a tr"
20
+ sections :emails, EmailSection, ".F.cf.zt tr"
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ require "rspec/expectations"
2
+
3
+ module GooglePages
4
+ class LoginPage < SitePrism::Page
5
+ set_url "https://accounts.google.com/ServiceLogin?service=mail&continue=https://mail.google.com/mail/"
6
+
7
+ # deem.automation.qa
8
+ # lp3$8)23%*@~[}x
9
+ element :email, "#Email"
10
+ element :password, "#Passwd"
11
+ element :sign_in_button, "#signIn"
12
+ element :re_auth, "#reauthEmail"
13
+
14
+ def sign_in
15
+ load
16
+ if has_email?
17
+ email.set("deem.automation.qa")
18
+ elsif has_re_auth?
19
+ raise "bad re-auth" unless re_auth.text == "deem.automation.qa@gmail.com"
20
+ end
21
+ password.set("lp3$8)23%*@~[}x")
22
+ sign_in_button.click
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,43 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+ require 'spec_helper'
4
+ require File.expand_path("../../config/environment", __FILE__)
5
+ require 'rspec/rails'
6
+
7
+ # Requires supporting ruby files with custom matchers and macros, etc, in
8
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
9
+ # run as spec files by default. This means that files in spec/support that end
10
+ # in _spec.rb will both be required and run as specs, causing the specs to be
11
+ # run twice. It is recommended that you do not name files matching this glob to
12
+ # end with _spec.rb. You can configure this pattern with with the --pattern
13
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
14
+ Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
15
+
16
+ # Checks for pending migrations before tests are run.
17
+ # If you are not using ActiveRecord, you can remove this line.
18
+ ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
19
+
20
+ RSpec.configure do |config|
21
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
22
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
23
+
24
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
25
+ # examples within a transaction, remove the following line or assign false
26
+ # instead of true.
27
+ config.use_transactional_fixtures = true
28
+
29
+ # RSpec Rails can automatically mix in different behaviours to your tests
30
+ # based on their file location, for example enabling you to call `get` and
31
+ # `post` in specs under `spec/controllers`.
32
+ #
33
+ # You can disable this behaviour by removing the line below, and instead
34
+ # explicitly tag your specs with their type, e.g.:
35
+ #
36
+ # RSpec.describe UsersController, :type => :controller do
37
+ # # ...
38
+ # end
39
+ #
40
+ # The different available types are documented in the features, such as in
41
+ # https://relishapp.com/rspec/rspec-rails/docs
42
+ config.infer_spec_type_from_file_location!
43
+ end