0.2.0 • Published 8 years ago

code_cowboy-jasmine-shared-examples v0.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

jasmine-shared-examples

My implementation of the shared examples pattern for jasmine on node.js.

How it works

It inserts (and executes) any function defined by shared_examples_for at the point where it_behaves_like is called. The shared examples definition function is wrapped by a describe with the name of the shared examples used for the description of the describe.

Installation

npm install --save-dev code_cowboy-jasmine-shared-examples

Setup

Install the helper into spec/helpers/shared-examples.js:

node_modules/.bin/code_cowboy-jasmine-shared-examples init

Usage

Definition

shared_examples_for("some aspect", () => {
  beforeEach(() => { … });

  it("does something", () => { … });
  …
});

Utilization

it_behaves_like("some aspect");
});

Parametrize the shared examples

shared_examples_for("some aspect", (arg1, arg2, …) => {
  beforeEach(() => {
    // You may use arg1 etc. here.
  });

  it("does something", () => {
    // You may use arg1 etc. here.
  });

  describe(`aspect ${arg1}`, () => { … });
});

it_behaves_like("some aspect", arg1, arg2, …);

Extend the shared examples context

it_behaves_like("some aspect", () => {
  // This gets called within the `describe` context.
  beforeEach(() => { … });
});

Combine both

it_behaves_like("some aspect", arg1, arg2, …, () => {
  beforeEach(() => { … });
});
0.2.0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago