From 9f08b25232c28c437454614c989659602cbfa18e Mon Sep 17 00:00:00 2001 From: Avi Press Date: Mon, 21 Oct 2019 10:35:36 -0700 Subject: [PATCH] Support key with leading underscore (#43) --- README.md | 4 +++- curl-runnings.cabal | 6 +++--- package.yaml | 2 +- src/Testing/CurlRunnings/Internal/Parser.hs | 6 +++--- test/Spec.hs | 1 + 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a443923..80f06cd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # curl-runnings -[![Build Status](https://travis-ci.org/aviaviavi/curl-runnings.svg?branch=master)](https://travis-ci.org/aviaviavi/curl-runnings) [![Hackage](https://img.shields.io/hackage/v/curl-runnings.svg)](https://hackage.haskell.org/package/curl-runnings) +[![Build Status](https://travis-ci.org/aviaviavi/curl-runnings.svg?branch=master)](https://travis-ci.org/aviaviavi/curl-runnings) +[![Hackage](https://img.shields.io/hackage/v/curl-runnings.svg)](https://hackage.haskell.org/package/curl-runnings) +[![Scarf](https://scarf.sh/package/badge/curl-runnings)](https://scarf.sh/package/avi/curl-runnings) _Feel the rhythm! Feel the rhyme! Get on up, it's testing time! curl-runnings!_ diff --git a/curl-runnings.cabal b/curl-runnings.cabal index 0564007..6fe566b 100644 --- a/curl-runnings.cabal +++ b/curl-runnings.cabal @@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.1. +-- This file has been generated from package.yaml by hpack version 0.31.2. -- -- see: https://github.com/sol/hpack -- --- hash: b7f43a448b7bffd8bc3340f6483fb99f6391934bc869150ced8021708ca83864 +-- hash: c5eff7acb49843acbacdcf64e3e57fd05242eee41e466f2468cc9bf696b5f666 name: curl-runnings -version: 0.11.0 +version: 0.11.1 synopsis: A framework for declaratively writing curl based API tests description: Please see the README on Github at category: Testing diff --git a/package.yaml b/package.yaml index 5ad3271..66c23a1 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: curl-runnings -version: 0.11.0 +version: 0.11.1 github: aviaviavi/curl-runnings license: MIT author: Avi Press diff --git a/src/Testing/CurlRunnings/Internal/Parser.hs b/src/Testing/CurlRunnings/Internal/Parser.hs index ab70419..2739e1c 100644 --- a/src/Testing/CurlRunnings/Internal/Parser.hs +++ b/src/Testing/CurlRunnings/Internal/Parser.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE OverloadedStrings #-} -- | Internal module for parsing string based directives inside of curl runnings -- suites. Use this module at your own risk, it may change. Currently, string @@ -48,7 +48,7 @@ parseQuery q = let trimmed = T.strip q in case Text.Megaparsec.parse parseFullTextWithQuery "" trimmed of Right a -> Right a >>= validateQuery - Left a -> Left $ QueryParseError (T.pack $ errorBundlePretty a) q + Left a -> Left $ QueryParseError (T.pack $ errorBundlePretty a) q -- | Once we have parsed a query successfully, ensure that it is a legal query validateQuery :: [InterpolatedQuery] -> Either QueryError [InterpolatedQuery] @@ -121,7 +121,7 @@ keyIndexParser = do notFollowedBy endingChars (lexeme . try) ((KeyIndex . T.pack) <$> p) where - p = (:) <$> letterChar <*> many (noneOf ['.', '[', ']', '<', '>', ' ', '{', '}']) + p = (:) <$> (letterChar <|> (char '_')) <*> many (noneOf ['.', '[', ']', '<', '>', ' ', '{', '}']) jsonIndexParser :: Parser Query jsonIndexParser = diff --git a/test/Spec.hs b/test/Spec.hs index a291495..ec3b52e 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -27,6 +27,7 @@ main = hspec $ parseQuery "just some text" `shouldSatisfy` isRight parseQuery "$" `shouldSatisfy` isRight parseQuery "$" `shouldSatisfy` isRight + parseQuery "$" `shouldSatisfy` isRight parseQuery "$" `shouldSatisfy` isRight parseQuery "some text before $ and after" `shouldSatisfy` isRight parseQuery "some $ querires $" `shouldSatisfy` isRight