Merge remote-tracking branch 'canonical/next'
[sinan.git] / test / sint_gen_app_src.erl
blob127175b01e47dc4eb5d981ba48dd4c2963fdac19
1 %%%-------------------------------------------------------------------
2 %%% @copyright (C) 2011, Erlware, LLC.
3 %%% @doc
4 %%% Test the ability to generate an app.src
5 %%% @end
6 %%% Created : 5 Sep 2011 by Eric Merritt <ericbmerritt@gmail.com>
7 %%%-------------------------------------------------------------------
8 -module(sint_gen_app_src).
10 -include_lib("eunit/include/eunit.hrl").
12 -export([given/3, 'when'/3, then/3]).
14 % Step definitions for the sample calculator Addition feature.
16 given([an, empty, temp, directory, with, no, project], _State,
17 _) ->
18 BaseDir = ec_file:mkdtemp(),
19 {ok, BaseDir}.
21 'when'([the, sinan, gen, task, is, called], BaseDir, _) ->
22 ProjectName = "super_foo",
23 {ProjectDir, _} =
24 sint_test_project_gen:single_app_project(BaseDir, ProjectName),
25 {ok, {ProjectDir, ProjectName}};
26 'when'([a, build, is, run],
27 {ProjectDir, ProjectName}, _) ->
28 Ret = sinan:run_sinan(["-s", ProjectDir, "build"]),
29 {ok, {ProjectDir, ProjectName, Ret}}.
32 then([sinan, should, generate, an, 'app.src',
33 into, the, src, directory],
34 State = {ProjectDir, ProjectName, _}, _) ->
35 Path = filename:join([ProjectDir, "src",
36 ProjectName ++ ".app.src"]),
38 ?assertMatch(true,
39 sin_utils:file_exists(sin_state:new(), Path)),
41 {ok, State};
42 then([build, the, project, normally],
43 State = {ProjectDir, ProjectName, BuildState}, _) ->
44 ?assertMatch({ok, _}, BuildState),
45 sint_test_project_gen:validate_single_app_project(ProjectDir,
46 ProjectName),
47 {ok, State}.