Sha256: a575b61163eddc22352cfbea6d93f9f5914c4bebabea569c57ff36879c0867de

Contents?: true

Size: 1.35 KB

Versions: 24

Compression:

Stored size: 1.35 KB

Contents

Ideas for expectation DSL

Unfortunately RSpec has already stolen the method "example".
Could use:
eg
ex

my_provider.
   given("a thing exists").
      upon_receiving("a request for a thing").with({:method => 'get', :path => '/thing'})
         will_respond_with({:body => {
            name: ex("Fred"),
            age: eg 29,
            mobile: eg("0415 134 234", /\d{4} \d{3} \d{3}/),
            dob: eg("1983-02-28", match: /\d\d\d\d-\d\d-\d\d/),
            driver_licence_number: eg(12345678, size: 8),
            children: eg([{name: 'Mary'}])
         }})

eg([ {name: 'Mary'} ]) should match any array where every element has a name String
eg([ {name: example('Mary', size: 4) } ]) should match any array where every element has a 4 letter name

eg("Fred") could return Pact::Term.new(:matcher => /.+/, :generate => 'Fred')
eg(29) could return Pact::Term.new(:matcher => /\d+/, :generate => 29)

Need a way to specify a literal empty hash, rather than a hash that matches anything as {} currently does.

{:something => literal({}) }
{:something => actual({}) }
{:something => empty_hash }

Slightly unintuitive behaviour: {} matches any hash, but [] only matches an empty array (or does now we've changed the code). Should [] match any array? How do we then specify an empty array?

{:something => literal([]) }
{:something => actual([]) }
{:something => empty_array }

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
pact-1.0.3 scratchpad.txt
pact-1.0.2 scratchpad.txt
pact-1.0.1 scratchpad.txt
pact-1.0.0 scratchpad.txt