Sha256: 4737d79dae4184e23f46ba2358dbe8a44ca14ddbbe6bc4adb227b742bc2fa72b

Contents?: true

Size: 761 Bytes

Versions: 3

Compression:

Stored size: 761 Bytes

Contents

require File.dirname(__FILE__) + '/../../spec_helper'

describe Class do
  describe "#to_js_func_name" do
    it "returns name without changes when is compatible with js" do
      :foo.to_js_func_name.should == :foo
    end

    it "changes '=' for 'set_' prefix" do
      :foo=.to_js_func_name.should == :set_foo
    end

    it "changes '?' for 'is_' prefix" do
      :foo?.to_js_func_name.should == :is_foo
    end

    it "changes '!' for '_bang' suffix" do
      :foo!.to_js_func_name.should == :foo_bang
    end

    it "returns nil when method name is unconvertable to javascript" do
      [:+, :-, :%, :&, :*, :~, :=~, :/, :>, :<, :>>, :<<, :'=', :'==', :'===', :'<=>'].each { |meth|
        meth.to_js_func_name.should_not be
      }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mustang-0.2.2 spec/mustang/core_ext/symbol_spec.rb
mustang-0.2.1 spec/mustang/core_ext/symbol_spec.rb
mustang-0.2.0 spec/mustang/core_ext/symbol_spec.rb