Sha256: fad2781436c73c0d777ffe1c13d07f1d54ba01788c4a98a8637e724a3d8963f4

Contents?: true

Size: 1.39 KB

Versions: 3

Compression:

Stored size: 1.39 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper.rb'

describe "JellyHelper" do

  describe "#init_specific_javascript" do
    it "should create a javascript include tag to initialize the Page object" do
      stub_controller = mock(Object, :controller_path => 'my_fun_controller', :action_name => 'super_good_action')
      helper.should_receive(:controller).any_number_of_times.and_return(stub_controller)
      helper.should_receive(:form_authenticity_token).and_return('areallysecuretoken')
      output = helper.spread_jelly
      output.should include('<script type="text/javascript">')
      output.should include("Jelly.activatePage('MyFunController', 'super_good_action');")
    end
  end

  describe "#application_jelly_files" do
    it "returns the javascript files in the given path" do
      my_rails_root = File.join(File.dirname(__FILE__), '/../fixtures')
      files = helper.application_jelly_files("foo", my_rails_root)
      files.should_not be_empty
      files.should =~ ['foo/pages/lions', 'foo/pages/tigers', 'foo/pages/bears']
    end
  end

  describe "#attach_javascript_component" do
    it "adds a call to page.attach in the javascript content" do
      helper.attach_javascript_component("MyComponent", 'arg1', 'arg2', 'arg3')
      expected_args = ['arg1','arg2','arg3'].to_json
      assigns[:content_for_javascript].should include("page.attach(MyComponent, #{expected_args}")
    end
  end

end

Version data entries

3 entries across 3 versions & 3 rubygems

Version Path
honkster-honkster-jelly-0.3.0 spec/helpers/jelly_helper_spec.rb
pivotal-honkster-jelly-0.3.0 spec/helpers/jelly_helper_spec.rb
pivotal-jelly-0.3.1 spec/helpers/jelly_helper_spec.rb