Module: Convenience

Defined in:
lib/test/spec/rails/convenience.rb

Instance Method Summary collapse

Instance Method Details

#cant_have(*var) ⇒ Object

> assigns(:user).should.be.nil



19
20
21
22
# File 'lib/test/spec/rails/convenience.rb', line 19

def cant_have(*var)
  return assigns(var).should.be.nil if var.length == 1
  var.each { |v| assigns(v).should.be.nil }
end

#has(*var) ⇒ Object

> assigns(:user).should.not.be.nil



9
10
11
12
# File 'lib/test/spec/rails/convenience.rb', line 9

def has(*var)
  return assigns(var).should.not.be.nil if var.length == 1
  var.each { |v| assigns(v).should.not.be.nil }
end

#has_flash(flash_type) ⇒ Object

shortcut for flash.should.not.be.nil has_flash :notice => assigns(flash).should.not.be.nil



26
27
28
# File 'lib/test/spec/rails/convenience.rb', line 26

def has_flash(flash_type)
  flash[flash_type].should.not.be.nil
end

#set_redirect_back(path = "/back/to/path") ⇒ Object

shortcut for setting the HTTP_REFERER variable set_redirect_back ‘/users’



32
33
34
# File 'lib/test/spec/rails/convenience.rb', line 32

def set_redirect_back(path="/back/to/path")
   @request.env["HTTP_REFERER"] = path
end