Class: Spec::Rails::Example::CookiesProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/spec/rails/example/cookies_proxy.rb

Instance Method Summary collapse

Constructor Details

#initialize(example) ⇒ CookiesProxy

Returns a new instance of CookiesProxy.



7
8
9
# File 'lib/spec/rails/example/cookies_proxy.rb', line 7

def initialize(example)
  @example = example
end

Instance Method Details

#[](name) ⇒ Object



19
20
21
# File 'lib/spec/rails/example/cookies_proxy.rb', line 19

def [](name)
  @example.response.cookies[name.to_s]
end

#[]=(name, value) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/spec/rails/example/cookies_proxy.rb', line 11

def[]=(name, value)
  if ::Rails::VERSION::STRING >= '2.3'
    @example.request.cookies[name.to_s] = value
  else
    @example.request.cookies[name.to_s] = CGI::Cookie.new(name.to_s, value)
  end
end

#delete(name) ⇒ Object



23
24
25
# File 'lib/spec/rails/example/cookies_proxy.rb', line 23

def delete(name)
  @example.response.cookies.delete(name.to_s)
end