Sha256: 7435f7a7004d49a491c538c8a07d8940a7031c026a0dd95d17c364beeb54af6d

Contents?: true

Size: 1.63 KB

Versions: 22

Compression:

Stored size: 1.63 KB

Contents

describe("toHaveBeenCalled", function() {
  it("passes when the actual was called, with a custom .not fail message", function() {
    var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
      calledSpy = jasmineUnderTest.createSpy('called-spy'),
      result;

    calledSpy();

    result = matcher.compare(calledSpy);
    expect(result.pass).toBe(true);
    expect(result.message).toEqual("Expected spy called-spy not to have been called.");
  });

  it("fails when the actual was not called", function() {
    var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
      uncalledSpy = jasmineUnderTest.createSpy('uncalled spy'),
      result;

    result = matcher.compare(uncalledSpy);
    expect(result.pass).toBe(false);
  });

  it("throws an exception when the actual is not a spy", function() {
    var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
      fn = function() {};

    expect(function() { matcher.compare(fn) }).toThrowError(Error, /Expected a spy, but got Function./);
  });

  it("throws an exception when invoked with any arguments", function() {
    var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
      spy = jasmineUnderTest.createSpy('sample spy');

    expect(function() { matcher.compare(spy, 'foo') }).toThrowError(Error, /Does not take arguments, use toHaveBeenCalledWith/);
  });

  it("has a custom message on failure", function() {
    var matcher = jasmineUnderTest.matchers.toHaveBeenCalled(),
      spy = jasmineUnderTest.createSpy('sample-spy'),
      result;

    result = matcher.compare(spy);

    expect(result.message).toEqual("Expected spy sample-spy to have been called.");
  });
});

Version data entries

22 entries across 19 versions & 2 rubygems

Version Path
tdiary-5.0.8 vendor/bundle/gems/tdiary-5.0.7/vendor/bundle/gems/jasmine-core-2.8.0/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js
jasmine-core-2.99.1 ./lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js
jasmine-core-2.99.0 ./lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js
jasmine-core-2.9.1 ./lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js
jasmine-core-2.9.0 ./lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js
tdiary-5.0.7 vendor/bundle/gems/jasmine-core-2.8.0/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js
tdiary-5.0.6 vendor/bundle/gems/jasmine-core-2.8.0/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js
jasmine-core-2.8.0 ./lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js
jasmine-core-2.7.0 ./lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js
tdiary-5.0.5 vendor/bundle/gems/jasmine-core-2.5.2/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/jasmine-core-2.5.2/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js
tdiary-5.0.5 vendor/bundle/gems/jasmine-core-2.6.4/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js
tdiary-5.0.5 vendor/bundle/gems/jasmine-core-2.6.3/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js
jasmine-core-2.6.4 ./lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js
jasmine-core-2.6.3 ./lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js
jasmine-core-2.6.2 ./lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js
jasmine-core-2.6.1 ./lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js
jasmine-core-2.6.0 ./lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js
tdiary-5.0.4 vendor/bundle/gems/jasmine-core-2.5.2/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js
jasmine-core-2.5.2 ./lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js