Skip to content

Commit

Permalink
Merge 2805e98 into 0d59c21
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud Dezandee authored and Arnaud Dezandee committed May 18, 2015
2 parents 0d59c21 + 2805e98 commit c418383
Show file tree
Hide file tree
Showing 56 changed files with 843 additions and 526 deletions.
4 changes: 2 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"no-label-var": 2,
"no-ternary": 0,
"no-self-compare": 2,
"no-sync": 2,
"no-sync": 0,
"no-underscore-dangle": 0,
"no-loop-func": 2,
"no-empty-label": 2,
Expand All @@ -64,7 +64,7 @@
"block-scoped-var": 0,
"camelcase": 2,
"complexity": [1, 11],
"consistent-this": [1, "_this"],
"consistent-this": 0,
"curly": 2,
"dot-notation": 2,
"eqeqeq": 2,
Expand Down
17 changes: 14 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
language: node_js
node_js:
- '0.10'
- '0.12'

env:
global:
secure: Iudzt3u8W/JujxrD9U+Z23rg3IS6mE604C/u49yvs+/8t+MwMfc1XHorIc5tHy+Uo5ViXc1sa/teRcsVFnZ5X+GzHV0Fd3TlbDRKopT4stHrRaApw1SJxUgJMMpGKU5jQnPo4E4VeDnU7tuylmX8N8rFudHg313yKi4CJsnphwQ=

addons:
firefox: "36.0"

cache:
directories:
- node_modules

before_install:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"

install:
- npm install -g webdriver-manager
- npm install -g codeclimate-test-reporter
- npm install -g coveralls
- npm install
- webdriver-manager update --standalone

before_script:
- phantomjs -w > /dev/null &
- sleep 3
- sleep 2
- webdriver-manager start > /dev/null &
- sleep 2
- npm start &
- sleep 3
- sleep 2

script: npm run coverage

Expand Down
175 changes: 175 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# API Reference

- [Core](#core)
- [`Mink.init(Object Cucumber, Object options)`](#minkinitobject-cucumber-object-options---undefined)
- [`Mink.call(Object Cucumber, Object options)`](#minkcallobject-cucumber-object-options---undefined)
- [`Mink.defineStep(Regex pattern, Function fn)`](#minkdefinestepregex-pattern-function-fn---stepobj)
- [`Mink.Given(Regex pattern, Function fn)`](#minkgivenregex-pattern-function-fn---stepobj)
- [`Mink.Then(Regex pattern, Function fn)`](#minkthenregex-pattern-function-fn---stepobj)
- [`Mink.When(Regex pattern, Function fn)`](#minkwhenregex-pattern-function-fn---stepobj)
- [`Mink.findStep(String input)`](#minkfindstepstring-input---stepobj)
- [`Mink.manyStep(String|Array<String> source, Function callback)`](#minkmanystepstringarraystring-source-function-callback---undefined)
- [`Mink.metaStep(Array<StepObj> steps, Function callback)`](#minkmetasteparraystepobj-steps-function-callback---undefined)
- [`Mink.runStep(String input, Function callback)`](#minkrunstepstring-input-function-callback---stepobj)
- [Driver](#driver)
- [Misc](#misc)

## Core

Core methods of `Mink` instance.

##### `Mink.init(Object Cucumber, Object options)` -> `Undefined`

Mink initialization method and entry point. Pass in the `Cucumber` context and an `options` object

```js
var parameters = {
driver: {
desiredCapabilities: {
browserName: 'phantomjs'
},
logLevel: 'silent',
port: 8910
}
};

Mink.init(Cucumber, parameters);
```

<hr>

##### `Mink.call(Object Cucumber, Object options)` -> `Undefined`

Deprecated. Use [`Mink.init()`](#minkinitobject-cucumber-object-options---undefined)

<hr>

##### `Mink.defineStep(Regex pattern, Function fn)` -> `StepObj`

Define a new step inside Mink-Cucumber context for use in `.features` files. Return the built `StepObj`.

The `Driver` object is injected as the first arguments in the step function. This avoid heavy use of `this` keyword.

```js
function doSomething(input, callback) {...}

Mink.defineStep(/^I do something with "([^"]*)" input$/, doSomething);
```

<hr>

##### `Mink.Given(Regex pattern, Function fn)` -> `StepObj`
##### `Mink.Then(Regex pattern, Function fn)` -> `StepObj`
##### `Mink.When(Regex pattern, Function fn)` -> `StepObj`

Syntactic sugar for [`Mink.defineStep()`](#minkdefinestepregex-pattern-function-fn---stepobj).

<hr>

##### `Mink.findStep(String input)` -> `StepObj`

Search through all defined step inside Mink context for a matching step with `input` string.

Return a `StepObj` or throws an error if none matches.

```js
Mink.findStep('Given I go to the homepage');
```

Note: the `StepObj` is enhanced with additional fields
* `input` - findStep query
* `args` - regex capturing groups

<hr>

##### `Mink.manyStep(String|Array<String> source, Function callback)` -> `Undefined`

Takes `String` or `Array<String>` as the `source` and tries to execute each line in series as Cucumber steps.

Callback when all steps are done.

```js
Mink.manyStep([
'I browse "http://localhost:3000/"',
'I am on the homepage',
'I should be on the homepage'
], callback);
```

<hr>

##### `Mink.metaStep(Array<StepObj> steps, Function callback)` -> `Undefined`

Takes `Array<StepObj>` and executes each step in series.

Callback when all steps are done.

```js
var stepsArray = [
{
fn: Ext.Navigation.browse,
args: ['/form']
},
{
fn: Ext.Action.click,
args: ['button[type="submit"]']
}
];

Mink.metaStep(stepsArray, callback);
```

<hr>

##### `Mink.runStep(String input, Function callback)` -> `StepObj`

Search and execute the step matching `input` string. Return the executed `StepObj`.

```js
Mink.runStep('I press ".button-missing"', function(err) {
assert.isNull(err);
});
```

## Driver

cucumber-mink uses WebDriverIO internally: [WebDriverIO](https://github.com/webdriverio/webdriverio).

This driver allow you to communicate with any Selenium compatible grid/hub. The driver default settings use Phantomjs/GhostDriver

``` javascript
var parameters = {
driver: {
desiredCapabilities: {
browserName: 'phantomjs'
},
logLevel: 'silent',
port: 8910
}
};
```

This driver can be used to communicate with various browser:
* [Chrome](examples/local-chrome.js)
* [Firefox](examples/local-firefox.js)
* [SauceLabs](https://saucelabs.com/)
* [BrowserStack](http://www.browserstack.com/)
See [examples](examples/)

## Misc

You can use an environment variable and then reference it in your features files to set the base url of your application

``` bash
export CUCUMBER_URL=http://localhost:3000
```

``` gherkin
...
Background:
Given I browse "${CUCUMBER_URL}"
Scenario:
Given I am on "/post/2"
...
```
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## Master
* BC: Unified `StepObj` blueprint between Mink's functions
* Added new methods on Mink object: `mink.findStep()`, `mink.manyStep()`, `mink.runStep()`
* Exported internal testing methods in spec files
* Enabled Firefox in Travis-CI

## v0.4.0 (2015-03-19)
* BC: `cucumber.defineStep()` and siblings reverted to standard cucumber-js.
* BC: Mink is now a less intrusive library. You should call it with `mink.init(cucumberContext, parameters)` instead of `mink.call()`.
Expand Down

0 comments on commit c418383

Please sign in to comment.