Sha256: ebca424eefff1969296d7f275742f1c743d4f0eff2adf7e5b6c5e2fb2edd667d

Contents?: true

Size: 930 Bytes

Versions: 117

Compression:

Stored size: 930 Bytes

Contents

namespace :shoulda do
  # From http://blog.internautdesign.com/2007/11/2/a-yaml_to_shoulda-rake-task
  # David.Lowenfels@gmail.com
  desc "Converts a YAML file (FILE=./path/to/yaml) into a Shoulda skeleton" 
  task :from_yaml do
    require 'yaml'
    
    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 
    
    puts("Please pass in a FILE argument.") and exit unless ENV['FILE']
      
    yaml_to_context( YAML.load_file( ENV['FILE'] ) )
  end
end

Version data entries

117 entries across 115 versions & 24 rubygems

Version Path
fairchild-poolparty-1.3.17 vendor/gems/shoulda/lib/shoulda/tasks/yaml_to_shoulda.rake
fairchild-poolparty-1.3.5 vendor/gems/shoulda/lib/shoulda/tasks/yaml_to_shoulda.rake
francois-shoulda-2.0.5.1 lib/shoulda/tasks/yaml_to_shoulda.rake
francois-shoulda-2.0.5.2 lib/shoulda/tasks/yaml_to_shoulda.rake
francois-shoulda-2.0.5.4 lib/shoulda/tasks/yaml_to_shoulda.rake
francois-shoulda-2.10.1 lib/shoulda/tasks/yaml_to_shoulda.rake
gnip-gnip-1.1.1 test/lib/shoulda/tasks/yaml_to_shoulda.rake
gsterndale-warrant-0.2.0 test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.6/lib/shoulda/tasks/yaml_to_shoulda.rake
gsterndale-warrant-0.3.0 test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.6/lib/shoulda/tasks/yaml_to_shoulda.rake
hashrocket-clearance-0.4.0 test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/tasks/yaml_to_shoulda.rake
hashrocket-clearance-0.4.1 test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/tasks/yaml_to_shoulda.rake
hashrocket-clearance-0.4.2 test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/tasks/yaml_to_shoulda.rake
hashrocket-clearance-0.4.3 test/rails_root/vendor/gems/thoughtbot-shoulda-2.0.4/lib/shoulda/tasks/yaml_to_shoulda.rake
iGEL-shoulda-2.10.2 lib/shoulda/tasks/yaml_to_shoulda.rake
jcnetdev-shoulda-4.2 tasks/yaml_to_shoulda.rake
mattknox-goaloc-0.3.0 lib/goaloc/generators/resources/shoulda/lib/shoulda/tasks/yaml_to_shoulda.rake
mattknox-goaloc-0.3.0 lib/goaloc/generators/resources/shoulda/tasks/yaml_to_shoulda.rake
mattknox-goaloc-0.4.0 lib/goaloc/generators/resources/shoulda/tasks/yaml_to_shoulda.rake
mattknox-goaloc-0.4.0 lib/goaloc/generators/resources/shoulda/lib/shoulda/tasks/yaml_to_shoulda.rake
mjankowski-shoulda-2.0.4 lib/shoulda/tasks/yaml_to_shoulda.rake