empiric 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: e8bc32770fd8f31266ed3374e5e1699add29726e
4
+ data.tar.gz: 7592483316917b70a5c25481944b8439c6f12665
5
+ SHA512:
6
+ metadata.gz: 13f4b280d4b03a33da549b6a0ea08b2be92fc254c68bae2cb01d58077d9591ea40766419b07316dbfc5241af9f6f880473a0a7a560d5972bca3afe09b056656b
7
+ data.tar.gz: ba6758770cdfca6317f0ae9f791a7669b429c76e78d501ab3df85209b9900ae177827fa0a61a3df059d3862afd9600a8450334d6b9ae903e45d8f4c93278562f
data/.gitignore ADDED
@@ -0,0 +1,40 @@
1
+ # Ruby-Specific
2
+
3
+ /.bundle/
4
+ /.yardoc
5
+ /Gemfile.lock
6
+ /_yardoc/
7
+
8
+ # Ouput-Specific
9
+
10
+ /coverage/
11
+ /doc/
12
+ /pkg/
13
+ /spec/reports/
14
+ /tmp/
15
+ *.log
16
+ *.tmp
17
+ *.swp
18
+ *.bak
19
+
20
+ # IDE-Specific
21
+
22
+ .idea
23
+ .settings
24
+ .project
25
+ .classpath
26
+ *.iws
27
+
28
+ # Windows-Specific
29
+
30
+ Thumbs.db
31
+
32
+ # Mac OS-Specific
33
+
34
+ *.DS_Store
35
+ ._*
36
+
37
+ # Linux-Specific
38
+
39
+ .directory
40
+ .Trash-*
data/.hound.yml ADDED
@@ -0,0 +1,68 @@
1
+ AllCops:
2
+ Exclude:
3
+ - empiric.gemspec
4
+ - test/*.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
+ # Allows has_ so RSpec predicate handling occurs.
53
+ Style/PredicateName:
54
+ NameWhitelist:
55
+ - has_correct_url?
56
+ - has_correct_title?
57
+
58
+ # Stop nesting so hard.
59
+ Metrics/BlockNesting:
60
+ Max: 2
61
+
62
+ # Encourage short methods.
63
+ Metrics/MethodLength:
64
+ Max: 10
65
+
66
+ # Encourage fewer parameters.
67
+ Metrics/ParameterLists:
68
+ Max: 4
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
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.13.6
@@ -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 jeffnyman@gmail.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 empiric.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 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,64 @@
1
+ # Empiric
2
+
3
+ Empiric provides a semantic DSL to construct a fluent interface for test execution libraries.
4
+
5
+ This fluent interface promotes the idea of compressibility of your test logic, allowing for more factoring, more reuse, and less repetition. You can use Symbiote directly as an automated test 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.
6
+
7
+ Note that Empiric is currently being put together as part of a series of classes I am teaching on micro-framework construction for modern testing practices.
8
+
9
+ ## Installation
10
+
11
+ To get the latest stable release, add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'empiric'
15
+ ```
16
+
17
+ To get the latest code:
18
+
19
+ ```ruby
20
+ gem 'empiric', git: 'https://github.com/jeffnyman/empiric'
21
+ ```
22
+
23
+ After doing one of the above, execute the following command:
24
+
25
+ $ bundle
26
+
27
+ You can also install Empiric just as you would any other gem:
28
+
29
+ $ gem install empiric
30
+
31
+ ## Usage
32
+
33
+ Probably the best way to get a feel for the current state of the code is to look at the [Empiric test script](https://github.com/jeffnyman/empiric/blob/master/test/empiric-script.rb). If you clone the repository, you can see this script in action by running the command `rake scripts:simple`.
34
+
35
+ More details will be forthcoming as the project evolves.
36
+
37
+ ## Development
38
+
39
+ 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.
40
+
41
+ The default `rake` command will run all tests as well as a RuboCop analysis.
42
+
43
+ To install this gem onto your local machine, run `bundle exec rake install`.
44
+
45
+ ## Contributing
46
+
47
+ Bug reports and pull requests are welcome on GitHub at [https://github.com/jeffnyman/empiric](https://github.com/jeffnyman/empiric). The testing ecosystem of Ruby is very large and this project is intended to be a welcoming arena for collaboration on yet another testing tool. As such, contributors are very much welcome but are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
48
+
49
+ To contribute to Empiric:
50
+
51
+ 1. [Fork the project](http://gun.io/blog/how-to-github-fork-branch-and-pull-request/).
52
+ 2. Create your feature branch. (`git checkout -b my-new-feature`)
53
+ 3. Commit your changes. (`git commit -am 'new feature'`)
54
+ 4. Push the branch. (`git push origin my-new-feature`)
55
+ 5. Create a new [pull request](https://help.github.com/articles/using-pull-requests).
56
+
57
+ ## Author
58
+
59
+ * [Jeff Nyman](http://testerstories.com)
60
+
61
+ ## License
62
+
63
+ Empiric is distributed under the [MIT](http://www.opensource.org/licenses/MIT) license.
64
+ See the [LICENSE](https://github.com/jeffnyman/empiric/blob/master/LICENSE.txt) file for details.
data/Rakefile ADDED
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rdoc/task"
5
+ require "rubocop/rake_task"
6
+ require "rspec/core/rake_task"
7
+
8
+ RuboCop::RakeTask.new
9
+
10
+ namespace :scripts do
11
+ desc "Run the Empiric script."
12
+ task :simple do
13
+ system("ruby ./test/empiric-script.rb")
14
+ end
15
+ end
16
+
17
+ namespace :spec do
18
+ desc "Clean all generated reports."
19
+ task :clean do
20
+ system('rm -rf spec/reports')
21
+ end
22
+
23
+ RSpec::Core::RakeTask.new(all: :clean) do |config|
24
+ options = %w(--color)
25
+ options += %w(--format documentation)
26
+ options += %w(--format html --out spec/reports/unit-test-report.html)
27
+
28
+ config.rspec_opts = options
29
+ end
30
+ end
31
+
32
+ Rake::RDocTask.new do |rdoc|
33
+ rdoc.rdoc_dir = 'doc'
34
+ rdoc.main = 'README.md'
35
+ rdoc.title = "Empiric #{Empiric::VERSION}"
36
+ rdoc.rdoc_files.include('README*', 'lib/**/*.rb')
37
+ end
38
+
39
+ 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 "empiric"
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
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
data/empiric.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 "empiric/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "empiric"
8
+ spec.version = Empiric::VERSION
9
+ spec.authors = ["Jeff Nyman"]
10
+ spec.email = ["jeffnyman@gmail.com"]
11
+
12
+ spec.summary = %q{Provides a semantic DSL to construct fluent interfaces for test execution logic.}
13
+ spec.description = %q{Provides a semantic DSL to construct fluent interfaces for test execution logic.}
14
+ spec.homepage = "https://github.com/jeffnyman/empiric"
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.13"
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"
31
+
32
+ spec.post_install_message = %{
33
+ (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
34
+ Empric #{Empiric::VERSION} has been installed.
35
+ (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
36
+ }
37
+ end
data/lib/empiric.rb ADDED
@@ -0,0 +1,33 @@
1
+ require "empiric/version"
2
+ require "empiric/interface"
3
+
4
+ require "watir-webdriver"
5
+
6
+ module Empiric
7
+ module_function
8
+
9
+ attr_accessor :browser
10
+
11
+ def included(caller)
12
+ caller.__send__ :include, Empiric::Interface::Page
13
+ end
14
+
15
+ def initialize(browser = nil)
16
+ @browser = Empiric.browser unless Empiric.browser.nil?
17
+ @browser = browser if Empiric.browser.nil?
18
+ Empiric.browser = browser if Empiric.browser.nil?
19
+ end
20
+
21
+ def set_browser(app = :chrome, *args)
22
+ @browser = Watir::Browser.new(app, *args)
23
+ Empiric.browser = @browser
24
+ end
25
+
26
+ def browser=(browser)
27
+ @browser = browser
28
+ end
29
+
30
+ def browser
31
+ @browser
32
+ end
33
+ end
@@ -0,0 +1,16 @@
1
+ module Empiric
2
+ module Interface
3
+ module Page
4
+ def resize(width, height)
5
+ browser.window.resize_to(width, height)
6
+ end
7
+
8
+ def position(x, y)
9
+ browser.window.move_to(x, y)
10
+ end
11
+
12
+ alias resize_to resize
13
+ alias move_to position
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ module Empiric
2
+ VERSION = "0.1.0".freeze
3
+
4
+ module_function
5
+
6
+ def version
7
+ """
8
+ Empiric v#{Empiric::VERSION}
9
+ watir-webdriver: #{Gem.loaded_specs['watir-webdriver'].version}
10
+ selenium-webdriver: #{Gem.loaded_specs['selenium-webdriver'].version}
11
+ """
12
+ end
13
+
14
+ def dependencies
15
+ puts Gem.loaded_specs.values.map { |x| "#{x.name} #{x.version}\n" }
16
+ .uniq.sort.join(",").split(",")
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: empiric
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: 2016-11-04 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.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
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: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Provides 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.txt
113
+ - README.md
114
+ - Rakefile
115
+ - bin/console
116
+ - bin/setup
117
+ - empiric.gemspec
118
+ - lib/empiric.rb
119
+ - lib/empiric/interface.rb
120
+ - lib/empiric/version.rb
121
+ homepage: https://github.com/jeffnyman/empiric
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
125
+ post_install_message: "\n(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)\n
126
+ \ Empric 0.1.0 has been installed.\n(::) (::) (::) (::) (::) (::) (::) (::) (::)
127
+ (::) (::) (::)\n "
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubyforge_project:
143
+ rubygems_version: 2.5.1
144
+ signing_key:
145
+ specification_version: 4
146
+ summary: Provides a semantic DSL to construct fluent interfaces for test execution
147
+ logic.
148
+ test_files: []