Sha256: 4343f80374dab88ffd460764b50877c551db7ebf69b3d525da9e2800d66e5fe9

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

require 'test_helper'

module Guts
  class OptionTest < ActiveSupport::TestCase
    test "should not create without key" do
      option = Option.new
      
      assert_not option.save
    end
    
    test "should create option" do
      option       = Option.new
      option.key   = "one_key"
      option.value = "To rule them all"
      
      assert_equal true, option.save
    end
    
    test "should normalize key name" do
      option       = Option.new
      option.key   = "One key!"
      
      option_two     = Option.new
      option_two.key = "one_key_two"
      
      assert_equal "one_key", option.key
      assert_equal "one_key_two", option_two.key
    end
    
    test "should not create with key less than three characters" do
      option     = Option.new
      option.key = "xy"
      
      assert_not option.save
    end
    
    test "should be trackable" do
      assert_equal true, Option.methods.include?(:trackable)
    end
    
    test "should find by key using helper method" do
      assert_instance_of Option, Option.for_key(:test_key)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
guts-1.0.8 test/models/guts/option_test.rb
guts-1.0.7 test/models/guts/option_test.rb
guts-1.0.5 test/models/guts/option_test.rb
guts-1.0.3 test/models/guts/option_test.rb