minitest-ax_elements 1.0.0.beta
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.
- data/.yardopts +12 -0
- data/History.markdown +4 -0
- data/README.markdown +46 -0
- data/Rakefile +40 -0
- data/lib/minitest/ax_elements.rb +180 -0
- data/lib/minitest/ax_elements/version.rb +6 -0
- data/test/helper.rb +3 -0
- metadata +119 -0
data/.yardopts
ADDED
data/History.markdown
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# minitest-ax\_elements
|
2
|
+
|
3
|
+
minitest is a library for writing tests. AXElements is a library for
|
4
|
+
automating GUI interactions on OS X. When you combine them you get
|
5
|
+
`minitest-ax_elements`, a powerful tool for writing automated tests for
|
6
|
+
GUI applications on OS X.
|
7
|
+
|
8
|
+
|
9
|
+
## Examples
|
10
|
+
|
11
|
+
TODO...
|
12
|
+
|
13
|
+
|
14
|
+
## Documentation
|
15
|
+
|
16
|
+
TODO...
|
17
|
+
|
18
|
+
|
19
|
+
## Copyright
|
20
|
+
|
21
|
+
Copyright (c) 2012, Mark Rada
|
22
|
+
All rights reserved.
|
23
|
+
|
24
|
+
Redistribution and use in source and binary forms, with or without
|
25
|
+
modification, are permitted provided that the following conditions are met:
|
26
|
+
|
27
|
+
* Redistributions of source code must retain the above copyright
|
28
|
+
notice, this list of conditions and the following disclaimer.
|
29
|
+
* Redistributions in binary form must reproduce the above copyright
|
30
|
+
notice, this list of conditions and the following disclaimer in the
|
31
|
+
documentation and/or other materials provided with the distribution.
|
32
|
+
* Neither the name of Mark Rada nor the names of its
|
33
|
+
contributors may be used to endorse or promote products derived
|
34
|
+
from this software without specific prior written permission.
|
35
|
+
|
36
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
37
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
38
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
39
|
+
DISCLAIMED. IN NO EVENT SHALL Mark Rada BE LIABLE FOR ANY
|
40
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
41
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
42
|
+
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
43
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
44
|
+
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
45
|
+
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
46
|
+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
if defined? MACRUBY_REVISION
|
2
|
+
require 'rubygems'
|
3
|
+
def on_macruby?
|
4
|
+
true
|
5
|
+
end
|
6
|
+
else
|
7
|
+
def on_macruby?
|
8
|
+
false
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def on_mri?
|
13
|
+
!on_macruby?
|
14
|
+
end
|
15
|
+
|
16
|
+
task :default => :test
|
17
|
+
|
18
|
+
|
19
|
+
# Testing
|
20
|
+
|
21
|
+
require 'rake/testtask'
|
22
|
+
Rake::TestTask.new do |t|
|
23
|
+
t.libs << '.'
|
24
|
+
t.pattern = "test/**/*_test.rb"
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
# Gem stuff
|
29
|
+
|
30
|
+
require 'rubygems/package_task'
|
31
|
+
SPEC = Gem::Specification.load('minitest-ax_elements.gemspec')
|
32
|
+
|
33
|
+
Gem::PackageTask.new(SPEC) { }
|
34
|
+
|
35
|
+
desc 'Build and install gem (not including deps)'
|
36
|
+
task :install => :gem do
|
37
|
+
require 'rubygems/installer'
|
38
|
+
Gem::Installer.new("pkg/#{SPEC.file_name}").install
|
39
|
+
end
|
40
|
+
|
@@ -0,0 +1,180 @@
|
|
1
|
+
require 'ax/element'
|
2
|
+
require 'accessibility/qualifier'
|
3
|
+
require 'accessibility/dsl'
|
4
|
+
|
5
|
+
##
|
6
|
+
# AXElements assertions for MiniTest.
|
7
|
+
# [Learn more about minitest.](https://github.com/seattlerb/minitest)
|
8
|
+
class MiniTest::Assertions
|
9
|
+
|
10
|
+
##
|
11
|
+
# Test that an element has a specific child. For example, test
|
12
|
+
# that a table has a row with certain contents. You can pass any
|
13
|
+
# filters that you normally would during a search, including a block.
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
#
|
17
|
+
# assert_has_child table, :row, static_text: { value: 'Mark' }
|
18
|
+
#
|
19
|
+
# @param parent [AX::Element]
|
20
|
+
# @param kind [#to_s]
|
21
|
+
# @param filters [Hash]
|
22
|
+
# @yield Optional block used for filtering
|
23
|
+
# @return [AX::Element]
|
24
|
+
def assert_has_child parent, kind, filters = {}, &block
|
25
|
+
msg = message {
|
26
|
+
child = ax_search_id kind, filters, block
|
27
|
+
"Expected #{parent.inspect} to have #{child} as a child"
|
28
|
+
}
|
29
|
+
result = ax_check_children parent, kind, filters, block
|
30
|
+
refute result.blank?, msg
|
31
|
+
result
|
32
|
+
end
|
33
|
+
|
34
|
+
##
|
35
|
+
# Test that an element has a specifc descendent. For example, test
|
36
|
+
# that a window contains a specific label. You can pass any filters
|
37
|
+
# that you normally would during a search, including a block.
|
38
|
+
#
|
39
|
+
# @example
|
40
|
+
#
|
41
|
+
# assert_has_descendent window, :static_text, value: /Cake/
|
42
|
+
#
|
43
|
+
# @param ancestor [AX::Element]
|
44
|
+
# @param kind [#to_s]
|
45
|
+
# @param filters [Hash]
|
46
|
+
# @yield Optional block used for filtering
|
47
|
+
# @return [AX::Element]
|
48
|
+
def assert_has_descendent ancestor, kind, filters = {}, &block
|
49
|
+
msg = message {
|
50
|
+
descendent = ax_search_id kind, filters, block
|
51
|
+
"Expected #{ancestor.inspect} to have #{descendent} as a descendent"
|
52
|
+
}
|
53
|
+
result = ax_check_descendent ancestor, kind, filters, block
|
54
|
+
refute result.blank?, msg
|
55
|
+
result
|
56
|
+
end
|
57
|
+
alias_method :assert_has_descendant, :assert_has_descendent
|
58
|
+
|
59
|
+
##
|
60
|
+
# Test that an element will have a child/descendent soon. This method
|
61
|
+
# will block until the element is found or a timeout occurs.
|
62
|
+
#
|
63
|
+
# This is a minitest front end to using {DSL#wait_for}, so any
|
64
|
+
# parameters you would normally pass to that method will work here.
|
65
|
+
# This also means that you must include either a `parent` key or an
|
66
|
+
# `ancestor` key as one of the filters.
|
67
|
+
#
|
68
|
+
# @param kind [#to_s]
|
69
|
+
# @param filters [Hash]
|
70
|
+
# @yield An optional block to be used in the search qualifier
|
71
|
+
def assert_shortly_has kind, filters = {}, &block
|
72
|
+
# need to know if parent/ancestor now because wait_for eats some keys
|
73
|
+
(ancest = filters[:ancestor]) || (parent = filters[:parent])
|
74
|
+
msg = message {
|
75
|
+
descend = ax_search_id kind, filters, block
|
76
|
+
if ancest
|
77
|
+
"Expected #{ancest.inspect} to have descendent #{descend} before a timeout occurred"
|
78
|
+
else
|
79
|
+
"Expected #{parent.inspect} to have child #{descend} before a timeout occurred"
|
80
|
+
end
|
81
|
+
}
|
82
|
+
result = wait_for kind, filters, &block
|
83
|
+
refute result.blank?, msg
|
84
|
+
result
|
85
|
+
end
|
86
|
+
|
87
|
+
##
|
88
|
+
# Test that an element _does not_ have a specific child. For example,
|
89
|
+
# test that a row is no longer in a table. You can pass any filters
|
90
|
+
# that you normally would during a search, including a block.
|
91
|
+
#
|
92
|
+
# @example
|
93
|
+
#
|
94
|
+
# refute_has_child table, :row, id: 'MyRow'
|
95
|
+
#
|
96
|
+
# @param parent [AX::Element]
|
97
|
+
# @param kind [#to_s]
|
98
|
+
# @param filters [Hash]
|
99
|
+
# @yield An optional block to be used in the search qualifier
|
100
|
+
# @return [nil]
|
101
|
+
def refute_has_child parent, kind, filters = {}, &block
|
102
|
+
result = ax_check_children parent, kind, filters, block
|
103
|
+
msg = message {
|
104
|
+
"Expected #{parent.inspect} NOT to have #{result} as a child"
|
105
|
+
}
|
106
|
+
assert result.blank?, msg
|
107
|
+
result
|
108
|
+
end
|
109
|
+
|
110
|
+
##
|
111
|
+
# Test that an element _does not_ have a specific descendent. For
|
112
|
+
# example, test that a window does not contain a spinning progress
|
113
|
+
# indicator anymore.
|
114
|
+
#
|
115
|
+
# @example
|
116
|
+
#
|
117
|
+
# refute_has_descendent window, :busy_indicator
|
118
|
+
#
|
119
|
+
# @param ancestor [AX::Element]
|
120
|
+
# @param kind [#to_s]
|
121
|
+
# @param filters [Hash]
|
122
|
+
# @yield An optional block to be used in the search qualifier
|
123
|
+
# @return [nil,Array()]
|
124
|
+
def refute_has_descendent ancestor, kind, filters = {}, &block
|
125
|
+
result = ax_check_descendent ancestor, kind, filters, block
|
126
|
+
msg = message {
|
127
|
+
"Expected #{ancestor.inspect} NOT to have #{result} as a descendent"
|
128
|
+
}
|
129
|
+
assert result.blank?, msg
|
130
|
+
result
|
131
|
+
end
|
132
|
+
alias_method :refute_has_descendant, :refute_has_descendent
|
133
|
+
|
134
|
+
##
|
135
|
+
# @todo Does having this assertion make sense? I've only added it
|
136
|
+
# for the time being because OCD demands it.
|
137
|
+
#
|
138
|
+
# Test that an element will NOT have a child/descendent soon. This
|
139
|
+
# method will block until the element is found or a timeout occurs.
|
140
|
+
#
|
141
|
+
# This is a minitest front end to using {DSL#wait_for}, so any
|
142
|
+
# parameters you would normally pass to that method will work here.
|
143
|
+
# This also means that you must include either a `parent` key or an
|
144
|
+
# `ancestor` key as one of the filters.
|
145
|
+
#
|
146
|
+
# @param kind [#to_s]
|
147
|
+
# @param filters [Hash]
|
148
|
+
# @yield An optional block to be used in the search qualifier
|
149
|
+
# @return [nil]
|
150
|
+
def refute_shortly_has kind, filters = {}, &block
|
151
|
+
result = wait_for kind, filters, &block
|
152
|
+
msg = message {
|
153
|
+
if ancest = filters[:ancestor]
|
154
|
+
"Expected #{ancest.inspect} NOT to have #{result.inspect} as a descendent"
|
155
|
+
else
|
156
|
+
parent = filters[:parent]
|
157
|
+
"Expected #{parent.inspect} NOT to have #{result.inspect} as a child"
|
158
|
+
end
|
159
|
+
}
|
160
|
+
assert result.blank?, msg
|
161
|
+
result
|
162
|
+
end
|
163
|
+
|
164
|
+
|
165
|
+
private
|
166
|
+
|
167
|
+
def ax_search_id kind, filters, block
|
168
|
+
Accessibility::Qualifier.new(kind, filters, &block).describe
|
169
|
+
end
|
170
|
+
|
171
|
+
def ax_check_children parent, kind, filters, block
|
172
|
+
q = Accessibility::Qualifier.new(kind, filters, &block)
|
173
|
+
parent.children.find { |x| q.qualifies? x }
|
174
|
+
end
|
175
|
+
|
176
|
+
def ax_check_descendent ancestor, kind, filters, block
|
177
|
+
ancestor.search(kind, filters, &block)
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
data/test/helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: minitest-ax_elements
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.beta
|
5
|
+
prerelease: 6
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Mark Rada
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-26 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: AXElements
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - '='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.0.beta
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.0.0.beta
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: minitest
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '4.3'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '4.3'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: yard
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.8.3
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.8.3
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: kramdown
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.14.1
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.14.1
|
78
|
+
description: ! 'MiniTest extensions for using AXElements
|
79
|
+
|
80
|
+
'
|
81
|
+
email: mrada@marketcircle.com
|
82
|
+
executables: []
|
83
|
+
extensions: []
|
84
|
+
extra_rdoc_files: []
|
85
|
+
files:
|
86
|
+
- lib/minitest/ax_elements/version.rb
|
87
|
+
- lib/minitest/ax_elements.rb
|
88
|
+
- Rakefile
|
89
|
+
- README.markdown
|
90
|
+
- History.markdown
|
91
|
+
- .yardopts
|
92
|
+
- test/helper.rb
|
93
|
+
homepage: http://github.com/AXElements/minitest-ax_elements
|
94
|
+
licenses:
|
95
|
+
- BSD 3-clause
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
|
+
requirements:
|
103
|
+
- - ! '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ! '>'
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: 1.3.1
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 1.8.24
|
115
|
+
signing_key:
|
116
|
+
specification_version: 3
|
117
|
+
summary: MiniTest extensions for using AXElements
|
118
|
+
test_files:
|
119
|
+
- test/helper.rb
|