side_to_capybara 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4782d6ff7fa955a88f58ed0f998fef8e37564b647a89be7f04383a5d9be10dc5
4
- data.tar.gz: 495d92f8a688ebc3b7fd306be24dcc6a413d7c01b59e9d3f13a7e486963a1993
3
+ metadata.gz: 6a52b89ddaff4e123351e90015c5e18829310efd033a382cb8b5a6986675d283
4
+ data.tar.gz: 2a339a4ad3707318d107b13b0052110e4d12b774aa1095c1c351b1352f5515fe
5
5
  SHA512:
6
- metadata.gz: 9744b0e838a57880a1f4b963ffe7cb2627376a00860d4b7f179cdcbe5766b61d33d7c9149a8c3725fa1bd275b4d3306bf6f11ccccd37e0c8cfcda394ef1ee22a
7
- data.tar.gz: 1b72b6a7deac061cafe6658af0898c769327126408b204fc3d8cf35b6dd5218a0621c8795a38183f97c403b5829435262343aae8d3edc195c3a0237539978f67
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 = [public_send(method_id)]
47
-
48
- # add the alternative selectors as comments
49
- translation.unshift(commented_targets.join("\n")) if targets.size > 1
50
- translation.join("\n")
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
- "click_on('#{selector}')"
49
+ "click_link_or_button('#{selector}')"
25
50
  end
26
51
  end
27
52
 
@@ -1,3 +1,3 @@
1
1
  module SideToCapybara
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -9,11 +9,16 @@ module SideToCapybara
9
9
  Minitest.new(command).translate
10
10
  end
11
11
 
12
- <<~EOS
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: side_to_capybara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Behr