Class: Peck::Should::Specification

Inherits:
Object
  • Object
show all
Defined in:
lib/peck_on_rails/assertions.rb

Constant Summary collapse

ALLOWED_EXCEPTIONS =
allowed_exceptions

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.allowed_exceptionsObject



85
86
87
88
89
90
91
92
93
94
# File 'lib/peck_on_rails/assertions.rb', line 85

def self.allowed_exceptions
  allowed_exceptions = []
  if defined?(ActiveRecord)
    allowed_exceptions << ActiveRecord::RecordNotFound
  end
  if defined?(AbstractController)
    allowed_exceptions << AbstractController::ActionNotFound
  end
  allowed_exceptions
end

Instance Method Details

#allowObject



113
114
115
116
117
118
119
# File 'lib/peck_on_rails/assertions.rb', line 113

def allow
  requirement = Disallow.new(context)
  requirement.negated = @negated
  requirement.method = :allowed?
  requirement.expected = true
  requirement
end

#disallowObject



105
106
107
108
109
110
111
# File 'lib/peck_on_rails/assertions.rb', line 105

def disallow
  requirement = Disallow.new(context)
  requirement.negated = @negated
  requirement.method = :disallowed?
  requirement.expected = true
  requirement
end

#findObject



121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/peck_on_rails/assertions.rb', line 121

def find
  requirement = Response.new(context)
  requirement.verb_description = 'find'
  requirement.method = :status
  if @negated
    requirement.expected = :not_found
    requirement.allowed_exceptions = ALLOWED_EXCEPTIONS
  else
    requirement.expected = :ok
  end
  requirement
end

#require_loginObject



97
98
99
100
101
102
103
# File 'lib/peck_on_rails/assertions.rb', line 97

def 
  requirement = RequireLogin.new(context)
  requirement.negated = @negated
  requirement.method = :login_required?
  requirement.expected = true
  requirement
end