Sha256: 0b89eb4a27a703b7d265398e0f1f36c69eedb39fb10aea20e0d131530748807e

Contents?: true

Size: 1.07 KB

Versions: 8

Compression:

Stored size: 1.07 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

  context "remove_prefix" do

    should "remove admin by default" 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 what we want to" 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

  end

  context "extract_class" do

    should "work for models" do
      assert_equal Post, "admin/posts".extract_class
      assert_equal TypusUser, "admin/typus_users".extract_class
    end

    should "work for namespaced models" do
      assert_equal Delayed::Task, "admin/delayed/tasks".extract_class
    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
typus-3.0.2 test/lib/support/string_test.rb
typus-3.0.1 test/lib/support/string_test.rb
typus-3.0.0 test/lib/support/string_test.rb
typus-1.0.0.pre13 test/lib/support/string_test.rb
typus-1.0.0.pre12 test/lib/support/string_test.rb
typus-1.0.0.pre11 test/lib/support/string_test.rb
typus-1.0.0.pre10 test/lib/support/string_test.rb
typus-1.0.0.pre9 test/lib/support/string_test.rb