Is this a bug?


#1

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”
)
end

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”,
)
end

Notice how bad_documents/edit…'s stub_model is missing both the
:…_idfields and how the
:body field line is comma terminated. After chasing down the comma
(which
caused rspec test to fail with a syntax error) I found that using *
:…_identifier* will also trigger the problem. This only appears in
the
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
    untested
    in the generated view specs
  2. same name if it occupies the last slot in the record will cause the
    test
    to fail due to spec format

Rick


#2

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
http://rspec.lighthouseapp.com/projects/5645.

Thanks,
David