Sha256: d077c7090e8a9ed92451055653285e44910d017d079042c1a9a4a1323f16b3e7

Contents?: true

Size: 1.74 KB

Versions: 8

Compression:

Stored size: 1.74 KB

Contents

require "test_helper"

class StringTest < ActiveSupport::TestCase

  should "extract_settings" do
    assert_equal %w( a b c ), "a, b, c".extract_settings
    assert_equal %w( a b c ), " a  , b,  c ".extract_settings
  end

  should "remove prefix" do
    assert_equal "posts", "admin/posts".remove_prefix
    assert_equal "typus_users", "admin/typus_users".remove_prefix
    assert_equal "delayed/jobs", "admin/delayed/jobs".remove_prefix
  end

  should "remove prefix with params" do
    assert_equal "posts", "typus/posts".remove_prefix("typus/")
    assert_equal "typus_users", "typus/typus_users".remove_prefix("typus/")
    assert_equal "delayed/tasks", "typus/delayed/tasks".remove_prefix("typus/")
  end

  should "extract_resource" do
    assert_equal "posts", "admin/posts".extract_resource
    assert_equal "typus_users", "admin/typus_users".extract_resource
    assert_equal "delayed/tasks", "admin/delayed/tasks".extract_resource
  end

  should "extract_class" do
    assert_equal Post, "admin/posts".extract_class
    assert_equal TypusUser, "admin/typus_users".extract_class
    assert_equal Delayed::Task, "admin/delayed/tasks".extract_class
  end

  should "extract_human_name" do
    assert_equal "Post", "admin/posts".extract_human_name
    assert_equal "Typus user", "admin/typus_users".extract_human_name
    assert_equal "Task", "admin/delayed/tasks".extract_human_name
  end

  should "verify String#typus_actions_on" do
    assert_equal %w(cleanup), "Post".typus_actions_on("index")
    assert_equal %w(cleanup), "Post".typus_actions_on(:index)
    assert_equal %w(send_as_newsletter preview), "Post".typus_actions_on(:edit)
    assert "TypusUser".typus_actions_on(:unexisting).empty?
    assert "Post".typus_actions_on(:index).kind_of?(Array)
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
typus-1.0.0.pre8 test/lib/support/string_test.rb
typus-1.0.0.pre7 test/lib/support/string_test.rb
typus-1.0.0.pre6 test/lib/support/string_test.rb
typus-1.0.0.pre5 test/lib/support/string_test.rb
typus-1.0.0.pre4 test/lib/support/string_test.rb
typus-1.0.0.pre3 test/lib/support/string_test.rb
typus-1.0.0.pre2 test/lib/support/string_test.rb
typus-1.0.0.pre test/lib/support/string_test.rb