minitest 用 helper 集
Add this line to your application's Gemfile:
gem 'ans-minitest_helper'And then execute:
$ bundle
Or install it yourself as:
$ gem install ans-minitest_helper
class ModelTest < ActiveSupport::TestCase
include Ans::MinitestHelper::Model
it "out of range validation" do
columns = passed_out_of_range_validation_columns(Model)
assert{columns == []}
end
it "out of range validation" do
columns = passed_out_of_range_validation_columns(Model,as: {name: "a"*20})
assert{columns == [:image_path]}
end
it "association indexes" do
columns = no_association_index_columns(Model)
assert{columns == []}
end
it "association indexes" do
columns = no_association_index_columns(Model,columns: %i{:my_association})
assert{columns == []}
end
endmysql のカラムの最大長以上の値を投入した場合に validation error にならないカラムを配列にして返す
文字列カラムのみチェックされる
カラム名はシンボルで返される
そのようなカラムが存在しない場合、空の配列が帰る
- as: カラムに対して out_of_range な値を指定する
インデックスが存在しない *_id のカラムを配列にして返す
そのようなカラムが存在しない場合、空の配列が帰る
- columns:
*_id以外のカラムをチェックする場合はカラムをシンボルで列挙する
- Fork it ( https://github.com/[my-github-username]/ans-minitest_helper/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request