effective_test_bot 0.4.12 → 0.4.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/effective_test_bot/version.rb +1 -1
- data/test/support/effective_test_bot_assertions.rb +6 -2
- data/test/support/effective_test_bot_form_helper.rb +11 -1
- data/test/test_bot/integration/application_test.rb +9 -4
- data/test/test_botable/base_test.rb +19 -7
- 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: 3d9f3e47968588a874f9e16b0fbefa9e98ee9aee
|
4
|
+
data.tar.gz: c025706727691c283a8d99a1e902ae4ae5d61cc4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffecc7b971cf73a4bf2d62e1c8a20d7978a4b81173fe2329c5da48fa5b5072b4ab9dd42bdd66420ee8182c94bafb379621c8d9dc9fa01a9469d82c1745ffe4a3
|
7
|
+
data.tar.gz: 0fbab2527ee173d00b150aad9f15a038736d0a067b6649ec9b72c30e535dec983a3037da1a56a5e685d8162ebaca445d1baa03042f9442f0c9c5a00cdc56c2ab
|
data/README.md
CHANGED
@@ -83,7 +83,7 @@ Finally, to test that your testing environment is set up correctly run `rake tes
|
|
83
83
|
|
84
84
|
You now have effective_test_bot configured and you're ready to go.
|
85
85
|
|
86
|
-
|
86
|
+
## How to use this gem
|
87
87
|
|
88
88
|
Effective TestBot provides 4 areas of support in writing [minitest](https://github.com/seattlerb/minitest) [capybara](https://github.com/jnicklas/capybara) tests. As a developer, use this gem to:
|
89
89
|
|
@@ -42,8 +42,12 @@ module EffectiveTestBotAssertions
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
46
|
-
|
45
|
+
def assert_form(selector, message = "(form) Expected visible form with selector :selector: to be present")
|
46
|
+
assert all(selector).present?, message.sub(':selector', selector)
|
47
|
+
end
|
48
|
+
|
49
|
+
def assert_submit_input(message = "(submit_input) Expected one or more visible input[type='submit'] to be present")
|
50
|
+
assert all('input[type=submit]').present?, message
|
47
51
|
end
|
48
52
|
|
49
53
|
def assert_page_status(status = 200, message = '(page_status) Expected :status: HTTP status code')
|
@@ -65,8 +65,18 @@ module EffectiveTestBotFormHelper
|
|
65
65
|
page.execute_script "$('input[data-disable-with]').each(function(i) { $.rails.enableFormElement($(this)); });"
|
66
66
|
end
|
67
67
|
|
68
|
-
label.present?
|
68
|
+
if label.present?
|
69
|
+
submit = find(:link_or_button, label)
|
70
|
+
assert submit.present?, "TestBotError: Unable to find a visible submit link or button on #{page.current_path} with the label #{label}"
|
71
|
+
submit.click
|
72
|
+
else
|
73
|
+
submit = first(:css, "input[type='submit']")
|
74
|
+
assert submit.present?, "TestBotError: Unable to find a visible input[type='submit'] on #{page.current_path}"
|
75
|
+
submit.click
|
76
|
+
end
|
77
|
+
|
69
78
|
synchronize!
|
79
|
+
true
|
70
80
|
end
|
71
81
|
|
72
82
|
def with_raised_unpermitted_params_exceptions(&block)
|
@@ -73,11 +73,16 @@ module TestBot
|
|
73
73
|
return false unless CRUD_ACTIONS.include?(route.defaults[:action])
|
74
74
|
return false unless route.defaults[:controller].present? && route.app.respond_to?(:controller)
|
75
75
|
|
76
|
-
|
77
|
-
|
76
|
+
begin
|
77
|
+
controller_klass = route.app.controller(route.defaults)
|
78
|
+
controller_instance = controller_klass.new()
|
79
|
+
|
80
|
+
# Is this a CRUD capable controller?
|
81
|
+
controller_instance.respond_to?(:new) && controller_instance.respond_to?(:create)
|
82
|
+
rescue => e
|
83
|
+
false
|
84
|
+
end
|
78
85
|
|
79
|
-
# Is this a CRUD capable controller?
|
80
|
-
controller_instance && controller_instance.respond_to?(:new) && controller_instance.respond_to?(:create)
|
81
86
|
end
|
82
87
|
|
83
88
|
end
|
@@ -31,21 +31,33 @@ module BaseTest
|
|
31
31
|
EffectiveTestBot.skip?((current_test if defined?(current_test)), assertion)
|
32
32
|
end
|
33
33
|
|
34
|
+
# There are numerous points of failure here, so we want to be very helpful with the error messages
|
34
35
|
def find_or_create_resource!
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
obj = resource_class.last
|
37
|
+
return obj if obj.present? && !obj.kind_of?(User)
|
38
|
+
|
39
|
+
hint = "Unable to find_or_create_resource!\nEither fixture/seed an instance of #{resource_class} or ensure that submitting form#new_#{resource_name} on #{(new_resource_path rescue nil) || 'the resource new page'} creates a new #{resource_name}"
|
38
40
|
|
39
|
-
|
41
|
+
# It doesn't exist, so lets go to the new page and submit a form to build one
|
40
42
|
without_screenshots do
|
43
|
+
assert((new_resource_path rescue nil), "TestBotError: Generated polymorphic route new_#{[*controller_namespace, resource_name].compact.join('_')}_path is undefined. #{hint}")
|
44
|
+
|
41
45
|
visit(new_resource_path)
|
42
46
|
|
47
|
+
assert_form "form#new_#{resource_name}", "TestBotError: Failed to find form#new_#{resource_name}. #{hint}"
|
48
|
+
|
43
49
|
within("form#new_#{resource_name}") do
|
44
|
-
fill_form(resource_attributes)
|
50
|
+
fill_form(resource_attributes)
|
51
|
+
|
52
|
+
assert_submit_input "TestBotError: Failed to find a visible input[type='submit'] on #{page.current_path}. #{hint}"
|
53
|
+
submit_novalidate_form
|
45
54
|
end
|
46
55
|
end
|
47
56
|
|
48
|
-
resource_class.last
|
57
|
+
obj = resource_class.last
|
58
|
+
assert obj.present?, "TestBotError: Failed to create a resource after submitting form. #{hint}"
|
59
|
+
|
60
|
+
obj
|
49
61
|
end
|
50
62
|
|
51
63
|
# Try to find a link_to_delete already on this page
|
@@ -76,7 +88,7 @@ module BaseTest
|
|
76
88
|
end
|
77
89
|
|
78
90
|
def new_resource_path # new
|
79
|
-
new_polymorphic_path([*controller_namespace, resource])
|
91
|
+
path = new_polymorphic_path([*controller_namespace, resource])
|
80
92
|
end
|
81
93
|
|
82
94
|
def edit_resource_path(resource) # edit
|
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.
|
4
|
+
version: 0.4.13
|
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-01-
|
11
|
+
date: 2016-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|