plummbur_kruk 0.1.2

  • README.md
  • Installing
  • Versions
  • 0

Plummbur Kruk

A “real fake” HTTP server specially designed to support browsers tests that make HTTP requests.

Build Status

Getting Started

You'll need Dart.

Install this from pub as plummbur_kruk.

To start the plummbur_kruk server, use the start.sh script:

# Start the test server
packages/plummbur_kruk/start.sh

The test server runs on port 31337.

To stop the server, use the stop.sh script:

# Stop the server
packages/plummbur_kruk/stop.sh

Using with dart:html

A REST-like API is available at http://localhost:31337/widgets. The most common REST verbs will work: GET, POST, PUT, DELETE.

When testing browser code, it is not possible to access a running server. The Kruk server can be controlled through a simple client-side API.

To create a record, use:

static Future<HttpRequest> create(String json)

For example:

  var id;
  setUp(() {
    return Kruk.
      create('{"foo": 42}').
      then((res) {
        id = JSON.parse(res.responseText)['id'];
      });
  });

If you would like a one-request alias for /widgets, use Kruk.alias():

static Future<HttpRequest> alias(String old_url, {as: String})

To delete all record, use Kruk.deleteAll():

static Future<HttpRequest> deleteAll()

This is especially useful when deleting records in a unittest tearDown():

  tearDown(()=> Kruk.deleteAll());

As Part of a Test Runner

In a test_runner.sh script, be sure to allow stop.sh to run before exiting on failure:

# Start the test server
echo "starting test server"
packages/plummbur_kruk/start.sh

echo "content_shell --dump-render-tree test/index.html"
results=`content_shell --dump-render-tree test/index.html 2>&1`

echo "$results"

# Stop the server
packages/plummbur_kruk/stop.sh

# check to see if DumpRenderTree tests
# fails, since it always returns 0
if [[ "$results" == *"Some tests failed"* ]]; then
    exit 1
fi

if [[ "$results" == *"Exception: "* ]]; then
    exit 1
fi

Address Already in Use

Sometimes it is possible for things to go quite wrong. If the kruk.pid file is deleted before the server shuts down, it needs to be stopped manually. The netstat command is your friend:

$ sudo netstat -nlp | grep 31337
tcp        0      0 127.0.0.1:31337         0.0.0.0:*               LISTEN      2879/dart
$ kill 2879

License

This software is licensed under the MIT License. See LICENSE for details.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  plummbur_kruk: ^0.1.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:plummbur_kruk/kruk.dart';
import 'package:plummbur_kruk/server.dart';
  
Version Uploaded Documentation Archive
0.1.2 Dec 5, 2013 Go to the documentation of plummbur_kruk 0.1.2 Download plummbur_kruk 0.1.2 archive
0.1.1 Dec 4, 2013 Go to the documentation of plummbur_kruk 0.1.1 Download plummbur_kruk 0.1.1 archive
0.1.0 Nov 7, 2013 Go to the documentation of plummbur_kruk 0.1.0 Download plummbur_kruk 0.1.0 archive
0.0.7 Oct 10, 2013 Go to the documentation of plummbur_kruk 0.0.7 Download plummbur_kruk 0.0.7 archive
0.0.6 Sep 21, 2013 Go to the documentation of plummbur_kruk 0.0.6 Download plummbur_kruk 0.0.6 archive
0.0.5 Sep 2, 2013 Go to the documentation of plummbur_kruk 0.0.5 Download plummbur_kruk 0.0.5 archive
0.0.4 Aug 31, 2013 Go to the documentation of plummbur_kruk 0.0.4 Download plummbur_kruk 0.0.4 archive
0.0.3 Aug 31, 2013 Go to the documentation of plummbur_kruk 0.0.3 Download plummbur_kruk 0.0.3 archive
0.0.2 Aug 31, 2013 Go to the documentation of plummbur_kruk 0.0.2 Download plummbur_kruk 0.0.2 archive
0.0.1 Aug 31, 2013 Go to the documentation of plummbur_kruk 0.0.1 Download plummbur_kruk 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
0
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Fix dependencies in pubspec.yaml.

Running pub upgrade failed with the following output:

ERR: The current Dart SDK version is 2.0.0.
 
 Because plummbur_kruk depends on uuid >=0.0.7 <1.0.3 which requires SDK version <2.0.0, version solving failed.

Health suggestions

Format lib/kruk.dart.

Run dartfmt to format lib/kruk.dart.

Format lib/server.dart.

Run dartfmt to format lib/server.dart.

Maintenance issues and suggestions

Fix platform conflicts. (-20 points)

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Package is too old. (-100 points)

The package was released more than two years ago.

Maintain CHANGELOG.md. (-20 points)

Changelog entries help clients to follow the progress in your code.

Add SDK constraint in pubspec.yaml. (-5 points)

For information about setting SDK constraint, please see https://www.dartlang.org/tools/pub/pubspec#sdk-constraints.

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use plummbur_kruk.dart.