Sha256: 74b3291b00fa591bdd74b468d578a9eb3ac467ba8f497710ac591b814224a6ec
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 KB
Contents
# frozen_string_literal: true require 'test_helper' require 'action_controller/metal/strong_parameters' module Upgrow class InputTest < ActiveSupport::TestCase class SampleInput < Input attribute :title attribute :body validates :title, presence: true end test '#errors is an empty Active Model Errors' do input = Input.new errors = input.errors assert_empty errors end test '.new accepts individual arguments' do input = SampleInput.new(title: 'volmer', body: 'hello') assert_equal 'volmer', input.title assert_equal 'hello', input.body end test '.new accepts a Hash of Symbols' do args = { title: 'volmer', body: 'hello' } input = SampleInput.new(args) assert_equal 'volmer', input.title assert_equal 'hello', input.body end test '.new accepts a Hash of Strings' do args = { 'title' => 'volmer', 'body' => 'hello' } input = SampleInput.new(args) assert_equal 'volmer', input.title assert_equal 'hello', input.body end test '.new accepts Action Controller parameters' do args = ActionController::Parameters.new( 'title' => 'volmer', 'body' => 'hello' ).permit(:title, :body) input = SampleInput.new(args) assert_equal 'volmer', input.title assert_equal 'hello', input.body end test '.valid? is true when validation passes' do input = SampleInput.new(title: 'volmer') assert_predicate input, :valid? end test '.valid? is false when validation fails' do input = SampleInput.new refute_predicate input, :valid? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
upgrow-0.0.2 | test/upgrow/input_test.rb |