Sha256: 7e44fd6dc6409cfd1827ceedf9d555aedce360b595a8105f3c13bb9ef3dac765

Contents?: true

Size: 758 Bytes

Versions: 2

Compression:

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

2 entries across 2 versions & 1 rubygems

Version Path
mustang-0.1.1 spec/core_ext/symbol_spec.rb
mustang-0.1.0 spec/core_ext/symbol_spec.rb