Sha256: ccbf2cb3b5946116d0dec9b3c1d3a260a0e3377e2517a4d0c5dd6bb68a155cac
Contents?: true
Size: 1.02 KB
Versions: 7
Compression:
Stored size: 1.02 KB
Contents
require 'test_helper' describe Merit::Rule do before do @rule = Merit::Rule.new end describe '#applies (with block)' do before do @rule.block = ->(obj) { obj.length < 4 } end it 'truthy block should make rule apply' do @rule.applies?('str').must_be :==, true end it 'falsy block should make rule fail' do @rule.applies?('string').must_be :==, false end it 'block needs parameter for rule to pass' do @rule.applies?.must_be :==, false end end describe '#applies (without block)' do it 'empty condition should make rule apply' do @rule.applies?.must_be :==, true end end describe '#badge' do it 'raises exception on inexistent badge' do @rule.badge_name = 'inexistent' ->{ @rule.badge }.must_raise Merit::BadgeNotFound end it 'finds related badge' do badge = Merit::Badge.create(id: 98, name: 'test-badge-98') @rule.badge_name = badge.name @rule.badge.must_be :==, Merit::Badge.find(98) end end end
Version data entries
7 entries across 7 versions & 1 rubygems