---
 src/sin_task_cucumber.erl |   30 ++++++++++++++++++++++++------
 1 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/src/sin_task_cucumber.erl b/src/sin_task_cucumber.erl
index be55342..0fb8566 100644
--- a/src/sin_task_cucumber.erl
+++ b/src/sin_task_cucumber.erl
@@ -42,16 +42,26 @@ do_task(BuildRef) ->
     ProjectRoot = sin_config:get_value(BuildRef, "project.dir"),
     Features = find_files(filename:join([ProjectRoot, "features"]),
                                         ".*\\.feature\$"),
-    Outcomes = [ run_feature(BuildRef, F) || F <- Features ],
-    case lists:all(fun(X) -> X =:= ok end, Outcomes) of
+
+    Outcomes =
+        case sin_config:get_value(BuildRef, "gen", undefined) of
+            undefined ->
+                [ {F, run_feature(BuildRef, F)} || F <- Features ];
+            Name ->
+                [ {F,
+                   gen_feature(BuildRef, F,
+                               sin_config:get_value(BuildRef, "where"))}
+                  || F <- Features, filename:basename(F, ".feature") == Name]
+        end,
+
+    case lists:all(fun({_F, X}) -> X =:= ok end, Outcomes) of
         true    ->
             ok;
         false   ->
             ?SIN_RAISE(BuildRef, {test_failures,
-                                  lists:filter(fun(X) ->
-                                                       X == ok
-                                               end, Outcomes)}),
-            ok
+                                  lists:filter(fun({_F, X}) ->
+                                                       X =/= ok
+                                               end, Outcomes)})
     end,
     sin_config:store(BuildRef, "cucumber.features", Features).
 
@@ -80,5 +90,13 @@ run_feature(BuildRef, FeatureFile) ->
             ?SIN_RAISE(BuildRef, {no_implementation, FeatureFile})
     end.
 
+gen_feature(BuildRef, FeatureFile, TargetApp) ->
+    TargetDir =
+        filename:join(
+          [sin_config:get_value(BuildRef, "apps." ++ TargetApp ++ ".basedir"),
+           "test"]),
+    ok = ewl_file:mkdir_p(TargetDir),
+    ok = cucumberl_gen:gen(FeatureFile, TargetDir).
+
 find_files(Dir, Regex) ->
     filelib:fold_files(Dir, Regex, true, fun(F, Acc) -> [F | Acc] end, []).
-- 
1.7.5.2

-- 
You received this message because you are subscribed to the Google Groups 
"erlware-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/erlware-dev?hl=en.

Reply via email to