<commit_before># FaradaySimulation

A [Faraday]() extension to provide dynamic stubbing. This makes it possible 
to simulate more of the behavior of the target service in your tests and when
your app is running in development mode.


## Usage

The `FaradaySimulation::Adapter` class is the equivalent of Faraday's own
test adapter, but you can do a bit more with the stubs:

    conn = Faraday::Connection.new { |builder|
      builder.use(FaradaySimulation::Adapter) { |stub|
        stub.get('/drink/:name.json') { |env|
          [200, {}, "Drinking #{env[:params]['name']}"]
        }
      }
    }

    resp = conn.get('/drink/sake.json')
    # resp.body => 'Drinking sake'

    resp = conn.get('/drink/ale.json')
    # resp.body => 'Drinking ale'

Put simply, any stub path you define that includes `:foo` will match to
any string, and that string will be the value of `env[:params]['foo']` in
your stub block.

For more complex routes, you can define the stub with a regular expression.
Any regex group (you know, parenthesized pattern) in the matching regex will
be placed in env[:segments]. For example:

    stub.get(/\/foo\/([A-Z]+)\//) { |env|
      [200, {}, "Segment is #{env[:segments][0]}"]
    }<commit_msg>Update master<commit_after># FaradaySimulation

A [Faraday](https://github.com/technoweenie/faraday) extension to provide 
dynamic stubbing. This makes it much easier to simulate the behavior 
of the target service in your tests and when your app is running in 
development mode.


## Usage

The `FaradaySimulation::Adapter` class is the equivalent of Faraday's own
test adapter, but the stubbing is more powerful:

    conn = Faraday::Connection.new { |builder|
      builder.use(FaradaySimulation::Adapter) { |stub|
        stub.get('/drink/:name.json') { |env|
          [200, {}, "Drinking #{env[:params]['name']}"]
        }
      }
    }

    resp = conn.get('/drink/sake.json')
    # resp.body => 'Drinking sake'

    resp = conn.get('/drink/ale.json')
    # resp.body => 'Drinking ale'

Put simply, any stub path you define that includes `:foo` will match to
any string, and that string will be the value of `env[:params]['foo']` in
your stub block.

For more complex routes, you can define the stub with a regular expression.
Any regex group in the matching regex will be placed in `env[:segments]`. 
For example:

    stub.get(/\/foo\/([A-Z]+)\//) { |env|
      [200, {}, "Segment is #{env[:segments][0]}"]
    }
{'fraction_non_alphanumeric': 0.13205233033524122, 'fraction_numerical': 0.005723630417007359, 'mean_word_length': 3.409009009009009, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '998708', 'n_tokens_mistral': 777, 'n_tokens_neox': 741, 'n_words': 276}