Sha256: 531b1c9f6f0d90b92583e0f6bb49d570472c24a408065413815cc9c94819c220

Contents?: true

Size: 1.53 KB

Versions: 8

Compression:

Stored size: 1.53 KB

Contents

# encoding: utf-8

step '次のブロックを配置する:' do |haml|
  haml = %(%xml{:xmlns => "http://www.w3.org/1999/xhtml"}\n) +
    haml.lines.map { |s| "  #{s}" }.join
  engine = Haml::Engine.new(haml)
  xml = engine.render
  page.execute_script(<<-JS)
    do {
      var dom = Blockly.Xml.textToDom('#{escape_javascript(xml)}');
      Blockly.Xml.domToWorkspace(Blockly.mainWorkspace, dom);
    } while (false);
  JS
end

step '次のブロック(:comment)を配置する:' do |_, haml|
  haml = %(%xml{:xmlns => "http://www.w3.org/1999/xhtml"}\n) +
    haml.lines.map { |s| "  #{s}" }.join
  engine = Haml::Engine.new(haml)
  xml = engine.render
  page.execute_script(<<-JS)
    do {
      var dom = Blockly.Xml.textToDom('#{escape_javascript(xml)}');
      Blockly.Xml.domToWorkspace(Blockly.mainWorkspace, dom);
    } while (false);
  JS
end

step 'すべてのブロックをクリアする' do
  page.execute_script('Blockly.mainWorkspace.clear()')
end

step 'ブロックからソースコードを生成する' do
  step '"ブロックタブ" にタブを切り替える'
  step '"Rubyタブ" にタブを切り替える'
end

step '次のキャラクターを追加する:' do |table|
  table.hashes.each do |h|
    costumes = h['costumes'].split(',').map { |s| "'#{s}'" }.join(', ')
    page.execute_script(<<-JS)
      Smalruby.Collections.CharacterSet.add(new Smalruby.Character({
        name: '#{h['name']}',
        costumes: [#{costumes}],
        x: #{h['x']},
        y: #{h['y']},
        angle: #{h['angle']}
      }))
    JS
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
smalruby-editor-0.1.5-x86-mingw32 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.5 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.4-x86-mingw32 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.4 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.3-x86-mingw32 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.3 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.2-x86-mingw32 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.2 spec/steps/block_mode_steps.rb