Sha256: 2f8eff0a9ad666a6f2abc1e4408d3cf8425013f8bd0d4a022602d3d4640a0df6

Contents?: true

Size: 1.59 KB

Versions: 29

Compression:

Stored size: 1.59 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 }


Pact.build do
   {
      status: 200,
      headers: exactly({

         }),
      body: including({
         age: literal('12'),
         phoneNumber: example("0415 134 234", /\d{4} \d{3} \d{3}/),
         favouriteColors:
      })
   }

end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
pact-1.4.0.rc4 scratchpad.rb
pact-1.4.0.rc3 scratchpad.rb
pact-1.4.0.rc2 scratchpad.rb
pact-1.3.3 scratchpad.rb
pact-1.3.2 scratchpad.rb
pact-1.3.1 scratchpad.rb
pact-1.3.0 scratchpad.rb
pact-1.2.1.rc2 scratchpad.rb
pact-1.2.1.rc1 scratchpad.rb
pact-1.1.1 scratchpad.rb
pact-1.1.0 scratchpad.rb
pact-1.1.0.rc5 scratchpad.rb
pact-1.1.0.rc4 scratchpad.rb
pact-1.1.0.rc3 scratchpad.rb
pact-1.0.39 scratchpad.rb
pact-1.1.0.rc2 scratchpad.rb
pact-1.0.38 scratchpad.rb
pact-1.1.0.rc1 scratchpad.rb
pact-1.0.37 scratchpad.rb
pact-1.0.36 scratchpad.rb