fgrehm-autotestforphp 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/License.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Fábio Rehm
1
+ Copyright (c) 2009 Fábio Galvão Rehm
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/Manifest.txt CHANGED
@@ -20,7 +20,6 @@ script/destroy
20
20
  script/generate
21
21
  test/autotestforphp/test_autotestforphp.rb
22
22
  test/cli/test_autotestforphp_cli.rb
23
- test/cli/test_install_cli.rb
24
23
  test/test_helper.rb
25
24
  test/test_linux.rb
26
25
  test/test_mac.rb
data/README.rdoc CHANGED
@@ -8,9 +8,13 @@
8
8
  AutotestForPHP is based off of ZenTest autotest which is a popular Ruby tool for running tests as soon as files get changed:
9
9
  * http://www.zenspider.com/ZSS/Products/ZenTest/
10
10
 
11
- The code for displaying notifications is based on Carlos Brando autotest-notification gem:
11
+ Code for displaying notifications is based on Carlos Brando autotest-notification gem:
12
12
  * http://github.com/carlosbrando/autotest-notification
13
13
 
14
+ The tool was written on Ruby but you don't need to be a Ruby programmer in order to use it, just make sure you have Ruby and RubyGems installed:
15
+ * http://www.ruby-lang.org/
16
+ * http://rubygems.org/read/chapter/3
17
+
14
18
 
15
19
  == SYNOPSYS
16
20
 
@@ -21,54 +25,59 @@ The code for displaying notifications is based on Carlos Brando autotest-notific
21
25
 
22
26
  == REQUIREMENTS:
23
27
 
24
- * Ruby
25
- * RubyGems
26
28
  * PHP5
27
29
  * PHPUnit
30
+ * Ruby
31
+ * RubyGems
32
+
33
+ * Linux: *(TESTED ON KDE ONLY)*
34
+ You need to have libnotify binaries installed.
35
+
36
+ For ubuntu this means: sudo apt-get install libnotify-bin
37
+
38
+ Other distributions may package it with other names, do a search for libnotify using your distribution package
39
+ manager.
40
+
41
+ If you use KDE and do not have libnotify-bin installed, it will try to use kdialog which is part of KDE.
42
+ It also works if you have zenity installed.
28
43
 
29
44
  * Mac: *(NOT TESTED)*
30
45
  You need to have Growl and growlnotify installed on your machine.
31
46
 
32
- Download the Growl [http://growl.info/index.php] and install it like any other application on your Mac
47
+ Download Growl[http://growl.info/index.php] and install it like any other application on your Mac.
33
48
 
34
49
  Then you must install the growlnotify.
35
50
 
36
51
  In your shell, cd to the directory on the Growl disk image containing growlnotify, and type ./install.sh.
37
52
  That script will install growlnotify to /usr/local/bin and the manpage to /usr/local/man.
38
53
 
39
- * Windows: *(NOT TESTED)*
54
+ * Windows: *(TESTED ON VISTA ONLY)*
40
55
  You need to have Snarl and ruby-snarl installed on your machine.
41
56
 
42
- Download Snarl [http://www.fullphat.net/] and install it like any other application on your machine.
57
+ Download Snarl[http://www.fullphat.net/] and install it like any other application on your machine.
43
58
 
44
59
  Run in the command prompt:
45
60
 
46
61
  $ gem install ruby-snarl
47
62
 
48
- * Linux: *(TESTED ON KDE ONLY)*
49
- You need to have libnotify binaries installed.
50
63
 
51
- For ubuntu this means: sudo apt-get install libnotify-bin
64
+ == INSTALL:
52
65
 
53
- Other distributions may package it with other names, do a search for libnotify using your distribution package
54
- manager.
66
+ gem install fgrehm-autotestforphp --source=http://gems.github.com
55
67
 
56
- If you use KDE and do not have libnotify-bin installed, it will try to use kdialog which is part of KDE.
57
- It also works if you have zenity installed.
58
68
 
69
+ == SETUP
59
70
 
60
- == INSTALL:
71
+ During instalation, AutotestForPHP will create:
61
72
 
62
- * gem install autotestforphp --source=http://gems.github.com
73
+ 1. An empty PHPUnit boostrap file on autotestforphp/bootstrap-autotest.php to be used when running tests
63
74
 
75
+ 2. An empty config file on autotestforphp/config.autotest
64
76
 
65
- == SETUP
77
+ 3. A PHPUnit config file on autotestforphp/phpunit-autotest.xml to will configure the bootstrap file to be used,
78
+ tests folder and log results to a XML file needed for displaying notifications:
66
79
 
67
- During instalation, AutotestForPHP will create:
68
- * An empty PHPUnit boostrap file on 'test/bootstrap-autotest.php' to be used when running tests
69
- * An empty config file on 'autotestforphp/config.autotest'
70
- * A PHPUnit config file on 'test/phpunit-autotest.xml' to will configure the bootstrap file to be used, tests folder and log results to a XML file needed for displaying notifications:
71
- <phpunit bootstrap="./test/bootstrap-autotest.php">
80
+ <phpunit bootstrap="./autotestforphp/bootstrap-autotest.php">
72
81
  <testsuite name="Application">
73
82
  <directory>./test/</directory>
74
83
  </testsuite>
@@ -77,22 +86,26 @@ During instalation, AutotestForPHP will create:
77
86
  </logging>
78
87
  </phpunit>
79
88
 
80
- You can specify the folders / files to be watched on 'autotestforphp/config.autotest' file by setting the FOLDERS_TO_WATCH Ruby constant:
89
+ You can specify the folders or files to be watched on <em>autotestforphp/config.autotest</em> file by setting the FOLDERS_TO_WATCH Ruby constant:
81
90
 
82
91
  Example:
92
+
83
93
  FOLDERS_TO_WATCH = ['./src/**/*', './app/**/*', './test/**/*', './some_specific_file.php']
84
94
 
85
- If no folders are specified on 'autotestforphp/config.autotest', AutotestForPHP will watch for changes on the following folders:
86
- * src
87
- * app
88
- * lib
89
- * test
95
+ If no folders are specified in config file, AutotestForPHP will watch for changes on the following folders (if they exist):
96
+
97
+ * src
98
+ * app
99
+ * lib
100
+ * test
90
101
 
91
102
 
92
103
  == TODO:
93
104
 
94
- * Skip files to be watched
95
- * Check if tool was already skip file creation
105
+ * Default <em>autotestforphp/bootstrap-autotest.php</em>
106
+ * Write comments about config usage on <em>autotestforphp/config.autotest</em>
107
+ * Some way to skip folders to be watched
108
+ * Check if tool was already installed and skip file creation
96
109
  * Test on Mac and XP
97
110
  * Like ZenTest autotest, focus on running previous failures until they are fixed instead of running all tests all the time
98
111
 
@@ -1,7 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{autotestforphp}
3
- s.version = "0.0.1"
4
-
3
+ s.version = "0.0.2"
5
4
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
5
  s.authors = ["F\303\241bio Rehm"]
7
6
  s.date = %q{2009-07-24}
@@ -11,15 +10,16 @@ Gem::Specification.new do |s|
11
10
  s.executables = ["autotestforphp"]
12
11
  s.homepage = %q{http://github.com/fgrehm/autotestforphp}
13
12
  s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc"]
14
- s.files = ["History.txt", "License.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "autotestforphp.gemspec", "bin/autotestforphp", "images/fail.png", "images/pass.png", "lib/autotestforphp.rb", "lib/autotestforphp/cli.rb", "lib/autotestforphp/notification.rb", "lib/autotestforphp/notification/linux.rb", "lib/autotestforphp/notification/mac.rb", "lib/autotestforphp/notification/windows.rb", "lib/autotestforphp/result.rb", "script/console", "script/destroy", "script/generate", "test/autotestforphp/test_autotestforphp.rb", "test/cli/test_autotestforphp_cli.rb", "test/cli/test_install_cli.rb", "test/test_helper.rb", "test/test_linux.rb", "test/test_mac.rb", "test/test_notification.rb", "test/test_result.rb", "test/test_windows.rb"]
13
+ s.files = ["History.txt", "License.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "autotestforphp.gemspec", "bin/autotestforphp", "images/fail.png", "images/pass.png", "lib/autotestforphp.rb", "lib/autotestforphp/cli.rb", "lib/autotestforphp/notification.rb", "lib/autotestforphp/notification/linux.rb", "lib/autotestforphp/notification/mac.rb", "lib/autotestforphp/notification/windows.rb", "lib/autotestforphp/result.rb", "script/console", "script/destroy", "script/generate", "test/autotestforphp/test_autotestforphp.rb", "test/cli/test_autotestforphp_cli.rb", "test/test_helper.rb", "test/test_linux.rb", "test/test_mac.rb", "test/test_notification.rb", "test/test_result.rb", "test/test_windows.rb"]
15
14
  s.post_install_message = %q{PostInstall.txt}
16
15
  s.rdoc_options = ["--main", "README.rdoc"]
17
16
  s.require_paths = ["lib"]
18
17
  s.rubyforge_project = %q{autotestforphp}
19
18
  s.rubygems_version = %q{1.3.4}
20
19
  s.summary = %q{Autotest tool for PHP}
21
- s.test_files = ["test/cli/test_autotestforphp_cli.rb", "test/cli/test_install_cli.rb", "test/test_linux.rb", "test/test_notification.rb", "test/test_helper.rb", "test/test_windows.rb", "test/test_result.rb", "test/test_mac.rb", "test/autotestforphp/test_autotestforphp.rb"]
20
+ s.test_files = ["test/cli/test_autotestforphp_cli.rb", "test/test_linux.rb", "test/test_notification.rb", "test/test_helper.rb", "test/test_windows.rb", "test/test_result.rb", "test/test_mac.rb", "test/autotestforphp/test_autotestforphp.rb"]
22
21
 
22
+
23
23
  if s.respond_to? :specification_version then
24
24
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
25
  s.specification_version = 3
@@ -34,13 +34,13 @@ class Autotestforphp
34
34
  end
35
35
 
36
36
  def base_path=(path)
37
- @@base_path = path
37
+ @base_path = path
38
38
  end
39
39
  def base_path
40
- if not defined? @@base_path
40
+ if @base_path.nil?
41
41
  self.base_path = File.expand_path('./') + "/"
42
42
  end
43
- @@base_path
43
+ @base_path
44
44
  end
45
45
  def config_file_path
46
46
  "#{base_path}autotestforphp/config.autotest"
@@ -49,10 +49,10 @@ class Autotestforphp
49
49
  "#{base_path}autotestforphp/logfile.xml"
50
50
  end
51
51
  def phpunit_config_file_path
52
- "#{base_path}test/phpunit-autotest.xml"
52
+ "#{base_path}autotestforphp/phpunit-autotest.xml"
53
53
  end
54
54
  def bootstrap_file_path
55
- "#{base_path}test/bootstrap.php"
55
+ "#{base_path}autotestforphp/bootstrap-autotest.php"
56
56
  end
57
57
 
58
58
  def phpunit_config_file_exists?
@@ -81,9 +81,10 @@ class Autotestforphp
81
81
  end
82
82
 
83
83
  def install
84
+ Dir.mkdir("#{base_path}autotestforphp/") unless File.exist?("#{base_path}autotestforphp/")
84
85
  File.open(phpunit_config_file_path, 'w') do |f|
85
86
  f.puts <<-CONFIG
86
- <phpunit bootstrap="./test/bootstrap-autotest.php">
87
+ <phpunit bootstrap="./autotestforphp/bootstrap-autotest.php">
87
88
  <testsuite name="Application">
88
89
  <directory>./test/</directory>
89
90
  </testsuite>
@@ -94,7 +95,6 @@ class Autotestforphp
94
95
  CONFIG
95
96
  end
96
97
  File.open(bootstrap_file_path, 'w').close
97
- Dir.mkdir("#{base_path}autotestforphp/") unless File.exist?("#{base_path}autotestforphp/")
98
98
  File.open(config_file_path, 'w').close
99
99
  end
100
100
 
@@ -179,7 +179,9 @@ private
179
179
  msg = 'Tests could not be executed'
180
180
  img = Notification::Config.fail_image
181
181
  else
182
- result = Result.build_from_xml(File.new(phpunit_log_file_path))
182
+ f = File.new(phpunit_log_file_path)
183
+ result = Result.build_from_xml(f)
184
+ f.close
183
185
  msg = result.message
184
186
  img = result.image
185
187
  end
@@ -3,7 +3,7 @@ require 'optparse'
3
3
  class Autotestforphp
4
4
  class CLI
5
5
  def self.execute(stdout, arguments=['--run'])
6
- arguments = ['--run'] unless arguments.count > 0 # defaults to run
6
+ arguments = ['--run'] unless arguments.size > 0 # defaults to run
7
7
 
8
8
  OptionParser.new do |opts|
9
9
  opts.banner = <<-BANNER.gsub(/^ /,'')
@@ -10,11 +10,16 @@ class TestAutotestforphp < Test::Unit::TestCase
10
10
 
11
11
  def setup
12
12
  @atp = Autotestforphp.new
13
+ @atp.base_path = File.dirname(__FILE__) + '/'
13
14
  end
14
15
 
15
16
  def teardown
16
17
  File.delete(File.dirname(__FILE__) + '/sample.php') if File.exist?(File.dirname(__FILE__) + '/sample.php')
17
18
  File.delete(File.dirname(__FILE__) + '/sample2.php') if File.exist?(File.dirname(__FILE__) + '/sample2.php')
19
+ File.delete(@atp.bootstrap_file_path) if File.exist?(@atp.bootstrap_file_path)
20
+ File.delete(@atp.phpunit_config_file_path) if File.exist?(@atp.phpunit_config_file_path)
21
+ File.delete(@atp.config_file_path) if File.exist?(@atp.config_file_path)
22
+ Dir.delete("#{@atp.base_path}autotestforphp/") if File.exist?("#{@atp.base_path}autotestforphp/")
18
23
  end
19
24
 
20
25
  def test_detect_file_change
@@ -44,6 +49,14 @@ class TestAutotestforphp < Test::Unit::TestCase
44
49
  assert_equal "phpunit.bat --configuration \"#{@atp.phpunit_config_file_path}\"", @atp.make_test_cmd
45
50
  end
46
51
 
52
+ def test_install
53
+ @atp.install
54
+
55
+ assert @atp.phpunit_config_file_exists?
56
+ assert @atp.bootstrap_file_exists?
57
+ assert @atp.config_file_exists?
58
+ end
59
+
47
60
  # def test_make_test_cmd_mac
48
61
  #
49
62
  # end
@@ -24,10 +24,18 @@ class TestAutotestforphpCli < Test::Unit::TestCase
24
24
  execute
25
25
  end
26
26
 
27
+ def test_print_message_after_installation
28
+ Autotestforphp.expects(:install).
29
+ once
30
+
31
+ execute(['--install'])
32
+
33
+ assert_match(/Autotest for PHP was installed successfully/, @stdout)
34
+ end
27
35
  private
28
36
 
29
- def execute
30
- Autotestforphp::CLI.execute(@stdout_io = StringIO.new)
37
+ def execute(args = [])
38
+ Autotestforphp::CLI.execute(@stdout_io = StringIO.new, args)
31
39
  @stdout_io.rewind
32
40
  @stdout = @stdout_io.read
33
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fgrehm-autotestforphp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "F\xC3\xA1bio Rehm"
@@ -58,7 +58,6 @@ files:
58
58
  - script/generate
59
59
  - test/autotestforphp/test_autotestforphp.rb
60
60
  - test/cli/test_autotestforphp_cli.rb
61
- - test/cli/test_install_cli.rb
62
61
  - test/test_helper.rb
63
62
  - test/test_linux.rb
64
63
  - test/test_mac.rb
@@ -94,7 +93,6 @@ specification_version: 3
94
93
  summary: Autotest tool for PHP
95
94
  test_files:
96
95
  - test/cli/test_autotestforphp_cli.rb
97
- - test/cli/test_install_cli.rb
98
96
  - test/test_linux.rb
99
97
  - test/test_notification.rb
100
98
  - test/test_helper.rb
@@ -1,33 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', "test_helper.rb")
2
- require 'autotestforphp/cli'
3
-
4
- class TestInstallCli < Test::Unit::TestCase
5
- def setup
6
- @atp = Autotestforphp.new
7
- @atp.base_path = File.dirname(__FILE__) + '/'
8
-
9
- Dir.mkdir("#{@atp.base_path}test/") unless File.exist?("#{@atp.base_path}test/")
10
-
11
- Autotestforphp::CLI.execute(@stdout_io = StringIO.new, ['--install'])
12
- @stdout_io.rewind
13
- @stdout = @stdout_io.read
14
- end
15
-
16
- def teardown
17
- File.delete(@atp.bootstrap_file_path) if File.exist?(@atp.bootstrap_file_path)
18
- File.delete(@atp.phpunit_config_file_path) if File.exist?(@atp.phpunit_config_file_path)
19
- File.delete(@atp.config_file_path) if File.exist?(@atp.config_file_path)
20
- Dir.delete("#{@atp.base_path}autotestforphp/") if File.exist?("#{@atp.base_path}autotestforphp/")
21
- Dir.delete("#{@atp.base_path}test/") if File.exist?("#{@atp.base_path}test/")
22
- end
23
-
24
- def test_print_default_output
25
- assert_match(/Autotest for PHP was installed successfully/, @stdout)
26
- end
27
-
28
- def test_create_files
29
- assert @atp.phpunit_config_file_exists?
30
- assert @atp.bootstrap_file_exists?
31
- assert @atp.config_file_exists?
32
- end
33
- end