side_to_capybara 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/side_to_capybara/base.rb +9 -5
- data/lib/side_to_capybara/minitest.rb +26 -1
- data/lib/side_to_capybara/version.rb +1 -1
- data/lib/side_to_capybara.rb +6 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a52b89ddaff4e123351e90015c5e18829310efd033a382cb8b5a6986675d283
|
4
|
+
data.tar.gz: 2a339a4ad3707318d107b13b0052110e4d12b774aa1095c1c351b1352f5515fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d786fd9793ddf43a51aee232c8352eace2fc798ca25747b18c2c86935cad95ddb4953b785da5de747a17eea2ae108dfcf4d7c2a5394dd711926fe9369d7186b
|
7
|
+
data.tar.gz: dfa78373ea259b760ce1d89c8c9d04dfb7d907ebc97e7d45f1275214d12666deaada57f02feb750ee2f34f618fc51b85fc162ed18a90cf881befbc195f67ad98
|
data/README.md
CHANGED
@@ -67,6 +67,10 @@ In order to create the needed .side files the Selenium IDE plugin must be instal
|
|
67
67
|
2. Save the test to the disk
|
68
68
|
3. run `side2capybara path/to/saved/*.side`
|
69
69
|
|
70
|
+
## Translation contribution
|
71
|
+
|
72
|
+
The translations for minitest are currently placed in `lib/side_to_capybara/minitest.rb`. Feel free to add more or update the existing translations. To add a new translation open the `.side` file in your favourite text editor. It's a JSON file. Search for the command you want to add and define a new method with the name of the command in `minitest.rb`. For a more detailed description of how to add a new command translation please look at the `minitest.rb` file.
|
73
|
+
|
70
74
|
## Development
|
71
75
|
|
72
76
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -43,11 +43,15 @@ module SideToCapybara
|
|
43
43
|
method_id = command.gsub(/([a-z])([A-Z])/, '\1_\2').downcase
|
44
44
|
if self.class.public_method_defined?(method_id)
|
45
45
|
# the translation itself
|
46
|
-
translation =
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
46
|
+
translation = public_send(method_id)
|
47
|
+
return "# WARNING: '#{command}' found but the selector_type '#{selector_type}' is unhandled." if translation.nil?
|
48
|
+
|
49
|
+
# add the alternative selectors as comments if present
|
50
|
+
if targets.size > 1
|
51
|
+
"#{commented_targets.join("\n")}\n#{translation}"
|
52
|
+
else
|
53
|
+
translation
|
54
|
+
end
|
51
55
|
else
|
52
56
|
"# WARNING: Conversion for '#{command}' not found."
|
53
57
|
end
|
@@ -1,5 +1,22 @@
|
|
1
1
|
module SideToCapybara
|
2
2
|
|
3
|
+
# This class holds the translations for minitest.
|
4
|
+
#
|
5
|
+
# To add a translation you need to do the following steps:
|
6
|
+
# 1. Open the .side file and find the command you want to add
|
7
|
+
# 2. Define a method in the Minitest class with the command as name.
|
8
|
+
# The command name must be translated to the ruby version of the name. `assertText` => `assert_text`
|
9
|
+
# 3. Define the translation
|
10
|
+
#
|
11
|
+
# The properties of the whole .side command object are accessible through ruby methods.
|
12
|
+
# - `target` is the preferred target selector of Selenium IDE
|
13
|
+
# - `targets` holds all possible target selectors identified by Selenium IDE
|
14
|
+
# - `selector_type` identifies the type of the preferred target selector (e.g css, xpath)
|
15
|
+
# - `selector` is the selector of the preferred target selector itself. (e.g 'body .header .title')
|
16
|
+
# - `value` e.g. the value that a text field should get
|
17
|
+
# - `command` the command name itself like `assertText` or `click`
|
18
|
+
# - `comment` a optional comment for that command
|
19
|
+
# - `id` the internal id generated by Selenium IDE
|
3
20
|
class Minitest < Base
|
4
21
|
def open
|
5
22
|
"visit('#{target}')"
|
@@ -11,6 +28,10 @@ module SideToCapybara
|
|
11
28
|
"find('#{selector}').double_click"
|
12
29
|
when 'id'
|
13
30
|
"find('##{selector}').double_click"
|
31
|
+
when 'xpath'
|
32
|
+
"find('#{selector}').double_click"
|
33
|
+
when 'name'
|
34
|
+
"find('[name=\"#{selector}\"]').double_click"
|
14
35
|
end
|
15
36
|
end
|
16
37
|
|
@@ -20,8 +41,12 @@ module SideToCapybara
|
|
20
41
|
"find('#{selector}').click"
|
21
42
|
when 'id'
|
22
43
|
"find('##{selector}').click"
|
44
|
+
when 'xpath'
|
45
|
+
"find('#{selector}').click"
|
46
|
+
when 'name'
|
47
|
+
"find('[name=\"#{selector}\"]').click"
|
23
48
|
when 'linkText'
|
24
|
-
"
|
49
|
+
"click_link_or_button('#{selector}')"
|
25
50
|
end
|
26
51
|
end
|
27
52
|
|
data/lib/side_to_capybara.rb
CHANGED
@@ -9,11 +9,16 @@ module SideToCapybara
|
|
9
9
|
Minitest.new(command).translate
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
warning_present = test_commands.any? {|translation| translation.start_with?('# WARNING:')}
|
13
|
+
|
14
|
+
output = []
|
15
|
+
output << <<~EOS
|
13
16
|
test '#{name}' do
|
14
17
|
#{test_commands.map {|x| " #{x.gsub(/\n/, "\n ")}"}.join("\n\n")}
|
15
18
|
end
|
16
19
|
EOS
|
20
|
+
output << "\n# WARNING: Some commands are unhandled. Please contribute here: https://github.com/DarkSwoop/side_to_capybara" if warning_present
|
21
|
+
output.join("\n")
|
17
22
|
end
|
18
23
|
|
19
24
|
end
|