Sha256: 7e048b6d075fa068cae8c02ee9fd164a88835fa738b397e34ee921cb99a85355

Contents?: true

Size: 1.17 KB

Versions: 29

Compression:

Stored size: 1.17 KB

Contents

require File.expand_path(File.dirname(__FILE__) + "/test_helper")
require File.expand_path(File.dirname(__FILE__) + "/utility_test_cases")

describe Artoo::Utility do
  include UtilityTestCases
  include Artoo::Utility

  describe "#random_string" do
    it "returns an 8-character String" do
      random_string.must_be_kind_of String
      random_string.size.must_equal 8
    end
  end

  describe "#classify" do
    it "converts a snake_case string to CamelCase" do
      classify("firmata").must_equal "Firmata"
      classify("ardrone_awesome").must_equal "ArdroneAwesome"

      CamelToUnderscore.each do |camel, underscore|
        classify(underscore).must_equal camel
      end
    end
  end

  describe "#underscore" do
    it "converts CamelCase strings to snake_case" do
      CamelToUnderscore.each do |camel, underscore|
        underscore(camel).must_equal underscore
      end

      underscore("HTMLTidy").must_equal "html_tidy"
      underscore("HTMLTidyGenerator").must_equal "html_tidy_generator"
    end
  end

  describe "#constantize" do
    it "converts strings to constants" do
      run_constantize_tests_on do |string|
        constantize(string)
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
artoo-1.8.2 test/utility_test.rb
artoo-1.8.1 test/utility_test.rb
artoo-1.8.0 test/utility_test.rb
artoo-1.6.7 test/utility_test.rb
artoo-1.6.6 test/utility_test.rb
artoo-1.6.5 test/utility_test.rb
artoo-1.6.4 test/utility_test.rb
artoo-1.6.3 test/utility_test.rb
artoo-1.6.2 test/utility_test.rb
artoo-1.6.1 test/utility_test.rb
artoo-1.6.0 test/utility_test.rb
artoo-1.5.0 test/utility_test.rb
artoo-1.4.1 test/utility_test.rb
artoo-1.4.0 test/utility_test.rb
artoo-1.3.0 test/utility_test.rb
artoo-1.2.2 test/utility_test.rb
artoo-1.2.1 test/utility_test.rb
artoo-1.2.0 test/utility_test.rb
artoo-1.1.1 test/utility_test.rb
artoo-1.1.0 test/utility_test.rb