rspec-ax_elements 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,12 @@
1
+ --no-cache
2
+ --no-output
3
+ --verbose
4
+ --markup markdown
5
+ --markup-provider redcarpet
6
+ --asset docs/images:images
7
+ --readme README.markdown
8
+ --hide-void-return
9
+ lib/**/*.rb
10
+ -
11
+ History.markdown
12
+
@@ -0,0 +1,4 @@
1
+ # 1.0.0
2
+
3
+ * Extracted from AXElements
4
+
@@ -0,0 +1,48 @@
1
+ # rspec-ax\_elements
2
+
3
+ RSpec is a framework for writing tests. AXElements is a library for
4
+ automating GUI interactions on OS X. When you combine them you get
5
+ `rspec-ax_elements`, a powerful tool for writing automated tests for
6
+ GUI applications on OS X.
7
+
8
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/AXElements/rspec-ax_elements)
9
+
10
+
11
+ ## Examples
12
+
13
+ TODO...
14
+
15
+
16
+ ## Documentation
17
+
18
+ TODO...
19
+
20
+
21
+ ## Copyright
22
+
23
+ Copyright (c) 2012, Mark Rada
24
+ All rights reserved.
25
+
26
+ Redistribution and use in source and binary forms, with or without
27
+ modification, are permitted provided that the following conditions are met:
28
+
29
+ * Redistributions of source code must retain the above copyright
30
+ notice, this list of conditions and the following disclaimer.
31
+ * Redistributions in binary form must reproduce the above copyright
32
+ notice, this list of conditions and the following disclaimer in the
33
+ documentation and/or other materials provided with the distribution.
34
+ * Neither the name of Mark Rada nor the names of its
35
+ contributors may be used to endorse or promote products derived
36
+ from this software without specific prior written permission.
37
+
38
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
39
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
40
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41
+ DISCLAIMED. IN NO EVENT SHALL Mark Rada BE LIABLE FOR ANY
42
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
43
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
44
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
45
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
46
+ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
47
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
48
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,37 @@
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 'rspec/core/rake_task'
22
+ RSpec::Core::RakeTask.new
23
+
24
+
25
+ # Gem stuff
26
+
27
+ require 'rubygems/package_task'
28
+ SPEC = Gem::Specification.load('rspec-ax_elements.gemspec')
29
+
30
+ Gem::PackageTask.new(SPEC) { }
31
+
32
+ desc 'Build and install gem (not including deps)'
33
+ task :install => :gem do
34
+ require 'rubygems/installer'
35
+ Gem::Installer.new("pkg/#{SPEC.file_name}").install
36
+ end
37
+
@@ -0,0 +1,5 @@
1
+ module RSpec
2
+ module Accessibility
3
+ VERSION = '0.9.0'
4
+ end
5
+ end
@@ -0,0 +1,234 @@
1
+ require 'accessibility/dsl'
2
+ require 'accessibility/qualifier'
3
+ require 'ax/element'
4
+
5
+ module Accessibility
6
+
7
+ ##
8
+ # @abstract
9
+ #
10
+ # Base class for RSpec matchers used with AXElements.
11
+ class AbstractMatcher
12
+
13
+ # @return [#to_s]
14
+ attr_reader :kind
15
+
16
+ # @return [Hash{Symbol=>Object}]
17
+ attr_reader :filters
18
+
19
+ # @return [Proc]
20
+ attr_reader :block
21
+
22
+ # @param kind [#to_s]
23
+ # @param filters [Hash]
24
+ # @yield Optional block used for search filtering
25
+ def initialize kind, filters, &block
26
+ @kind, @filters, @block = kind, filters, block
27
+ end
28
+
29
+ # @param element [AX::Element]
30
+ def does_not_match? element
31
+ !matches?(element)
32
+ end
33
+
34
+
35
+ private
36
+
37
+ # @return [Accessibility::Qualifier]
38
+ def qualifier
39
+ @qualifier ||= Accessibility::Qualifier.new(kind, filters, &block)
40
+ end
41
+ end
42
+
43
+ ##
44
+ # Custom matcher for RSpec to check if an element has the specified
45
+ # child element.
46
+ class HasChildMatcher < AbstractMatcher
47
+ # @param parent [AX::Element]
48
+ def matches? parent
49
+ @parent = parent
50
+ @result = parent.children.find { |x| qualifier.qualifies? x }
51
+ !@result.blank?
52
+ end
53
+
54
+ # @return [String]
55
+ def failure_message_for_should
56
+ "Expected #@parent to have child #{qualifier.describe}"
57
+ end
58
+
59
+ # @return [String]
60
+ def failure_message_for_should_not
61
+ "Expected #@parent to NOT have child #@result"
62
+ end
63
+
64
+ # @return [String]
65
+ def description
66
+ "should have a child that matches #{qualifier.describe}"
67
+ end
68
+ end
69
+
70
+ ##
71
+ # Custom matcher for RSpec to check if an element has the specified
72
+ # descendent element.
73
+ class HasDescendentMatcher < AbstractMatcher
74
+ # @param ancestor [AX::Element]
75
+ def matches? ancestor
76
+ @ancestor = ancestor
77
+ @result = ancestor.search(kind, filters, &block)
78
+ !@result.blank?
79
+ end
80
+
81
+ # @return [String]
82
+ def failure_message_for_should
83
+ "Expected #@ancestor to have descendent #{qualifier.describe}"
84
+ end
85
+
86
+ # @return [String]
87
+ def failure_message_for_should_not
88
+ "Expected #@ancestor to NOT have descendent #@result"
89
+ end
90
+
91
+ # @return [String]
92
+ def description
93
+ "should have a descendent matching #{qualifier.describe}"
94
+ end
95
+ end
96
+
97
+ ##
98
+ # Custom matcher for RSpec to check if an element has the specified
99
+ # child element within a grace period. Used for testing things
100
+ # after an asynchronous action is performed.
101
+ class HasChildShortlyMatcher < AbstractMatcher
102
+ include DSL
103
+
104
+ # @param parent [AX::Element]
105
+ def matches? parent
106
+ @filters[:parent] = @parent = parent
107
+ @result = wait_for kind, filters, &block
108
+ !@result.blank?
109
+ end
110
+
111
+ # @return [String]
112
+ def failure_message_for_should
113
+ "Expected #@parent to have child #{qualifier.describe} before a timeout occurred"
114
+ end
115
+
116
+ # @return [String]
117
+ def failure_message_for_should_not
118
+ "Expected #@parent to NOT have child #@result before a timeout occurred"
119
+ end
120
+
121
+ # @return [String]
122
+ def description
123
+ "should have a child that matches #{qualifier.describe} before a timeout occurs"
124
+ end
125
+ end
126
+
127
+ ##
128
+ # Custom matcher for RSpec to check if an element has the specified
129
+ # descendent element within a grace period. Used for testing things
130
+ # after an asynchronous action is performed.
131
+ class HasDescendentShortlyMatcher < AbstractMatcher
132
+ include DSL
133
+
134
+ # @param ancestor [AX::Element]
135
+ def matches? ancestor
136
+ @filters[:ancestor] = @ancestor = ancestor
137
+ @result = wait_for kind, filters, &block
138
+ !@result.blank?
139
+ end
140
+
141
+ # @return [String]
142
+ def failure_message_for_should
143
+ "Expected #@ancestor to have descendent #{qualifier.describe} before a timeout occurred"
144
+ end
145
+
146
+ # @return [String]
147
+ def failure_message_for_should_not
148
+ "Expected #@ancestor to NOT have descendent #@result before a timeout occurred"
149
+ end
150
+
151
+ # @return [String]
152
+ def description
153
+ "should have a descendent matching #{qualifier.describe} before a timeout occurs"
154
+ end
155
+ end
156
+ end
157
+
158
+
159
+ ##
160
+ # Assert that the receiving element has the specified child element. You
161
+ # can use any filters you would normally use in a search, including
162
+ # a block.
163
+ #
164
+ # @example
165
+ #
166
+ # window.toolbar.should have_child(:search_field)
167
+ # table.should have_child(:row, static_text: { value: /42/ })
168
+ #
169
+ # search_field.should_not have_child(:busy_indicator)
170
+ #
171
+ # @param kind [#to_s]
172
+ # @param filters [Hash]
173
+ # @yield An optional block to be used as part of the search qualifier
174
+ def have_child kind, filters = {}, &block
175
+ Accessibility::HasChildMatcher.new kind, filters, &block
176
+ end
177
+
178
+ ##
179
+ # Assert that the given element has the specified descendent. You can
180
+ # pass any parameters you normally would use during a search,
181
+ # including a block.
182
+ #
183
+ # @example
184
+ #
185
+ # app.main_window.should have_descendent(:button, title: 'Press Me')
186
+ #
187
+ # row.should_not have_descendent(:check_box)
188
+ #
189
+ # @param kind [#to_s]
190
+ # @param filters [Hash]
191
+ # @yield An optional block to be used as part of the search qualifier
192
+ def have_descendent kind, filters = {}, &block
193
+ Accessibility::HasDescendentMatcher.new kind, filters, &block
194
+ end
195
+ alias :have_descendant :have_descendent
196
+
197
+ ##
198
+ # Assert that the given element has the specified child soon. This
199
+ # method will block until the child is found or a timeout occurs. You
200
+ # can pass any parameters you normally would use during a search,
201
+ # including a block.
202
+ #
203
+ # @example
204
+ #
205
+ # app.main_window.should shortly_have_child(:row, static_text: { value: 'Cake' })
206
+ #
207
+ # row.should_not shortly_have_child(:check_box)
208
+ #
209
+ # @param kind [#to_s]
210
+ # @param filters [Hash]
211
+ # @yield An optional block to be used as part of the search qualifier
212
+ def shortly_have_child kind, filters = {}, &block
213
+ Accessibility::HasChildShortlyMatcher.new(kind, filters, &block)
214
+ end
215
+
216
+ ##
217
+ # Assert that the given element has the specified descendent soon. This
218
+ # method will block until the descendent is found or a timeout occurs.
219
+ # You can pass any parameters you normally would use during a search,
220
+ # including a block.
221
+ #
222
+ # @example
223
+ #
224
+ # app.main_window.should shortly_have_child(:row, static_text: { value: 'Cake' })
225
+ #
226
+ # row.should_not shortly_have_child(:check_box)
227
+ #
228
+ # @param kind [#to_s]
229
+ # @param filters [Hash]
230
+ # @yield An optional block to be used as part of the search qualifier
231
+ def shortly_have_descendent kind, filters = {}, &block
232
+ Accessibility::HasDescendentShortlyMatcher.new kind, filters, &block
233
+ end
234
+ alias :shortly_have_descendant :shortly_have_descendent
@@ -0,0 +1,2 @@
1
+ require 'rspec/autorun'
2
+
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-ax_elements
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mark Rada
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-21 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: 0.9.0
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: 0.9.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '2.11'
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: '2.11'
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: ! 'RSpec extensions for using AXElements
79
+
80
+ '
81
+ email: mrada@marketcircle.com
82
+ executables: []
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - lib/rspec/ax_elements/version.rb
87
+ - lib/rspec/expectations/ax_elements.rb
88
+ - Rakefile
89
+ - README.markdown
90
+ - History.markdown
91
+ - .yardopts
92
+ - spec/helper.rb
93
+ homepage: http://github.com/AXElements/rspec-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
+ segments:
107
+ - 0
108
+ hash: -1431659742520994729
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ none: false
111
+ requirements:
112
+ - - ! '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ segments:
116
+ - 0
117
+ hash: -1431659742520994729
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 1.8.24
121
+ signing_key:
122
+ specification_version: 3
123
+ summary: RSpec extensions for using AXElements
124
+ test_files:
125
+ - spec/helper.rb