Commit e4aa0f6f by Gabriel Falcão

finding feature files on given dir

parent 9d8bca20
all: unit functional
unit:
@echo "Running unit tests ..."
@nosetests -s --verbosity=2 --with-coverage --cover-inclusive tests/unit/
functional:
@echo "Running functional tests ..."
@nosetests -s --verbosity=2 --with-coverage --cover-inclusive tests/functional/
clean:
@echo -n "Cleaning up files that are already in .gitignore... "
@for pattern in `cat .gitignore`; do find . -name "$$pattern" -exec rm -rf {} \;; done
......
# -*- coding: utf-8 -*-
# <Lettuce - Behaviour Driven Development for python>
# Copyright (C) <2010> Gabriel Falcão <gabriel@nacaolivre.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from os import walk
from os.path import dirname, abspath, join
class FeatureFinder(object):
def __init__(self, base_dir):
self.base_dir = abspath(base_dir)
def find_feature_files(self):
paths = []
for root, dirs, files in walk(self.base_dir):
for filename in files:
if filename.endswith(".feature"):
path = join(root, filename)
paths.append(path)
return paths
# language: en
Feature: Division
In order to avoid silly mistakes
Cashiers must be able to calculate a fraction
Scenario: Regular numbers
* I have entered 3 into the calculator
* I have entered 2 into the calculator
* I press divide
* the result should be 1.5 on the screen
# language: en
Feature: Multiplication
In order to avoid silly mistakes
Cashiers must be able to multiplicate numbers :)
Scenario: Regular numbers
* I have entered 10 into the calculator
* I have entered 4 into the calculator
* I press multiply
* the result should be 40 on the screen
# language: en
Feature: Addition
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers
Scenario Outline: Add two numbers
Given I have entered <input_1> into the calculator
And I have entered <input_2> into the calculator
When I press <button>
Then the result should be <output> on the screen
Examples:
| input_1 | input_2 | button | output |
| 20 | 30 | add | 50 |
| 2 | 5 | add | 7 |
| 0 | 40 | add | 40 |
# -*- coding: utf-8 -*-
# <Lettuce - Behaviour Driven Development for python>
# Copyright (C) <2010> Gabriel Falcão <gabriel@nacaolivre.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from nose.tools import assert_equals
from os.path import dirname, abspath, join
from lettuce.fs import FeatureFinder
def test_feature_finder_finds_all_feature_files_within_a_dir():
"FeatureFinder finds all feature files within a directory"
current_dir = abspath(dirname(__file__))
ff = FeatureFinder(current_dir)
files = ff.find_feature_files()
cjoin = lambda *x: join(current_dir, *x)
assert_equals(
sorted(files),
sorted([
cjoin('1st_feature_dir', 'one_more.feature'),
cjoin('1st_feature_dir', 'some.feature'),
cjoin('1st_feature_dir', 'more_features_here', 'another.feature'),
])
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment