Sha256: 1793d8e125524789e5d35dd2d23962485bebde7cf95b88e10f57782914ec16ee
Contents?: true
Size: 1.49 KB
Versions: 19
Compression:
Stored size: 1.49 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 by name, when the name is a string' do Merit::Badge.create(id: 98, name: 'test-badge-98') @rule.badge_name = "test-badge-98" _(@rule.badge).must_be :==, Merit::Badge.find(98) end it 'finds related badge by name, when the name is a symbol' do Merit::Badge.create(id: 100, name: :testbadge) @rule.badge_name = 'testbadge' _(@rule.badge).must_be :==, Merit::Badge.find(100) @rule.badge end it 'finds related badge by name' do Merit::Badge.create(id: 98, name: 'test-badge-98') @rule.badge_id = 98 _(@rule.badge).must_be :==, Merit::Badge.find(98) end end end
Version data entries
19 entries across 19 versions & 2 rubygems