spec/gon/basic_spec.rb in gon-4.0.2 vs spec/gon/basic_spec.rb in gon-4.0.3
- old
+ new
@@ -45,10 +45,24 @@
Gon.set_variable var_name, 1
Gon.get_variable(var_name).should == 1
end
+ it 'can be support new push syntax' do
+ Gon.clear
+
+ Gon.push({ :int => 1, :string => 'string' })
+ Gon.all_variables.should == { :int => 1, :string => 'string' }
+ end
+
+ it 'push with wrong object' do
+ expect {
+ Gon.clear
+ Gon.push(String.new("string object"))
+ }.to raise_error("Object must have each_pair method")
+ end
+
end
describe '#include_gon' do
before(:each) do
@@ -130,9 +144,29 @@
it 'returns exception if try to set public method as variable' do
Gon.clear
lambda { Gon.all_variables = 123 }.should raise_error
lambda { Gon.rabl = 123 }.should raise_error
+ end
+
+
+ describe '#check_for_rabl_and_jbuilder' do
+
+ let(:controller) { ActionController::Base.new }
+
+ it 'should be able to handle ruby 1.8.7 style constants array (strings)' do
+ constants_as_strings = Gon.constants.map(&:to_s)
+ Gon.stub(:constants) { constants_as_strings }
+ lambda { Gon.rabl 'spec/test_data/sample.rabl', :controller => controller }.should_not raise_error
+ lambda { Gon.jbuilder 'spec/test_data/sample.json.jbuilder', :controller => controller }.should_not raise_error
+ end
+
+ it 'should be able to handle ruby 1.9+ style constants array (symbols)' do
+ constants_as_symbols = Gon.constants.map(&:to_sym)
+ Gon.stub(:constants) { constants_as_symbols }
+ lambda { Gon.rabl 'spec/test_data/sample.rabl', :controller => controller }.should_not raise_error
+ lambda { Gon.jbuilder 'spec/test_data/sample.json.jbuilder', :controller => controller }.should_not raise_error
+ end
end
def request
@request ||= double 'request', :env => {}
end