Sha256: 1588698b23ffd1b536294d3bdead3cf2e012344807de4ae869890aa904cfb79e

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

# gon_spec_rb
require 'gon'

describe Gon, '#all_variables' do 
  it 'returns all variables in hash' do
    Gon.a = 1
    Gon.b = 2
    Gon.c = Gon.a + Gon.b
    Gon.c.should == 3
    Gon.all_variables.should == {:a => 1, :b => 2, :c => 3}
  end
  
  it 'supports all data types' do
    Gon.clear
    Gon.int = 1
    Gon.float = 1.1
    Gon.string = 'string'
    Gon.array = [ 1, 'string' ]
    Gon.hash = { :a => 1, :b => '2'}
    Gon.hash_w_array = { :a => [ 2, 3 ] }
    Gon.klass = OpenStruct.new
    
    ActionView::Base.instance_methods.include?('include_gon').should == true
    base = ActionView::Base.new
    base.include_gon.should == "<script>window.Gon = {};" +
                                 "Gon.klass={\"table\":{}};" +
                                 "Gon.string=\"string\";" +
                                 "Gon.array=[1,\"string\"];" +
                                 "Gon.float=1.1;" +
                                 "Gon.int=1;" +
                                 "Gon.hash={\"a\":1,\"b\":\"2\"};" +
                                 "Gon.hash_w_array={\"a\":[2,3]};" +
                               "</script>"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gon-1.0.0 spec/gon/gon_spec.rb