Separate tests into groups

Also test content of insert redirect
This commit is contained in:
Joe Nelson
2014-08-25 16:53:44 -07:00
parent 731260e9ee
commit f34f8d8c35
3 changed files with 114 additions and 36 deletions
-36
View File
@@ -9,26 +9,6 @@ import SpecHelper
import Network.HTTP.Types
import qualified Data.Aeson as JSON
import Data.Aeson ((.:))
import Control.Applicative ((<$>), (<*>))
import Control.Monad (mzero)
data IncPK = IncPK {
incId :: Int
, incNullableStr :: Maybe String
, incStr :: String
, incInsert :: String
} deriving (Show)
instance JSON.FromJSON IncPK where
parseJSON (JSON.Object r) = IncPK <$>
r .: "id" <*>
r .: "nullable_string" <*>
r .: "non_nullable_string" <*>
r .: "inserted_at"
parseJSON _ = mzero
spec :: Spec
spec = around appWithFixture $ do
describe "GET /" $ do
@@ -92,19 +72,3 @@ spec = around appWithFixture $ do
context "with response under server size limit" $
it "returns whole range with status 200" $
get "/auto_incrementing_pk" `shouldRespondWith` 206
describe "Posting new record" $
context "into a table with auto-incrementing pk" $ do
it "does not require pk in the payload" $
post "/auto_incrementing_pk" [json|
{ "non_nullable_string":"not null"} |]
`shouldRespondWith` 201
it "links to the created resource" $
post "/auto_incrementing_pk" [json|
{ "non_nullable_string":"not null"} |]
`shouldRespondWith` ResponseMatcher {
matchBody = Nothing,
matchStatus = 201,
matchHeaders = [("Location", "/auto_incrementing_pk?id=eq.2")]
}