title: Testing of Backbone code inside anonymous function using Jasmine and Sinon
body: <p>Here are snippet from my code </p>
  
  <pre><code>(function(){
  var BootModel = Backbone.View.extend();
      var BootApp = Backbone.View.extend({
      initialize : function(options) {
              //some logical code
      },
      render : function() {
          //some more logical code
      }
  });
  new BootApp({
      aggregatedEvent : _.extend({}, Backbone.Events),
      model: new BootModel()
  });
  })();
  </code></pre>
  
  <p>Now as you can see I have logical code goes inside my views, I need to test these view using Jasmine, but in my case everything is inside private scope (I did this thing to prevent accessing of my code from external dev tool like firebug and modifying my model or any attribute state )</p>
  
  <p>I tried many things looked into Sinon to understand if I can use Spy but nothing worked for me </p>
  
  <p>Similar question could be : <a href="https://stackoverflow.com/questions/8242086/anonymous-function-in-coffeescript-how-to-test-it">Anonymous function in Coffeescript how to test it</a></p>
  
  <p>I want to understand where I going wrong?
  Is my approach for hiding everything inside Anonymous function is wrong?
  If Yes then what would be best practice for such implementation ? 
  If No then How I am going to test this kind of code</p>
  
  <p>PS : I am not in favor of backdoor manipulation. </p>
  
  <p>Thanks in advance for helping</p>