topoisomerase 0.1.3 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/topoisomerase.rb +6 -5
- data/lib/topoisomerase/template/page_object.rb +22 -12
- data/lib/topoisomerase/version.rb +1 -1
- data/topoisomerase.gemspec +1 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6e8aefd45f9a9034ca6fbf4f92916af9ffa16d01b78233fba93d20aaea883e13
|
4
|
+
data.tar.gz: fb2b497e2033f2ee9dfd6ebd2610a8370409587f28aac8e103e479ec2267daf5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 789c48ecd3772e93249f6d2c58baf251ed5d55f6e783c2cd8ac588482bb5e85a719beafb9c6d54476a24b6534e004525affffedeee8e005e3d2d2806b678b27a
|
7
|
+
data.tar.gz: 0a43d3a013b4814c896410f6fc29bc363ba9f2e7381b1eff89adb5154038796da8cd5526cb9defac1c66430680a364e13e009063500aadc7266c131d82ac0684
|
data/lib/topoisomerase.rb
CHANGED
@@ -3,6 +3,7 @@ require 'method_source'
|
|
3
3
|
require 'fileutils'
|
4
4
|
require 'topoisomerase/core_ext/string'
|
5
5
|
require 'topoisomerase/comments'
|
6
|
+
require 'rubocop'
|
6
7
|
|
7
8
|
# Module for parsing and creating stubs for dynamic methods
|
8
9
|
module Topoisomerase
|
@@ -67,15 +68,15 @@ module Topoisomerase
|
|
67
68
|
|
68
69
|
# Reads from 'comments_added' variable if no comment added above dynamic method
|
69
70
|
# @return [String] Comment defined by 'comments_added'
|
70
|
-
def comment_for(
|
71
|
+
def comment_for(stub_method, method_data)
|
71
72
|
return extracted_comment(method_data) unless comments_added[@inheriting_class]
|
72
73
|
|
73
|
-
|
74
|
+
stub_method = stub_method.to_s
|
74
75
|
comments_added[@inheriting_class].each do |comment_matcher|
|
75
76
|
matchers = comment_matcher[:matchers]
|
76
77
|
return ERB.new(comment_matcher[:message]).result(binding) if matchers.all? do |matcher_type, matcher_value|
|
77
78
|
extracted_match = case matcher_type
|
78
|
-
when :method_name then match?(
|
79
|
+
when :method_name then match?(stub_method, matcher_value)
|
79
80
|
when :source then match? method_data[:source], matcher_value
|
80
81
|
else
|
81
82
|
raise Topoisomerase::Error, "Undefined matcher #{matcher_type}"
|
@@ -100,8 +101,8 @@ module Topoisomerase
|
|
100
101
|
puts "Creating stubs for #{class_name} at #{filename}"
|
101
102
|
FileUtils.mkdir_p File.dirname(filename)
|
102
103
|
IO.write filename, ERB.new(File.read(template)).result(binding)
|
103
|
-
|
104
|
-
|
104
|
+
RuboCop::CLI.new.run(['-a', filename, '-o', 'stub_log'])
|
105
|
+
FileUtils.rm 'stub_log' # TODO: Should be a way of not producing this in first place
|
105
106
|
end
|
106
107
|
|
107
108
|
# Create stub files for each class that inherits from passed in class
|
@@ -6,42 +6,52 @@ require 'topoisomerase'
|
|
6
6
|
#
|
7
7
|
# Topoisomerase.comments_added[PageObject] = [
|
8
8
|
# {
|
9
|
-
# message: "@return [PageObject::Elements::Element] An object representing the '<%=
|
9
|
+
# message: "@return [PageObject::Elements::Element] An object representing the '<%= stub_method.gsub('_element', '') %>' element",
|
10
10
|
# matchers: { method_name: /_element$/ } # If either matcher matches, result returned
|
11
11
|
# },
|
12
12
|
# {
|
13
|
-
# message: "@return [Boolean] Whether the '<%=
|
13
|
+
# message: "@return [Boolean] Whether the '<%= stub_method.gsub('?', '') %>' element is present",
|
14
14
|
# matchers: { method_name: /\?$/ }
|
15
15
|
# },
|
16
16
|
# # Testing whether 2 matchers use AND
|
17
17
|
# {
|
18
|
-
# message: "Set the text of the '<%=
|
18
|
+
# message: "Set the text of the '<%= stub_method.gsub('?', '') %>' text field\n # @param [String] _value Value to set",
|
19
19
|
# matchers: { method_name: /=$/, source: /text_field_value_set/ }
|
20
20
|
# },
|
21
21
|
# {
|
22
|
-
# message: "Set the value of '<%=
|
22
|
+
# message: "Set the value of '<%= stub_method.gsub('?', '') %>' element\n # @param [String] _value Value to set",
|
23
23
|
# matchers: { method_name: /=$/ }
|
24
24
|
# },
|
25
25
|
# {
|
26
|
-
# message: "@return [String] The text of the '<%=
|
26
|
+
# message: "@return [String] The text of the '<%= stub_method.gsub('?', '') %>' element",
|
27
27
|
# matchers: { source: /\.text/ }
|
28
28
|
# },
|
29
29
|
# {
|
30
|
-
# message: "Click the '<%=
|
30
|
+
# message: "Click the '<%= stub_method.gsub('?', '') %>' element",
|
31
31
|
# matchers: { source: /\.click/ }
|
32
32
|
# }
|
33
33
|
# ]
|
34
34
|
|
35
|
-
|
36
|
-
# message: "@return [Watir::Elements::Element] An object representing the '<%= method_to_stub.to_s.gsub('_element', '') %>' element",
|
37
|
-
# matchers: { method_name: /_element$/ } # If either matcher matches, result returned
|
38
|
-
# },
|
39
|
-
|
40
35
|
Topoisomerase::Comments.add_for_class PageObject do
|
41
36
|
comment "Url of the page. Used by 'goto' method and when using 'visit'", method_name: 'page_url_value'
|
42
37
|
comment 'Open the page on the browser', method_name: 'goto'
|
43
|
-
comment "@return [PageObject::Elements::Element] An object representing the '<%=
|
38
|
+
comment "@return [PageObject::Elements::Element] An object representing the '<%= stub_method.gsub('_element', '') %>' element",
|
44
39
|
method_name: /_element$/
|
40
|
+
comment "Set the text of the '<%= stub_method.gsub('=', '') %>' text field\n # @param [String] _value Value to set",
|
41
|
+
method_name: /=$/, source: /text_field_value_set/
|
42
|
+
comment "Set the value of '<%= stub_method.gsub('=', '') %>' element\n # @param [String] _value Value to set",
|
43
|
+
method_name: /=$/
|
44
|
+
comment "Check the '<%= stub_method.gsub('check', '') %>' checkbox element", method_name: /^check_/
|
45
|
+
comment "uncheck the '<%= stub_method.gsub('uncheck', '') %>' checkbox element", method_name: /^uncheck_/
|
46
|
+
comment "@returns [Boolean] Whether the '<%= stub_method.gsub('_checked?', '') %>' Checkbox is checked",
|
47
|
+
method_name: /_checked\?$/
|
48
|
+
comment "Selects the '<%= stub_method.gsub('select', '') %>' radio element", method_name: /^select_/
|
49
|
+
comment "Clears the selected '<%= stub_method.gsub('clear_', '') %>' radio element", method_name: /^clear_/
|
50
|
+
comment "@returns [Boolean] Whether the '<%= stub_method.gsub('_selected?', '') %>' radiobox is selected",
|
51
|
+
method_name: /_selected\?$/
|
52
|
+
comment "@return [Boolean] Whether the '<%= stub_method.gsub('?', '') %>' element is present",
|
53
|
+
method_name: /\?$/
|
54
|
+
|
45
55
|
end
|
46
56
|
|
47
57
|
# This block demonstrates how a real browser could be used to create stubs.
|
data/topoisomerase.gemspec
CHANGED
@@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.add_dependency 'rubocop' # Clean up generated files
|
38
38
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
39
39
|
spec.add_development_dependency 'page-object'
|
40
|
+
spec.add_development_dependency 'ffi'
|
40
41
|
spec.add_development_dependency 'rake'
|
41
42
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
42
43
|
spec.add_development_dependency 'webdrivers' # Only used for testing page-object gem
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: topoisomerase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Garratt
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: method_source
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: ffi
|
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'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rake
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -174,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
188
|
version: '0'
|
175
189
|
requirements: []
|
176
190
|
rubyforge_project:
|
177
|
-
rubygems_version: 2.
|
191
|
+
rubygems_version: 2.7.9
|
178
192
|
signing_key:
|
179
193
|
specification_version: 4
|
180
194
|
summary: Used to create stubs for documenting dynamic Ruby methods.
|