From 058e2fee3971be32f0a3cfe6348fb37414c89e06 Mon Sep 17 00:00:00 2001 From: thosakwe Date: Fri, 3 Mar 2017 23:16:15 -0500 Subject: [PATCH] 1.0.4 --- lib/src/commands/test.dart | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/src/commands/test.dart b/lib/src/commands/test.dart index 91f5a5e8..5bc9c046 100644 --- a/lib/src/commands/test.dart +++ b/lib/src/commands/test.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'package:args/command_runner.dart'; import "package:console/console.dart"; +import 'package:pubspec/pubspec.dart'; class TestCommand extends Command { final TextPen _pen = new TextPen(); @@ -15,13 +16,13 @@ class TestCommand extends Command { run() async { final name = await readInput("Name of Test: "), lower = name.toLowerCase(); final testDir = new Directory("test/services"); - final testFile = new File.fromUri( - testDir.uri.resolve("${lower}_test.dart")); + final testFile = + new File.fromUri(testDir.uri.resolve("${lower}_test.dart")); - if (!await testFile.exists()) - await testFile.create(recursive: true); + if (!await testFile.exists()) await testFile.create(recursive: true); - await testFile.writeAsString(_generateTest(lower)); + await testFile.writeAsString( + _generateTest(await PubSpec.load(Directory.current), lower)); final runConfig = new File('./.idea/runConfigurations/${name}_tests.xml'); @@ -49,10 +50,10 @@ class TestCommand extends Command { .trim(); } - String _generateTest(String lower) { + String _generateTest(PubSpec pubspec, String lower) { return ''' import 'dart:io'; -import 'package:angel/angel.dart'; +import 'package:${pubspec.name}/${pubspec.name}.dart'; import 'package:angel_framework/angel_framework.dart'; import 'package:angel_test/angel_test.dart'; import 'package:test/test.dart';