module SeleniumToCapybara

Constants

VERSION

Public Class Methods

to_minitest(name, commands) click to toggle source
# File lib/selenium_to_capybara.rb, line 7
  def self.to_minitest(name, commands)
    test_commands = commands.map do |command|
      Minitest.new(command).translate
    end

    warning_present = test_commands.any? {|translation| translation.start_with?('# WARNING:')}

    output = []
    output << <<~EOS
      test '#{name}' do
      #{test_commands.map {|x| "  #{x.gsub(/\n/, "\n  ")}"}.join("\n\n")}
      end
    EOS
    output << "\n# WARNING: Some commands are unhandled. Please contribute here: https://github.com/DarkSwoop/selenium_to_capybara" if warning_present
    output.join("\n")
  end