Forum: RSpec Is this a bug?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Af2ce6689213fdb78913a9662b18da6b?d=identicon&s=25 Richard Lloyd (Guest)
on 2008-11-12 06: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"
    )
  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
*:..._id*fields 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
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2008-11-12 06:27
(Received via mailing list)
On Tue, Nov 11, 2008 at 11:22 PM, Richard Lloyd
<richard.t.lloyd@gmail.com> 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
This topic is locked and can not be replied to.