aws/aws-sdk-core-ruby — pull request #123 by trevorrowe (2014-09-29 20:47:01+00:00)
Title: Added support for stubbing client responses.

Enable response stubbing by passing `:stub_responses => true`
to a client constructor.

```ruby
s3 = Aws::S3::Client.new(stub_responses: true)

# no api calls made, defaults to fake empty responses
s3.list_buckets.buckets.map(&:name)
#=> []
```

You can configure what data should be returned by calling
`#stub_responses` on the client.

```ruby
s3.stub_responses(:list_buckets, buckets:[{name:'aws-sdk'}])
s3.list_buckets.buckets.map(&:name)
#=> ['aws-sdk']
```

You can pass error classes, objects or names and these will
be raised as errors:

```ruby
s3.stub_responses(:head_bucket, 'NotFound')
s3.head_bucket(bucket:'aws-sdk')
#=> raises Aws::S3::Errors::NotFound
```

You can stub multiple responses. These are returned in order.
You can mix response data with errors. The final stub is reused
when the number of calls exceeds the number of stubs.

```ruby
s3.stub_responses(:list_buckets,
{ buckets:[{name:'aws-sdk'}] },
{ buckets:[{name:'aws-sdk'}, {name:'aws-sdk-2'}] }
)

s3.list_buckets.buckets.map(&:name)
#=> ['aws-sdk']

s3.list_buckets.buckets.map(&:name)
#=> ['aws-sdk', 'aws-sdk-2']
```

Stubbed data is validated against the API model. This ensures you
do not attempt to simulate a response that is not valid.

```ruby
s3.stub_responses(:list_buckets, buckets:['name'])
# raises ArgumentError, expected params[:buckets][0] to be a hash

s3.stub_responses(:list_buckets, buckets:[{name:'name'}])
#=> ok, no errors
```

Fixes #37