Sha256: 6cb3a4a496a9599bbfec2b273be1435f4630320e16f5496e5a258c242dc52490

Contents?: true

Size: 780 Bytes

Versions: 31

Compression:

Stored size: 780 Bytes

Contents

# *Flexirest:* Faking calls

There are times when an API hasn't been developed yet, so you want to fake the API call response. To do this, you can simply pass a `:fake` option when mapping the call containing the response.

```ruby
class Person < Flexirest::Base
  get :all, '/people', fake: [{first_name:"Johnny"}, {first_name:"Bob"}]
end
```

You may want to run a proc when faking data (to put information from the parameters in to the response or return different responses depending on the parameters). To do this just pass a proc to `:fake`:

```ruby
class Person < Flexirest::Base
  get :all, '/people', fake: ->(request) { {result: request.get_params[:id]} }
end
```


-----

[< Parallel requests](parallel-requests.md) | [Per-request timeouts >](per-request-timeouts.md)

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
flexirest-1.9.16 docs/faking-calls.md
flexirest-1.9.15 docs/faking-calls.md
flexirest-1.9.14 docs/faking-calls.md
flexirest-1.9.13 docs/faking-calls.md
flexirest-1.9.12 docs/faking-calls.md
flexirest-1.9.11 docs/faking-calls.md
flexirest-1.9.10 docs/faking-calls.md
flexirest-1.8.9 docs/faking-calls.md
flexirest-1.8.8 docs/faking-calls.md
flexirest-1.8.7 docs/faking-calls.md
flexirest-1.8.6 docs/faking-calls.md
flexirest-1.8.5 docs/faking-calls.md
flexirest-1.8.4 docs/faking-calls.md
flexirest-1.8.3 docs/faking-calls.md
flexirest-1.8.2 docs/faking-calls.md
flexirest-1.8.1 docs/faking-calls.md
flexirest-1.8.0 docs/faking-calls.md
flexirest-1.7.9 docs/faking-calls.md
flexirest-1.7.8 docs/faking-calls.md
flexirest-1.7.7 docs/faking-calls.md