Empact-rbiphonetest 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/History.txt +18 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +54 -0
  4. data/PostInstall.txt +21 -0
  5. data/README.rdoc +90 -0
  6. data/Rakefile +4 -0
  7. data/app_generators/rbiphonetest/USAGE +5 -0
  8. data/app_generators/rbiphonetest/rbiphonetest_generator.rb +78 -0
  9. data/app_generators/rbiphonetest/templates/Rakefile +40 -0
  10. data/app_generators/rbiphonetest/templates/dot_autotest +18 -0
  11. data/bin/iphoneruby +10 -0
  12. data/bin/rbiphonetest +18 -0
  13. data/config/hoe.rb +70 -0
  14. data/config/requirements.rb +15 -0
  15. data/lib/rbiphonetest.rb +6 -0
  16. data/lib/rbiphonetest/version.rb +9 -0
  17. data/rbiphonetest_generators/install_rspec/USAGE +5 -0
  18. data/rbiphonetest_generators/install_rspec/install_rspec_generator.rb +51 -0
  19. data/rbiphonetest_generators/install_rspec/templates/spec/spec_helper.rb +3 -0
  20. data/rbiphonetest_generators/install_rspec/templates/tasks/rspec.rake +9 -0
  21. data/rbiphonetest_generators/install_test_unit/USAGE +5 -0
  22. data/rbiphonetest_generators/install_test_unit/install_test_unit_generator.rb +52 -0
  23. data/rbiphonetest_generators/install_test_unit/templates/tasks/test_unit.rake +11 -0
  24. data/rbiphonetest_generators/install_test_unit/templates/test/test_helper.rb +4 -0
  25. data/rbiphonetest_generators/model/USAGE +5 -0
  26. data/rbiphonetest_generators/model/model_generator.rb +85 -0
  27. data/rbiphonetest_generators/model/templates/model.h +15 -0
  28. data/rbiphonetest_generators/model/templates/model.m +22 -0
  29. data/rbiphonetest_generators/model_rspec/model_rspec_generator.rb +51 -0
  30. data/rbiphonetest_generators/model_rspec/templates/spec.rb +15 -0
  31. data/rbiphonetest_generators/model_test_unit/model_test_unit_generator.rb +51 -0
  32. data/rbiphonetest_generators/model_test_unit/templates/test.rb +10 -0
  33. data/rbiphonetest_generators/story/USAGE +5 -0
  34. data/rbiphonetest_generators/story/story_generator.rb +55 -0
  35. data/rbiphonetest_generators/story/templates/steps.rb +8 -0
  36. data/rbiphonetest_generators/story/templates/story +13 -0
  37. data/rbiphonetest_generators/story/templates/story.rb +5 -0
  38. data/rbiphonetest_generators/story/templates/story_helper.rb +15 -0
  39. data/script/console +10 -0
  40. data/script/destroy +14 -0
  41. data/script/generate +14 -0
  42. data/script/txt2html +82 -0
  43. data/setup.rb +1585 -0
  44. data/tasks/deployment.rake +34 -0
  45. data/tasks/environment.rake +7 -0
  46. data/tasks/website.rake +17 -0
  47. data/test/test_generator_helper.rb +29 -0
  48. data/test/test_helper.rb +2 -0
  49. data/test/test_install_rspec_generator.rb +46 -0
  50. data/test/test_install_test_unit_generator.rb +46 -0
  51. data/test/test_model_generator.rb +70 -0
  52. data/test/test_rbiphonetest.rb +11 -0
  53. data/test/test_rbiphonetest_generator.rb +56 -0
  54. data/test/test_story_generator.rb +49 -0
  55. metadata +149 -0
@@ -0,0 +1,18 @@
1
+ == 0.3.0 2008-07-05
2
+
3
+ * Support for test/unit AND rspec test frameworks (via install_test_unit and install_rspec generators)
4
+ * model generator: creates test/test_model.rb or spec/model_spec.rb as required
5
+ * story generator added for rspec developers
6
+ * app generator: adds selected test framework to script/generate
7
+
8
+ == 0.2.0 2008-07-03
9
+
10
+ * Renamed project from 'iphoneruby' to 'rbiphonetest'
11
+ * iphoneruby app: prints a deprecation message
12
+ * USE: "rbiphonetest ." to install test framework now
13
+
14
+ == 0.1.0 2008-06-28
15
+
16
+ * Initial release
17
+ * rbiphonetest cmd - adds test framework to your Xcode project
18
+ * script/generate model FooBar - creates Classes/FooBar.h+m and test/test_foo_bar.rb
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Dr Nic Williams
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,54 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ PostInstall.txt
5
+ README.rdoc
6
+ Rakefile
7
+ app_generators/rbiphonetest/USAGE
8
+ app_generators/rbiphonetest/rbiphonetest_generator.rb
9
+ app_generators/rbiphonetest/templates/Rakefile
10
+ app_generators/rbiphonetest/templates/dot_autotest
11
+ bin/iphoneruby
12
+ bin/rbiphonetest
13
+ config/hoe.rb
14
+ config/requirements.rb
15
+ lib/rbiphonetest.rb
16
+ lib/rbiphonetest/version.rb
17
+ rbiphonetest_generators/install_rspec/USAGE
18
+ rbiphonetest_generators/install_rspec/install_rspec_generator.rb
19
+ rbiphonetest_generators/install_rspec/templates/spec/spec_helper.rb
20
+ rbiphonetest_generators/install_rspec/templates/tasks/rspec.rake
21
+ rbiphonetest_generators/install_test_unit/USAGE
22
+ rbiphonetest_generators/install_test_unit/install_test_unit_generator.rb
23
+ rbiphonetest_generators/install_test_unit/templates/tasks/test_unit.rake
24
+ rbiphonetest_generators/install_test_unit/templates/test/test_helper.rb
25
+ rbiphonetest_generators/model/USAGE
26
+ rbiphonetest_generators/model/model_generator.rb
27
+ rbiphonetest_generators/model/templates/model.h
28
+ rbiphonetest_generators/model/templates/model.m
29
+ rbiphonetest_generators/model_rspec/model_rspec_generator.rb
30
+ rbiphonetest_generators/model_rspec/templates/spec.rb
31
+ rbiphonetest_generators/model_test_unit/model_test_unit_generator.rb
32
+ rbiphonetest_generators/model_test_unit/templates/test.rb
33
+ rbiphonetest_generators/story/USAGE
34
+ rbiphonetest_generators/story/story_generator.rb
35
+ rbiphonetest_generators/story/templates/steps.rb
36
+ rbiphonetest_generators/story/templates/story
37
+ rbiphonetest_generators/story/templates/story.rb
38
+ rbiphonetest_generators/story/templates/story_helper.rb
39
+ script/console
40
+ script/destroy
41
+ script/generate
42
+ script/txt2html
43
+ setup.rb
44
+ tasks/deployment.rake
45
+ tasks/environment.rake
46
+ tasks/website.rake
47
+ test/test_generator_helper.rb
48
+ test/test_helper.rb
49
+ test/test_install_rspec_generator.rb
50
+ test/test_install_test_unit_generator.rb
51
+ test/test_model_generator.rb
52
+ test/test_rbiphonetest.rb
53
+ test/test_rbiphonetest_generator.rb
54
+ test/test_story_generator.rb
@@ -0,0 +1,21 @@
1
+
2
+ You can add Ruby-based unit tests to any iPhone/Xcode project by changing to the
3
+ project's folder in the terminal/console and running:
4
+
5
+ rbiphonetest .
6
+
7
+ This adds the test framework, a Rakefile, and an `autotest` config file.
8
+
9
+ You can now create testable Objective-C models/classes using the generator:
10
+
11
+ $ script/generate model WidgetMaker
12
+ create Classes/WidgetMaker.h
13
+ create Classes/WidgetMaker.m
14
+ create test/test_widget_maker.rb
15
+
16
+ To run tests you have several options:
17
+
18
+ 1. `rake` or `rake test`
19
+ 1. `autotest` (after installing the ZenTest gem)
20
+
21
+ Enjoy iPhone development with Ruby!
@@ -0,0 +1,90 @@
1
+ = rbiphonetest - Unit Test iPhone apps with Ruby
2
+
3
+ * http://rbiphonetest.rubyforge.org
4
+
5
+ == DESCRIPTION:
6
+
7
+ Want to write iPhone apps with unit tests? Want to write them in Ruby?
8
+
9
+ * Blog introduction: http://drnicwilliams.com/2008/07/04/unit-testing-iphone-apps-with-ruby-rbiphonetest/
10
+ * Video introduction: http://www.vimeo.com/1262916
11
+ * Google Group: http://groups.google.com/group/rbiphonetest
12
+ * Bugs/Features: http://drnic.lighthouseapp.com/projects/13763-rbiphonetest
13
+
14
+ == FEATURES/PROBLEMS:
15
+
16
+ * Installs a Ruby-based unit testing framework into an iPhone/Objective-C/Xcode project
17
+ * Provides generators to create Objective-C classes with associated Ruby tests
18
+ * Uses RubyCocoa to bridge between Ruby tests and Objective-C via Loadable Bundles
19
+
20
+ Known issues:
21
+
22
+ * Currently only test/unit tests created; rspec etc coming soon
23
+ * Currently only supports Foundation framework, since its common between OS X and iPhone
24
+ * The plan is to mock out all the UIKit.framework classes so they can exist in RubyCocoa land.
25
+ * MacRuby (instead of RubyCocoa) is not yet tested
26
+
27
+ == SYNOPSIS:
28
+
29
+ * Create a new iPhone project using Xcode templates
30
+ * Open the terminal
31
+ * Change to project folder
32
+ * `rbiphonetest .`
33
+
34
+ This adds the test framework, a Rakefile, and an `autotest` config file.
35
+
36
+ You can now create testable Objective-C models/classes using the generator:
37
+
38
+ $ script/generate model WidgetMaker
39
+ create Classes/WidgetMaker.h
40
+ create Classes/WidgetMaker.m
41
+ create test/test_widget_maker.rb
42
+
43
+ To run tests you have several options:
44
+
45
+ 1. `rake` or `rake test`
46
+ 1. `autotest` (after installing the ZenTest gem)
47
+
48
+ All options will re-build the Objective-C code (if necessary) before running the tests.
49
+
50
+ If using autotest, your tests will be re-run if the test files or the Objective-C files are modified.
51
+
52
+ == REQUIREMENTS:
53
+
54
+ * RubyCocoa (installed on OS X Leopard; latest version at http://rubycocoa.com)
55
+ * XCode 3.1 (containing the iPhone SDK)
56
+
57
+ == INSTALL:
58
+
59
+ sudo gem install rbiphonetest
60
+
61
+ From source:
62
+
63
+ git clone git://github.com/drnic/rbiphonetest.git
64
+ cd rbiphonetest
65
+ rake install_gem
66
+
67
+ == LICENSE:
68
+
69
+ (The MIT License)
70
+
71
+ Copyright (c) 2008 Dr Nic Williams
72
+
73
+ Permission is hereby granted, free of charge, to any person obtaining
74
+ a copy of this software and associated documentation files (the
75
+ 'Software'), to deal in the Software without restriction, including
76
+ without limitation the rights to use, copy, modify, merge, publish,
77
+ distribute, sublicense, and/or sell copies of the Software, and to
78
+ permit persons to whom the Software is furnished to do so, subject to
79
+ the following conditions:
80
+
81
+ The above copyright notice and this permission notice shall be
82
+ included in all copies or substantial portions of the Software.
83
+
84
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
85
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
86
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
87
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
88
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
89
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
90
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,4 @@
1
+ require 'config/requirements'
2
+ require 'config/hoe' # setup Hoe + all gem configuration
3
+
4
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
@@ -0,0 +1,5 @@
1
+ Description:
2
+
3
+
4
+ Usage:
5
+
@@ -0,0 +1,78 @@
1
+ class RbiphonetestGenerator < RubiGen::Base
2
+
3
+ DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
4
+ Config::CONFIG['ruby_install_name'])
5
+
6
+ default_options :author => nil,
7
+ :test_framework => 'test_unit'
8
+
9
+ attr_reader :name
10
+ attr_reader :test_framework
11
+
12
+ def initialize(runtime_args, runtime_options = {})
13
+ super
14
+ usage if args.empty?
15
+ @destination_root = File.expand_path(args.shift)
16
+ @name = base_name
17
+ extract_options
18
+ end
19
+
20
+ def manifest
21
+ record do |m|
22
+ # Ensure appropriate folder(s) exists
23
+ m.directory ''
24
+ BASEDIRS.each { |path| m.directory path }
25
+
26
+ # Create stubs
27
+ m.file_copy_each ["Rakefile"]
28
+ m.file "dot_autotest", ".autotest"
29
+
30
+ # Selecting a test framework
31
+ case test_framework
32
+ when "test_unit"
33
+ m.dependency "install_test_unit", [name], :destination => destination_root, :collision => :force
34
+ when "rspec"
35
+ m.dependency "install_rspec", [name], :destination => destination_root, :collision => :force
36
+ end
37
+
38
+ m.dependency "install_rubigen_scripts", [destination_root, 'rbiphonetest', 'iphone', test_framework],
39
+ :shebang => options[:shebang], :collision => :force
40
+ end
41
+ end
42
+
43
+ protected
44
+ def banner
45
+ <<-EOS
46
+ Want to write iPhone unit tests? Want to write them in Ruby?
47
+ Run this generator in the root folder of your Xcode project for your iPhone app.
48
+
49
+ USAGE: #{spec.name} name
50
+ EOS
51
+ end
52
+
53
+ def add_options!(opts)
54
+ opts.separator ''
55
+ opts.separator 'Options:'
56
+ # For each option below, place the default
57
+ # at the top of the file next to "default_options"
58
+ opts.on("-s", "--test-with=TEST_FRAMEWORK", String,
59
+ "Select your preferred testing framework.",
60
+ "Options: test_unit (default), rspec.") { |x| options[:test_framework] = x }
61
+ opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
62
+ end
63
+
64
+ def extract_options
65
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
66
+ # Templates can access these value via the attr_reader-generated methods, but not the
67
+ # raw instance variable value.
68
+ # @author = options[:author]
69
+ @test_framework = options[:test_framework] || "test_unit"
70
+ end
71
+
72
+ # Installation skeleton. Intermediate directories are automatically
73
+ # created so don't sweat their absence here.
74
+ BASEDIRS = %w(
75
+ Classes
76
+ tasks
77
+ )
78
+ end
@@ -0,0 +1,40 @@
1
+ require "rubygems"
2
+ require "rake"
3
+
4
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
5
+
6
+ namespace :objc do
7
+ desc "Compiles all Objective-C bundles for testing"
8
+ task :compile
9
+ end
10
+
11
+ task :compile => "objc:compile"
12
+
13
+ namespace :objc do
14
+ # look for Classes/*.m files containing a line "void Init_ClassName"
15
+ # These are the primary classes for bundles; make a bundle for each
16
+ model_file_paths = `find Classes/*.m -exec grep -l "^void Init_" {} \\;`.split("\n")
17
+ model_file_paths.each do |path|
18
+ path =~ /Classes\/(.*)\.m/
19
+ model_name = $1
20
+
21
+ task :compile => model_name do
22
+ if Dir.glob("**/#{model_name}.bundle").length == 0
23
+ STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
24
+ STDERR.puts "Bundle actually failed to build."
25
+ STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
26
+ exit(1)
27
+ end
28
+ end
29
+
30
+ task model_name.to_sym => "build/bundles/#{model_name}.bundle"
31
+
32
+ file "build/bundles/#{model_name}.bundle" => ["Classes/#{model_name}.m", "Classes/#{model_name}.h"] do |t|
33
+ FileUtils.mkdir_p "build/bundles"
34
+ FileUtils.rm Dir["build/bundles/#{model_name}.bundle"]
35
+ sh "gcc -o build/bundles/#{model_name}.bundle -bundle -framework Foundation Classes/#{model_name}.m"
36
+ end
37
+ end
38
+
39
+ end
40
+
@@ -0,0 +1,18 @@
1
+ class String
2
+ def underscore
3
+ gsub(/::/, '/').
4
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
5
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').
6
+ downcase
7
+ end
8
+ end
9
+
10
+ Autotest.add_hook :initialize do |at|
11
+ at.add_mapping(/Classes\/(.*)\.[mh]/) do |_, m|
12
+ ["spec/#{m[1].underscore}_spec.rb", "test/test_#{m[1].underscore}.rb"]
13
+ end
14
+ end
15
+
16
+ Autotest.add_hook :run_command do |at|
17
+ system "rake compile"
18
+ end
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ puts <<-EOS
4
+ DEPRECATION: this project has been renamed to 'rbiphonetest'
5
+
6
+ Please use the new executable:
7
+
8
+ rbiphonetest .
9
+
10
+ EOS
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'rubigen'
5
+
6
+ if %w(-v --version).include? ARGV.first
7
+ require 'rbiphonetest/version'
8
+ puts "#{File.basename($0)} #{Iphoneruby::VERSION::STRING}"
9
+ exit(0)
10
+ end
11
+
12
+ require 'rubigen/scripts/generate'
13
+ RubiGen::Base.reset_sources
14
+ source = RubiGen::PathSource.new(:application, File.join(File.dirname(__FILE__), "../app_generators"))
15
+ RubiGen::Base.append_sources source
16
+ source = RubiGen::PathSource.new(:application, File.join(File.dirname(__FILE__), "../rbiphonetest_generators"))
17
+ RubiGen::Base.append_sources source
18
+ RubiGen::Scripts::Generate.new.run(ARGV, :generator => 'rbiphonetest')
@@ -0,0 +1,70 @@
1
+ require 'rbiphonetest/version'
2
+
3
+ AUTHOR = 'Dr Nic Williams'
4
+ EMAIL = "drnicwilliams@gmail.com"
5
+ DESCRIPTION = "Want to write iPhone unit tests? Want to write them in Ruby?"
6
+ GEM_NAME = 'rbiphonetest' # what ppl will type to install your gem
7
+ RUBYFORGE_PROJECT = 'rbiphonetest' # The unix name for your project
8
+ HOMEPATH = "http://github.com/drnic/rbiphonetest"
9
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
+ EXTRA_DEPENDENCIES = [
11
+ ['rubigen', '>= 1.3.2']
12
+ ] # An array of rubygem dependencies [name, version]
13
+
14
+ @config_file = "~/.rubyforge/user-config.yml"
15
+ @config = nil
16
+ RUBYFORGE_USERNAME = "unknown"
17
+ def rubyforge_username
18
+ unless @config
19
+ begin
20
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
21
+ rescue
22
+ puts <<-EOS
23
+ ERROR: No rubyforge config file found: #{@config_file}
24
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
25
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
26
+ EOS
27
+ exit
28
+ end
29
+ end
30
+ RUBYFORGE_USERNAME.replace @config["username"]
31
+ end
32
+
33
+
34
+ VERS = RbIphoneTest::VERSION::STRING
35
+ RDOC_OPTS = ['--quiet', '--title', 'rbiphonetest documentation',
36
+ "--opname", "index.html",
37
+ "--line-numbers",
38
+ "--main", "README",
39
+ "--inline-source"]
40
+
41
+ class Hoe
42
+ def extra_deps
43
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
44
+ @extra_deps
45
+ end
46
+ end
47
+
48
+ # Generate all the Rake tasks
49
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
50
+ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
51
+ p.developer(AUTHOR, EMAIL)
52
+ p.description = DESCRIPTION
53
+ p.summary = DESCRIPTION
54
+ p.url = HOMEPATH
55
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
56
+ p.test_globs = ["test/**/test_*.rb"]
57
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
58
+
59
+ # == Optional
60
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
61
+ #p.extra_deps = EXTRA_DEPENDENCIES
62
+
63
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
64
+ end
65
+
66
+ CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
67
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
68
+ $hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
69
+ $hoe.rsync_args = '-av --delete --ignore-errors'
70
+ $hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""