redstone-dart / redstone

A metadata driven microframework for Dart.
http://redstone-dart.github.io/redstone
MIT License
342 stars 42 forks source link

Documentation: Unittest example not working #176

Closed Sgoettschkes closed 8 years ago

Sgoettschkes commented 8 years ago

I was trying to get the example for Unit test working and had several issues:

I didn't find the source code for the documentation. If it's open source, I'd like to contribute!

sestegra commented 8 years ago

The documentation is located on gh-pages branch. https://help.github.com/articles/what-are-github-pages/

The corrected unittest code is following

library services;

import 'package:redstone/redstone.dart' as app;

@app.Route("/user/:username")
helloUser(String username) => "hello, $username";
import 'package:test/test.dart';
import 'package:redstone/redstone.dart' as app;
import 'package:your_package_name/services.dart';

main() {
  // Load handlers in 'services' library
  setUp(() => app.redstoneSetUp([#services]));

  // Remove all loaded handlers
  tearDown(() => app.redstoneTearDown());

  test("hello service", () {
    // Create a mock request
    var req = new app.MockRequest("/user/luiz");
    // Dispatch the request
    return app.dispatch(req).then((resp) {
      // Verify the response
      expect(resp.statusCode, equals(200));
      expect(resp.mockContent, equals("hello, luiz"));
    });
  });
}
sestegra commented 8 years ago

@Pacane this issue could be closed.

Pacane commented 8 years ago

@sestegra did you fix it? If so I'll close the issue. Otherwise, I'll fix it.

sestegra commented 8 years ago

@Pacane done with #179

Pacane commented 8 years ago

Thanks!