Sha256: 83e1d4466ba898cf4ba53633c2e8741f26daac57488ae8a69e3a1cba9f3d087c

Contents?: true

Size: 607 Bytes

Versions: 28

Compression:

Stored size: 607 Bytes

Contents

#!/usr/bin/env ruby
require "yaml"

buffer = []
STDIN.each_line { |l| buffer << l }

def yaml_to_context hash, indent=0
  indent1 = '  '*indent
  indent2 = '  '*(indent+1)
  hash.each_pair do |context,shoulds|
    puts indent1+"context \"#{context}\" do"
    puts    
    shoulds.each do |should|
      yaml_to_context( should, indent+1 ) and next if should.is_a?( Hash )
      puts indent2+"should_eventually \"#{should.gsub(/^should +/,'')}\" do"
      puts indent2+"end"
      puts
    end
    puts indent1+"end"
  end 
end

hash = YAML.load( buffer.join("\n") )
# puts hash.inspect
yaml_to_context hash

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
zena-1.2.7 vendor/TextMate/Ruby Shoulda.tmbundle/Support/bin/yaml_to_shoulda.rb
zena-1.2.6 vendor/TextMate/Ruby Shoulda.tmbundle/Support/bin/yaml_to_shoulda.rb
zena-1.2.5 vendor/TextMate/Ruby Shoulda.tmbundle/Support/bin/yaml_to_shoulda.rb
zena-1.2.4 vendor/TextMate/Ruby Shoulda.tmbundle/Support/bin/yaml_to_shoulda.rb
zena-1.2.3 vendor/TextMate/Ruby Shoulda.tmbundle/Support/bin/yaml_to_shoulda.rb
zena-1.2.2 vendor/TextMate/Ruby Shoulda.tmbundle/Support/bin/yaml_to_shoulda.rb
zena-1.2.1 vendor/TextMate/Ruby Shoulda.tmbundle/Support/bin/yaml_to_shoulda.rb
zena-1.2.0 vendor/TextMate/Ruby Shoulda.tmbundle/Support/bin/yaml_to_shoulda.rb
zena-1.0.0 vendor/TextMate/Ruby Shoulda.tmbundle/Support/bin/yaml_to_shoulda.rb
zena-1.0.0.rc3 vendor/TextMate/Ruby Shoulda.tmbundle/Support/bin/yaml_to_shoulda.rb
zena-1.0.0.rc2 vendor/TextMate/Ruby Shoulda.tmbundle/Support/bin/yaml_to_shoulda.rb
zena-1.0.0.rc1 vendor/TextMate/Ruby Shoulda.tmbundle/Support/bin/yaml_to_shoulda.rb
zena-0.16.9 vendor/TextMate/Ruby Shoulda.tmbundle/Support/bin/yaml_to_shoulda.rb
zena-1.0.0.beta3 vendor/TextMate/Ruby Shoulda.tmbundle/Support/bin/yaml_to_shoulda.rb
zena-0.16.8 vendor/TextMate/Ruby Shoulda.tmbundle/Support/bin/yaml_to_shoulda.rb
zena-1.0.0.beta2 vendor/TextMate/Ruby Shoulda.tmbundle/Support/bin/yaml_to_shoulda.rb
zena-1.0.0.beta1 vendor/TextMate/Ruby Shoulda.tmbundle/Support/bin/yaml_to_shoulda.rb
zena-0.16.7 vendor/TextMate/Ruby Shoulda.tmbundle/Support/bin/yaml_to_shoulda.rb
zena-0.16.6 vendor/TextMate/Ruby Shoulda.tmbundle/Support/bin/yaml_to_shoulda.rb
zena-0.16.5 vendor/TextMate/Ruby Shoulda.tmbundle/Support/bin/yaml_to_shoulda.rb