Sha256: fcb8ee54a5630fb5779323002ec4dbadbc554f2528494f48668d2facc71e4903
Contents?: true
Size: 1.07 KB
Versions: 4
Compression:
Stored size: 1.07 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 builder = Opal::Builder.new builder.build 'opal' # Any lib should be already required in the page, # require won't work in this kind of templates. builder.build 'native' context = ExecJS.compile builder.to_s context.eval source rescue $!.message << "\n\n#{source}" raise end end
Version data entries
4 entries across 4 versions & 1 rubygems