activesambaldap 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. data/NEWS.en +10 -1
  2. data/NEWS.ja +10 -1
  3. data/README.en +10 -3
  4. data/README.ja +10 -3
  5. data/Rakefile +3 -4
  6. data/data/locale/ja/LC_MESSAGES/active-samba-ldap.mo +0 -0
  7. data/example/asl-admin/README +243 -0
  8. data/example/asl-admin/Rakefile +10 -0
  9. data/example/asl-admin/app/controllers/application_controller.rb +10 -0
  10. data/example/asl-admin/app/controllers/samba_controller.rb +12 -0
  11. data/example/asl-admin/app/helpers/application_helper.rb +3 -0
  12. data/example/asl-admin/app/helpers/samba_helper.rb +2 -0
  13. data/example/asl-admin/app/models/computer.rb +3 -0
  14. data/example/asl-admin/app/models/dc.rb +3 -0
  15. data/example/asl-admin/app/models/group.rb +3 -0
  16. data/example/asl-admin/app/models/idmap.rb +3 -0
  17. data/example/asl-admin/app/models/ou.rb +3 -0
  18. data/example/asl-admin/app/models/unix_id_pool.rb +3 -0
  19. data/example/asl-admin/app/models/user.rb +3 -0
  20. data/example/asl-admin/app/views/samba/index.html.erb +17 -0
  21. data/example/asl-admin/app/views/samba/populate.html.erb +15 -0
  22. data/example/asl-admin/app/views/samba/purge.html.erb +10 -0
  23. data/example/asl-admin/config/boot.rb +110 -0
  24. data/example/asl-admin/config/database.yml +22 -0
  25. data/example/asl-admin/config/environment.rb +48 -0
  26. data/example/asl-admin/config/environments/development.rb +17 -0
  27. data/example/asl-admin/config/environments/production.rb +28 -0
  28. data/example/asl-admin/config/environments/test.rb +28 -0
  29. data/example/asl-admin/config/initializers/backtrace_silencers.rb +7 -0
  30. data/example/asl-admin/config/initializers/inflections.rb +10 -0
  31. data/example/asl-admin/config/initializers/mime_types.rb +5 -0
  32. data/example/asl-admin/config/initializers/new_rails_defaults.rb +19 -0
  33. data/example/asl-admin/config/initializers/session_store.rb +15 -0
  34. data/example/asl-admin/config/ldap.yml.sample +24 -0
  35. data/example/asl-admin/config/locales/en.yml +5 -0
  36. data/example/asl-admin/config/routes.rb +43 -0
  37. data/example/asl-admin/log/test.log +5 -0
  38. data/example/asl-admin/public/404.html +30 -0
  39. data/example/asl-admin/public/422.html +30 -0
  40. data/example/asl-admin/public/500.html +30 -0
  41. data/example/asl-admin/public/favicon.ico +0 -0
  42. data/example/asl-admin/public/images/rails.png +0 -0
  43. data/example/asl-admin/public/index.html +275 -0
  44. data/example/asl-admin/public/javascripts/application.js +2 -0
  45. data/example/asl-admin/public/javascripts/controls.js +963 -0
  46. data/example/asl-admin/public/javascripts/dragdrop.js +973 -0
  47. data/example/asl-admin/public/javascripts/effects.js +1128 -0
  48. data/example/asl-admin/public/javascripts/prototype.js +4320 -0
  49. data/example/asl-admin/public/robots.txt +5 -0
  50. data/example/asl-admin/script/about +4 -0
  51. data/example/asl-admin/script/console +3 -0
  52. data/example/asl-admin/script/dbconsole +3 -0
  53. data/example/asl-admin/script/destroy +3 -0
  54. data/example/asl-admin/script/generate +3 -0
  55. data/example/asl-admin/script/performance/benchmarker +3 -0
  56. data/example/asl-admin/script/performance/profiler +3 -0
  57. data/example/asl-admin/script/plugin +3 -0
  58. data/example/asl-admin/script/runner +3 -0
  59. data/example/asl-admin/script/server +3 -0
  60. data/example/asl-admin/test/performance/browsing_test.rb +9 -0
  61. data/example/asl-admin/test/test_helper.rb +38 -0
  62. data/lib/active_samba_ldap.rb +1 -1
  63. data/lib/active_samba_ldap/account_entry.rb +17 -9
  64. data/lib/active_samba_ldap/active_directory.rb +66 -0
  65. data/lib/active_samba_ldap/base.rb +8 -0
  66. data/lib/active_samba_ldap/computer.rb +1 -0
  67. data/lib/active_samba_ldap/configuration.rb +32 -4
  68. data/lib/active_samba_ldap/entry.rb +48 -0
  69. data/lib/active_samba_ldap/group_entry.rb +8 -8
  70. data/lib/active_samba_ldap/populate.rb +1 -0
  71. data/lib/active_samba_ldap/samba_account_entry.rb +31 -14
  72. data/lib/active_samba_ldap/samba_computer_account_entry.rb +18 -0
  73. data/lib/active_samba_ldap/samba_entry.rb +6 -5
  74. data/lib/active_samba_ldap/samba_group_entry.rb +22 -13
  75. data/lib/active_samba_ldap/version.rb +1 -1
  76. data/po/active-samba-ldap.pot +463 -0
  77. data/po/ja/active-samba-ldap.po +15 -11
  78. data/rails/init.rb +1 -18
  79. data/rails_generators/scaffold_active_samba_ldap/scaffold_active_samba_ldap_generator.rb +4 -3
  80. data/rails_generators/scaffold_active_samba_ldap/templates/computer.rb +1 -1
  81. data/rails_generators/scaffold_active_samba_ldap/templates/group.rb +1 -1
  82. data/rails_generators/scaffold_active_samba_ldap/templates/{samba_index.rhtml → samba_index.html.erb} +0 -0
  83. data/rails_generators/scaffold_active_samba_ldap/templates/{samba_populate.rhtml → samba_populate.html.erb} +0 -0
  84. data/rails_generators/scaffold_active_samba_ldap/templates/{samba_purge.rhtml → samba_purge.html.erb} +0 -0
  85. data/rails_generators/scaffold_active_samba_ldap/templates/user.rb +1 -1
  86. data/test-unit/History.txt +1 -1
  87. data/test-unit/README.txt +1 -1
  88. data/test-unit/lib/test/unit/assertions.rb +1 -1
  89. data/test-unit/lib/test/unit/autorunner.rb +19 -4
  90. data/test-unit/lib/test/unit/collector/load.rb +3 -1
  91. data/test-unit/lib/test/unit/color-scheme.rb +5 -1
  92. data/test-unit/lib/test/unit/error.rb +7 -5
  93. data/test-unit/lib/test/unit/runner/tap.rb +8 -0
  94. data/test-unit/lib/test/unit/ui/console/testrunner.rb +63 -8
  95. data/test-unit/lib/test/unit/ui/tap/testrunner.rb +92 -0
  96. data/test-unit/test/collector/test-load.rb +1 -5
  97. data/test-unit/test/test-color-scheme.rb +4 -0
  98. data/test/command.rb +8 -3
  99. data/test/run-test.rb +4 -1
  100. data/test/test_asl_useradd.rb +2 -2
  101. metadata +81 -20
@@ -1,14 +1,14 @@
1
- # Japanese translations for Ruby/ActiveSambaLdap.
1
+ # Japanese translations for ActiveSambaLdap.
2
2
  # Copyright (C) 2007-2009 Kouhei Sutou
3
- # This file is distributed under the same license as the Ruby/ActiveSambaLdap
3
+ # This file is distributed under the same license as the ActiveSambaLdap
4
4
  # package.
5
5
  # Kouhei Sutou <kou@clear-code.com>, 2007.
6
6
  #
7
7
  msgid ""
8
8
  msgstr ""
9
- "Project-Id-Version: Ruby/ActiveSambaLdap 0.0.7\n"
10
- "POT-Creation-Date: 2007-09-16 22:47+0900\n"
11
- "PO-Revision-Date: 2009-07-11 09:41+0900\n"
9
+ "Project-Id-Version: ActiveSambaLdap 0.0.8\n"
10
+ "POT-Creation-Date: 2009-09-22 14:42+0900\n"
11
+ "PO-Revision-Date: 2009-09-22 14:42+0900\n"
12
12
  "Last-Translator: Kouhei Sutou <kou@clear-code.com>\n"
13
13
  "Language-Team: Japanese\n"
14
14
  "MIME-Version: 1.0\n"
@@ -36,7 +36,7 @@ msgstr "このメッセージを表示"
36
36
  msgid "Show version"
37
37
  msgstr "バージョンを表示"
38
38
 
39
- #: lib/active_samba_ldap/entry.rb:39
39
+ #: lib/active_samba_ldap/entry.rb:59
40
40
  msgid "%s must be only ou"
41
41
  msgstr "%sはouだけでなくてはいけません"
42
42
 
@@ -95,15 +95,19 @@ msgstr "%sの値'%s'が不正です: %s"
95
95
  msgid "%s is not Samba available"
96
96
  msgstr "%sはSambaで利用できません"
97
97
 
98
- #: lib/active_samba_ldap/configuration.rb:310
98
+ #: lib/active_samba_ldap/base.rb:119
99
+ msgid "%s is not UNIX available"
100
+ msgstr "%sはUNIXで利用できません"
101
+
102
+ #: lib/active_samba_ldap/configuration.rb:338
99
103
  msgid "must be in %s"
100
104
  msgstr "%sの中になければいけません"
101
105
 
102
- #: lib/active_samba_ldap/samba_group_entry.rb:138
106
+ #: lib/active_samba_ldap/samba_group_entry.rb:141
103
107
  msgid "invalid type: %s"
104
108
  msgstr "不正な種類: %s"
105
109
 
106
- #: rails/plugin/active_samba_ldap/init.rb:10
110
+ #: rails/init.rb:12
107
111
  msgid ""
108
112
  "You should run 'script/generator scaffold_active_samba_ldap' to make %s."
109
113
  msgstr ""
@@ -334,7 +338,7 @@ msgstr "(Sambaのアカウント制御ビット。例: '[NDHTUMWSLXI]')"
334
338
  msgid "illegal %s name: %s"
335
339
  msgstr "不正な%s名: %s"
336
340
 
337
- #: bin/asl-useradd:182 bin/asl-usermod:308
341
+ #: bin/asl-useradd:182 bin/asl-usermod:309
338
342
  msgid "%s already exists: %s"
339
343
  msgstr "すでに存在する%sです: %s"
340
344
 
@@ -452,7 +456,7 @@ msgstr "このユーザを無効にする"
452
456
  msgid "enable this user"
453
457
  msgstr "このユーザを有効にする"
454
458
 
455
- #: bin/asl-usermod:234 bin/asl-usermod:238
459
+ #: bin/asl-usermod:235 bin/asl-usermod:239
456
460
  msgid "not implemented."
457
461
  msgstr "実装されていません。"
458
462
 
data/rails/init.rb CHANGED
@@ -2,32 +2,15 @@ require_library_or_gem 'active_samba_ldap'
2
2
 
3
3
  ActiveSambaLdap::Base.logger ||= RAILS_DEFAULT_LOGGER
4
4
 
5
- required_version = ["0", "0", "6"]
6
- if (ActiveLdap::VERSION.split(".") <=> required_version) < 0
7
- ActiveLdap::Base.class_eval do
8
- format = _("You need ActiveSambaLdap %s or later")
9
- logger.error(format % required_version.join("."))
10
- end
11
- end
12
-
13
5
  ldap_configuration_file = File.join(RAILS_ROOT, 'config', 'ldap.yml')
14
6
  if File.exist?(ldap_configuration_file)
15
7
  ActiveSambaLdap::Base.configurations =
16
8
  ActiveSambaLdap::Configuration.read(ldap_configuration_file)
17
9
  ActiveSambaLdap::Base.setup_connection
18
10
  else
19
- ActiveLdap::Base.class_eval do
11
+ ActiveSambaLdap::Base.class_eval do
20
12
  format = _("You should run 'script/generator scaffold_active_samba_ldap' " \
21
13
  "to make %s.")
22
14
  logger.error(format % ldap_configuration_file)
23
15
  end
24
16
  end
25
-
26
- class ActionView::Base
27
- include ActiveLdap::Helper
28
- end
29
-
30
- require 'active_ldap/action_controller/ldap_benchmarking'
31
- class ActionController::Base
32
- include ActiveLdap::ActionController::LdapBenchmarking
33
- end
@@ -1,3 +1,4 @@
1
+ p 1
1
2
  class ScaffoldActiveSambaLdapGenerator < Rails::Generator::Base
2
3
  def manifest
3
4
  record do |m|
@@ -9,7 +10,7 @@ class ScaffoldActiveSambaLdapGenerator < Rails::Generator::Base
9
10
  end
10
11
 
11
12
  component = "samba"
12
- controller_class_name = "#{Inflector.camelize(component)}Controller"
13
+ controller_class_name = "#{component.camelize}Controller"
13
14
  options = {:assigns => {:controller_class_name => controller_class_name}}
14
15
 
15
16
  m.template("#{component}_controller.rb",
@@ -18,8 +19,8 @@ class ScaffoldActiveSambaLdapGenerator < Rails::Generator::Base
18
19
  File.join("app", "helpers", "#{component}_helper.rb"))
19
20
  m.directory(File.join("app", "views", component))
20
21
  %w(index populate purge).each do |action|
21
- m.template("#{component}_#{action}.rhtml",
22
- File.join("app", "views", component, "#{action}.rhtml"),
22
+ m.template("#{component}_#{action}.html.erb",
23
+ File.join("app", "views", component, "#{action}.html.erb"),
23
24
  options)
24
25
  end
25
26
  end
@@ -1,3 +1,3 @@
1
- class Computer < ActiveSambaLdap::SambaComputer
1
+ class Computer < ActiveSambaLdap::Computer
2
2
  ldap_mapping
3
3
  end
@@ -1,3 +1,3 @@
1
- class Group < ActiveSambaLdap::SambaGroup
1
+ class Group < ActiveSambaLdap::Group
2
2
  ldap_mapping
3
3
  end
@@ -1,3 +1,3 @@
1
- class User < ActiveSambaLdap::SambaUser
1
+ class User < ActiveSambaLdap::User
2
2
  ldap_mapping
3
3
  end
@@ -1,4 +1,4 @@
1
- === 2.0.3 / 2009-07-17
1
+ === 2.0.3 / 2009-07-19
2
2
 
3
3
  * 6 major enhancements
4
4
  * add assert_predicate.
data/test-unit/README.txt CHANGED
@@ -7,7 +7,7 @@
7
7
  Test::Unit 2.x - Improved version of Test::Unit bundled in
8
8
  Ruby 1.8.x.
9
9
 
10
- Ruby 1.9.x bundles miniunit not Test::Unit. Test::Unit
10
+ Ruby 1.9.x bundles minitest not Test::Unit. Test::Unit
11
11
  bundled in Ruby 1.8.x had not been improved but unbundled
12
12
  Test::Unit (Test::Unit 2.x) will be improved actively.
13
13
 
@@ -880,7 +880,7 @@ EOT
880
880
  MaybeContainer.new(value, &formatter)
881
881
  end
882
882
 
883
- MAX_DIFF_TARGET_STRING_SIZE = 300
883
+ MAX_DIFF_TARGET_STRING_SIZE = 1000
884
884
  def diff_target_string?(string)
885
885
  if string.respond_to?(:bytesize)
886
886
  string.bytesize < MAX_DIFF_TARGET_STRING_SIZE
@@ -102,15 +102,23 @@ module Test
102
102
  @to_run = []
103
103
  @color_scheme = ColorScheme.default
104
104
  @runner_options = {}
105
+ @default_arguments = []
105
106
  @workdir = nil
106
- default_config_file = "test-unit.yml"
107
- load_config(default_config_file) if File.exist?(default_config_file)
107
+ config_file = "test-unit.yml"
108
+ if File.exist?(config_file)
109
+ load_config(config_file)
110
+ else
111
+ global_config_file = File.expand_path("~/.test-unit.xml")
112
+ load_config(global_config_file) if File.exist?(global_config_file)
113
+ end
108
114
  yield(self) if block_given?
109
115
  end
110
116
 
111
117
  def process_args(args = ARGV)
118
+ default_arguments = @default_arguments.dup
112
119
  begin
113
- options.order!(args) {|arg| @to_run << arg}
120
+ @default_arguments.concat(args)
121
+ options.order!(@default_arguments) {|arg| @to_run << arg}
114
122
  rescue OptionParser::ParseError => e
115
123
  puts e
116
124
  puts options
@@ -119,6 +127,8 @@ module Test
119
127
  @filters << proc{false} unless(@filters.empty?)
120
128
  end
121
129
  not @to_run.empty?
130
+ ensure
131
+ @default_arguments = default_arguments
122
132
  end
123
133
 
124
134
  def options
@@ -304,7 +314,11 @@ module Test
304
314
  (config["#{runner_name}_options"] || {}).each do |key, value|
305
315
  key = key.to_sym
306
316
  value = ColorScheme[value] if key == :color_scheme
307
- runner_options[key.to_sym] = value
317
+ if key == :arguments
318
+ @default_arguments.concat(value.split)
319
+ else
320
+ runner_options[key.to_sym] = value
321
+ end
308
322
  end
309
323
  @runner_options = @runner_options.merge(runner_options)
310
324
  end
@@ -327,3 +341,4 @@ end
327
341
 
328
342
  require 'test/unit/runner/console'
329
343
  require 'test/unit/runner/emacs'
344
+ require 'test/unit/runner/tap'
@@ -76,7 +76,9 @@ module Test
76
76
  sub_test_suites << sub_test_suite unless sub_test_suite.empty?
77
77
  end
78
78
  else
79
- collect_file(path, sub_test_suites, already_gathered)
79
+ unless excluded_file?(path.basename.to_s)
80
+ collect_file(path, sub_test_suites, already_gathered)
81
+ end
80
82
  end
81
83
 
82
84
  test_suite = TestSuite.new(path.basename.to_s)
@@ -14,7 +14,11 @@ module Test
14
14
  "omission" => Color.new("blue", :bold => true),
15
15
  "notification" => Color.new("cyan", :bold => true),
16
16
  "error" => Color.new("yellow", :bold => true) +
17
- Color.new("black", :foreground => false))
17
+ Color.new("black", :foreground => false),
18
+ "case" => Color.new("white", :bold => true) +
19
+ Color.new("blue", :foreground => false),
20
+ "suite" => Color.new("white", :bold => true) +
21
+ Color.new("green", :foreground => false))
18
22
  end
19
23
 
20
24
  @@schemes = {}
@@ -69,18 +69,20 @@ module Test
69
69
  end
70
70
  end
71
71
 
72
+ NOT_PASS_THROUGH_EXCEPTIONS = []
72
73
  PASS_THROUGH_EXCEPTIONS = [NoMemoryError, SignalException, Interrupt,
73
74
  SystemExit]
74
75
  private
75
76
  def handle_all_exception(exception)
76
77
  case exception
78
+ when *NOT_PASS_THROUGH_EXCEPTIONS
77
79
  when *PASS_THROUGH_EXCEPTIONS
78
- false
79
- else
80
- problem_occurred
81
- add_error(exception)
82
- true
80
+ return false
83
81
  end
82
+
83
+ problem_occurred
84
+ add_error(exception)
85
+ true
84
86
  end
85
87
 
86
88
  def add_error(exception)
@@ -0,0 +1,8 @@
1
+ module Test
2
+ module Unit
3
+ AutoRunner.register_runner(:tap) do |auto_runner|
4
+ require 'test/unit/ui/tap/testrunner'
5
+ Test::Unit::UI::Tap::TestRunner
6
+ end
7
+ end
8
+ end
@@ -1,7 +1,9 @@
1
1
  #--
2
2
  #
3
3
  # Author:: Nathaniel Talbott.
4
- # Copyright:: Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
4
+ # Copyright::
5
+ # * Copyright (c) 2000-2003 Nathaniel Talbott. All rights reserved.
6
+ # * Copyright (c) 2008-2009 Kouhei Sutou <kou@clear-code.com>
5
7
  # License:: Ruby license.
6
8
 
7
9
  require 'test/unit/color-scheme'
@@ -36,6 +38,9 @@ module Test
36
38
  @progress_row_max = @options[:progress_row_max]
37
39
  @progress_row_max ||= guess_progress_row_max
38
40
  @already_outputted = false
41
+ @n_successes = 0
42
+ @indent = 0
43
+ @top_level = true
39
44
  @faults = []
40
45
  end
41
46
 
@@ -68,6 +73,8 @@ module Test
68
73
  @mediator.add_listener(TestRunnerMediator::FINISHED, &method(:finished))
69
74
  @mediator.add_listener(TestCase::STARTED, &method(:test_started))
70
75
  @mediator.add_listener(TestCase::FINISHED, &method(:test_finished))
76
+ @mediator.add_listener(TestSuite::STARTED, &method(:test_suite_started))
77
+ @mediator.add_listener(TestSuite::FINISHED, &method(:test_suite_finished))
71
78
  end
72
79
 
73
80
  def start_mediator
@@ -91,8 +98,6 @@ module Test
91
98
 
92
99
  def finished(elapsed_time)
93
100
  nl if output?(NORMAL) and !output?(VERBOSE)
94
- nl
95
- output("Finished in #{elapsed_time} seconds.")
96
101
  @faults.each_with_index do |fault, index|
97
102
  nl
98
103
  output_single("%3d) " % (index + 1))
@@ -101,25 +106,75 @@ module Test
101
106
  output(detail)
102
107
  end
103
108
  nl
109
+ output("Finished in #{elapsed_time} seconds.")
110
+ nl
104
111
  output(@result, result_color)
112
+ n_tests = @result.run_count
113
+ if n_tests.zero?
114
+ pass_percentage = 0
115
+ else
116
+ pass_percentage = 100.0 * (@n_successes / n_tests.to_f)
117
+ end
118
+ output("%g%% passed" % pass_percentage, result_color)
105
119
  end
106
120
 
107
121
  def format_fault(fault)
108
122
  fault.long_display
109
123
  end
110
-
124
+
111
125
  def test_started(name)
112
- output_single(name + ": ", nil, VERBOSE)
126
+ return unless output?(VERBOSE)
127
+
128
+ name = name.sub(/\(.+?\)\z/, '')
129
+ right_space = 8 * 2
130
+ left_space = @progress_row_max - right_space
131
+ left_space = left_space - indent.size - name.size
132
+ tab_stop = "\t" * ((left_space - 1) / 8)
133
+ output_single("#{indent}#{name}:#{tab_stop}", nil, VERBOSE)
134
+ @test_start = Time.now
113
135
  end
114
-
136
+
115
137
  def test_finished(name)
116
138
  unless @already_outputted
139
+ @n_successes += 1
117
140
  output_progress(".", color("success"))
118
141
  end
119
- nl(VERBOSE)
120
142
  @already_outputted = false
143
+
144
+ return unless output?(VERBOSE)
145
+
146
+ output(": (%f)" % (Time.now - @test_start), nil, VERBOSE)
121
147
  end
122
-
148
+
149
+ def test_suite_started(name)
150
+ if @top_level
151
+ @top_level = false
152
+ return
153
+ end
154
+
155
+ output_single(indent, nil, VERBOSE)
156
+ if /\A[A-Z]/ =~ name
157
+ _color = color("case")
158
+ else
159
+ _color = color("suite")
160
+ end
161
+ output_single(name, _color, VERBOSE)
162
+ output(": ", nil, VERBOSE)
163
+ @indent += 2
164
+ end
165
+
166
+ def test_suite_finished(name)
167
+ @indent -= 2
168
+ end
169
+
170
+ def indent
171
+ if output?(VERBOSE)
172
+ " " * @indent
173
+ else
174
+ ""
175
+ end
176
+ end
177
+
123
178
  def nl(level=NORMAL)
124
179
  output("", nil, level)
125
180
  end
@@ -0,0 +1,92 @@
1
+ #--
2
+ #
3
+ # Author:: Kouhei Sutou.
4
+ # Copyright:: Copyright (c) 2009 Kouhei Sutou <kou@clear-code.com>.
5
+ # License:: Ruby license.
6
+
7
+ require 'test/unit/ui/testrunner'
8
+ require 'test/unit/ui/testrunnermediator'
9
+
10
+ module Test
11
+ module Unit
12
+ module UI
13
+ module Tap
14
+
15
+ # Runs a Test::Unit::TestSuite and outputs result
16
+ # as TAP format.
17
+ class TestRunner < UI::TestRunner
18
+ def initialize(suite, options={})
19
+ super
20
+ @output = @options[:output] || STDOUT
21
+ @n_tests = 0
22
+ @already_outputted = false
23
+ end
24
+
25
+ # Begins the test run.
26
+ def start
27
+ setup_mediator
28
+ result = start_mediator
29
+ def result.passed?
30
+ true # for prove commend :<
31
+ end
32
+ result
33
+ end
34
+
35
+ private
36
+ def setup_mediator
37
+ @mediator = TestRunnerMediator.new(@suite)
38
+ attach_to_mediator
39
+ end
40
+
41
+ def attach_to_mediator
42
+ @mediator.add_listener(TestResult::FAULT, &method(:add_fault))
43
+ @mediator.add_listener(TestRunnerMediator::STARTED, &method(:started))
44
+ @mediator.add_listener(TestRunnerMediator::FINISHED, &method(:finished))
45
+ @mediator.add_listener(TestCase::STARTED, &method(:test_started))
46
+ @mediator.add_listener(TestCase::FINISHED, &method(:test_finished))
47
+ end
48
+
49
+ def start_mediator
50
+ @mediator.run_suite
51
+ end
52
+
53
+ def add_fault(fault)
54
+ puts("not ok #{@n_tests} - #{fault.short_display}")
55
+ fault.long_display.each_line do |line|
56
+ puts("# #{line}")
57
+ end
58
+ @already_outputted = true
59
+ end
60
+
61
+ def started(result)
62
+ @result = result
63
+ puts("1..#{@suite.size}")
64
+ end
65
+
66
+ def finished(elapsed_time)
67
+ puts("# Finished in #{elapsed_time} seconds.")
68
+ @result.to_s.each_line do |line|
69
+ puts("# #{line}")
70
+ end
71
+ end
72
+
73
+ def test_started(name)
74
+ @n_tests += 1
75
+ end
76
+
77
+ def test_finished(name)
78
+ unless @already_outputted
79
+ puts("ok #{@n_tests} - #{name}")
80
+ end
81
+ @already_outputted = false
82
+ end
83
+
84
+ def puts(*args)
85
+ @output.puts(*args)
86
+ @output.flush
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end