Sha256: 7b1cfb091fb6bf35a93c6dc16ee9c6b7b39472e7499caa4030e0121ea09432b9

Contents?: true

Size: 1.35 KB

Versions: 8

Compression:

Stored size: 1.35 KB

Contents

require 'debugger'
require 'cieloz'

require 'minitest/autorun'
require 'turn/autorun'

require 'minitest/matchers'
require 'shoulda/matchers'

require 'fakeweb'
require 'erb'

class MiniTest::Spec
  include Shoulda::Matchers::ActiveModel

  class << self
    alias :_create :create

    def create name, desc
      cls = _create name, desc
      begin
        c = eval name
        cls.subject {
          if c.is_a? Class then c.new elsif c.is_a? Module then c end
        }
      rescue
      end
      cls
    end
  end
end

module Shoulda::Matchers::ActiveModel
  class AllowValueMatcher
    def matches? instance
      @instance = instance
      @values_to_match.none? do |value|
        @value = value
        @instance.instance_variable_set "@#{@attribute}", @value
        errors_match?
      end
    end
  end
end

def expected_xml opts={}
  root, id, versao = opts[:root], opts[:id], opts[:versao]

  '<?xml version="1.0" encoding="UTF-8"?>'    +
  %|<#{root} id="#{id}" versao="#{versao}">|  +
    "#{yield if block_given?}"                +
  "</#{root}>"
end

def render_template dir, filename, binding
  template = File.join dir, [ "xml", filename ]
  file = File.read template
  erb = ERB.new file
  res = erb.result binding
  res.split("\n").collect {|line| line.strip }.join
end

def xml_for type, dir, binding
  render_template dir, "dados-#{type}.xml", binding
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cieloz-0.0.11 test/minitest_helper.rb
cieloz-0.0.10 test/minitest_helper.rb
cieloz-0.0.9 test/minitest_helper.rb
cieloz-0.0.8 test/minitest_helper.rb
cieloz-0.0.7 test/minitest_helper.rb
cieloz-0.0.4 test/minitest_helper.rb
cieloz-0.0.3 test/minitest_helper.rb
cieloz-0.0.2 test/minitest_helper.rb