Sha256: 385ec1049c99aa355e40adbf231c6e5683aeda08a359fdb4b2941d00144de46d

Contents?: true

Size: 1.16 KB

Versions: 28

Compression:

Stored size: 1.16 KB

Contents

module Zafu
  # This is the 'src_helper' used when none is provided. Its main purpose is to provide some information
  # during testing.
  class MockHelper
    def initialize(strings = {})
      @strings = strings
    end

    def get_template_text(opts)
      src    = opts[:src]
      folder = (opts[:base_path] && opts[:base_path] != '') ? opts[:base_path][1..-1].split('/') : []
      src = src[1..-1] if src[0..0] == '/' # just ignore the 'relative' or 'absolute' tricks.
      url = (folder + src.split('/')).join('_')
      if test = @strings[url]
        return [test['src'], url.split('_').join('/')]
      else
        nil
      end
    end

    def template_url_for_asset(opts)
      "/test_#{opts[:type]}/#{opts[:src]}"
    end

    def method_missing(sym, *args)
      arguments = args.map do |arg|
        if arg.kind_of?(Hash)
          res = []
          arg.each do |k,v|
            unless v.nil?
              res << "#{k}:#{v.inspect.gsub(/'|"/, "|")}"
            end
          end
          res.sort.join(' ')
        else
          arg.inspect.gsub(/'|"/, "|")
        end
      end
      res = "[#{sym} #{arguments.join(' ')}]"
    end
  end # DummyHelper
end

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
zena-1.2.8 lib/zafu/mock_helper.rb
zena-1.2.7 lib/zafu/mock_helper.rb
zena-1.2.6 lib/zafu/mock_helper.rb
zena-1.2.5 lib/zafu/mock_helper.rb
zena-1.2.4 lib/zafu/mock_helper.rb
zena-1.2.3 lib/zafu/mock_helper.rb
zena-1.2.2 lib/zafu/mock_helper.rb
zafu-0.8.6 lib/zafu/mock_helper.rb
zafu-0.8.5 lib/zafu/mock_helper.rb
zafu-0.8.4 lib/zafu/mock_helper.rb
zafu-0.8.3 lib/zafu/mock_helper.rb
zafu-0.8.2 lib/zafu/mock_helper.rb
zafu-0.8.0 lib/zafu/mock_helper.rb
zafu-0.7.9 lib/zafu/mock_helper.rb
zafu-0.7.8 lib/zafu/mock_helper.rb
zafu-0.7.7 lib/zafu/mock_helper.rb
zafu-0.7.6 lib/zafu/mock_helper.rb
zafu-0.7.5 lib/zafu/mock_helper.rb
zafu-0.7.4 lib/zafu/mock_helper.rb
zafu-0.7.3 lib/zafu/mock_helper.rb