title: How can I mock something that "does not implement" a particular method?
body: <h2>The Background:</h2>
  
  <p>I'm trying to use cucumber to do some test-driven (or behavior-driven) development around an interface to AWS, in ruby.  </p>
  
  <p>So, I have a step definition that looks like this:</p>
  
  <pre><code>Then(/^the mock object should have had :(.*?) called, setting "(.*?)" to "(.*?)"$/) do |method, param, value|
    expect(@mock).to receive(method.to_sym).with(hash_including(param, value))
  end
  </code></pre>
  
  <p>Where <code>@mock</code> was previously set using:</p>
  
  <pre><code>@mock = instance_double(AWS::AutoScaling::Client)
  </code></pre>
  
  <p>And where I invoke this step definition with a feature line like:</p>
  
  <pre><code>And the mock object should have had :update_auto_scaling_group called, setting "auto_scaling_group_name" to "Some-test-value"
  </code></pre>
  
  <p>When that step gets run, it gets the following error (leaving out the full error, as I believe this is the most relevant part):</p>
  
  <pre><code>  AWS::AutoScaling::Client does not implement: update_auto_scaling_group (RSpec::Mocks::MockExpectationError)
  </code></pre>
  
  <p>I see that indeed, the <a href="https://github.com/rspec/rspec-mocks/blob/master/lib/rspec/mocks/method_reference.rb#L73" rel="nofollow">checks that RSpec runs</a> (as traced back <a href="https://github.com/rspec/rspec-mocks/blob/master/lib/rspec/mocks/any_instance/recorder.rb#L222" rel="nofollow">from where the <code>RSpec::Mocks::MockExpectationError</code> gets thrown</a>) are at least correctly reporting the information that they get from the class:</p>
  
  <pre><code>[1] pry(main)&gt; require 'aws-sdk'
  =&gt; true
  [2] pry(main)&gt; klass = AWS::AutoScaling::Client
  =&gt; AWS::AutoScaling::Client
  [3] pry(main)&gt; klass.public_method_defined? "update_auto_scaling_group"
  =&gt; false
  [4] pry(main)&gt; klass.private_method_defined? "update_auto_scaling_group"
  =&gt; false
  [5] pry(main)&gt; klass.protected_method_defined? "update_auto_scaling_group"
  =&gt; false
  </code></pre>
  
  <p>And yet, if we ask an actual instance, it lets us know that this is a method it would respond to:</p>
  
  <pre><code>[6] pry(main)&gt; x = klass.new
  =&gt; #&lt;AWS::AutoScaling::Client::V20110101&gt;
  [7] pry(main)&gt; x.respond_to? "update_auto_scaling_group"
  =&gt; true
  </code></pre>
  
  <p>Even while it doesn't say that about just anything:</p>
  
  <pre><code>[8] pry(main)&gt; x.respond_to? "bogus"
  =&gt; false
  </code></pre>
  
  <h2>First questions:</h2>
  
  <p>So... is this a bug in <a href="https://github.com/aws/aws-sdk-core-ruby/blob/master/aws-sdk-core/lib/aws-sdk-core/autoscaling.rb" rel="nofollow">the AWS::AutoScaling::Client code</a> (or really, probably <a href="https://github.com/aws/aws-sdk-core-ruby/blob/master/aws-sdk-core/lib/aws-sdk-core.rb#L251" rel="nofollow">here</a>), for not defining the methods in a way that the extant checks (<code>{public,private,protected}_method_defined?</code>) would come back true?</p>
  
  <p>Or perhaps a bug in RSpec's "doubles", for not doing all the checking it could do to try to find out that this is indeed a method that's callable in an instance of that class?</p>
  
  <p>Or perhaps it's simply something that I'm doing wrong here?  Other?</p>
  
  <h2>More generally:</h2>
  
  <p>How can I write tests for the code I'm writing, to ensure that it's making calls to what will be an <code>AWS::AutoScaling::Client</code> instance, with the correct parameters (as defined in several checks that I have)?  Are there alternate ways I can write my step definitions that would make this work? Alternative ways to create my mock objects?  Other?</p>