rugui 1.6.0 → 2.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/README.rdoc +48 -23
  2. data/Rakefile +3 -10
  3. data/bin/rugui +4 -1
  4. data/lib/rugui/base_view.rb +5 -5
  5. data/lib/rugui/configuration.rb +1 -29
  6. data/lib/rugui/entity_registration_support.rb +17 -2
  7. data/lib/rugui/framework_adapters/GTK.rb +15 -32
  8. data/lib/rugui/framework_adapters/Qt4.rb +22 -3
  9. data/lib/rugui/generators/rugui/rugui_generator.rb +3 -9
  10. data/lib/rugui/generators/rugui/templates/Gemfile.tt +20 -0
  11. data/lib/rugui/generators/rugui/templates/Rakefile +0 -4
  12. data/lib/rugui/generators/rugui/templates/app/main.rb +1 -1
  13. data/lib/rugui/generators/rugui/templates/config/boot.rb +5 -78
  14. data/lib/rugui/generators/rugui/templates/config/environment.rb.tt +7 -7
  15. data/lib/rugui/generators/rugui/templates/framework_specific/gtk/app/resources/xml/main_view.xml +43 -0
  16. data/lib/rugui/generators/rugui/templates/spec/spec_helper.rb +0 -2
  17. data/lib/rugui/initializer.rb +3 -60
  18. data/lib/rugui/observable_property_support.rb +5 -1
  19. data/lib/rugui/property_changed_support.rb +1 -1
  20. data/lib/rugui/signal_support.rb +2 -2
  21. data/lib/rugui/tasks/rugui.rb +1 -1
  22. data/lib/rugui/tasks/runner_application.rake +1 -1
  23. data/lib/rugui/tasks/spec_application.rake +5 -44
  24. data/lib/rugui/tasks/spec_framework.rake +3 -25
  25. data/lib/rugui/version.rb +1 -7
  26. data/lib/rugui.rb +0 -3
  27. data/spec/framework/base_controller_spec.rb +7 -14
  28. data/spec/framework/base_model_spec.rb +1 -3
  29. data/spec/framework/base_view_helper_spec.rb +1 -3
  30. data/spec/framework/base_view_spec.rb +2 -5
  31. data/spec/framework/log_support_spec.rb +2 -2
  32. data/spec/framework/observable_property_proxy_spec.rb +13 -14
  33. data/spec/framework/observable_property_support_spec.rb +8 -10
  34. data/spec/framework/property_observer_spec.rb +20 -22
  35. data/spec/helpers/controllers.rb +3 -3
  36. data/spec/helpers/helper_manager.rb +9 -0
  37. data/spec/helpers/observables.rb +40 -52
  38. data/spec/helpers/views.rb +15 -15
  39. data/spec/resource_files/my_other_view.xml +53 -0
  40. data/spec/resource_files/my_view.xml +53 -0
  41. data/spec/spec_helper.rb +9 -3
  42. metadata +98 -84
  43. data/lib/rugui/gem_builder.rb +0 -21
  44. data/lib/rugui/gem_dependency.rb +0 -282
  45. data/lib/rugui/generators/rugui/templates/framework_specific/gtk/app/resources/glade/main_view.glade +0 -33
  46. data/lib/rugui/generators/rugui/templates/spec/rcov.opts +0 -1
  47. data/lib/rugui/generators/rugui/templates/spec/spec.opts +0 -4
  48. data/lib/rugui/generators/rugui/templates/test/test_helper.rb +0 -12
  49. data/lib/rugui/plugin/loader.rb +0 -77
  50. data/lib/rugui/tasks/gems_application.rake +0 -71
  51. data/lib/rugui/tasks/test_application.rake +0 -77
  52. data/lib/rugui/vendor_gem_source_index.rb +0 -140
  53. data/spec/rcov.opts +0 -1
  54. data/spec/spec.opts +0 -5
@@ -1,5 +1,4 @@
1
1
  require 'rugui'
2
- require 'rugui/gem_dependency'
3
2
 
4
3
  module RuGUI
5
4
  class Initializer
@@ -43,22 +42,9 @@ module RuGUI
43
42
  start_initialization_process_log
44
43
 
45
44
  set_load_path
46
- add_gem_load_paths
47
45
 
48
- set_autoload_paths
49
46
  load_framework_adapter
50
-
51
- load_gems
52
- load_plugins
53
-
54
- # pick up any gems that plugins depend on
55
- add_gem_load_paths
56
- load_gems
57
- check_gem_dependencies
58
-
59
- # bail out if gems are missing - note that check_gem_dependencies will have
60
- # already called abort() unless $gems_rake_task is set
61
- return unless gems_dependencies_loaded
47
+ set_autoload_paths
62
48
 
63
49
  finish_initialization_process_log
64
50
  end
@@ -73,6 +59,7 @@ module RuGUI
73
59
 
74
60
  # Set the paths from which RuGUI will automatically load source files.
75
61
  def set_autoload_paths
62
+ require 'active_support/dependencies'
76
63
  ActiveSupport::Dependencies.autoload_paths = configuration.load_paths.uniq
77
64
  end
78
65
 
@@ -94,46 +81,6 @@ module RuGUI
94
81
  end
95
82
  end
96
83
 
97
- def load_plugins
98
- plugin_loader.load_plugins
99
- end
100
-
101
- def add_gem_load_paths
102
- RuGUI::GemDependency.add_frozen_gem_path
103
- unless @configuration.gems.empty?
104
- require "rubygems"
105
- @configuration.gems.each { |gem| gem.add_load_paths }
106
- end
107
- end
108
-
109
- def load_gems
110
- unless $gems_build_rake_task
111
- @configuration.gems.each { |gem| gem.load }
112
- end
113
- end
114
-
115
- def check_gem_dependencies
116
- unloaded_gems = @configuration.gems.reject { |g| g.loaded? }
117
- if unloaded_gems.size > 0
118
- @gems_dependencies_loaded = false
119
- # don't print if the gems rake tasks are being run
120
- unless $gems_rake_task
121
- abort <<-end_error
122
- Missing these required gems:
123
- #{unloaded_gems.map { |gem| "#{gem.name} #{gem.requirement}" } * "\n "}
124
-
125
- You're running:
126
- ruby #{Gem.ruby_version} at #{Gem.ruby}
127
- rubygems #{Gem::RubyGemsVersion} at #{Gem.path * ', '}
128
-
129
- Run `rake gems:install` to install the missing gems.
130
- end_error
131
- end
132
- else
133
- @gems_dependencies_loaded = true
134
- end
135
- end
136
-
137
84
  def load_logger
138
85
  RuGUILogger.logger
139
86
  end
@@ -146,17 +93,13 @@ Run `rake gems:install` to install the missing gems.
146
93
  logger.info "RuGUI application configurations loaded." unless silence_logs?
147
94
  end
148
95
 
149
- def plugin_loader
150
- @plugin_loader || RuGUI::Plugin::Loader.new(self, configuration)
151
- end
152
-
153
96
  def load_framework_adapter
154
97
  require "rugui/framework_adapters/#{RuGUI.configuration.framework_adapter}"
155
98
  end
156
99
 
157
100
  private
158
101
  def silence_logs?
159
- @@processed or $gems_build_rake_task or $gems_rake_task
102
+ @@processed
160
103
  end
161
104
  end
162
105
  end
@@ -119,7 +119,7 @@ module RuGUI
119
119
  module ClassMethods
120
120
  # Creates the necessary class inheritable attributes an initializes them.
121
121
  def create_class_inheritable_attributes
122
- self.class_inheritable_accessor :observable_properties_options
122
+ self.class_attribute :observable_properties_options
123
123
 
124
124
  self.observable_properties_options = {}
125
125
  end
@@ -225,6 +225,10 @@ module RuGUI
225
225
  def self.included(base)
226
226
  base.extend(ClassMethods)
227
227
  base.create_class_inheritable_attributes
228
+
229
+ def base.inherited(base)
230
+ base.create_class_inheritable_attributes
231
+ end
228
232
  end
229
233
 
230
234
  private
@@ -46,7 +46,7 @@ module RuGUI
46
46
  end
47
47
 
48
48
  def self.included(base)
49
- base.class_inheritable_accessor :property_changed_blocks
49
+ base.class_attribute :property_changed_blocks
50
50
  base.property_changed_blocks = []
51
51
  base.extend(ClassMethods)
52
52
  end
@@ -41,7 +41,7 @@ module RuGUI
41
41
  end
42
42
 
43
43
  def self.included(base)
44
- base.class_inheritable_accessor :signal_connections
44
+ base.class_attribute :signal_connections
45
45
  base.signal_connections = []
46
46
  base.extend(ClassMethods)
47
47
  end
@@ -54,4 +54,4 @@ module RuGUI
54
54
  attr_accessor :receiver_class
55
55
  end
56
56
  end
57
- end
57
+ end
@@ -5,4 +5,4 @@ Dir["#{File.dirname(__FILE__)}/*_application.rake"].each { |ext| load ext }
5
5
 
6
6
  # Load any custom rakefile extensions
7
7
  Dir["#{APPLICATION_ROOT}/lib/tasks/**/*.rake"].sort.each { |ext| load ext }
8
- Dir["#{APPLICATION_ROOT}/vendor/plugins/*/**/tasks/**/*.rake"].sort.each { |ext| load ext }
8
+
@@ -1,4 +1,4 @@
1
1
  desc 'Runs the application.'
2
2
  task :run do
3
- require 'main'
3
+ require APPLICATION_ROOT + '/app/main'
4
4
  end
@@ -1,52 +1,13 @@
1
1
  begin
2
- require 'rubygems'
3
- require 'spec/rake/spectask'
2
+ require 'rspec/core/rake_task'
4
3
 
5
- task :stats => "spec:statsetup"
4
+ desc "Run all examples"
5
+ RSpec::Core::RakeTask.new(:spec)
6
6
 
7
- desc "Run all specs in spec directory (excluding plugin specs)"
8
- Spec::Rake::SpecTask.new(:spec) do |t|
9
- t.spec_opts = ['--options', "\"#{APPLICATION_ROOT}/spec/spec.opts\""]
10
- t.spec_files = FileList['spec/**/*_spec.rb']
11
- end
7
+ task :stats => "spec:statsetup"
8
+ task :default => :spec
12
9
 
13
10
  namespace :spec do
14
- desc "Run all specs in spec directory with RCov (excluding plugin specs)"
15
- Spec::Rake::SpecTask.new(:rcov) do |t|
16
- t.spec_opts = ['--options', "\"#{APPLICATION_ROOT}/spec/spec.opts\""]
17
- t.spec_files = FileList['spec/**/*_spec.rb']
18
- t.rcov = true
19
- t.rcov_opts = lambda do
20
- IO.readlines("#{APPLICATION_ROOT}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
21
- end
22
- end
23
-
24
- desc "Print Specdoc for all specs (excluding plugin specs)"
25
- Spec::Rake::SpecTask.new(:doc) do |t|
26
- t.spec_opts = ["--format", "specdoc", "--dry-run"]
27
- t.spec_files = FileList['spec/**/*_spec.rb']
28
- end
29
-
30
- desc "Print Specdoc for all plugin specs"
31
- Spec::Rake::SpecTask.new(:plugin_doc) do |t|
32
- t.spec_opts = ["--format", "specdoc", "--dry-run"]
33
- t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*')
34
- end
35
-
36
- [:models, :controllers, :views, :view_helpers, :lib].each do |sub|
37
- desc "Run the specs under spec/#{sub}"
38
- Spec::Rake::SpecTask.new(sub) do |t|
39
- t.spec_opts = ['--options', "\"#{APPLICATION_ROOT}/spec/spec.opts\""]
40
- t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
41
- end
42
- end
43
-
44
- desc "Run the specs under vendor/plugins (except RSpec's own)"
45
- Spec::Rake::SpecTask.new(:plugins) do |t|
46
- t.spec_opts = ['--options', "\"#{APPLICATION_ROOT}/spec/spec.opts\""]
47
- t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*')
48
- end
49
-
50
11
  # Setup specs for stats
51
12
  task :statsetup do
52
13
  require 'code_statistics'
@@ -1,27 +1,5 @@
1
- require 'rubygems'
2
- require 'spec/rake/spectask'
1
+ require 'rspec/core/rake_task'
3
2
 
4
- RUGUI_ROOT = File.join(File.expand_path(File.dirname(__FILE__)), '..', '..', '..')
3
+ desc "Run all examples"
4
+ RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :stats => "spec:statsetup"
7
-
8
- desc "Run all specs in spec directory"
9
- Spec::Rake::SpecTask.new(:spec) do |t|
10
- t.spec_opts = ['--options', "\"#{RUGUI_ROOT}/spec/spec.opts\""]
11
- t.spec_files = FileList['spec/**/*_spec.rb']
12
- end
13
-
14
- namespace :spec do
15
- desc "Print Specdoc for all specs"
16
- Spec::Rake::SpecTask.new(:doc) do |t|
17
- t.spec_opts = ["--format", "specdoc", "--dry-run"]
18
- t.spec_files = FileList['spec/**/*_spec.rb']
19
- end
20
-
21
- # Setup specs for stats
22
- task :statsetup do
23
- require 'code_statistics'
24
- ::STATS_DIRECTORIES << %w(RuGUI\ specs) if File.exist?('spec')
25
- ::CodeStatistics::TEST_TYPES << "RuGUI specs" if File.exist?('spec')
26
- end
27
- end
data/lib/rugui/version.rb CHANGED
@@ -1,9 +1,3 @@
1
1
  module RuGUI
2
- module VERSION #:nodoc:
3
- MAJOR = 1
4
- MINOR = 6
5
- TINY = 0
6
-
7
- STRING = [MAJOR, MINOR, TINY].join('.')
8
- end
2
+ VERSION = "2.0.0.beta2"
9
3
  end
data/lib/rugui.rb CHANGED
@@ -1,6 +1,4 @@
1
1
  require 'rubygems'
2
- require 'active_support'
3
- require 'active_support/dependencies'
4
2
  require 'active_support/core_ext'
5
3
 
6
4
  module RuGUI
@@ -26,7 +24,6 @@ end
26
24
 
27
25
  require 'rugui/configuration'
28
26
  require 'rugui/log_support'
29
- require 'rugui/plugin/loader'
30
27
  require 'rugui/framework_adapters/framework_adapter_support'
31
28
  require 'rugui/base_object'
32
29
  require 'rugui/property_changed_support'
@@ -1,14 +1,10 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'spec_helper')
2
-
3
- require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'helpers', 'controllers')
4
- require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'helpers', 'views')
5
- require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'helpers', 'models')
1
+ require 'spec_helper'
6
2
 
7
3
  describe RuGUI::BaseController do
8
4
  before(:each) do
9
5
  @controller = MyController.new
10
6
  end
11
-
7
+
12
8
  describe "with view registering" do
13
9
  it "should make the view available in a views hash and in an attribute" do
14
10
  @controller.views[:my_view].should be_an_instance_of(MyView)
@@ -24,20 +20,20 @@ describe RuGUI::BaseController do
24
20
  end
25
21
  end
26
22
  end
27
-
23
+
28
24
  describe "with model registering" do
29
25
  it "should make the model available in a models hash and in an attribute" do
30
26
  @controller.models[:my_model].should be_an_instance_of(MyModel)
31
27
  @controller.my_model.should be_an_instance_of(MyModel)
32
28
  @controller.models[:my_model].should == @controller.my_model
33
29
  end
34
-
30
+
35
31
  it "should be notified using named observable property change calls" do
36
32
  @controller.my_other_model_instance.my_property = 1
37
33
  @controller.message.should == "Property my_property of named observable my_other_model_instance changed from to 1."
38
34
  end
39
35
  end
40
-
36
+
41
37
  describe "with controller registering" do
42
38
  it "should make the controller available in a controllers hash and in an attribute" do
43
39
  @controller.controllers[:my_child_controller].should be_an_instance_of(MyChildController)
@@ -84,7 +80,7 @@ describe RuGUI::BaseController do
84
80
  describe "of main models" do
85
81
  before :each do
86
82
  NewStyleController.main_models :new_style_model
87
-
83
+
88
84
  @main_controller = RuGUI::BaseMainController.new
89
85
  @main_controller.register_model :new_style_model
90
86
  @main_controller.register_controller :new_style_controller
@@ -110,12 +106,9 @@ describe RuGUI::BaseController do
110
106
  end
111
107
 
112
108
  describe "of controllers" do
113
- before :each do
109
+ it "should have the new_style_child_controller registered when instantiated" do
114
110
  NewStyleController.controllers :new_style_child_controller
115
111
  @controller = NewStyleController.new
116
- end
117
-
118
- it "should have the new_style_child_controller registered when instantiated" do
119
112
  @controller.controllers[:new_style_child_controller].should be_an_instance_of(NewStyleChildController)
120
113
  @controller.new_style_child_controller.should be_an_instance_of(NewStyleChildController)
121
114
  @controller.controllers[:new_style_child_controller].should == @controller.new_style_child_controller
@@ -1,6 +1,4 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'spec_helper')
2
-
3
- require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'helpers', 'models')
1
+ require 'spec_helper'
4
2
 
5
3
  describe RuGUI::BaseModel do
6
4
  describe "with initialization hooks" do
@@ -1,6 +1,4 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'spec_helper')
2
-
3
- require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'helpers', 'view_helpers')
1
+ require 'spec_helper'
4
2
 
5
3
  describe RuGUI::BaseViewHelper do
6
4
  describe "with initialization hooks" do
@@ -1,7 +1,4 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'spec_helper')
2
-
3
- require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'helpers', 'views')
4
- require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'helpers', 'view_helpers')
1
+ require 'spec_helper'
5
2
 
6
3
  describe RuGUI::BaseView do
7
4
  before(:each) do
@@ -75,7 +72,7 @@ describe RuGUI::BaseView do
75
72
  @my_view.helper.message = "another message"
76
73
  @my_view.message.should == "MyViewHelper property message changed from Some label in the middle to another message"
77
74
  end
78
-
75
+
79
76
  it "should be notified using named observable property change calls" do
80
77
  @my_view.my_other_view_helper_instance.message = "foo"
81
78
  @my_view.message.should == "Property message of my_other_view_helper_instance changed from Some label in the middle to foo"
@@ -1,4 +1,4 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  class MyObjectWithLogSupport
4
4
  include RuGUI::LogSupport
@@ -8,7 +8,7 @@ describe RuGUI::LogSupport do
8
8
  before(:each) do
9
9
  @my_object_with_log_support = MyObjectWithLogSupport.new
10
10
  end
11
-
11
+
12
12
  it "should have a default logger if it is not initialized" do
13
13
  @my_object_with_log_support.respond_to?(:logger).should be_true
14
14
  @my_object_with_log_support.logger.should be_an_instance_of(Logger)
@@ -1,12 +1,11 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'spec_helper')
2
- require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'helpers', 'observables')
1
+ require 'spec_helper'
3
2
 
4
3
  describe RuGUI::ObservablePropertyProxy do
5
4
  before(:each) do
6
5
  @observable = FakeObservable.new
7
6
  @custom_type = CustomType.new
8
7
  @custom_type.custom_property = "initial_value"
9
-
8
+
10
9
  @observable_properties = {
11
10
  :object => RuGUI::ObservablePropertyProxy.new(Object.new, @observable, :my_object_observable_property),
12
11
  :string => RuGUI::ObservablePropertyProxy.new("some_value", @observable, :my_string_observable_property),
@@ -17,7 +16,7 @@ describe RuGUI::ObservablePropertyProxy do
17
16
  :custom_type => RuGUI::ObservablePropertyProxy.new(@custom_type, @observable, :my_custom_type_observable_property),
18
17
  }
19
18
  end
20
-
19
+
21
20
  [:object, :string, :fixnum, :float, :array, :hash, :custom_type].each do |type|
22
21
  describe "with #{type.to_s.camelize} observable properties" do
23
22
  it "should work as proxy for #{type.to_s.camelize} methods" do
@@ -28,35 +27,35 @@ describe RuGUI::ObservablePropertyProxy do
28
27
  end
29
28
  end
30
29
  end
31
-
30
+
32
31
  describe "with notification" do
33
32
  it "should notifiy the observable when calling methods that changes the observable property" do
34
33
  @observable_properties[:string].reverse! # reversing a string
35
34
  @observable.property_changed_message.should == "my_string_observable_property changed from some_value to eulav_emos"
36
-
35
+
37
36
  @observable_properties[:array] << 1 # adding an element into an array
38
- @observable.property_changed_message.should == "my_array_observable_property changed from to 1"
39
-
37
+ @observable.property_changed_message.should == "my_array_observable_property changed from [] to [1]"
38
+
40
39
  @observable_properties[:hash][:key] = "value" # setting or changing a value in a hash
41
- @observable.property_changed_message.should == "my_hash_observable_property changed from to keyvalue"
42
-
40
+ @observable.property_changed_message.should == 'my_hash_observable_property changed from {} to {:key=>"value"}'
41
+
43
42
  @observable_properties[:custom_type].change_custom_property("new_value") # calling a custom method which changes the property
44
43
  @observable.property_changed_message.should == "my_custom_type_observable_property changed from initial_value to new_value"
45
44
 
46
45
  @observable_properties[:custom_type].custom_property = "another_new_value" # changing a custom property with setter method
47
46
  @observable.property_changed_message.should == "my_custom_type_observable_property changed from new_value to another_new_value"
48
47
  end
49
-
48
+
50
49
  it "should not notifiy the observable when calling methods that does not changes the observable property" do
51
50
  @observable_properties[:string].reverse # reversing a string and returning a new copy of it
52
51
  @observable.property_changed_message.should be_nil
53
-
52
+
54
53
  @observable_properties[:array].index("some_value") # getting an element in the array
55
54
  @observable.property_changed_message.should be_nil
56
-
55
+
57
56
  @observable_properties[:hash].include?("some_key") # checking if a key is included in a hash
58
57
  @observable.property_changed_message.should be_nil
59
-
58
+
60
59
  @observable_properties[:custom_type].custom_method # calling a custom method which does not change
61
60
  @observable.property_changed_message.should be_nil
62
61
 
@@ -1,6 +1,4 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'spec_helper')
2
-
3
- require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'helpers', 'observables')
1
+ require 'spec_helper'
4
2
 
5
3
  describe RuGUI::ObservablePropertySupport do
6
4
  before(:each) do
@@ -12,30 +10,30 @@ describe RuGUI::ObservablePropertySupport do
12
10
  describe "with notification" do
13
11
  it "should notify the observer when setting a new value in a observable property" do
14
12
  @observable.my_observable_property = "something"
15
- @observer.property_updated_message.should == "AnotherFakeObservable property my_observable_property changed from to something"
13
+ @observer.property_updated_message.should == 'AnotherFakeObservable property my_observable_property changed from nil to "something"'
16
14
 
17
15
  @observable.my_observable_property = 1
18
- @observer.property_updated_message.should == "AnotherFakeObservable property my_observable_property changed from something to 1"
16
+ @observer.property_updated_message.should == 'AnotherFakeObservable property my_observable_property changed from "something" to 1'
19
17
 
20
18
  @observable.my_observable_property = ["somearray"]
21
- @observer.property_updated_message.should == "AnotherFakeObservable property my_observable_property changed from 1 to somearray"
19
+ @observer.property_updated_message.should == 'AnotherFakeObservable property my_observable_property changed from 1 to ["somearray"]'
22
20
 
23
21
  @observable.my_observable_property = {'key' => "value"}
24
- @observer.property_updated_message.should == "AnotherFakeObservable property my_observable_property changed from somearray to key"
22
+ @observer.property_updated_message.should == 'AnotherFakeObservable property my_observable_property changed from ["somearray"] to {"key"=>"value"}'
25
23
  end
26
24
 
27
25
  it "should notify the observer when changing the value of a observable property" do
28
26
  @observable.my_observable_property = "something"
29
27
  @observable.my_observable_property << "_else"
30
- @observer.property_updated_message.should == "AnotherFakeObservable property my_observable_property changed from something to something_else"
28
+ @observer.property_updated_message.should == 'AnotherFakeObservable property my_observable_property changed from "something" to "something_else"'
31
29
 
32
30
  @observable.my_observable_property = ["somearray"]
33
31
  @observable.my_observable_property << "another_value"
34
- @observer.property_updated_message.should == "AnotherFakeObservable property my_observable_property changed from somearray to somearrayanother_value"
32
+ @observer.property_updated_message.should == 'AnotherFakeObservable property my_observable_property changed from ["somearray"] to ["somearray", "another_value"]'
35
33
 
36
34
  @observable.my_observable_property = {'key' => "value"}
37
35
  @observable.my_observable_property['another_key'] = "another_value"
38
- @observer.property_updated_message.should == "AnotherFakeObservable property my_observable_property changed from key to another_keykey"
36
+ @observer.property_updated_message.should == 'AnotherFakeObservable property my_observable_property changed from {"key"=>"value"} to {"key"=>"value", "another_key"=>"another_value"}'
39
37
  end
40
38
 
41
39
  it "should not notify the observer when setting the same value in a observable property" do
@@ -1,41 +1,39 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'spec_helper')
2
-
3
- require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'helpers', 'observables')
1
+ require 'spec_helper'
4
2
 
5
3
  describe RuGUI::PropertyObserver do
6
4
  before(:each) do
7
5
  @observer = FakeObserverForPropertyObserverTest.new
8
6
  end
9
-
7
+
10
8
  describe "with notification" do
11
9
  it "should be notified when setting a new value in a observable property" do
12
10
  @observer.observable.my_observable_property = "something"
13
- @observer.property_updated_message.should == "FakeObservableForPropertyObserverTest property my_observable_property changed from to something"
14
-
11
+ @observer.property_updated_message.should == 'FakeObservableForPropertyObserverTest property my_observable_property changed from nil to "something"'
12
+
15
13
  @observer.observable.my_observable_property = 1
16
- @observer.property_updated_message.should == "FakeObservableForPropertyObserverTest property my_observable_property changed from something to 1"
17
-
14
+ @observer.property_updated_message.should == 'FakeObservableForPropertyObserverTest property my_observable_property changed from "something" to 1'
15
+
18
16
  @observer.observable.my_observable_property = ["somearray"]
19
- @observer.property_updated_message.should == "FakeObservableForPropertyObserverTest property my_observable_property changed from 1 to somearray"
20
-
17
+ @observer.property_updated_message.should == 'FakeObservableForPropertyObserverTest property my_observable_property changed from 1 to ["somearray"]'
18
+
21
19
  @observer.observable.my_observable_property = {'key' => "value"}
22
- @observer.property_updated_message.should == "FakeObservableForPropertyObserverTest property my_observable_property changed from somearray to key"
20
+ @observer.property_updated_message.should == 'FakeObservableForPropertyObserverTest property my_observable_property changed from ["somearray"] to {"key"=>"value"}'
23
21
  end
24
-
22
+
25
23
  it "should be notified when changing the value of a observable property" do
26
24
  @observer.observable.my_observable_property = "something"
27
25
  @observer.observable.my_observable_property << "_else"
28
- @observer.property_updated_message.should == "FakeObservableForPropertyObserverTest property my_observable_property changed from something to something_else"
29
-
26
+ @observer.property_updated_message.should == 'FakeObservableForPropertyObserverTest property my_observable_property changed from "something" to "something_else"'
27
+
30
28
  @observer.observable.my_observable_property = ["somearray"]
31
29
  @observer.observable.my_observable_property << "another_value"
32
- @observer.property_updated_message.should == "FakeObservableForPropertyObserverTest property my_observable_property changed from somearray to somearrayanother_value"
33
-
30
+ @observer.property_updated_message.should == 'FakeObservableForPropertyObserverTest property my_observable_property changed from ["somearray"] to ["somearray", "another_value"]'
31
+
34
32
  @observer.observable.my_observable_property = {'key' => "value"}
35
33
  @observer.observable.my_observable_property['another_key'] = "another_value"
36
- @observer.property_updated_message.should == "FakeObservableForPropertyObserverTest property my_observable_property changed from key to another_keykey"
34
+ @observer.property_updated_message.should == 'FakeObservableForPropertyObserverTest property my_observable_property changed from {"key"=>"value"} to {"key"=>"value", "another_key"=>"another_value"}'
37
35
  end
38
-
36
+
39
37
  it "should not be notified when setting the same value in a observable property" do
40
38
  set_same_value_twice_clearing_property_updated_message("something")
41
39
  @observer.property_updated_message.should be_nil
@@ -46,14 +44,14 @@ describe RuGUI::PropertyObserver do
46
44
  set_same_value_twice_clearing_property_updated_message({'key' => "value"})
47
45
  @observer.property_updated_message.should be_nil
48
46
  end
49
-
47
+
50
48
  def set_same_value_twice_clearing_property_updated_message(value)
51
49
  @observer.observable.my_observable_property = value
52
50
  @observer.property_updated_message = nil
53
51
  @observer.observable.my_observable_property = value
54
52
  end
55
53
  end
56
-
54
+
57
55
  describe "class specific methods" do
58
56
  it "should be called when observable property changes" do
59
57
  @observer.observable.my_observable_property = "something"
@@ -66,7 +64,7 @@ describe RuGUI::PropertyObserver do
66
64
  @observer.class_specific_method_called_message.should == "Property my_observable_property changed, called from class specific method"
67
65
  end
68
66
  end
69
-
67
+
70
68
  describe "named instance specific methods" do
71
69
  it "should be called when observable property changes" do
72
70
  @observer.named_observable.my_observable_property = "something"
@@ -78,7 +76,7 @@ describe RuGUI::PropertyObserver do
78
76
  @observer.named_observable.my_observable_property << "something"
79
77
  @observer.instance_specific_method_called_message.should == "Property my_observable_property changed, called from named instance specific method"
80
78
  end
81
-
79
+
82
80
  it "should not be called when the instance name collides with the class name" do
83
81
  lambda {
84
82
  @observer.fake_named_observable_test.my_observable_property = "something"
@@ -6,16 +6,16 @@ class MyController < RuGUI::BaseController
6
6
  include InitializeHooksHelper
7
7
 
8
8
  attr_accessor :message
9
-
9
+
10
10
  def setup_models
11
11
  register_model :my_model
12
12
  register_model :my_model, :my_other_model_instance
13
13
  end
14
-
14
+
15
15
  def setup_controllers
16
16
  register_controller :my_child_controller
17
17
  end
18
-
18
+
19
19
  def property_my_other_model_instance_my_property_changed(model, new_value, old_value)
20
20
  @message = "Property my_property of named observable my_other_model_instance changed from #{old_value} to #{new_value}."
21
21
  end
@@ -0,0 +1,9 @@
1
+ module HelperManager
2
+ class << self
3
+ def clear!
4
+ RuGUI::BaseObject.descendants.each do |klass|
5
+ klass.clear_all_registries if klass.respond_to?(:clear_all_registries)
6
+ end
7
+ end
8
+ end
9
+ end