effective_test_bot 0.6.8 → 0.6.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -29
- data/lib/effective_test_bot/version.rb +1 -1
- data/lib/generators/effective_test_bot/install_generator.rb +2 -2
- data/test/support/effective_test_bot_form_filler.rb +17 -9
- data/test/support/effective_test_bot_screenshots_helper.rb +1 -0
- data/test/test_botable/redirect_test.rb +0 -2
- 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: 241328a26eabe88003d9952df8c3f52d2c8da2b9
|
4
|
+
data.tar.gz: d9aaf690438a97cf0469381f8c17766270e7df80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04eef468622acf70afdc3c6bb2245bf2d4a442db8990a4455b09bff42e7c363a297e7962aaea61de578b634cff444c340a5e05d289a3f5af032144211fe1028a
|
7
|
+
data.tar.gz: c8dbdd69aa54b95509900019e7d01d28fd830a74202363a17d00a09237f3c2d29f027a357b31200c8b5aebc17bc632ecb878d2d43bc5047a445baa9d7c24e7fc
|
data/README.md
CHANGED
@@ -8,13 +8,13 @@ Adds many additional assertions and quality of life helper functions.
|
|
8
8
|
|
9
9
|
Provides a curated set of minitest and capybara focused rails testing gems and a well configured `test_helper.rb` file.
|
10
10
|
|
11
|
-
Run `
|
11
|
+
Run `rails test:bot:environment` to validate your testing environment. Ensures that all fixtures and seeds are properly initialized. Makes sure database transactions and web sessions correctly reset between tests.
|
12
12
|
|
13
13
|
Adds many class and instance level 1-liners to run entire test suites and check many assertions all at once.
|
14
14
|
|
15
15
|
Autosaves an animated .gif for any failing test.
|
16
16
|
|
17
|
-
Run `
|
17
|
+
Run `rails test:bot` to automatically check every route in your application against an appropriate test suite, without writing any code. Clicks through every page, intelligently fills forms with appropriate pseudo-random input and checks for all kinds of errors and omissions.
|
18
18
|
|
19
19
|
Turn on tour mode to programatically generate an animated .gif of every workflow in your website.
|
20
20
|
|
@@ -60,7 +60,7 @@ The generator will run `minitest:install` if not already present and create an i
|
|
60
60
|
|
61
61
|
Fixture or seed one user. At least one user -- ideally a fully priviledged admin type user -- must be created.
|
62
62
|
|
63
|
-
(there are future plans to make this better. Right now `
|
63
|
+
(there are future plans to make this better. Right now `rails test:bot` just runs everything as one user. There really isn't support for 'this user should not be able to' yet.)
|
64
64
|
|
65
65
|
To create the initial user, please add it to either `test/fixtures/users.yml`, the `db/seeds.db` file or the effective_test_bot specific `test/fixtures/seeds.rb` file.
|
66
66
|
|
@@ -68,13 +68,13 @@ As per the included `test/test_helper.rb`, the following tasks run when minitest
|
|
68
68
|
|
69
69
|
```
|
70
70
|
# Rails default task, load fixtures from test/fixtures/*.yml (including users.yml if it exists)
|
71
|
-
|
71
|
+
rails db:fixtures:load
|
72
72
|
|
73
73
|
# Rails default task, loads db/seeds.rb
|
74
|
-
|
74
|
+
rails db:seed
|
75
75
|
|
76
76
|
# Added by effective_test_bot. loads test/fixtures/seeds.rb. 'cause screw yaml.
|
77
|
-
|
77
|
+
rails test:load_fixture_seeds
|
78
78
|
```
|
79
79
|
|
80
80
|
Your initial user may be created by any of the above 3 tasks.
|
@@ -82,7 +82,7 @@ Your initial user may be created by any of the above 3 tasks.
|
|
82
82
|
Finally, to test that your testing environment is set up correctly run and work through any issues with:
|
83
83
|
|
84
84
|
```
|
85
|
-
|
85
|
+
rails test:bot:environment
|
86
86
|
```
|
87
87
|
|
88
88
|
You now have effective_test_bot configured and you're ready to go.
|
@@ -97,7 +97,7 @@ Effective TestBot provides 4 areas of support in writing [minitest](https://gith
|
|
97
97
|
|
98
98
|
3.) Produce animated .gifs of test runs. Enable autosave_animated_gif_on_failure to help debug a tricky test, or run in tour mode and record walkthroughs of features.
|
99
99
|
|
100
|
-
4.) Apply full stack automated testing. Just run `
|
100
|
+
4.) Apply full stack automated testing. Just run `rails test:bot` to scan every route in your application and without writing any code check every controller action with an appropriate test suite.
|
101
101
|
|
102
102
|
## Minitest Assertions
|
103
103
|
|
@@ -486,7 +486,7 @@ User sessions need to properly reset and database transactions must be correctly
|
|
486
486
|
|
487
487
|
Included with this gem is the `rails generate effective_test_bot:install` that does its best to provide a known-good set of configuration files that initialize all required testing gems. However, every developer's machine is different, and there are just too many points of failure. Everyone's `test/test_helper.rb` will be slightly different.
|
488
488
|
|
489
|
-
Run `
|
489
|
+
Run `rails test:bot:environment` to check that capybara is doing the right thing, everything is reset properly between test runs, an initial user record exists, all seeded and fixtured data is valid, devise works and rails' jquery-ujs is present.
|
490
490
|
|
491
491
|
If all environment tests pass, you will have a great experience with automated testing.
|
492
492
|
|
@@ -494,7 +494,7 @@ If all environment tests pass, you will have a great experience with automated t
|
|
494
494
|
|
495
495
|
One of the main goals of `effective_test_bot` is to increase the speed at which tests can be written in any ruby on rails application. Well, there's no faster way of writing tests than by not writing them at all.
|
496
496
|
|
497
|
-
Run `
|
497
|
+
Run `rails test:bot` to scan every route defined in `routes.rb` and run an appropriate test suite.
|
498
498
|
|
499
499
|
You can configure test bot to skip individual tests or assertions, tweak screenshot behaviour and toggle tour mode via the `config/initializers/effective_test_bot.rb` file. As well, there are a few command line options available.
|
500
500
|
|
@@ -502,13 +502,13 @@ These are some quick ways to customize test bot's behaviour:
|
|
502
502
|
|
503
503
|
```
|
504
504
|
# Scan every route in the application as per config/initializers/effective_test_bot.rb
|
505
|
-
|
505
|
+
rails test:bot
|
506
506
|
|
507
507
|
# Test a specific controller (any routes matching posts)
|
508
|
-
|
508
|
+
rails test:bot TEST=posts
|
509
509
|
|
510
510
|
# Test a specific controller and action
|
511
|
-
|
511
|
+
rails test:bot TEST=posts#index
|
512
512
|
```
|
513
513
|
|
514
514
|
## Animated gifs and screenshots
|
@@ -535,44 +535,44 @@ You can run test bot in tour mode by setting `config.tour_mode = true` in the `c
|
|
535
535
|
|
536
536
|
```
|
537
537
|
# Run test:bot in tour mode, saving an animated .gif for all successful tests
|
538
|
-
|
539
|
-
|
538
|
+
rails test:bot:tour
|
539
|
+
rails test:bot TOUR=true
|
540
540
|
|
541
541
|
# Also prints the animated .gif file path to stdout
|
542
|
-
|
543
|
-
|
542
|
+
rails test:bot:tourv
|
543
|
+
rails test:bot TOUR=verbose
|
544
544
|
|
545
545
|
# Makes a whole bunch of extra screenshots when filling out forms
|
546
|
-
|
546
|
+
rails test:bot TOUR=extreme
|
547
547
|
|
548
548
|
# Runs in tour mode and tests only a specific controller or action
|
549
|
-
|
550
|
-
|
549
|
+
rails test:bot:tour TEST=posts
|
550
|
+
rails test:bot:tour TEST=posts#index
|
551
551
|
```
|
552
552
|
|
553
553
|
To print out the file location of all tour files, run the following:
|
554
554
|
|
555
555
|
```
|
556
556
|
# Prints out all animated .gif file locations
|
557
|
-
|
557
|
+
rails test:bot:tours
|
558
558
|
|
559
559
|
# Prints out any animated .gif files locations with a file name matching posts
|
560
|
-
|
560
|
+
rails test:bot:tours TEST=posts
|
561
561
|
```
|
562
562
|
|
563
563
|
To delete all tour and autosave on failure animated .gifs, run the following:
|
564
564
|
|
565
565
|
```
|
566
566
|
# Deletes all tour and failure animated .gifs
|
567
|
-
|
567
|
+
rails test:bot:purge
|
568
568
|
```
|
569
569
|
|
570
|
-
As well, to enable tour mode when running the standard `
|
570
|
+
As well, to enable tour mode when running the standard `rails test`:
|
571
571
|
|
572
572
|
```
|
573
573
|
# Runs all regular minitest tests with tour mode enabled
|
574
|
-
|
575
|
-
|
574
|
+
rails test:tour
|
575
|
+
rails test:tourv
|
576
576
|
```
|
577
577
|
|
578
578
|
### Fail fast
|
@@ -582,7 +582,7 @@ Set `config.fail_fast = true` to exit immediately if there is a test failure.
|
|
582
582
|
Or, override the config setting by running the following:
|
583
583
|
|
584
584
|
```
|
585
|
-
|
585
|
+
rails test:bot FAILFAST=true
|
586
586
|
```
|
587
587
|
|
588
588
|
This functionality is provided thanks to [minitest-fail-fast](https://github.com/teoljungberg/minitest-fail-fast/)
|
@@ -592,13 +592,13 @@ This functionality is provided thanks to [minitest-fail-fast](https://github.com
|
|
592
592
|
Skip any previously passed tests by running the following:
|
593
593
|
|
594
594
|
```
|
595
|
-
|
595
|
+
rails test:bot:fails
|
596
596
|
```
|
597
597
|
|
598
598
|
or
|
599
599
|
|
600
600
|
```
|
601
|
-
|
601
|
+
rails test:bot FAILS=true
|
602
602
|
```
|
603
603
|
|
604
604
|
## License
|
@@ -24,8 +24,8 @@ module EffectiveTestBot
|
|
24
24
|
def thank_you
|
25
25
|
puts "Thanks for using EffectiveTestBot"
|
26
26
|
puts "Make sure you create a user in your db/seeds.rb, test/fixtures/users.yml, or test/fixtures/seeds.rb"
|
27
|
-
puts "Run `
|
28
|
-
puts "Test your app with '
|
27
|
+
puts "Run `rails test:bot:environment` once to ensure the testing environment is correctly configured"
|
28
|
+
puts "Test your app with 'rails test:bot'"
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -69,32 +69,32 @@ module EffectiveTestBotFormFiller
|
|
69
69
|
next if skip_form_field?(field)
|
70
70
|
skip_field_screenshot = false
|
71
71
|
|
72
|
+
value = value_for_field(field, fills)
|
73
|
+
|
72
74
|
case [field.tag_name, field['type']].compact.join('_')
|
73
75
|
when 'input_text', 'input_email', 'input_password', 'input_tel', 'input_number', 'input_checkbox', 'input_radio', 'input_url', 'input_color'
|
74
|
-
field.set(
|
75
|
-
|
76
|
+
field.set(value)
|
76
77
|
close_effective_date_time_picker(field) if field['class'].to_s.include?('effective_date')
|
77
78
|
when 'textarea'
|
78
|
-
value = value_for_field(field, fills)
|
79
79
|
ckeditor_text_area?(field) ? fill_ckeditor_text_area(field, value) : field.set(value)
|
80
80
|
when 'select'
|
81
|
-
value = value_for_field(field, fills)
|
82
|
-
|
83
81
|
if EffectiveTestBot.tour_mode_extreme? && field['class'].to_s.include?('select2') # select2
|
84
82
|
page.execute_script("try { $('select##{field['id']}').select2('open'); } catch(e) {};")
|
85
83
|
save_test_bot_screenshot
|
86
84
|
end
|
87
85
|
|
88
|
-
field.
|
86
|
+
if field.all('option:enabled').length > 0 && value != :unselect
|
87
|
+
field.select(value, match: :first, disabled: false)
|
88
|
+
end
|
89
89
|
|
90
90
|
if EffectiveTestBot.tour_mode_extreme? && field['class'].to_s.include?('select2')
|
91
91
|
page.execute_script("try { $('select##{field['id']}').select2('close'); } catch(e) {};")
|
92
92
|
end
|
93
93
|
when 'input_file'
|
94
94
|
if field['class'].to_s.include?('asset-box-uploader-fileinput')
|
95
|
-
upload_effective_asset(field,
|
95
|
+
upload_effective_asset(field, value)
|
96
96
|
else
|
97
|
-
field.set(
|
97
|
+
field.set(value)
|
98
98
|
end
|
99
99
|
when 'input_submit', 'input_search', 'input_button'
|
100
100
|
skip_field_screenshot = true
|
@@ -250,6 +250,9 @@ module EffectiveTestBotFormFiller
|
|
250
250
|
when 'textarea'
|
251
251
|
Faker::Lorem.paragraph
|
252
252
|
|
253
|
+
when 'input_submit', 'input_search', 'input_button'
|
254
|
+
nil
|
255
|
+
|
253
256
|
else
|
254
257
|
raise "fill_value unsupported field type: #{field['type']}"
|
255
258
|
end
|
@@ -425,8 +428,13 @@ module EffectiveTestBotFormFiller
|
|
425
428
|
def skip_form_field?(field)
|
426
429
|
field.reload # Handle a field changing visibility/disabled state from previous form field manipulations
|
427
430
|
|
428
|
-
|
431
|
+
field_id = field['id'].to_s
|
432
|
+
|
433
|
+
field_id.start_with?('datatable_') ||
|
434
|
+
field_id.start_with?('filters_scope_') ||
|
435
|
+
field_id.start_with?('filters_') && field['name'].blank? ||
|
429
436
|
field.disabled? ||
|
437
|
+
(!field.visible? && !ckeditor_text_area?(field)) ||
|
430
438
|
['true', true, 1].include?(field['data-test-bot-skip']) ||
|
431
439
|
(@test_bot_excluded_fields_xpath.present? && field.path.include?(@test_bot_excluded_fields_xpath))
|
432
440
|
end
|
@@ -12,6 +12,7 @@ module EffectiveTestBotScreenshotsHelper
|
|
12
12
|
|
13
13
|
def save_test_bot_screenshot
|
14
14
|
return unless EffectiveTestBot.screenshots?
|
15
|
+
return unless page.current_path.present?
|
15
16
|
page.save_screenshot("#{current_test_temp_path}/#{current_test_screenshot_id}.png")
|
16
17
|
end
|
17
18
|
|
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
|
+
version: 0.6.9
|
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-10-
|
11
|
+
date: 2017-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|