<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="Geneva">A bit stuck here being new to ruby and rspec<br>
<br>
Im trying to spec out a rails controller and using machinist to
generate a model<br>
<br>
so in my spec i have<br>
<br>
<br>
<br>
it "should create new client" do<br>
// creates me a hash of generated values using Foregey<br>
client = Client.plan<br>
// specify that I should be creating a new client with the hash
values from client<br>
Client.should_receive(:new).with(client) <br>
//post to the server<br>
post 'create' , :client => client<br>
end<br>
<br>
in my controller<br>
<br>
def create<br>
client = Client.new(params[:client])<br>
end<br>
<br>
now this is failing with<br>
<br>
Spec::Mocks::MockExpectationError: <Client(id: integer, created_at:
datetime, updated_at: datetime, title: string, lastname: string,
firstname: string, email: string) (class)> received :new with
unexpected arguments<br>
expected: ({:title=>"Mr", :firstname=>"Ernest",
:lastname=>"Burke", :email=><a class="moz-txt-link-rfc2396E" href="mailto:rgarrett@blogtag.info">"rgarrett@blogtag.info"</a>})<br>
got: ({"title"=>"Mr", "lastname"=>"Burke",
"firstname"=>"Ernest", "email"=><a class="moz-txt-link-rfc2396E" href="mailto:rgarrett@blogtag.info">"rgarrett@blogtag.info"</a>})<br>
<br>
<br>
is there a way to specify to use symbols instead of the strings as
keys, as I dont want to be doing<br>
<br>
:client => { "title" => client.title , ............ }<br>
<br>
as the client model may change over time<br>
<br>
Cheers<br>
<br>
<br>
<br>
</font>
</body>
</html>