Refactory.

This commit is contained in:
Rafael Caricio 2011-08-18 19:39:52 -03:00
parent b58571c9b0
commit 5c90b472ea
4 changed files with 24 additions and 5 deletions

View file

@ -1,5 +1,5 @@
pyvows:
@env PYTHONPATH=$$PYTHONPATH:. pyvows --cover --cover_package=django_pyvows --cover_threshold=100 vows/
@env PYTHONPATH=$$PYTHONPATH:vows/sandbox/:. pyvows --cover --cover_package=django_pyvows --cover_threshold=100 vows/
db:
@env PYTHONPATH=$$PYTHONPATH:. mysql -u root -e 'DROP DATABASE IF EXISTS django_pyvows' && mysql -u root -e 'CREATE DATABASE IF NOT EXISTS django_pyvows' && python vows/sandbox/manage.py syncdb

View file

@ -11,5 +11,9 @@
from django.http import HttpResponse
def home(request):
#print request
return HttpResponse('hello world')
def say_hello(request):
if not 'name' in request.GET:
return HttpResponse("What's your name?")
return HttpResponse("Hello, %s!" % request.GET['name'])

View file

@ -16,6 +16,8 @@ from django.conf.urls.defaults import patterns, include, url
urlpatterns = patterns('',
url(r'^$', 'sandbox.main.views.home', name='home'),
url(r'^say/$', 'sandbox.main.views.say_hello', name='say_hello'),
# url(r'^sandbox/', include('sandbox.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:

View file

@ -14,9 +14,6 @@ from django_pyvows.assertions import *
@Vows.batch
class HttpContextVows(DjangoHTTPContext):
def get_settings(self):
return "sandbox.settings"
def topic(self):
self.start_server()
return self.get("/")
@ -35,3 +32,19 @@ class HttpContextVows(DjangoHTTPContext):
def should_be_possible_to_pass_get_parameters(self, topic):
expect(topic.getcode()).to_equal(200)
class AskMyName(DjangoContext):
def topic(self):
return self.get('/say/')
def should_ask_for_my_name(self, topic):
expect(topic.read()).to_equal('What\'s your name?')
class SayHelloToMe(DjangoContext):
def topic(self):
return self.get('/say/?name=Rafael')
def should_say_hello_to_me(self, topic):
expect(topic.read()).to_equal('Hello, Rafael!')