Sha256: 3d5491b32d4ae9ed7765fc0dbb17fadb39dcd50d70b97727772fcd8413fba1b1
Contents?: true
Size: 1.09 KB
Versions: 4
Compression:
Stored size: 1.09 KB
Contents
require 'spec_helper' require 'execjs' describe 'controller assignments' do it 'are in the template' do source = get_source_of '/application/with_assignments.js' source.gsub!(/;\s*\Z/,'') # execjs eval doesn't like the trailing semicolon assignments = opal_eval(source) { :number_var => 1234, :string_var => 'hello', :array_var => [1,'a'], :hash_var => {:a => 1, :b => 2}.stringify_keys, :object_var => {:contents => 'json representation'}.stringify_keys, :local_var => 'i am local', }.each_pair do |ivar, assignment| assignments[ivar.to_s].should eq(assignment) end end def get_source_of path get path response.should be_success source = response.body end def opal_eval source opal_source = get_source_of '/assets/opal.js' # Any lib should be already required in the page, # require won't work in this kind of templates. opal_source << get_source_of('/assets/native.js') context = ExecJS.compile opal_source context.eval source rescue $!.message << "\n\n#{source}" raise end end
Version data entries
4 entries across 4 versions & 1 rubygems