effective_test_bot 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +14 -14
- data/{lib/generators/templates → config}/test_helper.rb +10 -10
- data/lib/effective_test_bot.rb +4 -3
- data/lib/effective_test_bot/dsl.rb +33 -0
- data/lib/effective_test_bot/engine.rb +0 -33
- data/lib/effective_test_bot/version.rb +1 -1
- data/lib/generators/effective_test_bot/install_generator.rb +1 -1
- data/lib/tasks/effective_test_bot_tasks.rake +19 -10
- data/test/test_bot/integration/application_test.rb +1 -1
- data/test/test_bot/integration/environment_test.rb +2 -2
- metadata +4 -32
- data/Rakefile +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07bf0cd7c284cd899943335e6eabe61280ff4fb1
|
4
|
+
data.tar.gz: 5846e0ae040d8c3d44607e1550cdcc261a472e71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24fa43aec87401f7892873e4fe5deb19bc27cc82607d35b21ef11a8f5e613f324d0c094eaae8f069f5c018c9d13195a737d21d0bb3792fab2d35c7a448421020
|
7
|
+
data.tar.gz: 6d19efb1e8c8ccee2286911f9624be53bb2bdec3adf3d79e0a2aa49237936d56ddb7a9464d731058db65361d955736f0ddfb520431ca4b9bbae9fa7cd4ddbc1c
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -146,7 +146,7 @@ It clicks through bootstrap tabs and fill them nicely left-to-right, one tab at
|
|
146
146
|
You can pass a Hash of 'fills' to specify specific input values:
|
147
147
|
|
148
148
|
```ruby
|
149
|
-
class PostTest <
|
149
|
+
class PostTest < Capybara::Rails::TestCase
|
150
150
|
test 'creating a new post' do
|
151
151
|
visit new_post_path
|
152
152
|
fill_form(:title => 'A Cool Post', 'author.last_name' => 'Smith')
|
@@ -178,7 +178,7 @@ Clicks the first `input[type='submit']` field (or first submit field with the gi
|
|
178
178
|
Automatically checks for `assert_no_html5_form_validation_errors`, `assert_jquery_ujs_disable_with` and `assert_no_unpermitted_params`
|
179
179
|
|
180
180
|
```ruby
|
181
|
-
class PostTest <
|
181
|
+
class PostTest < Capybara::Rails::TestCase
|
182
182
|
test 'creating a new post' do
|
183
183
|
visit(new_post_path) and fill_form
|
184
184
|
submit_form # or submit_form('Save and Continue')
|
@@ -251,7 +251,7 @@ A quick note on speed: You can speed up these test suites by fixturing, seeding
|
|
251
251
|
There are a few variations on the one-liner method:
|
252
252
|
|
253
253
|
```ruby
|
254
|
-
class PostsTest <
|
254
|
+
class PostsTest < Capybara::Rails::TestCase
|
255
255
|
# Runs all 9 crud_action tests against /posts
|
256
256
|
crud_test(resource: Post, user: User.first)
|
257
257
|
|
@@ -275,7 +275,7 @@ end
|
|
275
275
|
The individual test suites may also be used as part of a larger test:
|
276
276
|
|
277
277
|
```ruby
|
278
|
-
class PostsTest <
|
278
|
+
class PostsTest < Capybara::Rails::TestCase
|
279
279
|
test 'user may only update a post once' do
|
280
280
|
crud_action_test(test: :create_valid, resource: Post, user: User.first)
|
281
281
|
assert_text 'successfully created post. You may only update it once.'
|
@@ -303,7 +303,7 @@ This test runs through the the [devise](https://github.com/plataformatec/devise)
|
|
303
303
|
Use as a one-liner:
|
304
304
|
|
305
305
|
```ruby
|
306
|
-
class MyApplicationTest <
|
306
|
+
class MyApplicationTest < Capybara::Rails::TestCase
|
307
307
|
devise_test # Runs all tests (sign_up, sign_in_valid, and sign_in_invalid)
|
308
308
|
end
|
309
309
|
```
|
@@ -311,7 +311,7 @@ end
|
|
311
311
|
Or each individually in part of a regular test:
|
312
312
|
|
313
313
|
```ruby
|
314
|
-
class MyApplicationTest <
|
314
|
+
class MyApplicationTest < Capybara::Rails::TestCase
|
315
315
|
test 'user receives 10 tokens after signing up' do
|
316
316
|
devise_action_test(test: :sign_up)
|
317
317
|
assert_text 'Tokens: 10'
|
@@ -336,7 +336,7 @@ This test signs in as the given user, visits the given controller/action/page an
|
|
336
336
|
Use it as a one-liner:
|
337
337
|
|
338
338
|
```ruby
|
339
|
-
class PostsTest <
|
339
|
+
class PostsTest < Capybara::Rails::TestCase
|
340
340
|
# Uses find_or_create_resource! to load a seeded resource or create a new one
|
341
341
|
member_test(controller: 'posts', action: 'unarchive', user: User.first)
|
342
342
|
|
@@ -348,7 +348,7 @@ end
|
|
348
348
|
Or as part of a regular test:
|
349
349
|
|
350
350
|
```ruby
|
351
|
-
class PostsTest <
|
351
|
+
class PostsTest < Capybara::Rails::TestCase
|
352
352
|
test 'posts can be unarchived' do
|
353
353
|
post = Post.create(title: 'first post', archived: true)
|
354
354
|
|
@@ -366,7 +366,7 @@ This test signs in as the given user, visits the given page and simply checks `a
|
|
366
366
|
Use it as a one-liner:
|
367
367
|
|
368
368
|
```ruby
|
369
|
-
class PostsTest <
|
369
|
+
class PostsTest < Capybara::Rails::TestCase
|
370
370
|
page_test(path: :posts_path, user: User.first) # Runs the page_test test suite against posts_path as User.first
|
371
371
|
end
|
372
372
|
```
|
@@ -374,7 +374,7 @@ end
|
|
374
374
|
Or as part of a regular test:
|
375
375
|
|
376
376
|
```ruby
|
377
|
-
class PostsTest <
|
377
|
+
class PostsTest < Capybara::Rails::TestCase
|
378
378
|
test 'posts are displayed on the index page' do
|
379
379
|
Post.create(title: 'first post')
|
380
380
|
|
@@ -393,7 +393,7 @@ This test signs in as the given user, visits the given page then checks `assert_
|
|
393
393
|
Use it as a one-liner:
|
394
394
|
|
395
395
|
```ruby
|
396
|
-
class PostsTest <
|
396
|
+
class PostsTest < Capybara::Rails::TestCase
|
397
397
|
# Visits /blog and tests that it redirects to a working /posts page
|
398
398
|
redirect_test(from: '/blog', to: '/posts', user: User.first)
|
399
399
|
end
|
@@ -402,7 +402,7 @@ end
|
|
402
402
|
Or as part of a regular test:
|
403
403
|
|
404
404
|
```ruby
|
405
|
-
class PostsTest <
|
405
|
+
class PostsTest < Capybara::Rails::TestCase
|
406
406
|
test 'visiting blog redirects to posts' do
|
407
407
|
Post.create(title: 'first post')
|
408
408
|
redirect_action_test(from: '/blog', to: '/posts', user: User.first)
|
@@ -422,7 +422,7 @@ As well, in the `wizard_action_test`, each page is yielded to the calling method
|
|
422
422
|
Use it as a one-liner:
|
423
423
|
|
424
424
|
```ruby
|
425
|
-
class PostsTest <
|
425
|
+
class PostsTest < Capybara::Rails::TestCase
|
426
426
|
wizard_test(from: '/build_post/step1', to: '/build_post/step5', user: User.first)
|
427
427
|
end
|
428
428
|
```
|
@@ -430,7 +430,7 @@ end
|
|
430
430
|
Or as part of a regular test:
|
431
431
|
|
432
432
|
```ruby
|
433
|
-
class PostsTest <
|
433
|
+
class PostsTest < Capybara::Rails::TestCase
|
434
434
|
test 'building a post in 5 steps' do
|
435
435
|
wizard_action_test(from: '/build_post/step1', to: '/build_post/step5', user: User.first) do
|
436
436
|
if page.current_path.end_with?('step4')
|
@@ -1,14 +1,12 @@
|
|
1
1
|
ENV['RAILS_ENV'] = 'test'
|
2
2
|
require File.expand_path('../../config/environment', __FILE__)
|
3
|
+
require 'rake'
|
3
4
|
require 'rails/test_help'
|
4
5
|
require 'minitest/rails'
|
5
6
|
require 'minitest/rails/capybara'
|
6
7
|
require 'minitest/pride'
|
7
8
|
require 'minitest/reporters'
|
8
9
|
|
9
|
-
require 'shoulda-matchers'
|
10
|
-
require 'shoulda'
|
11
|
-
|
12
10
|
require 'capybara/webkit'
|
13
11
|
require 'capybara-screenshot/minitest'
|
14
12
|
require 'capybara/slow_finder_errors'
|
@@ -21,13 +19,15 @@ class ActiveSupport::TestCase
|
|
21
19
|
use_transactional_fixtures = true
|
22
20
|
end
|
23
21
|
|
24
|
-
class
|
22
|
+
class Capybara::Rails::TestCase
|
25
23
|
# Make the Capybara DSL available in all integration tests
|
26
24
|
include Capybara::DSL
|
27
25
|
include Capybara::Assertions
|
28
26
|
include Capybara::Screenshot::MiniTestPlugin
|
29
27
|
include Warden::Test::Helpers if defined?(Devise)
|
30
28
|
|
29
|
+
include EffectiveTestBot::DSL
|
30
|
+
|
31
31
|
def after_setup
|
32
32
|
super()
|
33
33
|
DatabaseCleaner.start
|
@@ -58,21 +58,21 @@ Rails.backtrace_cleaner.add_silencer { |line| line =~ /effective_test_bot/ }
|
|
58
58
|
### Effective Test Bot specific stuff below ###
|
59
59
|
###############################################
|
60
60
|
|
61
|
+
Rails.application.load_tasks
|
62
|
+
|
61
63
|
# So the very first thing we do is consistently reset the database.
|
62
64
|
# This can be done with Snippet 1 or Snippet 2.
|
63
65
|
# Snippet 1 is faster, and will usually work. Snippet 2 should always work.
|
64
66
|
|
65
67
|
# Snippet 1:
|
66
|
-
|
68
|
+
Rake::Task['db:schema:load'].invoke
|
67
69
|
ActiveRecord::Migration.maintain_test_schema!
|
68
70
|
|
69
71
|
# Snippet 2:
|
70
72
|
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
74
|
-
# Rake::Task['db:migrate'].invoke
|
75
|
-
# end
|
73
|
+
# Rake::Task['db:drop'].invoke
|
74
|
+
# Rake::Task['db:create'].invoke
|
75
|
+
# Rake::Task['db:migrate'].invoke
|
76
76
|
|
77
77
|
# Now we populate our test data:
|
78
78
|
Rake::Task['db:fixtures:load'].invoke # There's just no way to get the seeds first, as this has to delete everything
|
data/lib/effective_test_bot.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'effective_test_bot/engine'
|
2
|
+
require 'effective_test_bot/dsl'
|
3
|
+
require 'effective_test_bot/middleware'
|
4
|
+
require 'effective_test_bot/version'
|
4
5
|
|
5
6
|
module EffectiveTestBot
|
6
7
|
mattr_accessor :except
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module EffectiveTestBot
|
2
|
+
module DSL
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
include EffectiveTestBotAssertions
|
7
|
+
include EffectiveTestBotFormHelper
|
8
|
+
include EffectiveTestBotFormFiller
|
9
|
+
include EffectiveTestBotLoginHelper
|
10
|
+
include EffectiveTestBotMinitestHelper
|
11
|
+
include EffectiveTestBotScreenshotsHelper
|
12
|
+
include EffectiveTestBotTestHelper
|
13
|
+
|
14
|
+
# test/test_botable/
|
15
|
+
include BaseTest
|
16
|
+
include CrudTest
|
17
|
+
include DeviseTest
|
18
|
+
include MemberTest
|
19
|
+
include PageTest
|
20
|
+
include RedirectTest
|
21
|
+
include WizardTest
|
22
|
+
|
23
|
+
# test/concerns/test_botable/
|
24
|
+
include TestBotable::BaseDsl
|
25
|
+
include TestBotable::CrudDsl
|
26
|
+
include TestBotable::DeviseDsl
|
27
|
+
include TestBotable::MemberDsl
|
28
|
+
include TestBotable::PageDsl
|
29
|
+
include TestBotable::RedirectDsl
|
30
|
+
include TestBotable::WizardDsl
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -12,39 +12,6 @@ module EffectiveTestBot
|
|
12
12
|
eval File.read("#{config.root}/config/effective_test_bot.rb")
|
13
13
|
end
|
14
14
|
|
15
|
-
initializer 'effective_test_bot.test_suite' do |app|
|
16
|
-
if Rails.env.test?
|
17
|
-
Rails.application.config.to_prepare do
|
18
|
-
# test/support/
|
19
|
-
ActionDispatch::IntegrationTest.include EffectiveTestBotAssertions
|
20
|
-
ActionDispatch::IntegrationTest.include EffectiveTestBotFormHelper
|
21
|
-
ActionDispatch::IntegrationTest.include EffectiveTestBotFormFiller
|
22
|
-
ActionDispatch::IntegrationTest.include EffectiveTestBotLoginHelper
|
23
|
-
ActionDispatch::IntegrationTest.include EffectiveTestBotMinitestHelper
|
24
|
-
ActionDispatch::IntegrationTest.include EffectiveTestBotScreenshotsHelper
|
25
|
-
ActionDispatch::IntegrationTest.include EffectiveTestBotTestHelper
|
26
|
-
|
27
|
-
# test/test_botable/
|
28
|
-
ActionDispatch::IntegrationTest.include BaseTest
|
29
|
-
ActionDispatch::IntegrationTest.include CrudTest
|
30
|
-
ActionDispatch::IntegrationTest.include DeviseTest
|
31
|
-
ActionDispatch::IntegrationTest.include MemberTest
|
32
|
-
ActionDispatch::IntegrationTest.include PageTest
|
33
|
-
ActionDispatch::IntegrationTest.include RedirectTest
|
34
|
-
ActionDispatch::IntegrationTest.include WizardTest
|
35
|
-
|
36
|
-
# test/concerns/test_botable/
|
37
|
-
ActionDispatch::IntegrationTest.include TestBotable::BaseDsl
|
38
|
-
ActionDispatch::IntegrationTest.include TestBotable::CrudDsl
|
39
|
-
ActionDispatch::IntegrationTest.include TestBotable::DeviseDsl
|
40
|
-
ActionDispatch::IntegrationTest.include TestBotable::MemberDsl
|
41
|
-
ActionDispatch::IntegrationTest.include TestBotable::PageDsl
|
42
|
-
ActionDispatch::IntegrationTest.include TestBotable::RedirectDsl
|
43
|
-
ActionDispatch::IntegrationTest.include TestBotable::WizardDsl
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
15
|
initializer 'effective_test_bot.middleware' do |app|
|
49
16
|
if Rails.env.test?
|
50
17
|
Rails.application.config.middleware.use EffectiveTestBot::Middleware
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'rake/testtask'
|
2
|
-
require 'rails/test_unit/sub_test_task'
|
3
2
|
|
4
3
|
# rake test:bot
|
5
4
|
# rake test:bot TEST=documents#new
|
@@ -28,7 +27,11 @@ namespace :test do
|
|
28
27
|
ENV['TEST'] = nil
|
29
28
|
end
|
30
29
|
|
31
|
-
|
30
|
+
if Gem::Version.new(Rails.version) < Gem::Version.new('5.0')
|
31
|
+
Rake::Task['test:effective_test_bot'].invoke
|
32
|
+
else
|
33
|
+
system("rails test #{File.dirname(__FILE__)}/../../test/test_bot/integration/application_test.rb")
|
34
|
+
end
|
32
35
|
end
|
33
36
|
|
34
37
|
desc "Runs 'rake test' with effective_test_bot tour mode enabled"
|
@@ -46,7 +49,11 @@ namespace :test do
|
|
46
49
|
namespace :bot do
|
47
50
|
desc 'Runs effective_test_bot environment test'
|
48
51
|
task :environment do
|
49
|
-
|
52
|
+
if Gem::Version.new(Rails.version) < Gem::Version.new('5.0')
|
53
|
+
Rake::Task['test:effective_test_bot_environment'].invoke
|
54
|
+
else
|
55
|
+
system("rails test #{File.dirname(__FILE__)}/../../test/test_bot/integration/environment_test.rb")
|
56
|
+
end
|
50
57
|
end
|
51
58
|
|
52
59
|
desc 'Deletes all effective_test_bot temporary, failure and tour screenshots'
|
@@ -114,14 +121,16 @@ namespace :test do
|
|
114
121
|
|
115
122
|
# This ensures rake test:prepare is run before rake test:bot or rake test:bot:environment run
|
116
123
|
# Test files stuff is minitest hackery to just load the 1 test file
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
124
|
+
if Gem::Version.new(Rails.version) < Gem::Version.new('5.0')
|
125
|
+
Rake::TestTask.new('effective_test_bot' => 'test:prepare') do |t|
|
126
|
+
t.libs << 'test'
|
127
|
+
t.test_files = FileList["#{File.dirname(__FILE__)}/../../test/test_bot/integration/application_test.rb"]
|
128
|
+
end
|
121
129
|
|
122
|
-
|
123
|
-
|
124
|
-
|
130
|
+
Rake::TestTask.new('effective_test_bot_environment' => 'test:prepare') do |t|
|
131
|
+
t.libs << 'test'
|
132
|
+
t.test_files = FileList["#{File.dirname(__FILE__)}/../../test/test_bot/integration/environment_test.rb"]
|
133
|
+
end
|
125
134
|
end
|
126
135
|
|
127
136
|
end
|
@@ -4,7 +4,7 @@ require 'test_helper'
|
|
4
4
|
# Scan through every route and run a test suite against it
|
5
5
|
|
6
6
|
module TestBot
|
7
|
-
class ApplicationTest <
|
7
|
+
class ApplicationTest < ::Capybara::Rails::TestCase
|
8
8
|
CRUD_ACTIONS = %w(index create new edit show update destroy) # Same order as resources :object creates them in
|
9
9
|
|
10
10
|
class << self
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require "test_helper"
|
2
2
|
|
3
3
|
module TestBot
|
4
|
-
class EnvironmentTest <
|
4
|
+
class EnvironmentTest < ::Capybara::Rails::TestCase
|
5
5
|
@@original_users_count = User.count
|
6
6
|
let(:original_users_count) { @@original_users_count }
|
7
7
|
|
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.1
|
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:
|
11
|
+
date: 2017-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -178,34 +178,6 @@ dependencies:
|
|
178
178
|
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
|
-
- !ruby/object:Gem::Dependency
|
182
|
-
name: shoulda
|
183
|
-
requirement: !ruby/object:Gem::Requirement
|
184
|
-
requirements:
|
185
|
-
- - ">="
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
version: '0'
|
188
|
-
type: :runtime
|
189
|
-
prerelease: false
|
190
|
-
version_requirements: !ruby/object:Gem::Requirement
|
191
|
-
requirements:
|
192
|
-
- - ">="
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
version: '0'
|
195
|
-
- !ruby/object:Gem::Dependency
|
196
|
-
name: shoulda-matchers
|
197
|
-
requirement: !ruby/object:Gem::Requirement
|
198
|
-
requirements:
|
199
|
-
- - ">="
|
200
|
-
- !ruby/object:Gem::Version
|
201
|
-
version: '0'
|
202
|
-
type: :runtime
|
203
|
-
prerelease: false
|
204
|
-
version_requirements: !ruby/object:Gem::Requirement
|
205
|
-
requirements:
|
206
|
-
- - ">="
|
207
|
-
- !ruby/object:Gem::Version
|
208
|
-
version: '0'
|
209
181
|
- !ruby/object:Gem::Dependency
|
210
182
|
name: rmagick
|
211
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -244,16 +216,16 @@ extra_rdoc_files: []
|
|
244
216
|
files:
|
245
217
|
- MIT-LICENSE
|
246
218
|
- README.md
|
247
|
-
- Rakefile
|
248
219
|
- app/helpers/effective_test_bot_controller_helper.rb
|
249
220
|
- app/helpers/effective_test_bot_mailer_helper.rb
|
250
221
|
- config/effective_test_bot.rb
|
222
|
+
- config/test_helper.rb
|
251
223
|
- lib/effective_test_bot.rb
|
224
|
+
- lib/effective_test_bot/dsl.rb
|
252
225
|
- lib/effective_test_bot/engine.rb
|
253
226
|
- lib/effective_test_bot/middleware.rb
|
254
227
|
- lib/effective_test_bot/version.rb
|
255
228
|
- lib/generators/effective_test_bot/install_generator.rb
|
256
|
-
- lib/generators/templates/test_helper.rb
|
257
229
|
- lib/tasks/effective_test_bot_tasks.rake
|
258
230
|
- test/concerns/test_botable/base_dsl.rb
|
259
231
|
- test/concerns/test_botable/crud_dsl.rb
|
data/Rakefile
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
|
-
begin
|
3
|
-
require 'bundler/setup'
|
4
|
-
rescue LoadError
|
5
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
-
end
|
7
|
-
|
8
|
-
# Testing tasks
|
9
|
-
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
10
|
-
load 'rails/tasks/engine.rake'
|
11
|
-
|
12
|
-
Bundler::GemHelper.install_tasks
|
13
|
-
|
14
|
-
require 'rspec/core'
|
15
|
-
require 'rspec/core/rake_task'
|
16
|
-
|
17
|
-
desc "Run all specs in spec directory (excluding plugin specs)"
|
18
|
-
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
19
|
-
|
20
|
-
task :default => :spec
|