Forum: RSpec Is this a bug?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Richard Lloyd (Guest)
on 2008-11-12 07:23
(Received via mailing list)
I'm new to rspec and, of course, my first time out and I'm tripped up by
what appears to me to be a bug.

A simple demonstration:

script/generate rspec_scaffold GoodDocument title:string body:text

>From spec/views/good_documents/edit.html.erb_spec.rb:

  before(:each) do
    assigns[:good_document] = @good_document = stub_model(GoodDocument,
      :new_record? => false,
      :title => "value for title",
      :body => "value for body"

script/generate rspec_scaffold BadDocument some_id:integer title:string
body:text someother_id:integer

>From spec/views/bad_documents/edit.html.erb_spec.rb:

  before(:each) do
    assigns[:bad_document] = @bad_document = stub_model(BadDocument,
      :new_record? => false,
      :title => "value for title",
      :body => "value for body",

Notice how bad_documents/edit...'s stub_model is missing both the
*:..._id*fields and how the
*:body* field line is comma terminated.  After chasing down the comma
caused rspec test to fail with a syntax error) I found that using *
:..._identifier* will also trigger the problem.  This only appears in
spec/views, spec/models have all attributes included in the *
@valid_attributes* hash.

So I think there are two problems here:

1) field name which includes some undefined magic will be silently
in the generated view specs
2) same name if it occupies the last slot in the record will cause the
to fail due to spec format

David C. (Guest)
on 2008-11-12 07:27
(Received via mailing list)
On Tue, Nov 11, 2008 at 11:22 PM, Richard Lloyd
<removed_email_address@domain.invalid> wrote:
>     assigns[:good_document] = @good_document = stub_model(GoodDocument,
> From spec/views/bad_documents/edit.html.erb_spec.rb:
> fields and how the :body field line is comma terminated.  After chasing down
> to fail due to spec format
Yep - seems like a bug. Please file a bug report at

This topic is locked and can not be replied to.