<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<blockquote
 cite="mid765a2c230702192014j7a365acfg3563a61301413815@mail.gmail.com"
 type="cite">
  <pre wrap="">
So, I still say my app code and my reduction look conceptually the
same, but I'm stumped as to why they don't behave the same way 
  </pre>
</blockquote>
David seems to have picked that up.&nbsp; Ignore my blatherings about
HashArgConstraint (though the rest is valid).<br>
<br>
Here's another twist under&nbsp; Rails 1.2.2 (which may not be supported but
works fine for what I am doing so far).&nbsp; <br>
<br>
Basically, a different <u>expectation</u> seems to be set up depending
on whether the argument to get/post is a variable or not.&nbsp; That cannot
be right.&nbsp; What am I missing?<br>
<br>
<tt>require File.dirname(__FILE__) + '/../spec_helper'<br>
<br>
class TestController &lt; ActionController::Base<br>
&nbsp; def index() self.amethod(params) end<br>
end<br>
<br>
context 'a test controller' do<br>
&nbsp; controller_name :test<br>
&nbsp; <br>
&nbsp; setup do<br>
&nbsp;&nbsp;&nbsp; @plist = { "id" =&gt; "1", "param2" =&gt; "bar" }<br>
&nbsp;&nbsp;&nbsp; controller.should_receive(:amethod).with(@plist).and_return(true)<br>
&nbsp; end<br>
&nbsp;<br>
&nbsp;specify "should pass a hash to #with (1)" do<br>
&nbsp;&nbsp;&nbsp; get :index, "id" =&gt; "1", "param2" =&gt; "bar"<br>
&nbsp; end<br>
&nbsp; specify "should pass a hash to #with (2)" do<br>
&nbsp;&nbsp;&nbsp; get :index, { "id" =&gt; "1", "param2" =&gt; "bar" }<br>
&nbsp; end<br>
&nbsp; specify "should pass a hash to #with (3)" do<br>
&nbsp;&nbsp;&nbsp; get :index, @plist<br>
&nbsp; end<br>
end<br>
<br>
</tt><tt>$ spec -cfs spec/controllers/test_controller_spec.rb <br>
/usr/bin/spec:17:Warning: require_gem is obsolete.&nbsp; Use gem instead.<br>
/home/jjw/rails/playground/config/boot.rb:29:Warning: require_gem is
obsolete.&nbsp; Use gem instead.<br>
<br>
a test controller<br>
- should pass a hash to #with (1) (FAILED - 1)<br>
- should pass a hash to #with (2) (FAILED - 2)<br>
- should pass a hash to #with (3) (FAILED - 3)<br>
<br>
1)<br>
'a test controller should pass a hash to #with (1)' FAILED <b>(ignore
the failure, look at the expectation)</b><br>
#&lt;TestController:0xb70a1df8&gt; expected :amethod with (["param2",
"bar"], ["id", "1"]) but received it with ({"action"=&gt;"index",
"id"=&gt;"1", "param2"=&gt;"bar", "controller"=&gt;"test"})<br>
(eval):3:in `amethod'<br>
./spec/controllers/test_controller_spec.rb:4:in `index'<br>
/usr/local/lib/site_ruby/1.8/benchmark.rb:300:in `measure'<br>
./spec/controllers/test_controller_spec.rb:13:<br>
<br>
2)<br>
'a test controller should pass a hash to #with (2)' FAILED </tt><tt><b>(ignore
the failure, look at the expectation)</b></tt><br>
<tt>#&lt;TestController:0xb7093820&gt; expected :amethod with
(["param2", "bar"], ["id", "1"]) but received it with
({"action"=&gt;"index", "id"=&gt;"1", "param2"=&gt;"bar",
"controller"=&gt;"test"})<br>
(eval):3:in `amethod'<br>
./spec/controllers/test_controller_spec.rb:4:in `index'<br>
/usr/local/lib/site_ruby/1.8/benchmark.rb:300:in `measure'<br>
./spec/controllers/test_controller_spec.rb:18:<br>
<br>
3)<br>
'a test controller should pass a hash to #with (3)' FAILED </tt><tt><b>(ignore
the failure, look at the expectation)</b></tt><br>
<tt>#&lt;TestController:0xb708cf34&gt; expected :amethod with (<b>[:only_path,
true]</b>, ["param2", "bar"], ["id", "1"], <b>[:action, :index]</b>)
but received it with ({"action"=&gt;"index", "id"=&gt;"1",
"param2"=&gt;"bar", "controller"=&gt;"test"})<br>
(eval):3:in `amethod'<br>
./spec/controllers/test_controller_spec.rb:4:in `index'<br>
/usr/local/lib/site_ruby/1.8/benchmark.rb:300:in `measure'<br>
./spec/controllers/test_controller_spec.rb:23:<br>
<br>
Finished in 0.022612 seconds<br>
<br>
3 specifications, 3 failures<br>
<br>
<br>
</tt>Where the heck did the :only_path stuff come from in the
expectation for case 3??&nbsp; They weren't there in
ArgumentExpectation#initialize.<br>
<br>
As expected, creating the 'right' expectation&nbsp; (<tt>@plist = { "id"
=&gt; "1","param2" =&gt; "bar", "action" =&gt; "index", "controller"
=&gt; "test" } ) </tt>allows the spec to pass in cases 1 &amp; 2, but
#3 still fails.<br>
<br>
rgds from "Confused of Hampshire".<br>
<br>
&nbsp;<br>
<tt><br>
</tt>
</body>
</html>