Not to be a downer, but... while I like the idea of a minitest-sequel 
helper, I'm don't find those assertions particularly helpful.  It seems 
like you're just duplicating the migrations and model validation statements 
in test form.  I guess it would protect you from someone accidentally 
deleting a validation in a model, but it creates a lot of extra work 
(keeping the tests in sync with schema and validation changes, and will 
probably result in copy/paste from models in practice, which means errors 
in defining the validation will be inherited in the tests).

What I might find useful is a way to make it easier to test custom 
validations and hook behavior, since that's where I'm writing my own code 
that could use tests, as opposed to simply calling the built-in validates_* 
methods (which are already tested in the sequel gem, and for which the 
syntax is intuitive and well-defined).

-ofer

On Tuesday, September 22, 2015 at 8:04:35 AM UTC-4, Kematzy wrote:
>
> Hi,
>
> I just released *Minitest-Sequel* [ 
> https://github.com/kematzy/minitest-sequel ], a collection of convenient 
> assertions for testing common Sequel features with Minitest.
>
> It is still very much work in progress, so please feel free to assist in 
> improving or adding to this gem. *Especially if you can work out how to 
> test Sequel validations in Minitest.*
>
> Any help will be gratefully received.
>
>
> Included assertions are:
>
> *- TABLE DEFINITIONS:*
>
> -- assert_have_column()
>
>
> *- ASSOCIATIONS:*
>
> -- assert_association_one_to_one()
>
> -- assert_association_one_to_many()
>
> -- assert_association_many_to_one()
>
> -- assert_association_many_to_many()
>
> -- assert_association()
>
>
> *- VALIDATIONS:*  (work in progress and not working)
>
> -- assert_validates_presence()
>  
> -- assert_validates_exact_length()
>  
> -- assert_validates_length_range()
>  
> -- assert_validates_max_length()
>  
> -- assert_validates_min_length()
>  
> -- assert_validates_format()
>  
> -- assert_validates_includes()
>  
> -- assert_validates_integer()
>  
> -- assert_validates_not_string()
>  
> -- assert_validates_numeric()
>  
> -- assert_validates_unique()
>
>
>
> *Test Examples:*
>    
> let(:m) { Post.first }
>     
> # test model/table definition
> it { assert_have_column(m, :title, { type: 'string', db_type: 
> 'varchar(255)', allow_null: :false }) }
> it { assert_have_column(m, :body,  { type: 'string', db_type: 'text'}) }
>     
> # test model associations
> it { assert_association_one_to_many(m, :comments) }
> it { assert_association_many_to_one(m, :author)   }
> it { assert_association_many_to_many(m, :tags)    }
>     
> it { assert_association_one_to_one(m, :first_comment, { class: :Commment, 
> order: :id }) }
>
>
>
> *USAGE:*
>
>   $ gem install minitest-sequel
>   
>
> In your project's *spec_helper.rb* or *test_helper.rb* file:
>
> require 'minitest/sequel'
> require 'minitest/autorun'
>   
> ## add migrations and seeds 
>
> require 'sqlite3'
>   
> DB = Sequel.sqlite # memory
>
>
>
>   
>
> Hopefully this will help someone.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to