<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

  <head>
    <title>Jasmine Spec Runner</title>
    <link rel="shortcut icon" type="image/png" href="lib/jasmine-1.3.0/jasmine_favicon.png" />
    <!-- include source files here... -->
    <link data-require="jasmine@*" data-semver="2.0.0" rel="stylesheet" href="//cdn.jsdelivr.net/jasmine/2.0.0rc2/jasmine.css" />
    <script data-require="jasmine@*" data-semver="2.0.0" src="//cdn.jsdelivr.net/jasmine/2.0.0rc2/jasmine.js"></script>
    <script data-require="jasmine@*" data-semver="2.0.0" src="//cdn.jsdelivr.net/jasmine/2.0.0rc2/jasmine-html.js"></script>
    <script data-require="jasmine@*" data-semver="2.0.0" src="//cdn.jsdelivr.net/jasmine/2.0.0rc2/boot.js"></script>
    <script data-require="json2@*" data-semver="0.0.2012100-8" src="//cdnjs.cloudflare.com/ajax/libs/json2/20121008/json2.js"></script>
    
    <!-- include src files here... -->
    <script type="text/javascript" src="Calculator.js"></script>
    <!-- include spec files here... -->
    <script type="text/javascript" src="Calculator.spec.js"></script>
    
    
    <script type="text/javascript">
    (function() {
      var jasmineEnv = jasmine.getEnv();
      jasmineEnv.updateInterval = 1000;

      var htmlReporter = new jasmine.HtmlReporter();

      jasmineEnv.addReporter(htmlReporter);

      jasmineEnv.specFilter = function(spec) {
        return htmlReporter.specFilter(spec);
      };

      var currentWindowOnload = window.onload;

      window.onload = function() {
        if (currentWindowOnload) {
          currentWindowOnload();
        }
        execJasmine();
      };

      function execJasmine() {
        jasmineEnv.execute();
      }

    })();
  </script>
  </head>

  <body></body>

</html>
function Calculator() {
}

Calculator.prototype.add = function() {
  var operands = Array.prototype.slice.call(arguments);
  var sum = 0;
  for(var i = 0; i < operands.length; i++) {
    sum += operands[i];
  }
  
  return sum;
}
describe('Given the Calculator', function() {
  var calc = new Calculator();
  var sum;

  it('Then it contains an add method', function() {
    expect(calc.add).toBeDefined();
  });

  describe('When I add two numbers', function() {

    it('Then the I get the correct answer', function() {
      sum = calc.add(1, 2);
      expect(sum).toBe(3);
    });
  });

  describe('When I add three numbers', function() {

    it('Then the I get the correct answer', function() {
      sum = calc.add(1, 2, 7);
      expect(sum).toBe(10);
    });
  });
});