[katello-devel] All warnings while running specs fixed

Justin Sherrill jsherril at redhat.com
Tue Sep 13 15:28:33 UTC 2011


On 09/13/2011 11:17 AM, Ivan Nečas wrote:
> Hi there,
>
> All warning we were getting while running specs should be gone now. I 
> would be glad to keep it as warning-less as possible.
>

+9999999999999999999999999999999999999999


> Quick summary of different types of warnings and how to solve them:
>
> 1. Overriding validate method
> Occured in src/app/models/glue/candlepin/consumer.rb
>
> def validate
> ...
> end
>
> Replace with
>
> def validate_something
>
> end
> validate :validate_something
>
> 2. rspec-rails-2.5.0/lib/rspec/rails/matchers/redirect_to.rb:5:
> warning: multiple values for a block parameter (0 for 1)
>
> caused by:
> response.should_not rediret_to() # redirect_to expects hash {:action 
> => ...}etc.
>
> fix:
> response.should_not be_redirected # we don't want specify the path
>
> 3. errors.add_to_base - deprecated
> use errors.add(:base, message)
>
> 4. object#id deprecated
> Occurs when one calls id on non-active-record object, typicaly mock or 
> OpenStruct
>
> with mock: stub id
> with OpenStruct - there is bug in Ruby for OpenStruct(:id => 123) 
> still throws this warning
> I defined MemoStruct with the same sematics, but without the warning 
> (spec/support/memo_struct.rb), feel free to use it.
>
> 5. constant already defined warning
> Sometimes a file with defined constants is load twice. Add condition 
> to fix, like:
>
> unless defined? CONSTANT
> CONSTANT="something"
> end
>
> 5b. constants defined in one spec file are visible in other specs and 
> cause the same problem,
> fix - use let(:constant) { "something" } instead.
>
>
> -- Ivan
> Regards,
>
> Ivan Necas
> Red Hat Czech s.r.o. Brno
>
> _______________________________________________
> katello-devel mailing list
> katello-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/katello-devel




More information about the katello-devel mailing list