Ladislav Slezak write:
> ref: refs/heads/backgroud_patches_bnc550934
> commit cf8abb9c2f7d0b2a1ecf9c4e26e817cb00a67bef
> Author: Ladislav Slezak <[email protected]>
> Date:   Fri Dec 18 10:04:23 2009 +0100
> 
>     testsuite update
> ---
>  webservice/test/unit/background_manager_test.rb |    4 ++++
>  webservice/test/unit/background_status_test.rb  |    2 +-
>  2 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/webservice/test/unit/background_manager_test.rb 
> b/webservice/test/unit/background_manager_test.rb
> index 81f0b39..61a88cf 100644
> --- a/webservice/test/unit/background_manager_test.rb
> +++ b/webservice/test/unit/background_manager_test.rb
> @@ -20,10 +20,14 @@ class BackgroundManagerTest < ActiveSupport::TestCase
>      @bm.update_progress(:dummy)
>      assert_equal nil, @bm.get_progress(:dummy)
>  
> +    changed = false
>      @bm.update_progress(:dummy) do |s|
> +      # this block must NOT be executed
>        s.progress = 10
> +      changed = true

Hi, again some notes :)

I personally don't like numbers and testing strings (even if I sometime 
especially in first iteration use it).
I think that constant is much better. If you use the number or string only once 
it is OK, but when it is more times in code (as here, where you set it in init 
and then test if progress is same that change is not invoked) then I think 
constant is better.
so something like INITIAL_PROGRESS = 10
s.progress = INITIAL_PROGRESS
assert !changed


>      end
>      assert_equal nil, @bm.get_progress(:dummy)
> +    assert !changed
>  
>  
>      # register a process
> diff --git a/webservice/test/unit/background_status_test.rb 
> b/webservice/test/unit/background_status_test.rb
> index 2131fa7..c63b93d 100644
> --- a/webservice/test/unit/background_status_test.rb
> +++ b/webservice/test/unit/background_status_test.rb
> @@ -38,7 +38,7 @@ class BackgroundStatusTest < ActiveSupport::TestCase
>    end
>  
>    def test_observing
> -    ot = ObserverTest.new(@bs, changed_flag)
> +    ot = ObserverTest.new(@bs)
>      s = 'dummy status'
>      p = 10
second part of first note
>      sp = 5
> 
If you use params then you close way to do backward compatible changes and also 
require strict order of parameters (see 
http://goruco2009.confreaks.com/30-may-2009-15-40-solid-object-oriented-design-sandi-metz.html
 ).
So you can initialize by hash and then you can benefit from another module of 
BaseModel - MassAssignment which add method load, which takes hash and 
initialize variables by its values so you can then have:

Class BackgroundStatus
  include BaseModel::MassAssignment

  def initialize(params={})
    #some defaults set
    load params
  end

if you use this, you can in future easy extend functionality just by adding new 
allowed key in hash and set default value for it.

feel free to ask questions
Josef

-- 
Josef Reidinger
YaST team
maintainer of perl-Bootloader, YaST2-Repair, webyast 
(language,time,basesystem,ntp)
-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to