page_magic 1.2.9 → 2.0.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +3 -3
  3. data/.simplecov +4 -2
  4. data/.zsh_config +6 -0
  5. data/Dockerfile +10 -0
  6. data/Gemfile +10 -11
  7. data/Gemfile.lock +120 -133
  8. data/Makefile +13 -0
  9. data/Rakefile +3 -1
  10. data/VERSION +1 -1
  11. data/lib/page_magic.rb +5 -3
  12. data/lib/page_magic/class_methods.rb +4 -1
  13. data/lib/page_magic/driver.rb +3 -0
  14. data/lib/page_magic/drivers.rb +3 -1
  15. data/lib/page_magic/drivers/poltergeist.rb +2 -0
  16. data/lib/page_magic/drivers/rack_test.rb +3 -1
  17. data/lib/page_magic/drivers/selenium.rb +4 -2
  18. data/lib/page_magic/element.rb +8 -5
  19. data/lib/page_magic/element/locators.rb +4 -1
  20. data/lib/page_magic/element/query.rb +11 -2
  21. data/lib/page_magic/element/query_builder.rb +15 -2
  22. data/lib/page_magic/element/selector.rb +3 -0
  23. data/lib/page_magic/element/selector_methods.rb +3 -0
  24. data/lib/page_magic/element_context.rb +2 -0
  25. data/lib/page_magic/element_definition_builder.rb +4 -1
  26. data/lib/page_magic/elements.rb +42 -6
  27. data/lib/page_magic/exceptions.rb +3 -1
  28. data/lib/page_magic/instance_methods.rb +2 -0
  29. data/lib/page_magic/matcher.rb +10 -1
  30. data/lib/page_magic/session.rb +7 -5
  31. data/lib/page_magic/session_methods.rb +2 -0
  32. data/lib/page_magic/utils/string.rb +2 -0
  33. data/lib/page_magic/wait_methods.rb +3 -0
  34. data/lib/page_magic/watcher.rb +2 -0
  35. data/lib/page_magic/watchers.rb +4 -1
  36. data/spec/element_spec.rb +2 -0
  37. data/spec/page_magic/class_methods_spec.rb +2 -0
  38. data/spec/page_magic/driver_spec.rb +2 -0
  39. data/spec/page_magic/drivers/poltergeist_spec.rb +2 -0
  40. data/spec/page_magic/drivers/rack_test_spec.rb +2 -0
  41. data/spec/page_magic/drivers/selenium_spec.rb +2 -0
  42. data/spec/page_magic/drivers_spec.rb +2 -0
  43. data/spec/page_magic/element/locators_spec.rb +2 -0
  44. data/spec/page_magic/element/query_builder_spec.rb +7 -5
  45. data/spec/page_magic/element/query_spec.rb +6 -4
  46. data/spec/page_magic/element/selector_spec.rb +7 -5
  47. data/spec/page_magic/element_context_spec.rb +3 -1
  48. data/spec/page_magic/element_definition_builder_spec.rb +2 -0
  49. data/spec/page_magic/elements_spec.rb +9 -0
  50. data/spec/page_magic/instance_methods_spec.rb +2 -0
  51. data/spec/page_magic/matcher_spec.rb +3 -1
  52. data/spec/page_magic/session_methods_spec.rb +2 -0
  53. data/spec/page_magic/session_spec.rb +1 -1
  54. data/spec/page_magic/utils/string_spec.rb +2 -0
  55. data/spec/page_magic/wait_methods_spec.rb +5 -3
  56. data/spec/page_magic/watchers_spec.rb +2 -0
  57. data/spec/page_magic_spec.rb +5 -7
  58. data/spec/spec_helper.rb +3 -0
  59. data/spec/support/shared_contexts.rb +3 -1
  60. data/spec/support/shared_contexts/files_context.rb +2 -0
  61. data/spec/support/shared_contexts/nested_elements_html_context.rb +2 -0
  62. data/spec/support/shared_contexts/rack_application_context.rb +2 -0
  63. data/spec/support/shared_contexts/webapp_fixture_context.rb +2 -0
  64. data/spec/support/shared_examples.rb +2 -0
  65. data/spec/watcher_spec.rb +3 -0
  66. metadata +45 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: cdfe7b7eb4aa09e8eab7a961a1b03156f4650af8
4
- data.tar.gz: faaf84a4ff0c42dffa54b405bfbcb31812a3be6e
2
+ SHA256:
3
+ metadata.gz: 4eec3ec93f7cd6ba430ba78860160822632cdc8949da2aea83afddc3366ea3d3
4
+ data.tar.gz: e3b3634979f0499bd0db1012a209a2d12cce94b7c0b870b1e91d3f8048e3f92b
5
5
  SHA512:
6
- metadata.gz: 352cdaa5d434b979ec5061193e9864f7fcb1b2d3418a4de064be94fef99ce71288da4421c4cfaceb1079fc0349e4b7c1ab4852c91c0f626bc9c7922f20f80b55
7
- data.tar.gz: 1b22dfc283761f9ded938a899d115b7ffb3b07c96e58736879f33161621b6ccfb1510d0f1886bec75e30a95d1d5c4656613fc9671c9cc79a23e2d0d5f21cca69
6
+ metadata.gz: afe8591e16f7afaa2e464b48ac9eabff046a140df8558dee5bb51aa3eac0ccb43c43cbb43eb7af9d7a2529f242f1cc87b7f63160c5c70decb3bbc9d2cd8d060a
7
+ data.tar.gz: 95802bd6ab8e1acca9f0d8142452469a743177cdbbf3a44e679016960a23bfe56b453ad53db758bd9ce9edc82f388f90a03c72f76341c24ff517995678e9f2eb
data/.rubocop.yml CHANGED
@@ -2,7 +2,7 @@ Metrics/LineLength:
2
2
  Max: 120
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.1
5
+ TargetRubyVersion: 2.7
6
6
  Exclude:
7
7
  - 'lib/active_support/**/*'
8
8
  - 'spec/lib/active_support/**/*'
@@ -18,8 +18,8 @@ Metrics/ParameterLists:
18
18
  Metrics/MethodLength:
19
19
  Max: 11
20
20
 
21
- Style/MethodMissing:
22
- Enabled: false
21
+ #Style/MethodMissing:
22
+ # Enabled: false
23
23
 
24
24
  Metrics/BlockLength:
25
25
  Enabled: true
data/.simplecov CHANGED
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pullreview/coverage'
2
4
 
3
- SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter,PullReview::Coverage::Formatter]
5
+ SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter, PullReview::Coverage::Formatter]
4
6
 
5
7
  SimpleCov.start do
6
8
  add_filter '/spec/'
7
9
  add_filter '/lib/active_support/core_ext/object/to_query.rb'
8
- end
10
+ end
data/.zsh_config ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ #alias bundle="docker run -v ${HOME}/.gitconfig:/root/.gitconfig -v $(pwd):/page_magic -t lvl-up/page-magic bundle"
3
+ #alias ruby="bundle exec ruby"
4
+ #alias rake="bundle exec rake"
5
+ #alias rubocop="bundle exec rubocop"
6
+ #alias gem="docker run -v $(pwd):/page_magic -t lvl-up/page-magic gem"
data/Dockerfile ADDED
@@ -0,0 +1,10 @@
1
+ FROM ruby:2.7.2-alpine
2
+
3
+ ENV APP_HOME /page_magic
4
+ RUN mkdir $APP_HOME
5
+
6
+ COPY . $APP_HOME
7
+ WORKDIR $APP_HOME
8
+
9
+ RUN apk --update --no-cache add build-base git
10
+ RUN bundle install
data/Gemfile CHANGED
@@ -1,24 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
- gem 'activesupport-inflector'
4
- gem 'capybara', '>= 2.5'
5
+ gem 'activesupport'
6
+ gem 'capybara', ">=3.0"
5
7
 
6
8
  group :test do
7
- gem 'arbre'
8
- gem 'codeclimate-test-reporter', group: :test, require: nil
9
9
  gem 'poltergeist'
10
- gem 'pullreview-coverage', require: false
11
- gem 'reek'
12
10
  gem 'rspec', require: 'rspec/core/rake_task'
13
11
  gem 'simplecov', require: false
14
12
  gem 'sinatra'
15
- gem 'watir-webdriver'
13
+ gem 'watir'
16
14
  end
17
15
 
18
16
  group :development do
19
- gem 'github-markup', '~> 1.4'
20
- gem 'jeweler', '~> 2.0'
21
- gem 'redcarpet', '~> 3.3'
22
- gem 'rubocop', '~> 0.34', require: 'rubocop/rake_task'
17
+ gem 'github-markup'
18
+ gem 'jeweler'
19
+ gem 'redcarpet'
20
+ gem 'rubocop', require: 'rubocop/rake_task'
21
+ gem 'ruby-debug-ide', require: false
23
22
  gem 'yard', '~> 0.8'
24
23
  end
data/Gemfile.lock CHANGED
@@ -1,48 +1,35 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- activesupport (4.2.10)
5
- i18n (~> 0.7)
6
- minitest (~> 5.1)
7
- thread_safe (~> 0.3, >= 0.3.4)
8
- tzinfo (~> 1.1)
9
- activesupport-inflector (0.1.0)
4
+ activesupport (6.1.3.1)
5
+ concurrent-ruby (~> 1.0, >= 1.0.2)
6
+ i18n (>= 1.6, < 2)
7
+ minitest (>= 5.1)
8
+ tzinfo (~> 2.0)
9
+ zeitwerk (~> 2.3)
10
10
  addressable (2.4.0)
11
- arbre (1.1.1)
12
- activesupport (>= 3.0.0)
13
- ast (2.3.0)
14
- axiom-types (0.1.1)
15
- descendants_tracker (~> 0.0.4)
16
- ice_nine (~> 0.11.0)
17
- thread_safe (~> 0.3, >= 0.3.1)
18
- builder (3.2.3)
19
- capybara (2.15.2)
11
+ ast (2.4.2)
12
+ builder (3.2.4)
13
+ capybara (3.35.3)
20
14
  addressable
21
15
  mini_mime (>= 0.1.3)
22
- nokogiri (>= 1.3.3)
23
- rack (>= 1.0.0)
24
- rack-test (>= 0.5.4)
25
- xpath (~> 2.0)
26
- certifi (2017.07.27)
27
- childprocess (0.8.0)
28
- ffi (~> 1.0, >= 1.0.11)
16
+ nokogiri (~> 1.8)
17
+ rack (>= 1.6.0)
18
+ rack-test (>= 0.6.3)
19
+ regexp_parser (>= 1.5, < 3.0)
20
+ xpath (~> 3.2)
21
+ childprocess (3.0.0)
29
22
  cliver (0.3.2)
30
- codeclimate-engine-rb (0.4.0)
31
- virtus (~> 1.0)
32
- codeclimate-test-reporter (1.0.8)
33
- simplecov (<= 0.13)
34
- coercible (1.0.0)
35
- descendants_tracker (~> 0.0.1)
23
+ concurrent-ruby (1.1.8)
36
24
  descendants_tracker (0.0.4)
37
25
  thread_safe (~> 0.3, >= 0.3.1)
38
- diff-lcs (1.3)
39
- docile (1.1.5)
40
- equalizer (0.0.11)
26
+ diff-lcs (1.4.4)
27
+ docile (1.3.5)
41
28
  faraday (0.9.2)
42
29
  multipart-post (>= 1.2, < 3)
43
- ffi (1.9.18)
44
- git (1.3.0)
45
- github-markup (1.6.1)
30
+ git (1.8.1)
31
+ rchardet (~> 1.8)
32
+ github-markup (4.0.0)
46
33
  github_api (0.16.0)
47
34
  addressable (~> 2.4.0)
48
35
  descendants_tracker (~> 0.0.4)
@@ -50,138 +37,138 @@ GEM
50
37
  hashie (>= 3.4)
51
38
  mime-types (>= 1.16, < 3.0)
52
39
  oauth2 (~> 1.0)
53
- hashie (3.5.6)
54
- highline (1.7.8)
55
- i18n (0.8.6)
56
- ice_nine (0.11.2)
57
- jeweler (2.3.7)
40
+ hashie (4.1.0)
41
+ highline (2.0.3)
42
+ i18n (1.8.10)
43
+ concurrent-ruby (~> 1.0)
44
+ jeweler (2.3.9)
58
45
  builder
59
- bundler (>= 1)
46
+ bundler
60
47
  git (>= 1.2.5)
61
48
  github_api (~> 0.16.0)
62
49
  highline (>= 1.6.15)
63
50
  nokogiri (>= 1.5.10)
64
- psych (~> 2.2)
51
+ psych
65
52
  rake
66
53
  rdoc
67
54
  semver2
68
- json (2.1.0)
69
- jwt (1.5.6)
55
+ jwt (2.2.2)
70
56
  mime-types (2.99.3)
71
- mini_mime (0.1.4)
72
- mini_portile2 (2.3.0)
73
- minitest (5.10.3)
74
- multi_json (1.12.2)
57
+ mini_mime (1.1.0)
58
+ mini_portile2 (2.5.0)
59
+ minitest (5.14.4)
60
+ multi_json (1.15.0)
75
61
  multi_xml (0.6.0)
76
- multipart-post (2.0.0)
77
- nokogiri (1.8.1)
78
- mini_portile2 (~> 2.3.0)
79
- oauth2 (1.4.0)
80
- faraday (>= 0.8, < 0.13)
81
- jwt (~> 1.0)
62
+ multipart-post (2.1.1)
63
+ mustermann (1.1.1)
64
+ ruby2_keywords (~> 0.0.1)
65
+ nokogiri (1.11.3)
66
+ mini_portile2 (~> 2.5.0)
67
+ racc (~> 1.4)
68
+ oauth2 (1.4.7)
69
+ faraday (>= 0.8, < 2.0)
70
+ jwt (>= 1.0, < 3.0)
82
71
  multi_json (~> 1.3)
83
72
  multi_xml (~> 0.5)
84
73
  rack (>= 1.2, < 3)
85
- parallel (1.12.0)
86
- parser (2.4.0.0)
87
- ast (~> 2.2)
88
- poltergeist (1.16.0)
89
- capybara (~> 2.1)
74
+ parallel (1.20.1)
75
+ parser (3.0.1.0)
76
+ ast (~> 2.4.1)
77
+ poltergeist (1.18.1)
78
+ capybara (>= 2.1, < 4)
90
79
  cliver (~> 0.3.1)
91
80
  websocket-driver (>= 0.2.0)
92
- powerpack (0.1.1)
93
- psych (2.2.4)
94
- pullreview-coverage (0.0.5)
95
- certifi
96
- simplecov (>= 0.7.1, < 1.0.0)
97
- rack (1.6.8)
98
- rack-protection (1.5.3)
81
+ psych (3.3.1)
82
+ racc (1.5.2)
83
+ rack (2.2.3)
84
+ rack-protection (2.1.0)
99
85
  rack
100
- rack-test (0.7.0)
86
+ rack-test (1.1.0)
101
87
  rack (>= 1.0, < 3)
102
- rainbow (2.2.2)
103
- rake
104
- rake (12.1.0)
105
- rdoc (5.1.0)
106
- redcarpet (3.4.0)
107
- reek (4.7.2)
108
- codeclimate-engine-rb (~> 0.4.0)
109
- parser (>= 2.4.0.0, < 2.5)
110
- rainbow (~> 2.0)
111
- rspec (3.6.0)
112
- rspec-core (~> 3.6.0)
113
- rspec-expectations (~> 3.6.0)
114
- rspec-mocks (~> 3.6.0)
115
- rspec-core (3.6.0)
116
- rspec-support (~> 3.6.0)
117
- rspec-expectations (3.6.0)
88
+ rainbow (3.0.0)
89
+ rake (13.0.3)
90
+ rchardet (1.8.0)
91
+ rdoc (6.3.0)
92
+ redcarpet (3.5.1)
93
+ regexp_parser (2.1.1)
94
+ rexml (3.2.5)
95
+ rspec (3.10.0)
96
+ rspec-core (~> 3.10.0)
97
+ rspec-expectations (~> 3.10.0)
98
+ rspec-mocks (~> 3.10.0)
99
+ rspec-core (3.10.1)
100
+ rspec-support (~> 3.10.0)
101
+ rspec-expectations (3.10.1)
118
102
  diff-lcs (>= 1.2.0, < 2.0)
119
- rspec-support (~> 3.6.0)
120
- rspec-mocks (3.6.0)
103
+ rspec-support (~> 3.10.0)
104
+ rspec-mocks (3.10.2)
121
105
  diff-lcs (>= 1.2.0, < 2.0)
122
- rspec-support (~> 3.6.0)
123
- rspec-support (3.6.0)
124
- rubocop (0.50.0)
106
+ rspec-support (~> 3.10.0)
107
+ rspec-support (3.10.2)
108
+ rubocop (1.12.1)
125
109
  parallel (~> 1.10)
126
- parser (>= 2.3.3.1, < 3.0)
127
- powerpack (~> 0.1)
128
- rainbow (>= 2.2.2, < 3.0)
110
+ parser (>= 3.0.0.0)
111
+ rainbow (>= 2.2.2, < 4.0)
112
+ regexp_parser (>= 1.8, < 3.0)
113
+ rexml
114
+ rubocop-ast (>= 1.2.0, < 2.0)
129
115
  ruby-progressbar (~> 1.7)
130
- unicode-display_width (~> 1.0, >= 1.0.1)
131
- ruby-progressbar (1.9.0)
132
- rubyzip (1.2.1)
133
- selenium-webdriver (3.6.0)
134
- childprocess (~> 0.5)
135
- rubyzip (~> 1.0)
116
+ unicode-display_width (>= 1.4.0, < 3.0)
117
+ rubocop-ast (1.4.1)
118
+ parser (>= 2.7.1.5)
119
+ ruby-debug-ide (0.7.2)
120
+ rake (>= 0.8.1)
121
+ ruby-progressbar (1.11.0)
122
+ ruby2_keywords (0.0.4)
123
+ rubyzip (2.3.0)
124
+ selenium-webdriver (3.142.7)
125
+ childprocess (>= 0.5, < 4.0)
126
+ rubyzip (>= 1.2.2)
136
127
  semver2 (3.4.2)
137
- simplecov (0.13.0)
138
- docile (~> 1.1.0)
139
- json (>= 1.8, < 3)
140
- simplecov-html (~> 0.10.0)
141
- simplecov-html (0.10.2)
142
- sinatra (1.4.8)
143
- rack (~> 1.5)
144
- rack-protection (~> 1.4)
145
- tilt (>= 1.3, < 3)
128
+ simplecov (0.21.2)
129
+ docile (~> 1.1)
130
+ simplecov-html (~> 0.11)
131
+ simplecov_json_formatter (~> 0.1)
132
+ simplecov-html (0.12.3)
133
+ simplecov_json_formatter (0.1.2)
134
+ sinatra (2.1.0)
135
+ mustermann (~> 1.0)
136
+ rack (~> 2.2)
137
+ rack-protection (= 2.1.0)
138
+ tilt (~> 2.0)
146
139
  thread_safe (0.3.6)
147
- tilt (2.0.8)
148
- tzinfo (1.2.3)
149
- thread_safe (~> 0.1)
150
- unicode-display_width (1.3.0)
151
- virtus (1.0.5)
152
- axiom-types (~> 0.1)
153
- coercible (~> 1.0)
154
- descendants_tracker (~> 0.0, >= 0.0.3)
155
- equalizer (~> 0.0, >= 0.0.9)
156
- watir-webdriver (0.9.9)
157
- selenium-webdriver (>= 2.46.2)
158
- websocket-driver (0.7.0)
140
+ tilt (2.0.10)
141
+ tzinfo (2.0.4)
142
+ concurrent-ruby (~> 1.0)
143
+ unicode-display_width (2.0.0)
144
+ watir (6.19.1)
145
+ regexp_parser (>= 1.2, < 3)
146
+ selenium-webdriver (>= 3.142.7)
147
+ websocket-driver (0.7.3)
159
148
  websocket-extensions (>= 0.1.0)
160
- websocket-extensions (0.1.2)
161
- xpath (2.1.0)
162
- nokogiri (~> 1.3)
163
- yard (0.9.9)
149
+ websocket-extensions (0.1.5)
150
+ xpath (3.2.0)
151
+ nokogiri (~> 1.8)
152
+ yard (0.9.26)
153
+ zeitwerk (2.4.2)
164
154
 
165
155
  PLATFORMS
166
156
  ruby
167
157
 
168
158
  DEPENDENCIES
169
- activesupport-inflector
170
- arbre
171
- capybara (>= 2.5)
172
- codeclimate-test-reporter
173
- github-markup (~> 1.4)
174
- jeweler (~> 2.0)
159
+ activesupport
160
+ capybara (>= 3.0)
161
+ github-markup
162
+ jeweler
175
163
  poltergeist
176
- pullreview-coverage
177
- redcarpet (~> 3.3)
178
- reek
164
+ redcarpet
179
165
  rspec
180
- rubocop (~> 0.34)
166
+ rubocop
167
+ ruby-debug-ide
181
168
  simplecov
182
169
  sinatra
183
- watir-webdriver
170
+ watir
184
171
  yard (~> 0.8)
185
172
 
186
173
  BUNDLED WITH
187
- 1.15.4
174
+ 2.1.4
data/Makefile ADDED
@@ -0,0 +1,13 @@
1
+ .PHONY: help
2
+ DOCKER_IMAGE = lvl-up/page-magic
3
+
4
+ help:
5
+ @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
6
+
7
+ build: ## build project docker image
8
+ docker build -t $(DOCKER_IMAGE) .
9
+
10
+ test: ## Run tests
11
+ docker run -v $(PWD):/usr/src/app -t $(DOCKER_IMAGE) bundle exec rspec
12
+
13
+ all: test
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Bundler.require :test, :development
2
4
 
3
5
  RuboCop::RakeTask.new
@@ -12,7 +14,7 @@ Jeweler::Tasks.new do |gem|
12
14
  gem.license = 'ruby'
13
15
  gem.summary = 'Framework for modeling and interacting with webpages'
14
16
  gem.description = 'Framework for modeling and interacting with webpages which wraps capybara'
15
- gem.email = 'info@lad-tech.com'
17
+ gem.email = 'info@lvl-up.uk'
16
18
  gem.authors = ['Leon Davis']
17
19
  gem.required_ruby_version = '>= 2.1'
18
20
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.9
1
+ 2.0.0.alpha1
data/lib/page_magic.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  $LOAD_PATH.unshift(File.dirname(__FILE__).to_s)
2
4
  require 'capybara'
3
5
  require 'page_magic/exceptions'
@@ -49,10 +51,10 @@ module PageMagic
49
51
  # @param [Symbol] browser name of browser
50
52
  # @param [String] url url to start the session on
51
53
  # @param [Hash] options browser driver specific options
52
- # @return [Session] configured sessoin
53
- def session(application: nil, browser: :rack_test, url:, options: {})
54
+ # @return [Session] configured session
55
+ def session(url: nil, application: nil, browser: :rack_test, options: {})
54
56
  driver = drivers.find(browser)
55
- raise UnspportedBrowserException unless driver
57
+ raise UnsupportedBrowserException unless driver
56
58
 
57
59
  Capybara.register_driver browser do |app|
58
60
  driver.build(app, browser: browser, options: options)