tapestry 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 736bda0dd5708d733bcf8462852fc6cfb85f83d7
4
+ data.tar.gz: 05c9cddcef3a79a481218722289f8b17a76cbb2f
5
+ SHA512:
6
+ metadata.gz: 8b15fa2ecd4c7062d16bd774fdfabf228fe0baa5de65e402c2f1b55bdc7e312422014f8d739560a79c73eee8713f205f725f0578cd91fdd89240ac6ba2f81afa
7
+ data.tar.gz: 39c0bd51b96fb07e6ff01f5e6483203a65051910457cff7a93fbd25fbd99f036722344dc055a6682157badd394ff346d2bd3c498f6f49707e4704b5ee4b7ed5c
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.hound.yml ADDED
@@ -0,0 +1,62 @@
1
+ AllCops:
2
+ Exclude:
3
+ - tapestry.gemspec
4
+ - examples/*.rb
5
+ - spec/**/*
6
+
7
+ # Removing need for frozen string literal comment.
8
+ #Style/FrozenStringLiteralComment:
9
+ # Enabled: false
10
+
11
+ # Removing the preference for string single quotes.
12
+ Style/StringLiterals:
13
+ Enabled: false
14
+
15
+ # Missing top-level module documentation comment.
16
+ Style/Documentation:
17
+ Enabled: false
18
+
19
+ # Prefer reduce over inject.
20
+ Style/CollectionMethods:
21
+ PreferredMethods:
22
+ reduce: 'inject'
23
+
24
+ # Use each_with_object instead of inject.
25
+ Style/EachWithObject:
26
+ Enabled: false
27
+
28
+ # Prefer fail over raise.
29
+ Style/SignalException:
30
+ Enabled: false
31
+
32
+ # This never works for validations.
33
+ Style/AlignHash:
34
+ EnforcedLastArgumentHashStyle: ignore_implicit
35
+
36
+ # Align multi-line params with previous line.
37
+ Style/AlignParameters:
38
+ EnforcedStyle: with_fixed_indentation
39
+
40
+ # Indent `when` clause one step from `case`.
41
+ Style/CaseIndentation:
42
+ IndentOneStep: true
43
+
44
+ # Don't force bad var names for reduce/inject loops.
45
+ Style/SingleLineBlockParams:
46
+ Enabled: false
47
+
48
+ # For method chains, keep the dot with the method name.
49
+ Style/DotPosition:
50
+ EnforcedStyle: leading
51
+
52
+ # Stop nesting so hard.
53
+ Metrics/BlockNesting:
54
+ Max: 2
55
+
56
+ # Encourage short methods.
57
+ Metrics/MethodLength:
58
+ Max: 15
59
+
60
+ # Encourage fewer parameters.
61
+ Metrics/ParameterLists:
62
+ Max: 4
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ inherit_from:
2
+ - .hound.yml
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.14.3
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at jeff.nyman@sproutsocial.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tapestry.gemspec
4
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Jeff Nyman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # Tapestry
2
+
3
+ > _Nature uses only the longest threads to weave her patterns, so that each
4
+ > small piece of her fabric reveals the organization of the entire tapestry._
5
+ >
6
+ >     **Richard Feynman**
7
+
8
+ The Tapestry gem serves as a micro-framework that provides a semantic DSL to construct a fluent interface for test execution libraries.
9
+
10
+ The fluent interface is designed to promote the idea of compressibility of your test logic, allowing for more factoring, more reuse, and less repetition. You can use Tapestry directly as an automated checking library or you can use it with other tools such as RSpec, Cucumber, or anything else that allows you to delegate down to a different level of abstraction.
11
+
12
+ > _There were loose threads ... untidy parts of me that I would like to
13
+ > remove. But when I pulled on one of those threads ... it unraveled the
14
+ > tapestry of my life._
15
+ >
16
+ >     **Captain Jean-Luc Picard, _Star Trek: The Next Generation_ ("Tapestry")**
17
+
18
+ Tapestry is an abstraction layer on top of WebDriver, quite similar to how, say, Express is an abstraction layer on top of Node's built-in HTTP server. Just as you could, in theory, write everything with plain vanilla Node and never touch Express, you could write everything directly at the level of Selenium and never worry about Tapestry.
19
+
20
+ The whole point of an abstraction layer is to smooth out the difficult and/or fiddly bits. As such, Tapestry is actually an abstraction on top of a library called Watir (Web Application Testing in Ruby). Watir itself is an abstraction layer over Selenium which is, in turn, a particular abstraction of WebDriver.
21
+
22
+ > _We look at life from the back side of the tapestry. And most of the time,
23
+ > what we see is loose threads, tangled knots and the like. But occasionally,
24
+ > God's light shines through the tapestry, and we get a glimpse of the larger
25
+ > design with God weaving together the darks and lights of existence._
26
+ >
27
+ >     **John Piper**
28
+
29
+ Tapestry is built, as are all my test-supporting tools, on the idea that automation should largely be small-footprint, low-fiction, high-yield.
30
+
31
+ The code that a test-supporting micro-framework allows should be modular, promoting both high cohesion and low coupling, as well as promoting a single level of abstraction. These concepts together lead to lightweight design as well as support traits that make change affordable. That makes the automation code less expensive to maintain and easier to change. That, ultimately, has a positive impact on the cost of change.
32
+
33
+ ## Installation
34
+
35
+ To get the latest stable release, add this line to your application's Gemfile:
36
+
37
+ ```ruby
38
+ gem 'tapestry'
39
+ ```
40
+
41
+ To get the latest code:
42
+
43
+ ```ruby
44
+ gem 'tapestry', git: 'https://github.com/jeffnyman/tapestry'
45
+ ```
46
+
47
+ After doing one of the above, execute the following command:
48
+
49
+ $ bundle
50
+
51
+ You can also install Tapestry just as you would any other gem:
52
+
53
+ $ gem install tapestry
54
+
55
+ ## Usage
56
+
57
+ Probably the best way to get a feel for the current state of the code is to look at the examples:
58
+
59
+ * [Simple script](https://github.com/jeffnyman/tapestry/blob/master/examples/tapestry-simple.rb)
60
+
61
+ You'll see references to "Veilus" and a "localhost" in the script. I'm using my own [Veilus application](https://veilus.herokuapp.com/). As far as the localhost, you can use the [Veilus repo](https://github.com/jeffnyman/veilus) to get a local copy to play around with.
62
+
63
+ If you clone this repository, you can see this script in action by running the command `rake script:simple`.
64
+
65
+ More details will be forthcoming as the project evolves.
66
+
67
+ ## Development
68
+
69
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake spec:all` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
70
+
71
+ The default `rake` command will run all tests as well as a RuboCop analysis.
72
+
73
+ To install this gem onto your local machine, run `bundle exec rake install`.
74
+
75
+ ## Contributing
76
+
77
+ Bug reports and pull requests are welcome on GitHub at [https://github.com/jeffnyman/tapestry](https://github.com/jeffnyman/tapestry). The testing ecosystem of Ruby is very large and this project is intended to be a welcoming arena for collaboration on yet another test-supporting tool. As such, contributors are very much welcome but are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
78
+
79
+ The Tapestry gems follows [semantic versioning](http://semver.org).
80
+
81
+ To contribute to Tapestry:
82
+
83
+ 1. [Fork the project](http://gun.io/blog/how-to-github-fork-branch-and-pull-request/).
84
+ 2. Create your feature branch. (`git checkout -b my-new-feature`)
85
+ 3. Commit your changes. (`git commit -am 'new feature'`)
86
+ 4. Push the branch. (`git push origin my-new-feature`)
87
+ 5. Create a new [pull request](https://help.github.com/articles/using-pull-requests).
88
+
89
+ ## Author
90
+
91
+ * [Jeff Nyman](http://testerstories.com)
92
+
93
+ ## License
94
+
95
+ Tapestry is distributed under the [MIT](http://www.opensource.org/licenses/MIT) license.
96
+ See the [LICENSE](https://github.com/jeffnyman/tapestry/blob/master/LICENSE.md) file for details.
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require "rdoc/task"
4
+ require "rspec/core/rake_task"
5
+ require "rubocop/rake_task"
6
+
7
+ RuboCop::RakeTask.new
8
+
9
+ RSpec::Core::RakeTask.new(:spec)
10
+
11
+ namespace :script do
12
+ desc "Run the Tapestry simple script"
13
+ task :simple do
14
+ system("ruby ./examples/tapestry-simple.rb")
15
+ end
16
+ end
17
+
18
+ namespace :spec do
19
+ desc 'Clean all generated reports'
20
+ task :clean do
21
+ system('rm -rf spec/reports')
22
+ end
23
+
24
+ RSpec::Core::RakeTask.new(all: :clean) do |config|
25
+ options = %w(--color)
26
+ options += %w(--format documentation)
27
+ options += %w(--format html --out spec/reports/unit-test-report.html)
28
+
29
+ config.rspec_opts = options
30
+ end
31
+ end
32
+
33
+ Rake::RDocTask.new do |rdoc|
34
+ rdoc.rdoc_dir = 'doc'
35
+ rdoc.main = 'README.md'
36
+ rdoc.title = "Tapestry #{Tapestry::VERSION}"
37
+ rdoc.rdoc_files.include('README*', 'lib/**/*.rb')
38
+ end
39
+
40
+ task default: ['spec:all', :rubocop]
data/bin/console ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tapestry"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ require "pry"
10
+ Pry.start
11
+
12
+ # require "irb"
13
+ # IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+ $: << "./lib"
3
+
4
+ require "rspec"
5
+ include RSpec::Matchers
6
+
7
+ require "tapestry"
8
+
9
+ puts Tapestry::VERSION
10
+
11
+ browser = Watir::Browser.new
12
+
13
+ class Home
14
+ include Tapestry
15
+
16
+ p :login_form, id: "open", visible: true
17
+ text_field :username, id: "username"
18
+ text_field :password
19
+ button :login, id: "login-button"
20
+
21
+ #element :login_form, id: "open", visible: true
22
+ #element :username, id: "username"
23
+ #element :password
24
+ #element :login, id: "login-button"
25
+ end
26
+
27
+ browser.goto("http://localhost:9292")
28
+ page = Home.new(browser)
29
+ page.login_form.click
30
+ page.username.set "admin"
31
+ page.password(id: 'password').set "admin"
32
+ page.login.click
33
+
34
+ browser.quit()
@@ -0,0 +1,213 @@
1
+ require "watir"
2
+
3
+ module Tapestry
4
+ module_function
5
+
6
+ NATIVE_QUALIFIERS = %i(visible).freeze
7
+
8
+ def elements
9
+ @elements = Watir::Container.instance_methods unless @elements
10
+ end
11
+
12
+ module Element
13
+ # This iterator goes through the Watir container methods and
14
+ # provides a method for each so that Watir-based element names
15
+ # cane be defined on an interface definition, as part of an
16
+ # element definition.
17
+ Tapestry.elements.each do |element|
18
+ define_method(element) do |*signature, &block|
19
+ puts "(1) signature: #{signature}"
20
+ identifier, signature = parse_signature(signature)
21
+ puts "(2) identifier: #{identifier}"
22
+ puts "(3) signature: #{signature}"
23
+ define_element_accessor(identifier, signature, element, &block)
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ # A "signature" consists of a full element definition. For example:
30
+ #
31
+ # text_field :username, id: 'username'
32
+ #
33
+ # The signature of this element definition is:
34
+ #
35
+ # [:username, {:id=>"username"}]
36
+ #
37
+ # This is the identifier of the element (`username`) and the locator
38
+ # provided for it. This method separates out the identifier and the
39
+ # locator.
40
+ def parse_signature(signature)
41
+ [signature.shift, signature.shift]
42
+ end
43
+
44
+ # This method provides the means to get the aspects of an accessor
45
+ # signature. The "aspects" refer to the locator information and any
46
+ # qualifier information that was provided along with the locator.
47
+ # This is important because the qualifier is not used to locate an
48
+ # element but rather to put conditions on how the state of the
49
+ # element is checked as it is being looked for.
50
+ #
51
+ # Note that "qualifiers" here refers to Watir boolean methods.
52
+ def accessor_aspects(element, *signature)
53
+ identifier = signature.shift
54
+ puts "(4) identifier: #{identifier}"
55
+ locator_args = {}
56
+ qualifier_args = {}
57
+ gather_aspects(identifier, element, locator_args, qualifier_args)
58
+ puts "(5) QUAL/LOC: #{[locator_args, qualifier_args]}"
59
+ [locator_args, qualifier_args]
60
+ end
61
+
62
+ # This method is used to separate the two aspects of an accessor --
63
+ # the locators and the qualifiers. Part of this process involves
64
+ # querying the Watir driver library to determine what qualifiers
65
+ # it handles natively. Consider the following:
66
+ #
67
+ # select_list :accounts, id: 'accounts', selected: 'Select Option'
68
+ #
69
+ # Given that, this method will return with the following:
70
+ #
71
+ # locator_args: {:id=>"accounts"}
72
+ # qualifier_args: {:selected=>"Select Option"}
73
+ #
74
+ # Consider this:
75
+ #
76
+ # p :login_form, id: 'open', index: 0, visible: true
77
+ #
78
+ # Given that, this method will return with the following:
79
+ #
80
+ # locator_args: {:id=>"open", :index=>0, :visible=>true}
81
+ # qualifier_args: {}
82
+ #
83
+ # Notice that the `visible` qualifier is part of the locator arguments
84
+ # as opposed to being a qualifier argument, like `selected` was in the
85
+ # previous example. This is because Watir 6.x handles the `visible`
86
+ # qualifier natively. "Handling natively" means that when a qualifier
87
+ # is part of the locator, Watir knows how to intrpret the qualifier
88
+ # as a condition on the element, not as a way to locate the element.
89
+ def gather_aspects(identifier, element, locator_args, qualifier_args)
90
+ identifier.each_with_index do |hashes, index|
91
+ next if hashes.nil? || hashes.is_a?(Proc)
92
+ hashes.each do |k, v|
93
+ methods = Watir.element_class_for(element).instance_methods
94
+ if methods.include?(:"#{k}?") && !NATIVE_QUALIFIERS.include?(k)
95
+ qualifier_args[k] = identifier[index][k]
96
+ else
97
+ locator_args[k] = v
98
+ end
99
+ end
100
+ end
101
+ [locator_args, qualifier_args]
102
+ end
103
+
104
+ # Defines an accessor method for an element that allows the "friendly
105
+ # name" (identifier) of the element to be proxied to a Watir element
106
+ # object that corresponds to the element type. When this identifier
107
+ # is referenced, it generates an accessor method for that element
108
+ # in the browser. Consider this element definition defined on a class
109
+ # with an instance of `page`:
110
+ #
111
+ # text_field :username, id: 'username'
112
+ #
113
+ # This allows:
114
+ #
115
+ # page.username.set 'tester'
116
+ #
117
+ # So any element identifier can be called as if it were a method on
118
+ # the interface (class) on which it is defined. Because the method
119
+ # is proxied to Watir, you can use the full Watir API by calling
120
+ # methods (like `set`, `click`, etc) on the element identifier.
121
+ #
122
+ # It is also possible to have an element definition like this:
123
+ #
124
+ # text_field :password
125
+ #
126
+ # This would allow access like this:
127
+ #
128
+ # page.username(id: 'username').set 'tester'
129
+ #
130
+ # This approach would lead to the *values variable having an array
131
+ # like this: [{:id => 'username'}].
132
+ #
133
+ # A third approach would be to utilize one element definition within
134
+ # the context of another. Consider the following element definitions:
135
+ #
136
+ # article :practice, id: 'practice'
137
+ #
138
+ # a :page_link do |text|
139
+ # practice.a(text: text)
140
+ # end
141
+ #
142
+ # This would allow access like this:
143
+ #
144
+ # page.page_link('Drag and Drop').click
145
+ #
146
+ # This approach would lead to the *values variable having an array
147
+ # like this: ["Drag and Drop"].
148
+ def define_element_accessor(identifier, *signature, element, &block)
149
+ locators, qualifiers = accessor_aspects(element, signature)
150
+ puts "(6) locators: #{locators}"
151
+ puts "(7) qualifiers: #{qualifiers}"
152
+ define_method(identifier.to_s) do |*values|
153
+ if block_given?
154
+ instance_exec(*values, &block)
155
+ else
156
+ puts "(8) values: #{values}"
157
+ locators = values[0] if locators.empty?
158
+ puts "(9) locators: #{locators} | empty? #{locators.empty?}"
159
+ access_element(element, locators, qualifiers)
160
+ end
161
+ end
162
+ end
163
+ end
164
+
165
+ module Locator
166
+ private
167
+
168
+ # This method is what actually calls the browser instance to find
169
+ # an element. If there is an element definition like this:
170
+ #
171
+ # text_field :username, id: 'username'
172
+ #
173
+ # This will become the following:
174
+ #
175
+ # browser.text_field(id: 'username')
176
+ #
177
+ # Note that the `to_subtype` method is called, which allows for the
178
+ # generic `element` to be expressed as the type of element, as opposed
179
+ # to `text_field` or `select_list`. For example, an `element` may be
180
+ # defined like this:
181
+ #
182
+ # element :enable, id: 'enableForm'
183
+ #
184
+ # Which means it would look like this:
185
+ #
186
+ # Watir::HTMLElement:0x1c8c9 selector={:id=>"enableForm"}
187
+ #
188
+ # Whereas getting the subtype would give you:
189
+ #
190
+ # Watir::CheckBox:0x12f8b elector={element: (webdriver element)}
191
+ #
192
+ # Which is what you would get if the element definition were this:
193
+ #
194
+ # checkbox :enable, id: 'enableForm'
195
+ #
196
+ # Using the subtype does get tricky for scripts that require the
197
+ # built-in sychronization aspects and wait states of Watir.
198
+ #
199
+ # The approach being used in this method is necessary to allow actions
200
+ # like `set`, which are not available on `element`, even though other
201
+ # actions, like `click`, are. But if you use `element` for your element
202
+ # definitions, and your script requires a series of actions where elements
203
+ # may be delayed in appearing, you'll get an "unable to locate element"
204
+ # message, along with a Watir::Exception::UnknownObjectException.
205
+ def access_element(element, locators, _qualifiers)
206
+ if element == "element".to_sym
207
+ @browser.element(locators).to_subtype
208
+ else
209
+ @browser.__send__(element, locators)
210
+ end
211
+ end
212
+ end
213
+ end
@@ -0,0 +1,3 @@
1
+ module Tapestry
2
+ VERSION = "0.1.0".freeze
3
+ end
data/lib/tapestry.rb ADDED
@@ -0,0 +1,15 @@
1
+ require "tapestry/version"
2
+ require "tapestry/element"
3
+
4
+ require "watir"
5
+
6
+ module Tapestry
7
+ def self.included(caller)
8
+ caller.extend Tapestry::Element
9
+ caller.__send__ :include, Tapestry::Locator
10
+ end
11
+
12
+ def initialize(browser)
13
+ @browser = browser
14
+ end
15
+ end
data/tapestry.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tapestry/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tapestry"
8
+ spec.version = Tapestry::VERSION
9
+ spec.authors = ["Jeff Nyman"]
10
+ spec.email = ["jeffnyman@gmail.com"]
11
+
12
+ spec.summary = %q{Weaving a semantic DSL to construct fluent interfaces for test execution logic.}
13
+ spec.description = %q{Weaving a semantic DSL to construct fluent interfaces for test execution logic.}
14
+ spec.homepage = "https://github.com/jeffnyman/tapestry"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.14"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "rubocop"
28
+ spec.add_development_dependency "pry"
29
+
30
+ spec.add_runtime_dependency "watir", "~> 6.0"
31
+
32
+ spec.post_install_message = %{
33
+ (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
34
+ Tapestry #{Tapestry::VERSION} has been installed.
35
+ (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
36
+ }
37
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tapestry
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jeff Nyman
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-01-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: watir
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '6.0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '6.0'
97
+ description: Weaving a semantic DSL to construct fluent interfaces for test execution
98
+ logic.
99
+ email:
100
+ - jeffnyman@gmail.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".hound.yml"
107
+ - ".rspec"
108
+ - ".rubocop.yml"
109
+ - ".travis.yml"
110
+ - CODE_OF_CONDUCT.md
111
+ - Gemfile
112
+ - LICENSE.md
113
+ - README.md
114
+ - Rakefile
115
+ - bin/console
116
+ - bin/setup
117
+ - examples/tapestry-simple.rb
118
+ - lib/tapestry.rb
119
+ - lib/tapestry/element.rb
120
+ - lib/tapestry/version.rb
121
+ - tapestry.gemspec
122
+ homepage: https://github.com/jeffnyman/tapestry
123
+ licenses:
124
+ - MIT
125
+ metadata: {}
126
+ post_install_message: "\n(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)\n
127
+ \ Tapestry 0.1.0 has been installed.\n(::) (::) (::) (::) (::) (::) (::) (::) (::)
128
+ (::) (::) (::)\n "
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubyforge_project:
144
+ rubygems_version: 2.6.10
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: Weaving a semantic DSL to construct fluent interfaces for test execution
148
+ logic.
149
+ test_files: []