amp-front 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/.document +5 -0
  2. data/.gitignore +24 -0
  3. data/Ampfile +3 -0
  4. data/Gemfile +10 -0
  5. data/Gemfile.lock +36 -0
  6. data/LICENSE +20 -0
  7. data/README.md +50 -0
  8. data/Rakefile +64 -0
  9. data/VERSION +1 -0
  10. data/design_docs/commands.md +91 -0
  11. data/design_docs/dependencies.md +35 -0
  12. data/design_docs/plugins.md +47 -0
  13. data/features/amp.feature +8 -0
  14. data/features/amp_help.feature +36 -0
  15. data/features/amp_plugin_list.feature +10 -0
  16. data/features/step_definitions/amp-front_steps.rb +23 -0
  17. data/features/support/env.rb +4 -0
  18. data/lib/amp-front.rb +30 -0
  19. data/lib/amp-front/dispatch/commands/base.rb +158 -0
  20. data/lib/amp-front/dispatch/commands/builtin/help.rb +23 -0
  21. data/lib/amp-front/dispatch/commands/builtin/plugin.rb +24 -0
  22. data/lib/amp-front/dispatch/commands/validations.rb +171 -0
  23. data/lib/amp-front/dispatch/runner.rb +86 -0
  24. data/lib/amp-front/help/entries/__default__.erb +31 -0
  25. data/lib/amp-front/help/entries/ampfiles.md +42 -0
  26. data/lib/amp-front/help/entries/commands.erb +6 -0
  27. data/lib/amp-front/help/entries/new-commands.md +81 -0
  28. data/lib/amp-front/help/help.rb +312 -0
  29. data/lib/amp-front/plugins/base.rb +87 -0
  30. data/lib/amp-front/support/module_extensions.rb +92 -0
  31. data/lib/amp-front/third_party/maruku.rb +136 -0
  32. data/lib/amp-front/third_party/maruku/attributes.rb +227 -0
  33. data/lib/amp-front/third_party/maruku/defaults.rb +71 -0
  34. data/lib/amp-front/third_party/maruku/errors_management.rb +92 -0
  35. data/lib/amp-front/third_party/maruku/helpers.rb +260 -0
  36. data/lib/amp-front/third_party/maruku/input/charsource.rb +326 -0
  37. data/lib/amp-front/third_party/maruku/input/extensions.rb +69 -0
  38. data/lib/amp-front/third_party/maruku/input/html_helper.rb +189 -0
  39. data/lib/amp-front/third_party/maruku/input/linesource.rb +111 -0
  40. data/lib/amp-front/third_party/maruku/input/parse_block.rb +615 -0
  41. data/lib/amp-front/third_party/maruku/input/parse_doc.rb +234 -0
  42. data/lib/amp-front/third_party/maruku/input/parse_span_better.rb +746 -0
  43. data/lib/amp-front/third_party/maruku/input/rubypants.rb +225 -0
  44. data/lib/amp-front/third_party/maruku/input/type_detection.rb +147 -0
  45. data/lib/amp-front/third_party/maruku/input_textile2/t2_parser.rb +163 -0
  46. data/lib/amp-front/third_party/maruku/maruku.rb +33 -0
  47. data/lib/amp-front/third_party/maruku/output/to_ansi.rb +223 -0
  48. data/lib/amp-front/third_party/maruku/output/to_html.rb +991 -0
  49. data/lib/amp-front/third_party/maruku/output/to_markdown.rb +164 -0
  50. data/lib/amp-front/third_party/maruku/output/to_s.rb +56 -0
  51. data/lib/amp-front/third_party/maruku/string_utils.rb +191 -0
  52. data/lib/amp-front/third_party/maruku/structures.rb +167 -0
  53. data/lib/amp-front/third_party/maruku/structures_inspect.rb +87 -0
  54. data/lib/amp-front/third_party/maruku/structures_iterators.rb +61 -0
  55. data/lib/amp-front/third_party/maruku/textile2.rb +1 -0
  56. data/lib/amp-front/third_party/maruku/toc.rb +199 -0
  57. data/lib/amp-front/third_party/maruku/usage/example1.rb +33 -0
  58. data/lib/amp-front/third_party/maruku/version.rb +40 -0
  59. data/lib/amp-front/third_party/trollop.rb +766 -0
  60. data/spec/amp-front_spec.rb +25 -0
  61. data/spec/command_specs/base_spec.rb +123 -0
  62. data/spec/command_specs/command_spec.rb +97 -0
  63. data/spec/command_specs/help_spec.rb +33 -0
  64. data/spec/command_specs/spec_helper.rb +37 -0
  65. data/spec/command_specs/validations_spec.rb +267 -0
  66. data/spec/dispatch_specs/runner_spec.rb +116 -0
  67. data/spec/dispatch_specs/spec_helper.rb +15 -0
  68. data/spec/help_specs/help_entry_spec.rb +78 -0
  69. data/spec/help_specs/help_registry_spec.rb +77 -0
  70. data/spec/help_specs/spec_helper.rb +15 -0
  71. data/spec/plugin_specs/base_spec.rb +36 -0
  72. data/spec/plugin_specs/spec_helper.rb +15 -0
  73. data/spec/spec.opts +1 -0
  74. data/spec/spec_helper.rb +33 -0
  75. data/spec/support_specs/module_extensions_spec.rb +104 -0
  76. data/spec/support_specs/spec_helper.rb +15 -0
  77. data/test/third_party_tests/test_trollop.rb +1181 -0
  78. metadata +192 -0
@@ -0,0 +1,116 @@
1
+ ##################################################################
2
+ # Licensing Information #
3
+ # #
4
+ # The following code is licensed, as standalone code, under #
5
+ # the Ruby License, unless otherwise directed within the code. #
6
+ # #
7
+ # For information on the license of this code when distributed #
8
+ # with and used in conjunction with the other modules in the #
9
+ # Amp project, please see the root-level LICENSE file. #
10
+ # #
11
+ # © Michael J. Edgar and Ari Brown, 2009-2010 #
12
+ # #
13
+ ##################################################################
14
+
15
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
16
+
17
+ describe Amp::Dispatch::Runner do
18
+ before do
19
+ @runner = Amp::Dispatch::Runner.new(['--version'], :ampfile => "NO SUCH FILE@@@@@@@@@@@@@@@@@@")
20
+ end
21
+
22
+ describe '#run!' do
23
+ it 'parses arguments' do
24
+ proc { @runner.run! }.should raise_error(SystemExit)
25
+ end
26
+
27
+ it 'runs the matching command' do
28
+ mock_command_class = mock('command class')
29
+ mock_command = mock('command')
30
+ Amp::Command.should_receive(:for_name).
31
+ with('tester --verbose').
32
+ and_return(mock_command_class)
33
+ mock_command_class.should_receive(:inspect).and_return('Amp::Command::Tester')
34
+ mock_command_class.should_receive(:new).and_return(mock_command)
35
+ mock_command.should_receive(:collect_options).and_return([{:verbose => true}, ['--verbose']])
36
+ mock_command.should_receive(:call).with(
37
+ {:verbose => true, :help => false, :version => false}, ['--verbose'])
38
+
39
+ runner = Amp::Dispatch::Runner.new(['tester', '--verbose'])
40
+ runner.run!
41
+ end
42
+
43
+ it 'does not crash when no valid command' do
44
+ Amp::Command.should_receive(:for_name).
45
+ with('').
46
+ and_return(nil)
47
+ mock_command_class = mock('command class')
48
+ mock_command = mock('command')
49
+ Amp::Command::Help = mock_command_class
50
+ mock_command_class.should_receive(:name).at_most(:once).and_return('Amp::Command::Help')
51
+ mock_command_class.should_receive(:new).and_return(mock_command)
52
+ mock_command.should_receive(:collect_options).and_return([{}, []])
53
+ mock_command.should_receive(:call).with(
54
+ {:help => false, :version => false}, [])
55
+
56
+ runner = Amp::Dispatch::Runner.new([''])
57
+ runner.run!
58
+ end
59
+ end
60
+
61
+ describe '#trim_argv_for_command' do
62
+ it 'strips arguments when arguments matches the command name' do
63
+ arguments = ['base', 'help']
64
+ command = mock(:command_class)
65
+ command.should_receive(:inspect).and_return('Amp::Command::Base')
66
+ @runner.trim_argv_for_command(arguments, command).should == ['help']
67
+ arguments.should == ['base', 'help']
68
+ end
69
+
70
+ it 'strips arguments for commands in namespaces' do
71
+ arguments = ['base', 'help']
72
+ command = mock(:command_class)
73
+ command.should_receive(:inspect).and_return('Amp::Command::Base::Help')
74
+ @runner.trim_argv_for_command(arguments, command).should == []
75
+ arguments.should == ['base', 'help']
76
+ end
77
+
78
+ it 'raises when the command name does not match arguments' do
79
+ arguments = ['base', 'hello']
80
+ command = mock(:command_class)
81
+ command.should_receive(:inspect).twice.and_return('Amp::Command::Base::Help')
82
+ proc { @runner.trim_argv_for_command(arguments, command) }.should raise_error(ArgumentError)
83
+ end
84
+ end
85
+
86
+ describe '#collect_options' do
87
+ it 'stops un unknown options' do
88
+ arguments = ['help', 'please']
89
+ options = @runner.collect_options(arguments)
90
+ arguments.should == ['help', 'please']
91
+ end
92
+
93
+ it 'parses --version automatically and exit' do
94
+ swizzling_stdout do
95
+ proc { @runner.collect_options(['--version', 'please']) }.should raise_error(SystemExit)
96
+ end
97
+ end
98
+
99
+ it 'displays Amp::VERSION_TITLE with --version' do
100
+ result = swizzling_stdout do
101
+ proc { @runner.collect_options(['--version', 'please']) }.should raise_error(SystemExit)
102
+ end
103
+ result.should include(Amp::VERSION_TITLE)
104
+ end
105
+
106
+ it 'returns the parsed options' do
107
+ options, arguments = @runner.collect_options(['help', 'please'])
108
+ options.should == {:version => false, :help => false}
109
+ end
110
+
111
+ it 'returns the unparsed arguments' do
112
+ options, arguments = @runner.collect_options(['help', 'please'])
113
+ arguments.should == ['help', 'please']
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,15 @@
1
+ ##################################################################
2
+ # Licensing Information #
3
+ # #
4
+ # The following code is licensed, as standalone code, under #
5
+ # the Ruby License, unless otherwise directed within the code. #
6
+ # #
7
+ # For information on the license of this code when distributed #
8
+ # with and used in conjunction with the other modules in the #
9
+ # Amp project, please see the root-level LICENSE file. #
10
+ # #
11
+ # © Michael J. Edgar and Ari Brown, 2009-2010 #
12
+ # #
13
+ ##################################################################
14
+
15
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
@@ -0,0 +1,78 @@
1
+ ##################################################################
2
+ # Licensing Information #
3
+ # #
4
+ # The following code is licensed, as standalone code, under #
5
+ # the Ruby License, unless otherwise directed within the code. #
6
+ # #
7
+ # For information on the license of this code when distributed #
8
+ # with and used in conjunction with the other modules in the #
9
+ # Amp project, please see the root-level LICENSE file. #
10
+ # #
11
+ # © Michael J. Edgar and Ari Brown, 2009-2010 #
12
+ # #
13
+ ##################################################################
14
+
15
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
16
+
17
+ describe Amp::Help::HelpEntry do
18
+ before(:each) do
19
+ @entry_counter ||= 0
20
+ @entry_counter += 1
21
+ @entry_name = "fake_help_#{@entry_counter}"
22
+ end
23
+
24
+ after(:each) do
25
+ Amp::Help::HelpRegistry.entries[@entry_name] = []
26
+ end
27
+
28
+ describe '#text' do
29
+ it 'equals the text provided in the constructor' do
30
+ entry = Amp::Help::HelpEntry.new(@entry_name, 'abcba')
31
+ entry.text.should == 'abcba'
32
+ end
33
+ end
34
+
35
+ describe Amp::Help::MarkdownHelpEntry do
36
+ describe '#text' do
37
+ it 'equals the text provided run through the markdown parser' do
38
+ input = '*hello* **there**'
39
+ entry = Amp::Help::MarkdownHelpEntry.new(@entry_name, input)
40
+ output = entry.text
41
+ output.should == "\e[4mhello\e[24m \e[1mthere\e[22m\n\n"
42
+ end
43
+ end
44
+ end
45
+
46
+ describe Amp::Help::ErbHelpEntry do
47
+ describe '#text' do
48
+ it 'equals the text provided run through ERb' do
49
+ input = '<% 5.times do |x| %><%= x %><% end %>'
50
+ entry = Amp::Help::ErbHelpEntry.new(@entry_name, input)
51
+ output = entry.text
52
+ output.should == "01234"
53
+ end
54
+ end
55
+ end
56
+
57
+ describe Amp::Help::CommandHelpEntry do
58
+ describe '#text' do
59
+ it "contains the command's description" do
60
+ @klass = Class.new(Amp::Command::Base) { desc 'foo bar baz' }
61
+ entry = Amp::Help::CommandHelpEntry.new(@entry_name, @klass)
62
+ output = entry.text
63
+ output.should include('foo bar baz')
64
+ end
65
+
66
+ it "contains the command's options" do
67
+ @klass = Class.new(Amp::Command::Base) do
68
+ opt :force, 'forces something dangerous', :short => '-f'
69
+ end
70
+ entry = Amp::Help::CommandHelpEntry.new(@entry_name, @klass)
71
+ output = entry.text
72
+ output.should include('--force')
73
+ output.should include('forces something dangerous')
74
+ output.should include('-f')
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,77 @@
1
+ ##################################################################
2
+ # Licensing Information #
3
+ # #
4
+ # The following code is licensed, as standalone code, under #
5
+ # the Ruby License, unless otherwise directed within the code. #
6
+ # #
7
+ # For information on the license of this code when distributed #
8
+ # with and used in conjunction with the other modules in the #
9
+ # Amp project, please see the root-level LICENSE file. #
10
+ # #
11
+ # © Michael J. Edgar and Ari Brown, 2009-2010 #
12
+ # #
13
+ ##################################################################
14
+
15
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
16
+
17
+ describe Amp::Help::HelpRegistry do
18
+ before(:each) do
19
+ @entry_counter ||= 0
20
+ @entry_counter += 1
21
+ @entry_name = "fake_help_#{@entry_counter}"
22
+ end
23
+
24
+ after(:each) do
25
+ Amp::Help::HelpRegistry.entries[@entry_name] = []
26
+ end
27
+
28
+ describe '#register' do
29
+ it 'makes help entries available through #[]' do
30
+ fake_help_entry = mock(:help_entry)
31
+ Amp::Help::HelpRegistry.register(@entry_name, fake_help_entry)
32
+ Amp::Help::HelpRegistry[@entry_name].should == [fake_help_entry]
33
+ end
34
+
35
+ it 'makes help entries availabe through #entries' do
36
+ fake_help_entry = mock(:help_entry)
37
+ Amp::Help::HelpRegistry.register(@entry_name, fake_help_entry)
38
+ Amp::Help::HelpRegistry.entries[@entry_name].should == [fake_help_entry]
39
+ end
40
+ end
41
+
42
+ describe '#unregister' do
43
+ it 'raises an error when the help entry is not found' do
44
+ lambda {
45
+ Amp::Help::HelpRegistry.unregister('frobnozzle')
46
+ }.should raise_error(ArgumentError)
47
+ end
48
+
49
+ it 'only needs one argument when a help entry is unambiguous' do
50
+ fake_help_entry = mock(:help_entry)
51
+ Amp::Help::HelpRegistry.entries[@entry_name] = [fake_help_entry]
52
+ # Sanity check before unregistering it
53
+ Amp::Help::HelpRegistry.entries[@entry_name].should == [fake_help_entry]
54
+ Amp::Help::HelpRegistry.unregister(@entry_name)
55
+ Amp::Help::HelpRegistry.entries[@entry_name].should == []
56
+ end
57
+
58
+ it 'raises an error when giving 1 argument on an ambiguous match' do
59
+ fake_1, fake_2 = mock(:help_entry), mock(:other_help_entry)
60
+ Amp::Help::HelpRegistry.entries[@entry_name] = [fake_1, fake_2]
61
+ # Sanity check before unregistering it
62
+ Amp::Help::HelpRegistry.entries[@entry_name].should == [fake_1, fake_2]
63
+ lambda {
64
+ Amp::Help::HelpRegistry.unregister(@entry_name)
65
+ }.should raise_error(ArgumentError)
66
+ end
67
+
68
+ it 'succeeds when ambiguous matches are clarified' do
69
+ fake_1, fake_2 = mock(:help_entry), mock(:other_help_entry)
70
+ Amp::Help::HelpRegistry.entries[@entry_name] = [fake_1, fake_2]
71
+ # Sanity check before unregistering it
72
+ Amp::Help::HelpRegistry.entries[@entry_name].should == [fake_1, fake_2]
73
+ Amp::Help::HelpRegistry.unregister(@entry_name, fake_2)
74
+ Amp::Help::HelpRegistry.entries[@entry_name].should == [fake_1]
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,15 @@
1
+ ##################################################################
2
+ # Licensing Information #
3
+ # #
4
+ # The following code is licensed, as standalone code, under #
5
+ # the Ruby License, unless otherwise directed within the code. #
6
+ # #
7
+ # For information on the license of this code when distributed #
8
+ # with and used in conjunction with the other modules in the #
9
+ # Amp project, please see the root-level LICENSE file. #
10
+ # #
11
+ # © Michael J. Edgar and Ari Brown, 2009-2010 #
12
+ # #
13
+ ##################################################################
14
+
15
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
@@ -0,0 +1,36 @@
1
+ ##################################################################
2
+ # Licensing Information #
3
+ # #
4
+ # The following code is licensed, as standalone code, under #
5
+ # the Ruby License, unless otherwise directed within the code. #
6
+ # #
7
+ # For information on the license of this code when distributed #
8
+ # with and used in conjunction with the other modules in the #
9
+ # Amp project, please see the root-level LICENSE file. #
10
+ # #
11
+ # © Michael J. Edgar and Ari Brown, 2009-2010 #
12
+ # #
13
+ ##################################################################
14
+
15
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
16
+
17
+ describe Amp::Plugins::Base do
18
+ it 'yields itself for easy configuration' do
19
+ new_plugin = Amp::Plugins::Base.create('silly') do |plugin|
20
+ plugin.author = 'Michael Edgar'
21
+ end
22
+ new_plugin.author.should == 'Michael Edgar'
23
+ end
24
+
25
+ it 'mentions its author when inspected' do
26
+ plugin = Amp::Plugins::Base.create('silly') do |plugin|
27
+ plugin.author = 'adgar@carboni.ca'
28
+ end
29
+ plugin.new.inspect.should include('adgar@carboni.ca')
30
+ end
31
+
32
+ it 'infers its own module name' do
33
+ plugin = Amp::Plugins::Base.create('silly')
34
+ plugin.new.module.should == 'Amp::Plugins::Silly'
35
+ end
36
+ end
@@ -0,0 +1,15 @@
1
+ ##################################################################
2
+ # Licensing Information #
3
+ # #
4
+ # The following code is licensed, as standalone code, under #
5
+ # the Ruby License, unless otherwise directed within the code. #
6
+ # #
7
+ # For information on the license of this code when distributed #
8
+ # with and used in conjunction with the other modules in the #
9
+ # Amp project, please see the root-level LICENSE file. #
10
+ # #
11
+ # © Michael J. Edgar and Ari Brown, 2009-2010 #
12
+ # #
13
+ ##################################################################
14
+
15
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
@@ -0,0 +1 @@
1
+ --color --backtrace
@@ -0,0 +1,33 @@
1
+ ##################################################################
2
+ # Licensing Information #
3
+ # #
4
+ # The following code is licensed, as standalone code, under #
5
+ # the Ruby License, unless otherwise directed within the code. #
6
+ # #
7
+ # For information on the license of this code when distributed #
8
+ # with and used in conjunction with the other modules in the #
9
+ # Amp project, please see the root-level LICENSE file. #
10
+ # #
11
+ # © Michael J. Edgar and Ari Brown, 2009-2010 #
12
+ # #
13
+ ##################################################################
14
+
15
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
16
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
17
+ require 'amp-front'
18
+ require 'spec'
19
+
20
+ include Amp
21
+
22
+ Spec::Runner.configure do |config|
23
+ end
24
+
25
+ def swizzling_stdout
26
+ new_stdout = StringIO.new
27
+ $stdout, old_stdout = new_stdout, $stdout
28
+ yield
29
+ new_stdout.string
30
+ ensure
31
+ $stdout = old_stdout
32
+ new_stdout.string
33
+ end
@@ -0,0 +1,104 @@
1
+ ##################################################################
2
+ # Licensing Information #
3
+ # #
4
+ # The following code is licensed, as standalone code, under #
5
+ # the Ruby License, unless otherwise directed within the code. #
6
+ # #
7
+ # For information on the license of this code when distributed #
8
+ # with and used in conjunction with the other modules in the #
9
+ # Amp project, please see the root-level LICENSE file. #
10
+ # #
11
+ # © Michael J. Edgar and Ari Brown, 2009-2010 #
12
+ # #
13
+ ##################################################################
14
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
15
+
16
+ describe ModuleExtensions do
17
+ before do
18
+ @class = Class.new do
19
+ extend ModuleExtensions
20
+ cattr_reader :read1, :read2
21
+ cattr_writer :write1, :write2
22
+ cattr_accessor :both1, :both2
23
+ cattr_accessor_with_default :arr1, []
24
+ end
25
+ end
26
+
27
+ describe '#cattr_reader' do
28
+ it 'creates reading methods for the given variables' do
29
+ @class.__send__(:instance_variable_set, :@read1, 'hello')
30
+ @class.read1.should == 'hello'
31
+ @class.__send__(:instance_variable_set, :@read2, 5)
32
+ @class.read2.should == 5
33
+ end
34
+ end
35
+
36
+ describe '#cattr_writer' do
37
+ it 'creates writing methods for the given variables' do
38
+ @class.write1 = 'hello'
39
+ @class.__send__(:instance_variable_get, :@write1).should == 'hello'
40
+ @class.write2 = 5
41
+ @class.__send__(:instance_variable_get, :@write2).should == 5
42
+ end
43
+ end
44
+
45
+ describe '#cattr_accessor' do
46
+ it 'creates reading and writing methods for the given variables' do
47
+ @class.both1 = 'hello'
48
+ @class.both1.should == 'hello'
49
+ @class.__send__(:instance_variable_get, :@both1).should == 'hello'
50
+ @class.__send__(:instance_variable_set, :@both1, 'world')
51
+ @class.both1.should == 'world'
52
+ @class.both2 = 5
53
+ @class.both2.should == 5
54
+ @class.__send__(:instance_variable_get, :@both2).should == 5
55
+ @class.__send__(:instance_variable_set, :@both2, 10)
56
+ @class.both2.should == 10
57
+ end
58
+ end
59
+
60
+ describe '#cattr_accessor_with_default' do
61
+ it 'creates reading and writing methods, but defaults the ivar value' do
62
+ @class.arr1.should == []
63
+ @class.__send__(:instance_variable_get, :@arr1).should == []
64
+ @class.arr1.should == [] # second invocation, after default value set
65
+ @class.arr1 = [1, 2]
66
+ @class.arr1.should == [1, 2]
67
+ @class.__send__(:instance_variable_get, :@arr1).should == [1, 2]
68
+ end
69
+ end
70
+
71
+ describe '#cattr_get_and_setter' do
72
+ before do
73
+ @base = Class.new do
74
+ extend ModuleExtensions
75
+ cattr_get_and_setter :type
76
+ type :silly
77
+ end
78
+ end
79
+
80
+ it 'acts a setter and getter on the base class' do
81
+ @base.type.should == :silly
82
+ end
83
+
84
+ it 'is not inherited' do
85
+ @derived = Class.new(@base)
86
+ @derived.type.should_not == :silly
87
+ end
88
+
89
+ it 'can be used by inherited classes' do
90
+ @derived = Class.new(@base) do
91
+ type :laughable
92
+ end
93
+ @derived.type.should == :laughable
94
+ @base.type.should == :silly
95
+ end
96
+
97
+ it 'turns a block into a proc and sets it' do
98
+ @derived = Class.new(@base) do
99
+ type { 5 + 3 }
100
+ end
101
+ @derived.type.call.should == 8
102
+ end
103
+ end
104
+ end