effective_test_bot 0.4.16 → 0.5.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 124e24f5a23f78013a2895ed9b1cb6c84553f50c
4
- data.tar.gz: bf2e35d6c19792b9fd322c870d6dd65260a86f48
3
+ metadata.gz: 9718dff008026433cc1541ce36c27eefbf396777
4
+ data.tar.gz: 6710d59f4c60c6861a450d7c1b277bc32b1d6eaa
5
5
  SHA512:
6
- metadata.gz: fe29d076bafcb5ab447e37f7a4f69e5417e3169eec65a6c446019e5cb92428e385ac7fb4cb1ad530eaba669bb52d06fdef167ab44bada016fae093c0d57bf02e
7
- data.tar.gz: 5a703c21aa3183e2c3fdc1c4429810ea052947696ab0078b591181392c526e2f5e88389db9c532dbab20a88f9f9c0b3eaf3c9573c6b65eace9c2e6938219294b
6
+ metadata.gz: 14251ee81b143df1aa5f70f72cde976fd2f288f8df5dda323f301799f4001f87962b84e4d3e0af3423e404c8ad27c801d81063147770e2cc2904807c57d141a4
7
+ data.tar.gz: f65722976ab5a9974736d7cabf9a7a6e3fb983711dbcae8ff8c88c6092fa17629be239c7ed3b17265149f88fca25ea1b0c35240b3a1a958d5f84b4bf6ef80a1d
data/README.md CHANGED
@@ -248,22 +248,22 @@ There are a few variations on the one-liner method:
248
248
  ```ruby
249
249
  class PostsTest < ActionDispatch::IntegrationTest
250
250
  # Runs all 9 crud_action tests against /posts
251
- crud_test(Post, User.first)
251
+ crud_test(resource: Post, user: User.first)
252
252
 
253
253
  # Runs all 9 crud_action tests against /posts and use this Post's attributes when calling fill_form.
254
- crud_test(Post.new(title: 'my first post'), User.first)
254
+ crud_test(resource: Post.new(title: 'my first post'), user: User.first)
255
255
 
256
256
  # Runs all 9 crud_action tests against /admin/posts controller as a previously seeded or fixtured admin user
257
- crud_test('admin/posts', User.where(admin: true).first)
257
+ crud_test(resource: 'admin/posts', user: User.where(admin: true).first)
258
258
 
259
259
  # Run only some tests
260
- crud_test(Post, User.first, only: [:new, :create_valid, :create_invalid, :show, :index])
260
+ crud_test(resource: Post, user: User.first, only: [:new, :create_valid, :create_invalid, :show, :index])
261
261
 
262
262
  # Run all except some tests
263
- crud_test(Post, User.first, except: [:edit, :update_valid, :update_invalid])
263
+ crud_test(resource: Post, user: User.first, except: [:edit, :update_valid, :update_invalid])
264
264
 
265
265
  # Skip individual assertions
266
- crud_test(Post, User.first, skip: {create_valid: :path, update_invalid: [:path, :flash]})
266
+ crud_test(resource: Post, user: User.first, skip: {create_valid: :path, update_invalid: [:path, :flash]})
267
267
  end
268
268
  ```
269
269
 
@@ -272,13 +272,13 @@ The individual test suites may also be used as part of a larger test:
272
272
  ```ruby
273
273
  class PostsTest < ActionDispatch::IntegrationTest
274
274
  test 'user may only update a post once' do
275
- crud_action_test(:create_valid, Post, User.first)
275
+ crud_action_test(test: :create_valid, resource: Post, user: User.first)
276
276
  assert_text 'successfully created post. You may only update it once.'
277
277
 
278
- crud_action_test(:update_valid, Post.last, User.first)
278
+ crud_action_test(test: :update_valid, resource: Post.last, user: User.first)
279
279
  assert_text 'successfully updated post.'
280
280
 
281
- crud_action_test(:update_valid, Post.last, User.first, skip: [:no_assigns_errors, :updated_at])
281
+ crud_action_test(test: :update_valid, resource: Post.last, user: User.first, skip: [:no_assigns_errors, :updated_at])
282
282
  assert_assigns_errors(:post, 'you may no longer update this post.')
283
283
  assert_text 'you may no longer update this post.'
284
284
  end
@@ -308,7 +308,7 @@ Or each individually in part of a regular test:
308
308
  ```ruby
309
309
  class MyApplicationTest < ActionDispatch::IntegrationTest
310
310
  test 'user receives 10 tokens after signing up' do
311
- devise_action_test(:sign_up)
311
+ devise_action_test(test: :sign_up)
312
312
  assert_text 'Tokens: 10'
313
313
  assert_equals 10, User.last.tokens
314
314
  assert_equals 10, assigns(:current_user).tokens
@@ -333,10 +333,10 @@ Use it as a one-liner:
333
333
  ```ruby
334
334
  class PostsTest < ActionDispatch::IntegrationTest
335
335
  # Uses find_or_create_resource! to load a seeded resource or create a new one
336
- member_test('posts', 'unarchive', User.first)
336
+ member_test(controller: 'posts', action: 'unarchive', user: User.first)
337
337
 
338
338
  # Run the member_test with a specific post
339
- member_test('posts', 'unarchive', User.first, Post.find(1))
339
+ member_test(controller: 'posts', action: 'unarchive', user: User.first, member: Post.find(1))
340
340
  end
341
341
  ```
342
342
 
@@ -348,7 +348,7 @@ class PostsTest < ActionDispatch::IntegrationTest
348
348
  post = Post.create(title: 'first post', archived: true)
349
349
 
350
350
  assert Post.where(archived: false).empty?
351
- member_action_test('posts', 'unarchive', User.first, post)
351
+ member_action_test(controller: 'posts', action: 'unarchive', user: User.first, member: post)
352
352
  assert Post.where(archived: false).present?
353
353
  end
354
354
  end
@@ -362,7 +362,7 @@ Use it as a one-liner:
362
362
 
363
363
  ```ruby
364
364
  class PostsTest < ActionDispatch::IntegrationTest
365
- page_test(:posts_path, User.first) # Runs the page_test test suite against posts_path as User.first
365
+ page_test(path: :posts_path, user: User.first) # Runs the page_test test suite against posts_path as User.first
366
366
  end
367
367
  ```
368
368
 
@@ -373,7 +373,7 @@ class PostsTest < ActionDispatch::IntegrationTest
373
373
  test 'posts are displayed on the index page' do
374
374
  Post.create(title: 'first post')
375
375
 
376
- page_action_test(:posts_path, User.first)
376
+ page_action_test(path: :posts_path, user: User.first)
377
377
 
378
378
  assert page.current_path, '/posts'
379
379
  assert_text 'first post'
@@ -390,7 +390,7 @@ Use it as a one-liner:
390
390
  ```ruby
391
391
  class PostsTest < ActionDispatch::IntegrationTest
392
392
  # Visits /blog and tests that it redirects to a working /posts page
393
- redirect_test('/blog', '/posts', User.first)
393
+ redirect_test(from: '/blog', to: '/posts', user: User.first)
394
394
  end
395
395
  ```
396
396
 
@@ -400,7 +400,7 @@ Or as part of a regular test:
400
400
  class PostsTest < ActionDispatch::IntegrationTest
401
401
  test 'visiting blog redirects to posts' do
402
402
  Post.create(title: 'first post')
403
- redirect_action_test('/blog', '/posts', User.first)
403
+ redirect_action_test(from: '/blog', to: '/posts', user: User.first)
404
404
  assert_text 'first post'
405
405
  end
406
406
  end
@@ -418,7 +418,7 @@ Use it as a one-liner:
418
418
 
419
419
  ```ruby
420
420
  class PostsTest < ActionDispatch::IntegrationTest
421
- wizard_test('/build_post/step1', '/build_post/step5', User.first)
421
+ wizard_test(from: '/build_post/step1', to: '/build_post/step5', user: User.first)
422
422
  end
423
423
  ```
424
424
 
@@ -427,7 +427,7 @@ Or as part of a regular test:
427
427
  ```ruby
428
428
  class PostsTest < ActionDispatch::IntegrationTest
429
429
  test 'building a post in 5 steps' do
430
- wizard_action_test('/build_post/step1', '/build_post/step5', User.first) do
430
+ wizard_action_test(from: '/build_post/step1', to: '/build_post/step5', user: User.first) do
431
431
  if page.current_path.end_with?('step4')
432
432
  assert_text 'your post is ready but must first be approved by an admin.'
433
433
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveTestBot
2
- VERSION = '0.4.16'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  end
@@ -5,6 +5,10 @@ module TestBotable
5
5
  module ClassMethods
6
6
  TEST_BOT_TEST_PREFIXES = ['crud_test', 'devise_test', 'member_test', 'page_test', 'redirect_test', 'wizard_test']
7
7
 
8
+ def _test_bot_user
9
+ @test_bot_user
10
+ end
11
+
8
12
  # Parses and validates lots of options
9
13
  # This is a big manual merge wherein we translate some DSL methods into one consistent Hash here
10
14
  # The output is what gets sent to each test and defined as lets
@@ -119,6 +123,10 @@ module TestBotable
119
123
 
120
124
  # Instance Methods
121
125
 
126
+ def _test_bot_user
127
+ @test_bot_user
128
+ end
129
+
122
130
  # Using reverse_merge! in the dsl action_tests makes sure that the
123
131
  # class level can assign a current_test variable
124
132
  # wheras the action level ones it's not present.
@@ -1,10 +1,10 @@
1
1
  # This DSL gives a class level and an instance level way of calling specific test suite
2
2
  #
3
3
  # class PostsTest < ActionDispatch::IntegrationTest
4
- # crud_test(Post || 'admin/posts', User.first, except: :show, skip: {create_valid: :path, update_invalid: [:path, :flash]})
4
+ # crud_test(resource: (Post || 'admin/posts'), user: User.first, except: :show, skip: {create_valid: :path, update_invalid: [:path, :flash]})
5
5
  #
6
6
  # test 'a one-off action' do
7
- # crud_action_test(:new, Post, User.first, skip: :title)
7
+ # crud_action_test(test: :new, resource: Post, user: User.first, skip: :title)
8
8
  # end
9
9
  # end
10
10
 
@@ -18,29 +18,25 @@ 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
- def crud_test(resource, user, options = {})
21
+ def crud_test(resource:, user: _test_bot_user(), label: nil, skip: {}, only: nil, except: nil, **options)
22
22
  # This skips paramaters is different than the initializer skips, which affect just the rake task
23
23
 
24
24
  # These are specificially for the DSL
25
25
  # In the class method, this value is a Hash, in the instance method it's expecting an Array
26
- skips = options.delete(:skip) || options.delete(:skips) || {} # So you can skip sub tests
27
- raise 'invalid skip syntax, expecting skip: {create_invalid: [:path]}' unless skips.kind_of?(Hash)
26
+ raise 'invalid skip syntax, expecting skip: {create_invalid: [:path]}' unless skip.kind_of?(Hash)
28
27
 
29
- label = options.delete(:label).presence
30
- only = options.delete(:only)
31
- except = options.delete(:except)
32
28
  current_crud_tests = crud_tests_to_define(only, except)
33
29
 
34
30
  begin
35
- normalize_test_bot_options!(options.merge!(user: user, resource: resource, current_crud_tests: current_crud_tests))
31
+ normalize_test_bot_options!(options.merge!(resource: resource, user: user, current_crud_tests: current_crud_tests))
36
32
  rescue => e
37
- raise "Error: #{e.message}. Expected usage: crud_test(Post || Post.new, User.first, only: [:new, :create], skip: {create_invalid: [:path]})"
33
+ raise "Error: #{e.message}. Expected usage: crud_test(resource: (Post || Post.new), user: User.first, only: [:new, :create], skip: {create_invalid: [:path]})"
38
34
  end
39
35
 
40
36
  current_crud_tests.each do |test|
41
37
  options_for_method = options.dup
42
38
 
43
- options_for_method[:skips] = Array(skips[test]) if skips[test]
39
+ options_for_method[:skip] = Array(skip[test]) if skip[test]
44
40
  options_for_method[:current_test] = [
45
41
  options[:controller_namespace].presence,
46
42
  options[:resource_name].pluralize
@@ -50,7 +46,7 @@ module TestBotable
50
46
 
51
47
  method_name = test_bot_method_name('crud_test', label || options_for_method[:current_test])
52
48
 
53
- define_method(method_name) { crud_action_test(test, resource, user, options_for_method) }
49
+ define_method(method_name) { crud_action_test(test: test, resource: resource, user: user, options: options_for_method) }
54
50
  end
55
51
  end
56
52
 
@@ -82,11 +78,11 @@ module TestBotable
82
78
  #
83
79
  # If obj is a Hash {:resource => ...} just skip over parsing options
84
80
  # And assume it's already been done (by the ClassMethod crud_test)
85
- def crud_action_test(test, resource, user = nil, options = {})
81
+ def crud_action_test(test:, resource:, user: _test_bot_user(), **options)
86
82
  begin
87
- assign_test_bot_lets!(options.reverse_merge!(user: user, resource: resource))
83
+ assign_test_bot_lets!(options.reverse_merge!(resource: resource, user: user))
88
84
  rescue => e
89
- raise "Error: #{e.message}. Expected usage: crud_action_test(:new, Post || Post.new, User.first)"
85
+ raise "Error: #{e.message}. Expected usage: crud_action_test(test: :new, resource: (Post || Post.new), user: User.first)"
90
86
  end
91
87
 
92
88
  self.send("test_bot_#{test}_test")
@@ -4,9 +4,9 @@
4
4
  # devise_test()
5
5
  #
6
6
  # test 'a one-off action' do
7
- # devise_action_test(:sign_up)
8
- # devise_action_test(:sign_in_valid)
9
- # devise_action_test(:sign_in_invalid)
7
+ # devise_action_test(test: :sign_up)
8
+ # devise_action_test(test: :sign_in_valid)
9
+ # devise_action_test(test: :sign_in_invalid)
10
10
  # end
11
11
  # end
12
12
 
@@ -16,23 +16,21 @@ module TestBotable
16
16
 
17
17
  module ClassMethods
18
18
 
19
- def devise_test(options = {})
20
- label = options.delete(:label).presence
21
-
19
+ def devise_test(label: nil, **options)
22
20
  [:sign_up, :sign_in_valid, :sign_in_invalid].each do |test|
23
21
  options[:current_test] = label || test
24
22
  next if EffectiveTestBot.skip?(options[:current_test])
25
23
 
26
24
  method_name = test_bot_method_name('devise_test', options[:current_test])
27
25
 
28
- define_method(method_name) { devise_action_test(test, options) }
26
+ define_method(method_name) { devise_action_test(test: test, options: options) }
29
27
  end
30
28
  end
31
29
 
32
30
  end
33
31
 
34
32
  # Instance Methods - Call me from within a test
35
- def devise_action_test(test, options = {})
33
+ def devise_action_test(test:, **options)
36
34
  options[:email] ||= "unique-#{Time.zone.now.to_i}@example.com"
37
35
  options[:password] ||= '!Password123'
38
36
  options[:username] ||= 'unique-username'
@@ -1,10 +1,10 @@
1
1
  # This DSL gives a class level and an instance level way of calling specific test suite
2
2
  #
3
3
  # class PostsTest < ActionDispatch::IntegrationTest
4
- # member_test('admin/jobs', 'unarchive', User.first, Post.first)
4
+ # member_test(controller: 'admin/jobs', action: 'unarchive', user: User.first, member: Post.first)
5
5
  #
6
6
  # test 'a one-off action' do
7
- # member_action_test('admin/jobs', 'unarchive', User.first)
7
+ # member_action_test(controller: 'admin/jobs', action: 'unarchive', user: User.first, member: Post.first)
8
8
  # end
9
9
  # end
10
10
 
@@ -16,24 +16,23 @@ module TestBotable
16
16
  extend ActiveSupport::Concern
17
17
 
18
18
  module ClassMethods
19
-
20
- def member_test(controller, action, user, obj_to_param = nil, options = {})
21
- options[:current_test] = options.delete(:label) || "#{controller}##{action}"
19
+ def member_test(controller:, action:, user: _test_bot_user(), member: nil, label: nil, **options)
20
+ options[:current_test] = label || "#{controller}##{action}"
22
21
  return if EffectiveTestBot.skip?(options[:current_test])
23
22
 
24
23
  method_name = test_bot_method_name('member_test', options[:current_test])
25
24
 
26
- define_method(method_name) { member_action_test(controller, action, user, obj_to_param, options) }
25
+ define_method(method_name) { member_action_test(controller: controller, action: action, user: user, member: member, options: options) }
27
26
  end
28
27
 
29
28
  end
30
29
 
31
30
  # Instance Methods - Call me from within a test
32
- def member_action_test(controller, action, user, member = nil, options = {})
31
+ def member_action_test(controller:, action:, user: _test_bot_user(), member:, **options)
33
32
  begin
34
33
  assign_test_bot_lets!(options.reverse_merge!(resource: controller, action: action, user: user, member: member))
35
34
  rescue => e
36
- raise "Error: #{e.message}. Expected usage: member_test('admin/jobs', 'unarchive', User.first, Post.first || nil)"
35
+ raise "Error: #{e.message}. Expected usage: member_test(controller: 'admin/jobs', action: 'unarchive', user: User.first, member: (Post.first || nil))"
37
36
  end
38
37
 
39
38
  self.send(:test_bot_member_test)
@@ -1,10 +1,10 @@
1
1
  # This DSL gives a class level and an instance level way of calling specific test suite
2
2
  #
3
3
  # class PostsTest < ActionDispatch::IntegrationTest
4
- # page_test(:posts_path, User.first)
4
+ # page_test(path: :posts_path, user: User.first)
5
5
  #
6
6
  # test 'a one-off action' do
7
- # page_action_test(:posts_path, User.first)
7
+ # page_action_test(path: :posts_path, user: User.first)
8
8
  # end
9
9
  # end
10
10
 
@@ -15,23 +15,23 @@ module TestBotable
15
15
 
16
16
  module ClassMethods
17
17
 
18
- def page_test(path, user, options = {})
19
- options[:current_test] = options.delete(:label) || path.to_s
18
+ def page_test(path:, user: _test_bot_user(), label: nil, **options)
19
+ options[:current_test] = label || path.to_s
20
20
  return if EffectiveTestBot.skip?(options[:current_test])
21
21
 
22
22
  method_name = test_bot_method_name('page_test', options[:current_test])
23
23
 
24
- define_method(method_name) { page_action_test(path, user, options) }
24
+ define_method(method_name) { page_action_test(path: path, user: user, options: options) }
25
25
  end
26
26
 
27
27
  end
28
28
 
29
29
  # Instance Methods - Call me from within a test
30
- def page_action_test(path, user, options = {})
30
+ def page_action_test(path:, user: _test_bot_user(), **options)
31
31
  begin
32
32
  assign_test_bot_lets!(options.reverse_merge!(user: user, page_path: path))
33
33
  rescue => e
34
- raise "Error: #{e.message}. Expected usage: page_action_test(root_path, User.first)"
34
+ raise "Error: #{e.message}. Expected usage: page_action_test(path: root_path, user: User.first)"
35
35
  end
36
36
 
37
37
  self.send(:test_bot_page_test)
@@ -1,10 +1,10 @@
1
1
  # This DSL gives a class level and an instance level way of calling specific test suite
2
2
  #
3
3
  # class AboutTest < ActionDispatch::IntegrationTest
4
- # redirect_test('/about', '/new-about', User.first)
4
+ # redirect_test(from: '/about', to: '/new-about', user: User.first)
5
5
  #
6
6
  # test 'a one-off action' do
7
- # redirect_action_test('/about', '/new-about', User.first)
7
+ # redirect_action_test(from: '/about', to: '/new-about', user: User.first)
8
8
  # end
9
9
  # end
10
10
 
@@ -14,22 +14,22 @@ module TestBotable
14
14
 
15
15
  module ClassMethods
16
16
 
17
- def redirect_test(from_path, to_path, user, options = {})
18
- options[:current_test] = options.delete(:label) || "#{from_path} to #{to_path}"
17
+ def redirect_test(from:, to:, user: _test_bot_user(), label: nil, **options)
18
+ options[:current_test] = label || "#{from} to #{to}"
19
19
  return if EffectiveTestBot.skip?(options[:current_test])
20
20
 
21
21
  method_name = test_bot_method_name('redirect_test', options[:current_test])
22
22
 
23
- define_method(method_name) { redirect_action_test(from_path, to_path, user, options) }
23
+ define_method(method_name) { redirect_action_test(from: from, to: to, user: user, options: options) }
24
24
  end
25
25
  end
26
26
 
27
27
  # Instance Methods - Call me from within a test
28
- def redirect_action_test(from_path, to_path, user, options = {})
28
+ def redirect_action_test(from:, to:, user: _test_bot_user(), options: {})
29
29
  begin
30
- assign_test_bot_lets!(options.reverse_merge!(from_path: from_path, to_path: to_path, user: user))
30
+ assign_test_bot_lets!(options.reverse_merge!(from: from, to: to, user: user))
31
31
  rescue => e
32
- raise "Error: #{e.message}. Expected usage: redirect_action_test('/about', '/new-about', User.first)"
32
+ raise "Error: #{e.message}. Expected usage: redirect_action_test(from: '/about', to: '/new-about', user: User.first)"
33
33
  end
34
34
 
35
35
  self.send(:test_bot_redirect_test)
@@ -1,10 +1,10 @@
1
1
  # This DSL gives a class level and an instance level way of calling specific test suite
2
2
  #
3
3
  # class PostsTest < ActionDispatch::IntegrationTest
4
- # wizard_test('/fee_wizard/step1', '/fee_wizard/step5', User.first)
4
+ # wizard_test(from: '/fee_wizard/step1', to: ('/fee_wizard/step5' || nil), user: User.first)
5
5
  #
6
6
  # test 'a one-off action' do
7
- # wizard_action_test('/fee_wizard/step1', '/fee_wizard/step5', User.first) do
7
+ # wizard_action_test(from: '/fee_wizard/step1', to: ('/fee_wizard/step5' || nil), user: User.first) do
8
8
  # puts page.current_path
9
9
  # end
10
10
  # end
@@ -19,28 +19,29 @@ module TestBotable
19
19
 
20
20
  module ClassMethods
21
21
 
22
- def wizard_test(from_path, to_path, user, options = {})
23
- if to_path.present?
24
- options[:current_test] = options.delete(:label) || "#{from_path} to #{to_path}"
22
+ def wizard_test(from:, to: nil, user: _test_bot_user(), label: nil, **options)
23
+
24
+ if to.present?
25
+ options[:current_test] = label || "#{from} to #{to}"
25
26
  else
26
- options[:current_test] = options.delete(:label) || "#{from_path}"
27
+ options[:current_test] = label || "#{from}"
27
28
  end
28
29
 
29
30
  return if EffectiveTestBot.skip?(options[:current_test])
30
31
 
31
32
  method_name = test_bot_method_name('wizard_test', options[:current_test])
32
33
 
33
- define_method(method_name) { wizard_action_test(from_path, to_path, user, options) }
34
+ define_method(method_name) { wizard_action_test(from: from, to: to, user: user, options: options) }
34
35
  end
35
36
 
36
37
  end
37
38
 
38
39
  # Instance Methods - Call me from within a test
39
- def wizard_action_test(from_path, to_path, user, options = {})
40
+ def wizard_action_test(from:, to: nil, user: _test_bot_user(), **options)
40
41
  begin
41
- assign_test_bot_lets!(options.reverse_merge!(from_path: from_path, to_path: to_path, user: user))
42
+ assign_test_bot_lets!(options.reverse_merge!(from: from, to: to, user: user))
42
43
  rescue => e
43
- raise "Error: #{e.message}. Expected usage: wizard_action_test('/fee_wizard/step1', '/fee_wizard/step5', User.first)"
44
+ raise "Error: #{e.message}. Expected usage: wizard_action_test(from: '/fee_wizard/step1', to: ('/fee_wizard/step5' || nil), user: User.first)"
44
45
  end
45
46
 
46
47
  block_given? ? test_bot_wizard_test { yield } : test_bot_wizard_test
@@ -2,7 +2,9 @@
2
2
 
3
3
  module EffectiveTestBotLoginHelper
4
4
  def as_user(user)
5
- sign_in(user); yield; sign_out
5
+ sign_in(user); @test_bot_user = user
6
+ yield
7
+ sign_out; @test_bot_user = nil
6
8
  end
7
9
 
8
10
  # This is currently hardcoded to use the warden login_as test helper
@@ -13,6 +13,8 @@ module TestBot
13
13
  def initialize_tests
14
14
  puts 'test_bot scanning....'
15
15
 
16
+ @test_bot_user = User.first
17
+
16
18
  routes = Rails.application.routes.routes.to_a
17
19
  seen_actions = Hash.new([]) # {posts: ['new', 'edit'], events: ['new', 'edit', 'show']}
18
20
 
@@ -31,7 +33,7 @@ module TestBot
31
33
  elsif route.app.kind_of?(ActionDispatch::Routing::PathRedirect) && route.path.required_names.blank?
32
34
  path = route.path.spec.to_s
33
35
  route.path.optional_names.each { |name| path.sub!("(.:#{name})", '') } # Removes (.:format) from path
34
- redirect_test(path, route.app.path([], nil), User.first)
36
+ redirect_test(from: path, to: route.app.path([], nil))
35
37
 
36
38
  # CRUD Test
37
39
  elsif is_crud_controller?(route)
@@ -46,7 +48,7 @@ module TestBot
46
48
  only_tests = seen_actions.delete(controller)
47
49
  only_tests << :tour if EffectiveTestBot.tour_mode?
48
50
 
49
- crud_test(controller, User.first, only: only_tests)
51
+ crud_test(resource: controller, only: only_tests)
50
52
  rescue => e
51
53
  puts e.message # Sometimes there is an object that can't be instantiated, so we still want to continue the application test
52
54
  end
@@ -55,15 +57,15 @@ module TestBot
55
57
  # Wizard Test
56
58
  elsif is_wicked_controller?(route)
57
59
  first_step_path = "/#{controller}/#{controller_instance(route).wizard_steps.first}"
58
- wizard_test(first_step_path, nil, User.first)
60
+ wizard_test(from: first_step_path)
59
61
 
60
62
  # Member Test
61
63
  elsif route.verb.to_s.include?('GET') && route.path.required_names == ['id']
62
- member_test(controller, action, User.first)
64
+ member_test(controller: controller, action: action)
63
65
 
64
66
  # Page Test
65
67
  elsif route.verb.to_s.include?('GET') && route.name.present? && Array(route.path.required_names).blank? # This could eventually be removed to supported nested routes
66
- page_test("#{route.name}_path".to_sym, User.first, route: route, label: "#{route.name}_path")
68
+ page_test(path: "#{route.name}_path".to_sym, route: route, label: "#{route.name}_path")
67
69
 
68
70
  else
69
71
  puts "skipping #{route.name}_path | #{route.path.spec} | #{route.verb} | #{route.defaults[:controller]} | #{route.defaults[:action]}"
@@ -5,7 +5,7 @@ module WizardTest
5
5
  protected
6
6
 
7
7
  def test_bot_wizard_test(&block)
8
- sign_in(user) and visit(from_path)
8
+ sign_in(user) and visit(from)
9
9
 
10
10
  0.upto(50) do |index| # Can only test wizards 51 steps long
11
11
  assert_page_normal
@@ -21,9 +21,9 @@ module WizardTest
21
21
 
22
22
  assert_no_assigns_errors
23
23
 
24
- if to_path.present?
24
+ if to.present?
25
25
  # Keep going till we hit a certain to_path
26
- break if page.current_path == to_path
26
+ break if page.current_path == to
27
27
  else
28
28
  # Keep going till there's no more submit buttons
29
29
  break if all("input[type='submit']").blank?
@@ -32,7 +32,7 @@ module WizardTest
32
32
 
33
33
  save_test_bot_screenshot
34
34
 
35
- assert_current_path(to_path) if to_path.present?
35
+ assert_current_path(to) if to.present?
36
36
  end
37
37
 
38
38
  end
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.4.16
4
+ version: 0.5.0
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: 2016-04-15 00:00:00.000000000 Z
11
+ date: 2016-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails