Skip to content
Permalink
Browse files
fix(core): actor throws ConfigurationError when it's not given the ab…
…ilities needed to run the test
  • Loading branch information
jan-molak committed Jan 29, 2020
1 parent d7049a2 commit d99ac88b2024b70e1d0d16420613a0b941fc1a99
Showing with 4 additions and 3 deletions.
  1. +2 −1 packages/core/spec/screenplay/actor.spec.ts
  2. +2 −2 packages/core/src/screenplay/actor/Actor.ts
@@ -1,6 +1,7 @@
import 'mocha';

import * as sinon from 'sinon';
import { ConfigurationError } from '../../src/errors';

import { InteractionFinished, InteractionStarts } from '../../src/events';
import { ActivityDetails, ExecutionSuccessful, Name, Timestamp } from '../../src/model';
@@ -104,7 +105,7 @@ describe('Actor', () => {

expect(actor('Ben').attemptsTo(
PlayAChord.of(Chords.AMajor),
)).to.be.eventually.rejectedWith(`Ben can't PlayAGuitar yet. Did you give them the ability to do so?`));
)).to.be.eventually.rejectedWith(ConfigurationError, `Ben can't PlayAGuitar yet. Did you give them the ability to do so?`));

/** @test {Actor} */
it('can be instantiated without explicitly specifying the Stage', () => {
@@ -1,5 +1,5 @@
import { ActivityRelatedArtifactGenerated } from '../../events';
import { Ability, AbilityType, Answerable, DressingRoom, serenity, TestCompromisedError } from '../../index';
import { Ability, AbilityType, Answerable, ConfigurationError, DressingRoom, serenity, TestCompromisedError } from '../../index';
import { Artifact, Name } from '../../model';
import { Stage } from '../../stage';
import { TrackedActivity } from '../activities';
@@ -41,7 +41,7 @@ export class Actor implements PerformsActivities, UsesAbilities, CanHaveAbilitie

abilityTo<T extends Ability>(doSomething: AbilityType<T>): T {
if (! this.can(doSomething)) {
throw new TestCompromisedError(`${ this.name } can't ${ doSomething.name } yet. ` +
throw new ConfigurationError(`${ this.name } can't ${ doSomething.name } yet. ` +
`Did you give them the ability to do so?`);
}

0 comments on commit d99ac88

Please sign in to comment.