Sha256: dbaec868fe8c5aafa1f1264c079659f3d8d32eb6d3f86aaf7f17bc2195dcf661
Contents?: true
Size: 980 Bytes
Versions: 1
Compression:
Stored size: 980 Bytes
Contents
shared_examples_for '.validate' do |attribute, invalid_attribute, valid_attribute| using_test_classes do const_name = attribute.to_s.split('_').map(&:capitalize).join class Model < Fortnox::API::Model::Base end Model.send( :include, Fortnox::API::Model::Attribute. const_get( const_name ) ) class Validator < Fortnox::API::Validator::Base end Validator.send( :include, Fortnox::API::Validator::Attribute. const_get( const_name ) ) end describe '.validate' do subject{ Validator.new } context "with :#{attribute} set to '#{invalid_attribute}'" do let( :invalid_model ){ Model.new( attribute => invalid_attribute ) } specify{ expect(subject.validate( invalid_model )).to eql( false ) } end context "with :#{attribute} set to '#{valid_attribute}'" do let( :valid_model ){ Model.new( attribute => valid_attribute ) } specify{ expect( subject.validate( valid_model )).to eql( true ) } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fortnox-api-0.1.0 | spec/fortnox/api/validators/attributes/examples_for_validate.rb |