rbiphonetest 0.2.0

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.
@@ -0,0 +1,11 @@
1
+ == 0.2.0 2008-07-03
2
+
3
+ * Renamed project from 'iphoneruby' to 'rbiphonetest'
4
+ * iphoneruby app: prints a deprecation message
5
+ * USE: "rbiphonetest ." to install test framework now
6
+
7
+ == 0.1.0 2008-06-28
8
+
9
+ * Initial release
10
+ * rbiphonetest cmd - adds test framework to your Xcode project
11
+ * 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,35 @@
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
+ app_generators/rbiphonetest/templates/test/test_helper.rb
12
+ bin/iphoneruby
13
+ bin/rbiphonetest
14
+ config/hoe.rb
15
+ config/requirements.rb
16
+ lib/rbiphonetest.rb
17
+ lib/rbiphonetest/version.rb
18
+ rbiphonetest_generators/model/USAGE
19
+ rbiphonetest_generators/model/model_generator.rb
20
+ rbiphonetest_generators/model/templates/model.h
21
+ rbiphonetest_generators/model/templates/model.m
22
+ rbiphonetest_generators/model/templates/test.rb
23
+ script/console
24
+ script/destroy
25
+ script/generate
26
+ script/txt2html
27
+ setup.rb
28
+ tasks/deployment.rake
29
+ tasks/environment.rake
30
+ tasks/website.rake
31
+ test/test_generator_helper.rb
32
+ test/test_helper.rb
33
+ test/test_model_generator.rb
34
+ test/test_rbiphonetest.rb
35
+ test/test_rbiphonetest_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,85 @@
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
+ == FEATURES/PROBLEMS:
10
+
11
+ * Installs a Ruby-based unit testing framework into an iPhone/Objective-C/Xcode project
12
+ * Provides generators to create Objective-C classes with associated Ruby tests
13
+ * Uses RubyCocoa to bridge between Ruby tests and Objective-C via Loadable Bundles
14
+
15
+ Known issues:
16
+
17
+ * Currently only test/unit tests created; rspec etc coming soon
18
+ * Currently only supports Foundation framework, since its common between OS X and iPhone
19
+ * The plan is to mock out all the UIKit.framework classes so they can exist in RubyCocoa land.
20
+ * MacRuby (instead of RubyCocoa) is not yet tested
21
+
22
+ == SYNOPSIS:
23
+
24
+ * Create a new iPhone project using Xcode templates
25
+ * Open the terminal
26
+ * Change to project folder
27
+ * `rbiphonetest .`
28
+
29
+ This adds the test framework, a Rakefile, and an `autotest` config file.
30
+
31
+ You can now create testable Objective-C models/classes using the generator:
32
+
33
+ $ script/generate model WidgetMaker
34
+ create Classes/WidgetMaker.h
35
+ create Classes/WidgetMaker.m
36
+ create test/test_widget_maker.rb
37
+
38
+ To run tests you have several options:
39
+
40
+ 1. `rake` or `rake test`
41
+ 1. `autotest` (after installing the ZenTest gem)
42
+
43
+ All options will re-build the Objective-C code (if necessary) before running the tests.
44
+
45
+ If using autotest, your tests will be re-run if the test files or the Objective-C files are modified.
46
+
47
+ == REQUIREMENTS:
48
+
49
+ * RubyCocoa (installed on OS X Leopard; latest version at http://rubycocoa.com)
50
+ * XCode 3.1 (containing the iPhone SDK)
51
+
52
+ == INSTALL:
53
+
54
+ sudo gem install rbiphonetest (COMING SOON)
55
+
56
+ From source:
57
+
58
+ git clone git://github.com/drnic/rbiphonetest.git
59
+ cd rbiphonetest
60
+ rake install_gem
61
+
62
+ == LICENSE:
63
+
64
+ (The MIT License)
65
+
66
+ Copyright (c) 2008 Dr Nic Williams
67
+
68
+ Permission is hereby granted, free of charge, to any person obtaining
69
+ a copy of this software and associated documentation files (the
70
+ 'Software'), to deal in the Software without restriction, including
71
+ without limitation the rights to use, copy, modify, merge, publish,
72
+ distribute, sublicense, and/or sell copies of the Software, and to
73
+ permit persons to whom the Software is furnished to do so, subject to
74
+ the following conditions:
75
+
76
+ The above copyright notice and this permission notice shall be
77
+ included in all copies or substantial portions of the Software.
78
+
79
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
80
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
81
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
82
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
83
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
84
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
85
+ 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,68 @@
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
+
8
+ attr_reader :name
9
+
10
+ def initialize(runtime_args, runtime_options = {})
11
+ super
12
+ usage if args.empty?
13
+ @destination_root = File.expand_path(args.shift)
14
+ @name = base_name
15
+ extract_options
16
+ end
17
+
18
+ def manifest
19
+ record do |m|
20
+ # Ensure appropriate folder(s) exists
21
+ m.directory ''
22
+ BASEDIRS.each { |path| m.directory path }
23
+
24
+ # Create stubs
25
+ m.file_copy_each ["Rakefile"]
26
+ m.file "dot_autotest", ".autotest"
27
+ m.file_copy_each ["test/test_helper.rb"]
28
+
29
+ m.dependency "install_rubigen_scripts", [destination_root, 'rbiphonetest'],
30
+ :shebang => options[:shebang], :collision => :force
31
+ end
32
+ end
33
+
34
+ protected
35
+ def banner
36
+ <<-EOS
37
+ Want to write iPhone unit tests? Want to write them in Ruby?
38
+ Run this generator in the root folder of your Xcode project for your iPhone app.
39
+
40
+ USAGE: #{spec.name} name
41
+ EOS
42
+ end
43
+
44
+ def add_options!(opts)
45
+ opts.separator ''
46
+ opts.separator 'Options:'
47
+ # For each option below, place the default
48
+ # at the top of the file next to "default_options"
49
+ # opts.on("-a", "--author=\"Your Name\"", String,
50
+ # "Some comment about this option",
51
+ # "Default: none") { |options[:author]| }
52
+ opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
53
+ end
54
+
55
+ def extract_options
56
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
57
+ # Templates can access these value via the attr_reader-generated methods, but not the
58
+ # raw instance variable value.
59
+ # @author = options[:author]
60
+ end
61
+
62
+ # Installation skeleton. Intermediate directories are automatically
63
+ # created so don't sweat their absence here.
64
+ BASEDIRS = %w(
65
+ Classes
66
+ test
67
+ )
68
+ end
@@ -0,0 +1,49 @@
1
+ require "rubygems"
2
+ require "rake"
3
+ require "rake/testtask"
4
+
5
+ task :default => :test
6
+
7
+ Rake::TestTask.new do |t|
8
+ t.libs << "test" << "test/bundles"
9
+ t.test_files = FileList['test/test*.rb']
10
+ t.verbose = true
11
+ end
12
+
13
+ namespace :objc do
14
+ desc "Compiles all Objective-C bundles for testing"
15
+ task :compile
16
+ end
17
+
18
+ task :compile => "objc:compile"
19
+
20
+ task :test => :compile
21
+
22
+ namespace :objc do
23
+ # look for Classes/*.m files containing a line "void Init_ClassName"
24
+ # These are the primary classes for bundles; make a bundle for each
25
+ model_file_paths = `find Classes/*.m -exec grep -l "^void Init_" {} \\;`.split("\n")
26
+ model_file_paths.each do |path|
27
+ path =~ /Classes\/(.*)\.m/
28
+ model_name = $1
29
+
30
+ task :compile => model_name do
31
+ if Dir.glob("**/#{model_name}.bundle").length == 0
32
+ STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
33
+ STDERR.puts "Bundle actually failed to build."
34
+ STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
35
+ exit(1)
36
+ end
37
+ end
38
+
39
+ task model_name.to_sym => "build/bundles/#{model_name}.bundle"
40
+
41
+ file "build/bundles/#{model_name}.bundle" => ["Classes/#{model_name}.m", "Classes/#{model_name}.h"] do |t|
42
+ FileUtils.mkdir_p "build/bundles"
43
+ FileUtils.rm Dir["build/bundles/#{model_name}.bundle"]
44
+ sh "gcc -o build/bundles/#{model_name}.bundle -bundle -framework Foundation Classes/#{model_name}.m"
45
+ end
46
+ end
47
+
48
+ end
49
+
@@ -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
+ ["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,8 @@
1
+ require "test/unit"
2
+
3
+ require "rubygems"
4
+ require "Shoulda"
5
+
6
+ require "osx/cocoa"
7
+
8
+ $:.unshift File.dirname(__FILE__) + "/../build/bundles"
@@ -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,17 @@
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
+ source = RubiGen::PathSource.new(:application,
14
+ File.join(File.dirname(__FILE__), "../app_generators"))
15
+ RubiGen::Base.reset_sources
16
+ RubiGen::Base.append_sources source
17
+ 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 ""
@@ -0,0 +1,15 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ require 'rubygems'
5
+ %w[rake hoe newgem rubigen].each do |req_gem|
6
+ begin
7
+ require req_gem
8
+ rescue LoadError
9
+ puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
+ puts "Installation: gem install #{req_gem} -y"
11
+ exit
12
+ end
13
+ end
14
+
15
+ $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))