Module: SideToCapybara

Defined in:
lib/side_to_capybara.rb,
lib/side_to_capybara/base.rb,
lib/side_to_capybara/version.rb,
lib/side_to_capybara/minitest.rb

Defined Under Namespace

Classes: Base, Minitest

Constant Summary collapse

VERSION =
"0.1.2"

Class Method Summary collapse

Class Method Details

.to_minitest(name, commands) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/side_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 << "    test '\#{name}' do\n    \#{test_commands.map {|x| \"  \#{x.gsub(/\\n/, \"\\n  \")}\"}.join(\"\\n\\n\")}\n    end\n  EOS\n  output << \"\\n# WARNING: Some commands are unhandled. Please contribute here: https://github.com/DarkSwoop/side_to_capybara\" if warning_present\n  output.join(\"\\n\")\nend\n"