Module: RackTestPoc

Defined in:
lib/rack/test/poc.rb

Defined Under Namespace

Modules: EXT, ObjectExt

Class Method Summary collapse

Class Method Details

.desc_comp_search(container, object, description_text) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rack/test/poc.rb', line 35

def desc_comp_search(container,object,description_text)
  case container

    when Array
      if container.index(object)
        container[container.index(object)]= description_text
      else
        container.each do |element|
          desc_comp_search(element,object,description_text)
        end
      end

    when Hash
      if container.key(object)
        container[container.key(object)]= description_text
      else
        container.each { |k,v| desc_comp_search(v,object,description_text) }
      end

  end
end

.description_helper(object, description_text) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/rack/test/poc.rb', line 57

def description_helper(object,description_text)
  case container = RackTestPoc.last_poc['response']['body']['description']

    when Array,Hash
      desc_comp_search(container,object,description_text)

    else
      RackTestPoc.last_poc['response']['body']['description']=description_text

  end

end

.dump_objectObject



80
81
82
# File 'lib/rack/test/poc.rb', line 80

def dump_object
  @dump_object ||= Hash.new
end

.last_pocObject



88
89
90
# File 'lib/rack/test/poc.rb', line 88

def last_poc
  @last_poc
end

.last_poc=(last_poc) ⇒ Object



84
85
86
# File 'lib/rack/test/poc.rb', line 84

def last_poc=(last_poc)
  @last_poc=last_poc
end

.rootObject



70
71
72
73
74
75
76
77
78
# File 'lib/rack/test/poc.rb', line 70

def root
  if defined?(Rails) && Rails.respond_to?(:root) && !!Rails.root
    Rails.root.to_s
  elsif !!ENV['BUNDLE_GEMFILE']
    ENV['BUNDLE_GEMFILE'].split(File::Separator)[0..-2].join(File::Separator)
  else
    Dir.pwd
  end
end