0
-
context "Halcyon::Server" do
0
+
describe "Halcyon::Server" do
0
@app = Specr.new :port => 4000
0
-
specify "should dispatch methods according to their respective routes" do
0
+
it "should dispatch methods according to their respective routes" do
0
Rack::MockRequest.new(@app).get("/hello/Matt")
0
last_line = File.new(@app.instance_variable_get("@config")[:log_file]).readlines.last
0
last_line.should =~ /INFO \[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] \(\d+\) Specr#test :: \[200\] .* => greeter \(.+\)/
0
-
specify "should provide various shorthand methods for simple responses but take custom response values" do
0
+
it "should provide various shorthand methods for simple responses but take custom response values" do
0
response = {:status => 200, :body => 'OK'}
0
@app.ok.should == response
0
@app.success.should == response
0
@@ -20,25 +20,25 @@ context "Halcyon::Server" do
0
@app.ok(['OK', 'Sure Thang', 'Correcto']).should == {:status => 200, :body => ['OK', 'Sure Thang', 'Correcto']}
0
-
specify "should handle requests and respond with JSON" do
0
+
it "should handle requests and respond with JSON" do
0
body = JSON.parse(Rack::MockRequest.new(@app).get("/").body)
0
body['status'].should == 200
0
body['body'].should == "Found"
0
-
specify "should handle requests with param values in the URL" do
0
+
it "should handle requests with param values in the URL" do
0
body = JSON.parse(Rack::MockRequest.new(@app).get("/hello/Matt").body)
0
body['status'].should == 200
0
body['body'].should == "Hello Matt"
0
-
specify "should route unmatchable requests to the default route and return JSON with appropriate status" do
0
+
it "should route unmatchable requests to the default route and return JSON with appropriate status" do
0
body = JSON.parse(Rack::MockRequest.new(@app).get("/garbage/request/url").body)
0
body['status'].should == 404
0
body['body'].should == "Not Found"
0
-
specify "should log activity" do
0
+
it "should log activity" do
0
prev_line = File.new(@app.instance_variable_get("@config")[:log_file]).readlines.last
0
Rack::MockRequest.new(@app).get("/url/that/will/not/be/found/#{rand}")
0
last_line = File.new(@app.instance_variable_get("@config")[:log_file]).readlines.last
0
@@ -46,18 +46,18 @@ context "Halcyon::Server" do
0
prev_line.should_not == last_line
0
-
specify "should create a PID file while running with the correct process ID" do
0
+
it "should create a PID file while running with the correct process ID" do
0
pid_file = @app.instance_variable_get("@config")[:pid_file]
0
File.exist?(pid_file).should be_true
0
File.open(pid_file){|file|file.read.should == "#{$$}\n"}
0
-
specify "should parse URI query params correctly" do
0
+
it "should parse URI query params correctly" do
0
Rack::MockRequest.new(@app).get("/?query=value&lang=en-US")
0
@app.query_params.should == {'query' => 'value', 'lang' => 'en-US'}
0
-
specify "should parse the URI correctly" do
0
+
it "should parse the URI correctly" do
0
Rack::MockRequest.new(@app).get("http://localhost:4000/slaughterhouse/5")
0
@app.uri.should == '/slaughterhouse/5'
0
@@ -68,7 +68,7 @@ context "Halcyon::Server" do
0
-
specify "should provide a quick way to find out what method the request was performed using" do
0
+
it "should provide a quick way to find out what method the request was performed using" do
0
Rack::MockRequest.new(@app).get("/#{rand}")
0
@app.method.should == :get
0
@@ -82,12 +82,16 @@ context "Halcyon::Server" do
0
@app.method.should == :delete
0
-
specify "should deny all unacceptable requests" do
0
+
it "should deny all unacceptable requests" do
0
conf = @app.instance_variable_get("@config")
0
conf[:acceptable_requests] = Halcyon::Server::ACCEPTABLE_REQUESTS
0
- Rack::MockRequest.new(@app).
put("/#{rand}")
0
+ Rack::MockRequest.new(@app).
get("/#{rand}")
0
@app.acceptable_request! rescue Halcyon::Exceptions::Base
0
+ it "should record the correct environment details" do
0
+ @app.instance_eval { @config[:root].should == Dir.pwd }
Comments
No one has commented yet.