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



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

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



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

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



78
79
80
# File 'lib/rack/test/poc.rb', line 78

def dump_object
  @dump_object ||= Hash.new
end

.last_pocObject



86
87
88
# File 'lib/rack/test/poc.rb', line 86

def last_poc
  @last_poc
end

.last_poc=(last_poc) ⇒ Object



82
83
84
# File 'lib/rack/test/poc.rb', line 82

def last_poc=(last_poc)
  @last_poc=last_poc
end

.rootObject



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

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