avh4-rbiphonetest 0.3.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.
Files changed (49) hide show
  1. data/History.txt +24 -0
  2. data/Manifest.txt +51 -0
  3. data/PostInstall.txt +21 -0
  4. data/README.rdoc +90 -0
  5. data/Rakefile +24 -0
  6. data/app_generators/rbiphonetest/USAGE +5 -0
  7. data/app_generators/rbiphonetest/rbiphonetest_generator.rb +79 -0
  8. data/app_generators/rbiphonetest/templates/Rakefile +55 -0
  9. data/app_generators/rbiphonetest/templates/dot_autotest +18 -0
  10. data/bin/iphoneruby +10 -0
  11. data/bin/rbiphonetest +18 -0
  12. data/lib/rbiphonetest.rb +6 -0
  13. data/lib/rbiphonetest/version.rb +9 -0
  14. data/rbiphonetest_generators/install_rspec/USAGE +5 -0
  15. data/rbiphonetest_generators/install_rspec/install_rspec_generator.rb +52 -0
  16. data/rbiphonetest_generators/install_rspec/templates/spec/spec_helper.rb +7 -0
  17. data/rbiphonetest_generators/install_rspec/templates/tasks/rspec.rake +9 -0
  18. data/rbiphonetest_generators/install_test_unit/USAGE +5 -0
  19. data/rbiphonetest_generators/install_test_unit/install_test_unit_generator.rb +53 -0
  20. data/rbiphonetest_generators/install_test_unit/templates/tasks/test_unit.rake +11 -0
  21. data/rbiphonetest_generators/install_test_unit/templates/test/test_helper.rb +8 -0
  22. data/rbiphonetest_generators/model/USAGE +5 -0
  23. data/rbiphonetest_generators/model/model_generator.rb +85 -0
  24. data/rbiphonetest_generators/model/templates/model.h +15 -0
  25. data/rbiphonetest_generators/model/templates/model.m +22 -0
  26. data/rbiphonetest_generators/model_rspec/model_rspec_generator.rb +51 -0
  27. data/rbiphonetest_generators/model_rspec/templates/spec.rb +9 -0
  28. data/rbiphonetest_generators/model_test_unit/model_test_unit_generator.rb +51 -0
  29. data/rbiphonetest_generators/model_test_unit/templates/test.rb +7 -0
  30. data/rbiphonetest_generators/story/USAGE +5 -0
  31. data/rbiphonetest_generators/story/story_generator.rb +55 -0
  32. data/rbiphonetest_generators/story/templates/steps.rb +8 -0
  33. data/rbiphonetest_generators/story/templates/story +13 -0
  34. data/rbiphonetest_generators/story/templates/story.rb +5 -0
  35. data/rbiphonetest_generators/story/templates/story_helper.rb +15 -0
  36. data/script/console +10 -0
  37. data/script/destroy +14 -0
  38. data/script/generate +14 -0
  39. data/script/txt2html +82 -0
  40. data/setup.rb +1585 -0
  41. data/test/test_generator_helper.rb +29 -0
  42. data/test/test_helper.rb +2 -0
  43. data/test/test_install_rspec_generator.rb +46 -0
  44. data/test/test_install_test_unit_generator.rb +46 -0
  45. data/test/test_model_generator.rb +70 -0
  46. data/test/test_rbiphonetest.rb +11 -0
  47. data/test/test_rbiphonetest_generator.rb +56 -0
  48. data/test/test_story_generator.rb +49 -0
  49. metadata +150 -0
@@ -0,0 +1,7 @@
1
+ require "osx/cocoa"
2
+
3
+ $:.unshift File.dirname(__FILE__) + "/../build/bundles"
4
+
5
+ bundle_name = '<%= module_name %>'
6
+ require "#{bundle_name}.bundle"
7
+ OSX::ns_import bundle_name.to_sym
@@ -0,0 +1,9 @@
1
+ require "spec/rake/spectask"
2
+
3
+ task :default => :spec
4
+
5
+ task :spec => :compile
6
+
7
+ Spec::Rake::SpecTask.new do |t|
8
+ t.warning = true
9
+ end
@@ -0,0 +1,5 @@
1
+ Description:
2
+
3
+
4
+ Usage:
5
+
@@ -0,0 +1,53 @@
1
+ class InstallTestUnitGenerator < RubiGen::Base
2
+
3
+ default_options :author => nil
4
+
5
+ attr_reader :name, :module_name
6
+
7
+ def initialize(runtime_args, runtime_options = {})
8
+ super
9
+ usage if args.empty?
10
+ @name = args.shift
11
+ @module_name = File.basename(destination_root).gsub("-", "_").camelize
12
+ extract_options
13
+ end
14
+
15
+ def manifest
16
+ record do |m|
17
+ # Ensure appropriate folder(s) exists
18
+ m.directory 'test'
19
+ m.directory 'tasks'
20
+
21
+ m.template_copy_each ["test/test_helper.rb"]
22
+ m.file_copy_each ["tasks/test_unit.rake"]
23
+
24
+ end
25
+ end
26
+
27
+ protected
28
+ def banner
29
+ <<-EOS
30
+ Creates a ...
31
+
32
+ USAGE: #{$0} #{spec.name} name
33
+ EOS
34
+ end
35
+
36
+ def add_options!(opts)
37
+ # opts.separator ''
38
+ # opts.separator 'Options:'
39
+ # For each option below, place the default
40
+ # at the top of the file next to "default_options"
41
+ # opts.on("-a", "--author=\"Your Name\"", String,
42
+ # "Some comment about this option",
43
+ # "Default: none") { |options[:author]| }
44
+ # opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
45
+ end
46
+
47
+ def extract_options
48
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
49
+ # Templates can access these value via the attr_reader-generated methods, but not the
50
+ # raw instance variable value.
51
+ # @author = options[:author]
52
+ end
53
+ end
@@ -0,0 +1,11 @@
1
+ require "rake/testtask"
2
+
3
+ task :default => :test
4
+
5
+ task :test => :compile
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
@@ -0,0 +1,8 @@
1
+ require "test/unit"
2
+ require "osx/cocoa"
3
+
4
+ $:.unshift File.dirname(__FILE__) + "/../build/bundles"
5
+
6
+ bundle_name = '<%= module_name %>'
7
+ require "#{bundle_name}.bundle"
8
+ OSX::ns_import bundle_name.to_sym
@@ -0,0 +1,5 @@
1
+ Description:
2
+
3
+
4
+ Usage:
5
+
@@ -0,0 +1,85 @@
1
+ class ModelGenerator < RubiGen::Base
2
+
3
+ default_options :author => nil
4
+
5
+ attr_reader :name, :class_name
6
+ attr_reader :installed_frameworks
7
+
8
+ def initialize(runtime_args, runtime_options = {})
9
+ super
10
+ usage if args.empty?
11
+ @name = args.shift.underscore
12
+ @class_name = @name.camelcase
13
+ extract_options
14
+ extract_test_frameworks
15
+ end
16
+
17
+ def manifest
18
+ record do |m|
19
+ # Ensure appropriate folder(s) exists
20
+ m.directory 'Classes'
21
+
22
+ # Create stubs
23
+ m.template "model.h", "Classes/#{class_name}.h"
24
+ m.template "model.m", "Classes/#{class_name}.m"
25
+
26
+ # It is possible for 2+ test frameworks to be installed.
27
+ # Current behaviour is to generate test stubs for all of them
28
+ # and let the developer delete files they don't want
29
+ if installed_frameworks.include? "test_unit"
30
+ m.dependency "model_test_unit", [name], :destination => destination_root, :collision => :force
31
+ end
32
+ if installed_frameworks.include? "rspec"
33
+ m.dependency "model_rspec", [name], :destination => destination_root, :collision => :force
34
+ end
35
+ end
36
+ end
37
+
38
+ protected
39
+ def banner
40
+ <<-EOS
41
+ Creates an NSObject model (header and implementation files)
42
+ plus a Ruby test file (either test/unit or rspec).
43
+
44
+ USAGE: #{$0} #{spec.name} name
45
+ EOS
46
+ end
47
+
48
+ def add_options!(opts)
49
+ # opts.separator ''
50
+ # opts.separator 'Options:'
51
+ # For each option below, place the default
52
+ # at the top of the file next to "default_options"
53
+ # opts.on("-a", "--author=\"Your Name\"", String,
54
+ # "Some comment about this option",
55
+ # "Default: none") { |options[:author]| }
56
+ # opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
57
+ end
58
+
59
+ def extract_options
60
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
61
+ # Templates can access these value via the attr_reader-generated methods, but not the
62
+ # raw instance variable value.
63
+ # @author = options[:author]
64
+ end
65
+
66
+ # Attempts to determine which test framework is being used
67
+ # Else prompts user
68
+ def extract_test_frameworks
69
+ @installed_frameworks = []
70
+ @installed_frameworks << "test_unit" if Dir[File.join(destination_root, "test")].length > 0
71
+ @installed_frameworks << "rspec" if Dir[File.join(destination_root, "spec")].length > 0
72
+
73
+ if @installed_frameworks.length == 0
74
+ # no test-related files created
75
+ puts <<-EOS
76
+ WARNING: you do not have a test-framework installed.
77
+ Run either:
78
+ script/generate install_test_unit
79
+ script/generate install_rspec
80
+
81
+ and then rerun this generator.
82
+ EOS
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,15 @@
1
+ //
2
+ // <%= class_name %>.h
3
+ // <%= class_name %>
4
+ //
5
+ // Created by FIXME on <%= Date.today %>.
6
+ // Copyright <%= Date.today.year %> FIXME. All rights reserved.
7
+ //
8
+
9
+ #import <Foundation/Foundation.h>
10
+
11
+ @interface <%= class_name %> : NSObject {
12
+
13
+ }
14
+
15
+ @end
@@ -0,0 +1,22 @@
1
+ //
2
+ // <%= class_name %>.h
3
+ // <%= class_name %>
4
+ //
5
+ // Created by FIXME on <%= Date.today %>.
6
+ // Copyright <%= Date.today.year %> FIXME. All rights reserved.
7
+ //
8
+
9
+ #import "<%= class_name %>.h"
10
+
11
+
12
+ @implementation <%= class_name %>
13
+
14
+ @end
15
+
16
+ // This initialization function gets called when we import the Ruby module.
17
+ // It doesn't need to do anything because the RubyCocoa bridge will do
18
+ // all the initialization work.
19
+ // The rbiphonetest test framework automatically generates bundles for
20
+ // each objective-c class containing the following line. These
21
+ // can be used by your tests.
22
+ void Init_<%= class_name %>() { }
@@ -0,0 +1,51 @@
1
+ class ModelRspecGenerator < RubiGen::Base
2
+
3
+ default_options :author => nil
4
+
5
+ attr_reader :name, :class_name
6
+
7
+ def initialize(runtime_args, runtime_options = {})
8
+ super
9
+ usage if args.empty?
10
+ @name = args.shift.underscore
11
+ @class_name = @name.camelcase
12
+ extract_options
13
+ end
14
+
15
+ def manifest
16
+ record do |m|
17
+ # Ensure appropriate folder(s) exists
18
+ m.directory 'spec'
19
+
20
+ m.template "spec.rb", "spec/#{name}_spec.rb"
21
+ end
22
+ end
23
+
24
+ protected
25
+ def banner
26
+ <<-EOS
27
+ Creates an RSpec-based spec file for a model.
28
+ NOTE: this generator is typically called via the 'model' generator.
29
+
30
+ USAGE: #{$0} #{spec.name} name
31
+ EOS
32
+ end
33
+
34
+ def add_options!(opts)
35
+ # opts.separator ''
36
+ # opts.separator 'Options:'
37
+ # For each option below, place the default
38
+ # at the top of the file next to "default_options"
39
+ # opts.on("-a", "--author=\"Your Name\"", String,
40
+ # "Some comment about this option",
41
+ # "Default: none") { |options[:author]| }
42
+ # opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
43
+ end
44
+
45
+ def extract_options
46
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
47
+ # Templates can access these value via the attr_reader-generated methods, but not the
48
+ # raw instance variable value.
49
+ # @author = options[:author]
50
+ end
51
+ end
@@ -0,0 +1,9 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe OSX::<%= class_name %> do
4
+
5
+ it "should exist" do
6
+ OSX::<%= class_name %>
7
+ end
8
+
9
+ end
@@ -0,0 +1,51 @@
1
+ class ModelTestUnitGenerator < RubiGen::Base
2
+
3
+ default_options :author => nil
4
+
5
+ attr_reader :name, :class_name
6
+
7
+ def initialize(runtime_args, runtime_options = {})
8
+ super
9
+ usage if args.empty?
10
+ @name = args.shift.underscore
11
+ @class_name = @name.camelcase
12
+ extract_options
13
+ end
14
+
15
+ def manifest
16
+ record do |m|
17
+ # Ensure appropriate folder(s) exists
18
+ m.directory 'test'
19
+
20
+ m.template "test.rb", "test/test_#{name}.rb"
21
+ end
22
+ end
23
+
24
+ protected
25
+ def banner
26
+ <<-EOS
27
+ Creates an Test/Unit-based test file for a model.
28
+ NOTE: this generator is typically called via the 'model' generator.
29
+
30
+ USAGE: #{$0} #{spec.name} name
31
+ EOS
32
+ end
33
+
34
+ def add_options!(opts)
35
+ # opts.separator ''
36
+ # opts.separator 'Options:'
37
+ # For each option below, place the default
38
+ # at the top of the file next to "default_options"
39
+ # opts.on("-a", "--author=\"Your Name\"", String,
40
+ # "Some comment about this option",
41
+ # "Default: none") { |options[:author]| }
42
+ # opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
43
+ end
44
+
45
+ def extract_options
46
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
47
+ # Templates can access these value via the attr_reader-generated methods, but not the
48
+ # raw instance variable value.
49
+ # @author = options[:author]
50
+ end
51
+ end
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class Test<%= class_name %> < Test::Unit::TestCase
4
+ def test_<%= name %>_class_exists
5
+ OSX::<%= class_name %>
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ Description:
2
+
3
+
4
+ Usage:
5
+
@@ -0,0 +1,55 @@
1
+ class StoryGenerator < RubiGen::Base
2
+
3
+ default_options :author => nil
4
+
5
+ attr_reader :name, :class_name
6
+
7
+ def initialize(runtime_args, runtime_options = {})
8
+ super
9
+ usage if args.empty?
10
+ @name = args.shift
11
+ @class_name = @name.camelcase
12
+ extract_options
13
+ end
14
+
15
+ def manifest
16
+ record do |m|
17
+ # Ensure appropriate folder(s) exists
18
+ m.directory 'stories'
19
+ m.directory 'stories/steps'
20
+
21
+ # Create stubs
22
+ m.file "story_helper.rb", "stories/story_helper.rb"
23
+ m.template "story", "stories/#{name}_story"
24
+ m.template "story.rb", "stories/#{name}_story.rb"
25
+ m.template "steps.rb", "stories/steps/#{name}_steps.rb"
26
+ end
27
+ end
28
+
29
+ protected
30
+ def banner
31
+ <<-EOS
32
+ Creates a ...
33
+
34
+ USAGE: #{$0} #{spec.name} name
35
+ EOS
36
+ end
37
+
38
+ def add_options!(opts)
39
+ # opts.separator ''
40
+ # opts.separator 'Options:'
41
+ # For each option below, place the default
42
+ # at the top of the file next to "default_options"
43
+ # opts.on("-a", "--author=\"Your Name\"", String,
44
+ # "Some comment about this option",
45
+ # "Default: none") { |options[:author]| }
46
+ # opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
47
+ end
48
+
49
+ def extract_options
50
+ # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
51
+ # Templates can access these value via the attr_reader-generated methods, but not the
52
+ # raw instance variable value.
53
+ # @author = options[:author]
54
+ end
55
+ end
@@ -0,0 +1,8 @@
1
+ require "<%= class_name %>.bundle"
2
+ OSX::ns_import :<%= class_name %>
3
+
4
+ steps_for(:<%= name %>) do
5
+ Given "a <%= class_name %> instance" do
6
+ @tame = OSX::<%= class_name %>.alloc.init
7
+ end
8
+ end
@@ -0,0 +1,13 @@
1
+ Story: <%= name %>
2
+ As a ___
3
+ I want ___
4
+ So that ___
5
+
6
+ Scenario: <%= name %>
7
+ Given a <%= class_name %> instance
8
+ And ___
9
+
10
+ When ___
11
+
12
+ Then ___
13
+