effective_test_bot 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 533f4dfe9d458e6c298b9da728e511cc2346e466
4
- data.tar.gz: 92e5aad66b7f4d7ef653324412c45b5cc6b445e9
3
+ metadata.gz: 53b1f6eb61535946c045b482f76d1ae3d63fec3e
4
+ data.tar.gz: 7555d00cfa5a082f9bd31d8a6df9ee8bb6fd1b39
5
5
  SHA512:
6
- metadata.gz: afec0dac31e2002a83206d087e4b3706b6966addfc8e63b5ec58461da5d020bd9f9d28ec4181c68e356758c6134fe4bb319a7b316548437989ca8f5cb4b71f6c
7
- data.tar.gz: 328fcf108174c8348c251da7a5eaab777453b35bee4604ec36e997271e138e5bae4323f0fb1524147eec83847f505170be8c19254e818cbf0ea67e8a31f01d10
6
+ metadata.gz: f9c7aa1fb3975a50c60575e507a3fb3d3c6050927d8a96e8290af145597af4804ba5ec12e5c02b5fc25a68f89b420055685852f2b53f746e7bd84fead8df6163
7
+ data.tar.gz: af84cd4901cdcfb05cc382019bd02270922d7003d2ee21a8de4bd3368db6580cecf1ce73610bf6bb575e4807e08ed481185007831fd0a8a66626d5fe683b3e74
data/README.md CHANGED
@@ -105,7 +105,7 @@ The following assertions are added for use in any integration test:
105
105
 
106
106
  - `assert_assigns` asserts a given rails view_assigns object is present.
107
107
  - `assert_assigns_errors` use after an intentionally invalid form submit to make sure your assigned rails object has errors, or a specific error.
108
- - `assert_authorization` checks for a 403 Access Denied error. Add `assign_test_bot_access_denied_exception(exception)` to your ApplicationController's `rescue_from` block to generate more information.
108
+ - `assert_authorization` checks for a 403 Access Denied error. For this to work, please add `assign_test_bot_access_denied_exception(exception) if defined?(EffectiveTestBot)` to your ApplicationController's `rescue_from` block to generate more information.
109
109
  - `assert_no_assigns_errors` should be used after any form submit to make sure your assigned rails object has no errors. Prints out any errors if they exist.
110
110
  - `assert_current_path(path)` asserts the current page path.
111
111
  - `assert_email(action)` asserts an email with the given action name was sent. Also supports `assert_email(to: email)` type syntax with to, from, subject, body.
@@ -212,7 +212,6 @@ effective_test_bot fills in this knowledge gap by serializing any interesting va
212
212
  The following representations of the rails internal state are made available:
213
213
 
214
214
  - `assigns` a Hash representation of the current page's rails `view_assigns`. Serializes any `ActiveRecord` objects, as well as any `TrueClass`, `FalseClass`, `NilClass`, `String`, `Symbol`, and `Numeric` objects. Does not serialize anything else, but sets a symbol `assigns[key] == :present_but_not_serialized`.
215
- - `exceptions` an Array with the exception message and a stacktrace.
216
215
  - `flash` a Hash representation of the current page's flash.
217
216
  - `unpermitted_params` an Array of any unpermitted parameters that were encountered by the last request.
218
217
 
@@ -13,6 +13,9 @@ module EffectiveTestBotControllerHelper
13
13
  when ActiveRecord::Base
14
14
  test_bot_assigns[key] = object.attributes
15
15
  test_bot_assigns[key][:errors] = object.errors.messages.delete_if { |_, v| v.blank? } if object.errors.present?
16
+ when (ActiveModel::Model rescue nil)
17
+ test_bot_assigns[key] = object.respond_to?(:attributes) ? object.attributes : {present_but_not_serialized: true}
18
+ test_bot_assigns[key][:errors] = object.errors.messages.delete_if { |_, v| v.blank? } if object.errors.present?
16
19
  when TrueClass, FalseClass, NilClass, String, Symbol, Numeric
17
20
  test_bot_assigns[key] = object
18
21
  else
@@ -1,3 +1,3 @@
1
1
  module EffectiveTestBot
2
- VERSION = '0.6.4'.freeze
2
+ VERSION = '0.6.5'.freeze
3
3
  end
@@ -115,6 +115,7 @@ namespace :test do
115
115
 
116
116
  desc 'loads test/fixtures/seeds.rb'
117
117
  task :load_fixture_seeds => :environment do
118
+ puts 'loading fixture seed'
118
119
  seeds = "#{Rails.root}/test/fixtures/seeds.rb"
119
120
  load(seeds) if File.exist?(seeds)
120
121
  end
@@ -18,6 +18,8 @@ module TestBotable
18
18
 
19
19
  # All this does is define a 'test_bot' method for each required action on this class
20
20
  # So that MiniTest will see the test functions and run them
21
+ # Expected usage: crud_test(resource: Post)
22
+ # Expected usage: crud_test(resource: (Post || Post.new), user: User.first, only: [:new, :create], skip: {create_invalid: [:path]})"
21
23
  def crud_test(resource:, user: nil, label: nil, skip: {}, only: nil, except: nil, **options)
22
24
  # This skips paramaters is different than the initializer skips, which affect just the rake task
23
25
 
@@ -30,7 +32,7 @@ module TestBotable
30
32
  begin
31
33
  normalize_test_bot_options!(options.merge!(resource: resource, current_crud_tests: current_crud_tests))
32
34
  rescue => e
33
- raise "Error: #{e.message}. Expected usage: crud_test(resource: (Post || Post.new), user: User.first, only: [:new, :create], skip: {create_invalid: [:path]})"
35
+ raise "\e[33mError\e[0m: #{e.message}"
34
36
  end
35
37
 
36
38
  current_crud_tests.each do |test|
@@ -62,7 +62,7 @@ module EffectiveTestBotAssertions
62
62
  "Encountered a 403 Access Denied",
63
63
  ("(cannot :#{exception['action']}, #{exception['subject']})" if exception.present?),
64
64
  "on #{page.current_path} as user #{user || 'no user'}.",
65
- ("\nAdd assign_test_bot_access_denied_exception(exception) to your ApplicationController's rescue_from block to gather more information." unless exception.present?),
65
+ ("\nAdd assign_test_bot_access_denied_exception(exception) if defined?(EffectiveTestBot) to your ApplicationController's rescue_from block to gather more information." unless exception.present?),
66
66
  ].compact.join(' ')
67
67
 
68
68
  assert false, "#{message}.\n#{info}"
@@ -17,14 +17,14 @@ module EffectiveTestBotFormHelper
17
17
  end
18
18
 
19
19
  # This submits the form, while checking for html5 form validation errors and unpermitted params
20
- def submit_form(label = nil)
20
+ def submit_form(label = nil, last: false)
21
21
  assert_no_html5_form_validation_errors unless test_bot_skip?(:no_html5_form_validation_errors)
22
22
  assert_jquery_ujs_disable_with(label) unless test_bot_skip?(:jquery_ujs_disable_with)
23
23
 
24
24
  if test_bot_skip?(:no_unpermitted_params)
25
- click_submit(label)
25
+ click_submit(label, last: last)
26
26
  else
27
- with_raised_unpermitted_params_exceptions { click_submit(label) }
27
+ with_raised_unpermitted_params_exceptions { click_submit(label, last: last) }
28
28
  end
29
29
 
30
30
  assert_no_unpermitted_params unless test_bot_skip?(:no_unpermitted_params)
@@ -63,12 +63,12 @@ module EffectiveTestBotFormHelper
63
63
  # This kind of sucks, as we want to simulate mouse movements with the tour
64
64
  # Instead we manually trigger submit buttons and use the data-disable-with to
65
65
  # make the 'submit form' step look nice
66
- def click_submit(label)
66
+ def click_submit(label, last: false)
67
67
  if label.present?
68
68
  submit = find(:link_or_button, label)
69
69
  assert submit.present?, "TestBotError: Unable to find a visible submit link or button on #{page.current_path} with the label #{label}"
70
70
  else
71
- submit = first(:css, "input[type='submit'],button[type='submit']")
71
+ submit = all("input[type='submit'],button[type='submit']").send(last ? :last : :first)
72
72
  assert submit.present?, "TestBotError: Unable to find a visible input[type='submit'] or button[type='submit'] on #{page.current_path}"
73
73
  end
74
74
 
@@ -13,16 +13,21 @@ module WizardTest
13
13
  visit(from)
14
14
  end
15
15
 
16
+ paths = []
16
17
  0.upto(50) do |index| # Can only test wizards 51 steps long
17
18
  assert_page_normal
18
19
 
19
20
  yield if block_given?
20
21
 
22
+ # If we are on the same page as last time, use submit_form(last: true)
23
+ # to click the last submit button on the page
24
+ last = (paths[index-1] == page.current_path)
25
+
21
26
  if defined?(within_form)
22
- within(within_form) { fill_form; submit_form; }
27
+ within(within_form) { fill_form; submit_form(last: last); }
23
28
  else
24
29
  fill_form
25
- submit_form
30
+ submit_form(last: last)
26
31
  end
27
32
 
28
33
  assert_no_flash_errors unless test_bot_skip?(:no_flash_errors)
@@ -30,10 +35,12 @@ module WizardTest
30
35
  if to.present?
31
36
  # Keep going till we hit a certain to_path
32
37
  break if page.current_path == to
33
- else
34
- # Keep going till there's no more submit buttons
35
- break if all("input[type='submit']").blank?
36
38
  end
39
+
40
+ # Keep going till there's no more submit buttons
41
+ break if all("input[type='submit']").blank?
42
+
43
+ paths << page.current_path.to_s
37
44
  end
38
45
 
39
46
  save_test_bot_screenshot
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_test_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-06 00:00:00.000000000 Z
11
+ date: 2017-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails