title: How can I get my jasmine tests fixtures to load before the javascript considers the document to be "ready"?
body: <p>I am fairly certain that the issue is that the jquery bindings set to run on $(document).ready do not have the fixture html available to them.  So when my events occur that are intended to make a change to the DOM via a jquery function, nothing happens, and my tests fail.  I saw a "solution" to this problem <a href="https://stackoverflow.com/questions/11191966/jquery-triggerclick-not-working-with-jasmine-jquery">here</a>, but that solution which did work for me, required changing my working jquery function to bind with the .live method instead of the .click method.  I have two issue with this.  First I do not want to have to change my working code so that the tests will pass properly.  The testing framework ought to test whether the code will work in the app, where the DOM load and the javascript bindings occur in the correct order.  The second issue I have with the solution is that .on and .delegate both did not work for some reason and the only thing that ended up working was to use the .live method which is currently in the process of being deprecated.  In conclusion, I would like to figure out how to change either my tests or the testing framework itself, such that the fixtures are loaded before the functions that run in $(document).ready. </p>
  
  <p>I am working with rails 3.2.8 and I have two different branches set up to experiment with jasmine testing. One of the branches uses the jasminerice gem and the other uses the jasmine-rails gem. The Javascript and jQuery(when using the .live method) tests all pass properly in both of these set-ups.</p>
  
  <p>Here is a description of the branch using jasminerice:</p>
  
  <p>Here are the lines from my Gemfile.lock file describing the jasmine and jQuery set-up:</p>
  
  <pre><code>jasminerice (0.0.9)
    coffee-rails
    haml
  jquery-rails (2.1.3)
    railties (&gt;= 3.1.0, &lt; 5.0)
    thor (~&gt; 0.14)
  </code></pre>
  
  <p>Jasminerice includes the <a href="https://github.com/velesin/jasmine-jquery" rel="nofollow noreferrer">jasmine-jquery</a> extension by default.  The jasmine-jQuery extension provides the toHaveText method I am using in the tests.</p>
  
  <p>The test file jasmine_jquery_test.js which is located directly within the spec/javascripts directory contains this content:</p>
  
  <pre><code>#= require application
  
  describe ("my basic jasmine jquery test", function(){
  
      beforeEach(function(){
          $('&lt;a id="test_link" href="somewhere.html"&gt;My test link&lt;/a&gt;').appendTo('body');
      });
  
      afterEach(function(){
          $('a#test_link').remove();
      });
  
      it ("does some basic jQuery thing", function () {
          $('a#test_link').click();
          expect($("a#test_link")).toHaveText('My test link is now longer');
      });
  
      it ("does some the same basic jQuery thing with a different trigger type", function () {
          $('a#test_link').trigger('click');
          expect($("a#test_link")).toHaveText('My test link is now longer');
      });
  
  });
  describe ('subtraction', function(){
  
      var a = 1;
      var b = 2;
  
      it("returns the correct answer", function(){
          expect(subtraction(a,b)).toBe(-1);
      });
  
  });
  </code></pre>
  
  <p>My javascript file tests.js which is located in the app/assets/javascripts dir has this content:</p>
  
  <pre><code>function subtraction(a,b){
      return a - b;
  }
  
  jQuery (function($) {
  /* 
      The function I would rather use - 
      $("a#test_link").click(changeTheTextOfTheLink)
      function changeTheTextOfTheLink(e) {
          e.preventDefault()
          $("a#test_link").append(' is now longer');
      }
  */
  
      $("a#test_link").live('click', function(e) {
          e.preventDefault();
          $("a#test_link").append(' is now longer');
      });
  
  });
  </code></pre>
  
  <p>My application.js file located in the same app/assets/javascripts dir has this content:</p>
  
  <pre><code>//= require jquery
  //= require jquery_ujs
  //= require bootstrap
  //= require vendor
  //= require_tree . 
  </code></pre>
  
  <p>And the description of the jasmine-rails branch can be found in the content of my <a href="https://stackoverflow.com/questions/12358051/why-is-the-jquery-code-not-executing-or-at-least-not-appearing-to-execute-in-m">first jasmine test related stackoverflow question</a>.</p>
  
  <p>So if anyone has an idea how to manipulate the tests such that the $(document).ready functions are run after the fixtures are loaded I would very much like to hear your thoughts?</p>