Sha256: 771073a4db3fc162787ad8ec4166298fb414b63ab2307366d6bfead9c390b831

Contents?: true

Size: 1.81 KB

Versions: 37

Compression:

Stored size: 1.81 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
  page.execute_script('window.blockMode = true')
  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

step '次のXMLと同等のブロックが配置されていること:' do |xml|
  expect(page.evaluate_script('Smalruby.dumpXml()')).to eq(xml)
end

step 'ブロックが配置されていないこと' do
  send '次のXMLと同等のブロックが配置されていること:', '<xml></xml>'
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
smalruby-editor-0.1.24-x86-mingw32 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.24 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.23-x86-mingw32 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.23 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.22-x86-mingw32 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.22 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.21-x86-mingw32 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.21 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.20-x86-mingw32 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.20 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.19-x86-mingw32 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.19 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.18-x86-mingw32 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.18 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.17-x86-mingw32 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.17 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.16-x86-mingw32 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.16 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.15-x86-mingw32 spec/steps/block_mode_steps.rb
smalruby-editor-0.1.15 spec/steps/block_mode_steps.rb