Sha256: 3c3c14362bfce7250b0277d94691089256ae3eb6ac31f2de19c4515be7ed3e61
Contents?: true
Size: 952 Bytes
Versions: 14
Compression:
Stored size: 952 Bytes
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' context = ExecJS.compile opal_source context.eval source rescue $!.message << "\n\n#{source}" raise end end
Version data entries
14 entries across 14 versions & 1 rubygems