chemlab 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chemlab/cli/new_library.rb +1 -1
- data/lib/chemlab/cli/stubber.rb +1 -1
- data/lib/chemlab/core_ext/string/inflections.rb +25 -0
- data/lib/chemlab/core_ext/string/root_module.rb +13 -0
- data/lib/chemlab/library.rb +36 -0
- data/lib/chemlab/runtime/browser.rb +47 -3
- data/lib/chemlab/version.rb +1 -1
- data/lib/chemlab.rb +1 -0
- metadata +40 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8768461aba3f55a80a1ef51e13b894d8f876343abb1a402c7de72e4fbfa4a9e
|
4
|
+
data.tar.gz: a3a48670a730d1d873ce671d94de87198478e54bfa2f29665aa2c05bf686f328
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f6b5cd6c624455c9204da1815b891f65a97725309acf4157b280df795c56f072aa905ae3d48c75a3c42c7414bee7a3408d379dcfdbbc406eb1d849f6c4da3ed
|
7
|
+
data.tar.gz: 5cc500d4395d6470dc19cb4e250721d600d34e2f0f561410de26437490cf83d2529122c19d7da64ed7f17fd135f3fbfd93cfd01e90a253faae8b54956a7b2092
|
@@ -16,7 +16,7 @@ module Chemlab
|
|
16
16
|
raise %(Cannot create new library `#{library_name}` as the directory "#{library_name}" already exists)
|
17
17
|
end
|
18
18
|
|
19
|
-
require '
|
19
|
+
require 'chemlab/core_ext/string/inflections'
|
20
20
|
|
21
21
|
@library = {
|
22
22
|
name: library_name,
|
data/lib/chemlab/cli/stubber.rb
CHANGED
@@ -53,7 +53,7 @@ module Chemlab
|
|
53
53
|
|
54
54
|
library = Stubber.libraries.last # last appended library is this Page Library
|
55
55
|
|
56
|
-
require '
|
56
|
+
require 'chemlab/core_ext/string/inflections'
|
57
57
|
|
58
58
|
stub_path = @path.gsub(@path[@path.rindex('.')..], '.stub.rb')
|
59
59
|
File.open(stub_path, 'w') do |stub|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Start monkey patch of Object::String
|
4
|
+
class String
|
5
|
+
# Classify a string
|
6
|
+
# @example
|
7
|
+
# 'test_class'.classify #=> TestClass
|
8
|
+
# @example
|
9
|
+
# 'testclass'.classify #=> Testclass
|
10
|
+
def classify
|
11
|
+
split('_').map(&:capitalize).join
|
12
|
+
end
|
13
|
+
|
14
|
+
# Underscore a multi-worded string
|
15
|
+
# @example
|
16
|
+
# 'TestClass'.underscore #=> 'test_class'
|
17
|
+
# @example
|
18
|
+
# 'Class'.underscore #=> 'class'
|
19
|
+
def underscore
|
20
|
+
chars.each_with_object(+'') do |c, str|
|
21
|
+
str << '_' if c.match?(/[A-Z]/) && !str.size.zero?
|
22
|
+
str << c.downcase
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Start monkey patch of String
|
4
|
+
class String
|
5
|
+
# Find the root module (parent module) of a class or module
|
6
|
+
# @example
|
7
|
+
# 'A::B::C'.root_module #=> A
|
8
|
+
# 'A::B'.root_module => A
|
9
|
+
# @return [Module] the root module
|
10
|
+
def root_module
|
11
|
+
Object.const_get(split('::').first)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Chemlab
|
4
|
+
# Application Library Definition
|
5
|
+
# Provides accessors for +:base_url+, +:base_url=+
|
6
|
+
# +base_url+ will default to Chemlab's configured base_url
|
7
|
+
module Library
|
8
|
+
def self.included(base)
|
9
|
+
base.module_eval do
|
10
|
+
class << self
|
11
|
+
# The Base URL where this library / application exists
|
12
|
+
# If you have multiple applications that Chemlab will target,
|
13
|
+
# this is useful for having separate base_urls.
|
14
|
+
#
|
15
|
+
# @return [String] the base_url. +Chemlab.configuration.base_url+ by default if not set
|
16
|
+
#
|
17
|
+
# @example
|
18
|
+
# Chemlab.configure do |chemlab|
|
19
|
+
# A.base_url = 'https://first_app'
|
20
|
+
# B.base_url = 'https://second_app'
|
21
|
+
# chemlab.base_url = 'https://main_app'
|
22
|
+
#
|
23
|
+
# chemlab.libraries = [A, B, C]
|
24
|
+
#
|
25
|
+
# C.base_url #=> https://main_app
|
26
|
+
# end
|
27
|
+
attr_writer :base_url
|
28
|
+
|
29
|
+
def base_url
|
30
|
+
@base_url ||= Chemlab.configuration.base_url
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'forwardable'
|
4
|
+
require 'chemlab/core_ext/string/root_module'
|
4
5
|
|
5
6
|
module Chemlab
|
6
7
|
module Runtime
|
@@ -17,13 +18,56 @@ module Chemlab
|
|
17
18
|
@session = Session.new(browser_options)
|
18
19
|
end
|
19
20
|
|
21
|
+
# Navigate to a given Page library
|
22
|
+
# @param [Class<Chemlab::Page>] page_class the class of the Page to navigate to
|
23
|
+
# @example
|
24
|
+
# Given:
|
25
|
+
# module TheLibrary
|
26
|
+
# def self.base_url
|
27
|
+
# 'https://example.com'
|
28
|
+
# end
|
29
|
+
# class ThePage < Chemlab::Page
|
30
|
+
# path '/path'
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# Chemlab::Runtime::Browser.navigate_to(TheLibrary::ThePage) #=> Navigates to https://example.com/path
|
35
|
+
#
|
36
|
+
# @example
|
37
|
+
# Given:
|
38
|
+
# Chemlab.configure do |chemlab|
|
39
|
+
# chemlab.base_url = 'https://example.com'
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# class ThePage < Chemlab::Page
|
43
|
+
# path '/'
|
44
|
+
# end
|
45
|
+
#
|
46
|
+
# Chemlab::Runtime::Browser.navigate_to(ThePage) #=> Navigates to https://example.com/path
|
20
47
|
def self.navigate_to(page_class)
|
21
|
-
|
48
|
+
unless page_class&.name.respond_to?(:root_module)
|
49
|
+
return Chemlab.configuration.browser.navigate_to(Chemlab.configuration.base_url + page_class.path)
|
50
|
+
end
|
51
|
+
|
52
|
+
# workaround for file:// protocol. URI.join() does not work with URI.join('file:///Users', '/user')
|
53
|
+
uri = if URI(page_class.name.root_module.base_url).scheme == 'file'
|
54
|
+
URI(File.join(page_class.name.root_module.base_url, page_class.path))
|
55
|
+
else
|
56
|
+
URI.join(page_class.name.root_module.base_url, page_class.path)
|
57
|
+
end
|
58
|
+
|
59
|
+
Chemlab.configuration.browser.navigate_to(uri)
|
22
60
|
end
|
23
61
|
|
24
|
-
|
62
|
+
# Navigate to a URI or Path
|
63
|
+
# @param [URI,String] uri_or_path the URI or path
|
64
|
+
# @return [URI,String] the URI or Path that was navigated to
|
65
|
+
# @example
|
66
|
+
# Chemlab.configuration.browser.navigate_to('/path') #=> /path
|
67
|
+
# Chemlab.configuration.browser.navigate_to(URI('https://example.com/path')) #=> URI('https://example.com/path')
|
68
|
+
def navigate_to(uri_or_path)
|
25
69
|
@session ||= Chemlab.configuration.browser.session
|
26
|
-
@session.engine.goto(
|
70
|
+
@session.engine.goto(uri_or_path.to_s)
|
27
71
|
end
|
28
72
|
|
29
73
|
# The options used to create the browser session
|
data/lib/chemlab/version.rb
CHANGED
data/lib/chemlab.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chemlab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitLab Quality
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: climate_control
|
@@ -122,90 +122,94 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 0.9.26
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: activesupport-inflector
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: 0.1.0
|
132
|
-
type: :runtime
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: 0.1.0
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: colorize
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
142
128
|
requirements:
|
143
129
|
- - "~>"
|
144
130
|
- !ruby/object:Gem::Version
|
145
|
-
version: 0.8
|
131
|
+
version: '0.8'
|
146
132
|
type: :runtime
|
147
133
|
prerelease: false
|
148
134
|
version_requirements: !ruby/object:Gem::Requirement
|
149
135
|
requirements:
|
150
136
|
- - "~>"
|
151
137
|
- !ruby/object:Gem::Version
|
152
|
-
version: 0.8
|
138
|
+
version: '0.8'
|
153
139
|
- !ruby/object:Gem::Dependency
|
154
140
|
name: i18n
|
155
141
|
requirement: !ruby/object:Gem::Requirement
|
156
142
|
requirements:
|
157
143
|
- - "~>"
|
158
144
|
- !ruby/object:Gem::Version
|
159
|
-
version: 1.8
|
145
|
+
version: '1.8'
|
160
146
|
type: :runtime
|
161
147
|
prerelease: false
|
162
148
|
version_requirements: !ruby/object:Gem::Requirement
|
163
149
|
requirements:
|
164
150
|
- - "~>"
|
165
151
|
- !ruby/object:Gem::Version
|
166
|
-
version: 1.8
|
152
|
+
version: '1.8'
|
167
153
|
- !ruby/object:Gem::Dependency
|
168
154
|
name: rake
|
169
155
|
requirement: !ruby/object:Gem::Requirement
|
170
156
|
requirements:
|
171
|
-
- - "
|
157
|
+
- - ">="
|
172
158
|
- !ruby/object:Gem::Version
|
173
|
-
version:
|
159
|
+
version: '12'
|
160
|
+
- - "<"
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: '14'
|
174
163
|
type: :runtime
|
175
164
|
prerelease: false
|
176
165
|
version_requirements: !ruby/object:Gem::Requirement
|
177
166
|
requirements:
|
178
|
-
- - "
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '12'
|
170
|
+
- - "<"
|
179
171
|
- !ruby/object:Gem::Version
|
180
|
-
version:
|
172
|
+
version: '14'
|
181
173
|
- !ruby/object:Gem::Dependency
|
182
174
|
name: selenium-webdriver
|
183
175
|
requirement: !ruby/object:Gem::Requirement
|
184
176
|
requirements:
|
185
|
-
- - "
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '3'
|
180
|
+
- - "<"
|
186
181
|
- !ruby/object:Gem::Version
|
187
|
-
version:
|
182
|
+
version: '5'
|
188
183
|
type: :runtime
|
189
184
|
prerelease: false
|
190
185
|
version_requirements: !ruby/object:Gem::Requirement
|
191
186
|
requirements:
|
192
|
-
- - "
|
187
|
+
- - ">="
|
193
188
|
- !ruby/object:Gem::Version
|
194
|
-
version:
|
189
|
+
version: '3'
|
190
|
+
- - "<"
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '5'
|
195
193
|
- !ruby/object:Gem::Dependency
|
196
194
|
name: watir
|
197
195
|
requirement: !ruby/object:Gem::Requirement
|
198
196
|
requirements:
|
199
|
-
- - "
|
197
|
+
- - ">="
|
198
|
+
- !ruby/object:Gem::Version
|
199
|
+
version: '6'
|
200
|
+
- - "<"
|
200
201
|
- !ruby/object:Gem::Version
|
201
|
-
version:
|
202
|
+
version: '8'
|
202
203
|
type: :runtime
|
203
204
|
prerelease: false
|
204
205
|
version_requirements: !ruby/object:Gem::Requirement
|
205
206
|
requirements:
|
206
|
-
- - "
|
207
|
+
- - ">="
|
208
|
+
- !ruby/object:Gem::Version
|
209
|
+
version: '6'
|
210
|
+
- - "<"
|
207
211
|
- !ruby/object:Gem::Version
|
208
|
-
version:
|
212
|
+
version: '8'
|
209
213
|
description:
|
210
214
|
email:
|
211
215
|
- quality@gitlab.com
|
@@ -235,7 +239,10 @@ files:
|
|
235
239
|
- lib/chemlab/cli/stubber.rb
|
236
240
|
- lib/chemlab/component.rb
|
237
241
|
- lib/chemlab/configuration.rb
|
242
|
+
- lib/chemlab/core_ext/string/inflections.rb
|
243
|
+
- lib/chemlab/core_ext/string/root_module.rb
|
238
244
|
- lib/chemlab/element.rb
|
245
|
+
- lib/chemlab/library.rb
|
239
246
|
- lib/chemlab/page.rb
|
240
247
|
- lib/chemlab/runtime/browser.rb
|
241
248
|
- lib/chemlab/runtime/env.rb
|
@@ -258,7 +265,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
258
265
|
requirements:
|
259
266
|
- - ">="
|
260
267
|
- !ruby/object:Gem::Version
|
261
|
-
version: 2.
|
268
|
+
version: '2.5'
|
262
269
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
263
270
|
requirements:
|
264
271
|
- - ">="
|