Module: Mulang::Expectation
- Defined in:
- lib/mulang/expectation.rb
Defined Under Namespace
Modules: I18n
Classes: Custom, Standard, V0, V2
Constant Summary
collapse
- SMELLS =
%w(DiscardsExceptions DoesConsolePrint DoesNilTest DoesNullTest DoesTypeTest
HasAssignmentReturn HasCodeDuplication HasEmptyIfBranches HasRedundantRepeat HasLongParameterList
HasMisspelledBindings HasMisspelledIdentifiers
HasRedundantBooleanComparison HasRedundantGuards HasRedundantIf
HasRedundantLambda HasRedundantLocalVariableReturn HasRedundantParameter
HasRedundantReduction HasTooManyMethods HasTooShortBindings HasTooShortIdentifiers HasUnreachableCode
HasWrongCaseBinding HasWrongCaseIdentifiers IsLongCode OverridesEqualOrHashButNotBoth
ReturnsNil ReturnsNull UsesCut UsesFail UsesUnificationOperator)
Class Method Summary
collapse
Class Method Details
.guess_type(expectation) ⇒ Object
11
12
13
14
15
16
17
18
19
|
# File 'lib/mulang/expectation.rb', line 11
def self.guess_type(expectation)
if expectation[:binding] == '<<custom>>'
Custom
elsif expectation[:inspection] =~ /(Not\:)?Has.*/ && !has_smell?(expectation[:inspection])
V0
else
V2
end
end
|
.has_smell?(smell) ⇒ Boolean
21
22
23
|
# File 'lib/mulang/expectation.rb', line 21
def self.has_smell?(smell)
SMELLS.include? smell
end
|
.parse(expectation) ⇒ Object
25
26
27
|
# File 'lib/mulang/expectation.rb', line 25
def self.parse(expectation)
guess_type(expectation).parse(expectation)
end
|
.valid?(expectation) ⇒ Boolean
29
30
31
|
# File 'lib/mulang/expectation.rb', line 29
def self.valid?(expectation)
guess_type(expectation).valid?(expectation)
end
|