merb-slices 0.9.7 → 0.9.8

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 (68) hide show
  1. data/README +4 -4
  2. data/Rakefile +27 -13
  3. data/TODO +1 -2
  4. data/bin/slice +77 -0
  5. data/lib/generators/templates/common/Rakefile +16 -12
  6. data/lib/generators/templates/full/README +4 -4
  7. data/lib/generators/templates/full/Rakefile +32 -13
  8. data/lib/generators/templates/full/config/init.rb +43 -0
  9. data/lib/generators/templates/full/lib/%base_name%.rb +3 -1
  10. data/lib/generators/templates/full/spec/%base_name%_spec.rb +10 -121
  11. data/lib/generators/templates/full/spec/controllers/main_spec.rb +18 -8
  12. data/lib/generators/templates/thin/README +4 -4
  13. data/lib/generators/templates/very_thin/README +4 -4
  14. data/lib/merb-slices.rb +3 -3
  15. data/lib/merb-slices/controller_mixin.rb +34 -7
  16. data/lib/merb-slices/merbtasks.rb +5 -34
  17. data/lib/merb-slices/module.rb +9 -3
  18. data/lib/merb-slices/module_mixin.rb +19 -31
  19. data/lib/merb-slices/router_ext.rb +10 -7
  20. data/spec/full_slice_generator_spec.rb +31 -2
  21. data/spec/full_slice_spec.rb +162 -0
  22. data/spec/merb-slice_spec.rb +97 -3
  23. data/spec/slice_generator_spec.rb +15 -3
  24. data/spec/slices/full-test-slice/LICENSE +20 -0
  25. data/spec/slices/full-test-slice/README +170 -0
  26. data/spec/slices/full-test-slice/Rakefile +67 -0
  27. data/spec/slices/full-test-slice/TODO +15 -0
  28. data/spec/slices/full-test-slice/app/controllers/application.rb +5 -0
  29. data/spec/slices/full-test-slice/app/controllers/main.rb +7 -0
  30. data/spec/slices/full-test-slice/app/helpers/application_helper.rb +64 -0
  31. data/spec/slices/full-test-slice/app/views/layout/full_test_slice.html.erb +16 -0
  32. data/spec/slices/full-test-slice/app/views/main/index.html.erb +1 -0
  33. data/spec/slices/full-test-slice/config/init.rb +43 -0
  34. data/spec/slices/full-test-slice/lib/full-test-slice.rb +80 -0
  35. data/spec/slices/full-test-slice/lib/full-test-slice/merbtasks.rb +103 -0
  36. data/spec/slices/full-test-slice/lib/full-test-slice/slicetasks.rb +18 -0
  37. data/spec/slices/full-test-slice/lib/full-test-slice/spectasks.rb +65 -0
  38. data/spec/slices/full-test-slice/public/javascripts/master.js +0 -0
  39. data/spec/slices/full-test-slice/public/stylesheets/master.css +2 -0
  40. data/spec/slices/full-test-slice/stubs/app/controllers/application.rb +2 -0
  41. data/spec/slices/full-test-slice/stubs/app/controllers/main.rb +2 -0
  42. data/spec/slices/thin-test-slice/LICENSE +20 -0
  43. data/spec/slices/thin-test-slice/README +130 -0
  44. data/spec/slices/thin-test-slice/Rakefile +43 -0
  45. data/spec/slices/thin-test-slice/TODO +7 -0
  46. data/spec/slices/thin-test-slice/application.rb +36 -0
  47. data/spec/slices/thin-test-slice/lib/thin-test-slice.rb +93 -0
  48. data/spec/slices/thin-test-slice/lib/thin-test-slice/merbtasks.rb +103 -0
  49. data/spec/slices/thin-test-slice/lib/thin-test-slice/slicetasks.rb +18 -0
  50. data/spec/slices/thin-test-slice/public/javascripts/master.js +0 -0
  51. data/spec/slices/thin-test-slice/public/stylesheets/master.css +2 -0
  52. data/spec/slices/thin-test-slice/stubs/application.rb +9 -0
  53. data/spec/slices/thin-test-slice/views/layout/thin_test_slice.html.erb +16 -0
  54. data/spec/slices/thin-test-slice/views/main/index.html.erb +1 -0
  55. data/spec/slices/very-thin-test-slice/LICENSE +20 -0
  56. data/spec/slices/very-thin-test-slice/README +110 -0
  57. data/spec/slices/very-thin-test-slice/Rakefile +43 -0
  58. data/spec/slices/very-thin-test-slice/TODO +7 -0
  59. data/spec/slices/very-thin-test-slice/application.rb +36 -0
  60. data/spec/slices/very-thin-test-slice/lib/very-thin-test-slice.rb +89 -0
  61. data/spec/slices/very-thin-test-slice/lib/very-thin-test-slice/merbtasks.rb +103 -0
  62. data/spec/slices/very-thin-test-slice/lib/very-thin-test-slice/slicetasks.rb +18 -0
  63. data/spec/spec_helper.rb +27 -2
  64. data/spec/thin_slice_generator_spec.rb +24 -2
  65. data/spec/thin_slice_spec.rb +139 -0
  66. data/spec/very_thin_slice_generator_spec.rb +22 -2
  67. data/spec/very_thin_slice_spec.rb +119 -0
  68. metadata +79 -5
data/README CHANGED
@@ -58,19 +58,19 @@ file: config/router.rb
58
58
 
59
59
  # example: /blog-slice/:controller/:action/:id
60
60
 
61
- r.add_slice(:BlogSlice)
61
+ add_slice(:BlogSlice)
62
62
 
63
63
  # example: /foo/:controller/:action/:id
64
64
 
65
- r.add_slice(:BlogSlice, 'foo') # same as :path => 'foo'
65
+ add_slice(:BlogSlice, 'foo') # same as :path => 'foo'
66
66
 
67
67
  # example: /:lang/:controller/:action/:id (with :a param set)
68
68
 
69
- r.add_slice(:BlogSlice, :path => ':lang', :params => { :a => 'b' })
69
+ add_slice(:BlogSlice, :path => ':lang', :params => { :a => 'b' })
70
70
 
71
71
  # example: /:controller/:action/:id
72
72
 
73
- r.slice(:BlogSlice)
73
+ slice(:BlogSlice)
74
74
 
75
75
  Normally you should also run the following rake task:
76
76
 
data/Rakefile CHANGED
@@ -17,7 +17,7 @@ GEM_EMAIL = "info@fabien.be"
17
17
 
18
18
  GEM_NAME = "merb-slices"
19
19
  PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
20
- GEM_VERSION = (Merb::MORE_VERSION rescue "0.9.7") + PKG_BUILD
20
+ GEM_VERSION = (Merb::MORE_VERSION rescue "0.9.8") + PKG_BUILD
21
21
 
22
22
  RELEASE_NAME = "REL #{GEM_VERSION}"
23
23
 
@@ -35,9 +35,11 @@ spec = Gem::Specification.new do |s|
35
35
  s.author = GEM_AUTHOR
36
36
  s.email = GEM_EMAIL
37
37
  s.homepage = PROJECT_URL
38
- s.add_dependency('merb-core', '>= 0.9.7')
38
+ s.add_dependency('merb-core', '>= 0.9.8')
39
39
  s.require_path = 'lib'
40
40
  s.files = %w(LICENSE README Rakefile Generators TODO) + Dir.glob("{lib,spec}/**/*")
41
+ s.bindir = "bin"
42
+ s.executables = %w( slice )
41
43
  end
42
44
 
43
45
  Rake::GemPackageTask.new(spec) do |pkg|
@@ -45,21 +47,33 @@ Rake::GemPackageTask.new(spec) do |pkg|
45
47
  end
46
48
 
47
49
  desc "Install the gem"
48
- task :install => [:package] do
49
- sh install_command(GEM_NAME, GEM_VERSION)
50
+ task :install do
51
+ Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
50
52
  end
51
53
 
52
- namespace :jruby do
54
+ desc "Uninstall the gem"
55
+ task :uninstall do
56
+ Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
57
+ end
53
58
 
54
- desc "Run :package and install the resulting .gem with jruby"
55
- task :install => :package do
56
- sh jinstall_command(GEM_NAME, GEM_VERSION)
59
+ desc "Create a gemspec file"
60
+ task :gemspec do
61
+ File.open("#{GEM_NAME}.gemspec", "w") do |file|
62
+ file.puts spec.to_ruby
57
63
  end
58
-
59
64
  end
60
65
 
61
- desc "Run all specs"
62
- Spec::Rake::SpecTask.new("specs") do |t|
63
- t.spec_opts = ["--format", "specdoc", "--colour"]
64
- t.spec_files = Dir["spec/**/*_spec.rb"].sort
66
+ desc "Run all examples (or a specific spec with TASK=xxxx)"
67
+ Spec::Rake::SpecTask.new('spec') do |t|
68
+ t.spec_opts = ["-cfs"]
69
+ t.spec_files = begin
70
+ if ENV["TASK"]
71
+ ENV["TASK"].split(',').map { |task| "spec/**/#{task}_spec.rb" }
72
+ else
73
+ FileList['spec/**/*_spec.rb']
74
+ end
75
+ end
65
76
  end
77
+
78
+ desc 'Default: run spec examples'
79
+ task :default => 'spec'
data/TODO CHANGED
@@ -1,2 +1 @@
1
- Leverage new routing features:
2
- - better name_prefix handling .name(..., prefix)
1
+ - Add specs for dynamic loading/unloading of slices
data/bin/slice ADDED
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ __DIR__ = Dir.pwd
4
+
5
+ require 'rubygems'
6
+ require 'merb-core'
7
+ require 'merb-slices'
8
+
9
+ slice_name = File.basename(__DIR__)
10
+
11
+ Merb::Config.use { |c|
12
+ c[:framework] = { :public => [Merb.root / "public", nil] }
13
+ c[:session_store] = 'none'
14
+ c[:exception_details] = true
15
+ }
16
+
17
+ if File.exists?(slice_file = File.join(__DIR__, 'lib', "#{slice_name}.rb"))
18
+ Merb::BootLoader.before_app_loads do
19
+ # See Merb::Slices::ModuleMixin - $SLICE_MODULE is used as a flag
20
+ $SLICE_MODULE = Merb::Slices.filename2module(slice_file)
21
+ require slice_file
22
+ Merb::Router.prepare do
23
+ slice($SLICE_MODULE)
24
+ slice_id = slice_name.gsub('-', '_').to_sym
25
+ slice_routes = Merb::Slices.named_routes[slice_id] || {}
26
+
27
+ # Setup a / root path matching route - try several defaults
28
+ route = slice_routes[:home] || slice_routes[:index]
29
+ if route
30
+ params = route.params.inject({}) do |hsh,(k,v)|
31
+ hsh[k] = v.gsub("\"", '') if k == :controller || k == :action
32
+ hsh
33
+ end
34
+ match('/').to(params)
35
+ else
36
+ match('/').to(:controller => 'merb_slices', :action => 'index')
37
+ end
38
+ end
39
+ end
40
+ else
41
+ puts "No slice found (expected: #{slice_name})"
42
+ exit
43
+ end
44
+
45
+ class MerbSlices < Merb::Controller
46
+
47
+ def index
48
+ html = "<h1>#{slice.name}</h1><p>#{slice.description}</p>"
49
+ html << "<h2>Routes</h2><ul>"
50
+ sorted_names = slice.named_routes.keys.map { |k| [k.to_s, k] }.sort_by { |pair| pair.first }
51
+ sorted_names.each do |_, name|
52
+ if name != :default && (route = slice.named_routes[name])
53
+ if name == :index
54
+ html << %Q[<li><a href="#{url(route.name)}" title="visit #{name}">#{name}: #{route.inspect}</a></li>]
55
+ else
56
+ html << %Q[<li>#{name}: #{route.inspect}</li>]
57
+ end
58
+ end
59
+ end
60
+ html << "</ul>"
61
+ html
62
+ end
63
+
64
+ private
65
+
66
+ def slice
67
+ @slice ||= Merb::Slices.slices.first
68
+ end
69
+
70
+ end
71
+
72
+ ARGV.push '-H' if ARGV[0] && ARGV[0] =~ /^[^-]/
73
+ unless %w[-a --adapter -i --irb-console -r --script-runner].any? { |o| ARGV.index(o) }
74
+ ARGV.push *%w[-a mongrel]
75
+ end
76
+
77
+ Merb.start
@@ -1,9 +1,10 @@
1
1
  require 'rubygems'
2
2
  require 'rake/gempackagetask'
3
- require 'merb-core/version'
4
- require 'merb-core/tasks/merb_rake_helper'
5
3
 
6
- NAME = "<%= base_name %>"
4
+ require 'merb-core'
5
+ require 'merb-core/tasks/merb'
6
+
7
+ GEM_NAME = "<%= base_name %>"
7
8
  AUTHOR = "Your Name"
8
9
  EMAIL = "Your Email"
9
10
  HOMEPAGE = "http://merbivore.com/"
@@ -12,7 +13,7 @@ GEM_VERSION = "<%= Merb::VERSION %>"
12
13
 
13
14
  spec = Gem::Specification.new do |s|
14
15
  s.rubyforge_project = 'merb'
15
- s.name = NAME
16
+ s.name = GEM_NAME
16
17
  s.version = GEM_VERSION
17
18
  s.platform = Gem::Platform::RUBY
18
19
  s.has_rdoc = true
@@ -31,16 +32,19 @@ Rake::GemPackageTask.new(spec) do |pkg|
31
32
  pkg.gem_spec = spec
32
33
  end
33
34
 
34
- desc "Install <%= module_name %> as a gem"
35
- task :install => [:package] do
36
- sh %{#{sudo} gem install pkg/#{NAME}-#{GEM_VERSION} --no-update-sources}
35
+ desc "Install the gem"
36
+ task :install do
37
+ Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
37
38
  end
38
39
 
39
- namespace :jruby do
40
+ desc "Uninstall the gem"
41
+ task :uninstall do
42
+ Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
43
+ end
40
44
 
41
- desc "Run :package and install the resulting .gem with jruby"
42
- task :install => :package do
43
- sh %{#{sudo} jruby -S gem install #{install_home} pkg/#{NAME}-#{GEM_VERSION}.gem --no-rdoc --no-ri}
45
+ desc "Create a gemspec file"
46
+ task :gemspec do
47
+ File.open("#{GEM_NAME}.gemspec", "w") do |file|
48
+ file.puts spec.to_ruby
44
49
  end
45
-
46
50
  end
@@ -90,19 +90,19 @@ file: config/router.rb
90
90
 
91
91
  # example: /<%= symbol_name %>/:controller/:action/:id
92
92
 
93
- r.add_slice(:<%= module_name %>)
93
+ add_slice(:<%= module_name %>)
94
94
 
95
95
  # example: /foo/:controller/:action/:id
96
96
 
97
- r.add_slice(:<%= module_name %>, 'foo') # same as :path => 'foo'
97
+ add_slice(:<%= module_name %>, 'foo') # same as :path => 'foo'
98
98
 
99
99
  # example: /:lang/:controller/:action/:id (with :a param set)
100
100
 
101
- r.add_slice(:<%= module_name %>, :path => ':lang', :params => { :a => 'b' })
101
+ add_slice(:<%= module_name %>, :path => ':lang', :params => { :a => 'b' })
102
102
 
103
103
  # example: /:controller/:action/:id
104
104
 
105
- r.slice(:<%= module_name %>)
105
+ slice(:<%= module_name %>)
106
106
 
107
107
  Normally you should also run the following rake task:
108
108
 
@@ -1,11 +1,12 @@
1
1
  require 'rubygems'
2
2
  require 'rake/gempackagetask'
3
3
  require 'spec/rake/spectask'
4
- require 'merb-core/version'
5
- require 'merb-core/tasks/merb_rake_helper'
4
+
5
+ require 'merb-core'
6
+ require 'merb-core/tasks/merb'
6
7
  require 'merb-core/test/tasks/spectasks'
7
8
 
8
- NAME = "<%= base_name %>"
9
+ GEM_NAME = "<%= base_name %>"
9
10
  AUTHOR = "Your Name"
10
11
  EMAIL = "Your Email"
11
12
  HOMEPAGE = "http://merbivore.com/"
@@ -14,7 +15,7 @@ GEM_VERSION = "<%= Merb::VERSION %>"
14
15
 
15
16
  spec = Gem::Specification.new do |s|
16
17
  s.rubyforge_project = 'merb'
17
- s.name = NAME
18
+ s.name = GEM_NAME
18
19
  s.version = GEM_VERSION
19
20
  s.platform = Gem::Platform::RUBY
20
21
  s.has_rdoc = true
@@ -33,16 +34,34 @@ Rake::GemPackageTask.new(spec) do |pkg|
33
34
  pkg.gem_spec = spec
34
35
  end
35
36
 
36
- desc "Install <%= module_name %> as a gem"
37
- task :install => [:package] do
38
- sh %{#{sudo} gem install pkg/#{NAME}-#{GEM_VERSION} --no-update-sources}
37
+ desc "Install the gem"
38
+ task :install do
39
+ Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
39
40
  end
40
41
 
41
- namespace :jruby do
42
+ desc "Uninstall the gem"
43
+ task :uninstall do
44
+ Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
45
+ end
42
46
 
43
- desc "Run :package and install the resulting .gem with jruby"
44
- task :install => :package do
45
- sh %{#{sudo} jruby -S gem install #{install_home} pkg/#{NAME}-#{GEM_VERSION}.gem --no-rdoc --no-ri}
47
+ desc "Create a gemspec file"
48
+ task :gemspec do
49
+ File.open("#{GEM_NAME}.gemspec", "w") do |file|
50
+ file.puts spec.to_ruby
46
51
  end
47
-
48
- end
52
+ end
53
+
54
+ desc "Run all examples (or a specific spec with TASK=xxxx)"
55
+ Spec::Rake::SpecTask.new('spec') do |t|
56
+ t.spec_opts = ["-cfs"]
57
+ t.spec_files = begin
58
+ if ENV["TASK"]
59
+ ENV["TASK"].split(',').map { |task| "spec/**/#{task}_spec.rb" }
60
+ else
61
+ FileList['spec/**/*_spec.rb']
62
+ end
63
+ end
64
+ end
65
+
66
+ desc 'Default: run spec examples'
67
+ task :default => 'spec'
@@ -0,0 +1,43 @@
1
+ #
2
+ # ==== Standalone <%= module_name %> configuration
3
+ #
4
+ # This configuration/environment file is only loaded by bin/slice, which can be
5
+ # used during development of the slice. It has no effect on this slice being
6
+ # loaded in a host application. To run your slice in standalone mode, just
7
+ # run 'slice' from its directory. The 'slice' command is very similar to
8
+ # the 'merb' command, and takes all the same options, including -i to drop
9
+ # into an irb session for example.
10
+ #
11
+ # The usual Merb configuration directives and init.rb setup methods apply,
12
+ # including use_orm and before_app_loads/after_app_loads.
13
+ #
14
+ # If you need need different configurations for different environments you can
15
+ # even create the specific environment file in config/environments/ just like
16
+ # in a regular Merb application.
17
+ #
18
+ # In fact, a slice is no different from a normal # Merb application - it only
19
+ # differs by the fact that seamlessly integrates into a so called 'host'
20
+ # application, which in turn can override or finetune the slice implementation
21
+ # code and views.
22
+ #
23
+
24
+ Merb::Config.use do |c|
25
+
26
+ # Sets up a custom session id key which is used for the session persistence
27
+ # cookie name. If not specified, defaults to '_session_id'.
28
+ # c[:session_id_key] = '_session_id'
29
+
30
+ # The session_secret_key is only required for the cookie session store.
31
+ c[:session_secret_key] = '<%= SHA1.new(rand(100000000000).to_s).to_s %>'
32
+
33
+ # There are various options here, by default Merb comes with 'cookie',
34
+ # 'memory', 'memcache' or 'container'.
35
+ # You can of course use your favorite ORM instead:
36
+ # 'datamapper', 'sequel' or 'activerecord'.
37
+ c[:session_store] = 'cookie'
38
+
39
+ # When running a slice standalone, you're usually developing it,
40
+ # so enable template reloading by default.
41
+ c[:reload_templates] = true
42
+
43
+ end
@@ -53,7 +53,9 @@ if defined?(Merb::Plugins)
53
53
  # to avoid potential conflicts with global named routes.
54
54
  def self.setup_router(scope)
55
55
  # example of a named route
56
- scope.match('/index.:format').to(:controller => 'main', :action => 'index').name(:<%= symbol_name %>_index)
56
+ scope.match('/index(.:format)').to(:controller => 'main', :action => 'index').name(:index)
57
+ # the slice is mounted at /<%= base_name %> - note that it comes before default_routes
58
+ scope.match('/').to(:controller => 'main', :action => 'index').name(:home)
57
59
  end
58
60
 
59
61
  end
@@ -2,129 +2,18 @@ require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
3
  describe "<%= module_name %> (module)" do
4
4
 
5
- it "should have proper specs"
6
-
7
- # Feel free to remove the specs below
8
-
9
- before :all do
10
- Merb::Router.prepare { |r| r.add_slice(:<%= module_name %>) } if standalone?
11
- end
12
-
13
- after :all do
14
- Merb::Router.reset! if standalone?
15
- end
16
-
17
- it "should be registered in Merb::Slices.slices" do
18
- Merb::Slices.slices.should include(<%= module_name %>)
19
- end
20
-
21
- it "should be registered in Merb::Slices.paths" do
22
- Merb::Slices.paths[<%= module_name %>.name].should == current_slice_root
23
- end
24
-
25
- it "should have an :identifier property" do
26
- <%= module_name %>.identifier.should == "<%= base_name %>"
27
- end
28
-
29
- it "should have an :identifier_sym property" do
30
- <%= module_name %>.identifier_sym.should == :<%= symbol_name %>
31
- end
32
-
33
- it "should have a :root property" do
34
- <%= module_name %>.root.should == Merb::Slices.paths[<%= module_name %>.name]
35
- <%= module_name %>.root_path('app').should == current_slice_root / 'app'
36
- end
37
-
38
- it "should have a :file property" do
39
- <%= module_name %>.file.should == current_slice_root / 'lib' / '<%= base_name %>.rb'
40
- end
41
-
42
- it "should have metadata properties" do
43
- <%= module_name %>.description.should == "<%= module_name %> is a chunky Merb slice!"
44
- <%= module_name %>.version.should == "0.0.1"
45
- <%= module_name %>.author.should == "YOUR NAME"
46
- end
5
+ # Implement your <%= module_name %> specs here
47
6
 
48
- it "should have :routes and :named_routes properties" do
49
- <%= module_name %>.routes.should_not be_empty
50
- <%= module_name %>.named_routes[:<%= symbol_name %>_index].should be_kind_of(Merb::Router::Route)
51
- end
52
-
53
- it "should have an url helper method for slice-specific routes" do
54
- <%= module_name %>.url(:controller => 'main', :action => 'show', :format => 'html').should == "/<%= base_name %>/main/show.html"
55
- <%= module_name %>.url(:<%= symbol_name %>_index, :format => 'html').should == "/<%= base_name %>/index.html"
56
- end
57
-
58
- it "should have a config property (Hash)" do
59
- <%= module_name %>.config.should be_kind_of(Hash)
60
- end
61
-
62
- it "should have bracket accessors as shortcuts to the config" do
63
- <%= module_name %>[:foo] = 'bar'
64
- <%= module_name %>[:foo].should == 'bar'
65
- <%= module_name %>[:foo].should == <%= module_name %>.config[:foo]
66
- end
67
-
68
- it "should have a :layout config option set" do
69
- <%= module_name %>.config[:layout].should == :<%= symbol_name %>
70
- end
71
-
72
- it "should have a dir_for method" do
73
- app_path = <%= module_name %>.dir_for(:application)
74
- app_path.should == current_slice_root / 'app'
75
- [:view, :model, :controller, :helper, :mailer, :part].each do |type|
76
- <%= module_name %>.dir_for(type).should == app_path / "#{type}s"
77
- end
78
- public_path = <%= module_name %>.dir_for(:public)
79
- public_path.should == current_slice_root / 'public'
80
- [:stylesheet, :javascript, :image].each do |type|
81
- <%= module_name %>.dir_for(type).should == public_path / "#{type}s"
82
- end
83
- end
84
-
85
- it "should have a app_dir_for method" do
86
- root_path = <%= module_name %>.app_dir_for(:root)
87
- root_path.should == Merb.root / 'slices' / '<%= base_name %>'
88
- app_path = <%= module_name %>.app_dir_for(:application)
89
- app_path.should == root_path / 'app'
90
- [:view, :model, :controller, :helper, :mailer, :part].each do |type|
91
- <%= module_name %>.app_dir_for(type).should == app_path / "#{type}s"
92
- end
93
- public_path = <%= module_name %>.app_dir_for(:public)
94
- public_path.should == Merb.dir_for(:public) / 'slices' / '<%= base_name %>'
95
- [:stylesheet, :javascript, :image].each do |type|
96
- <%= module_name %>.app_dir_for(type).should == public_path / "#{type}s"
97
- end
98
- end
99
-
100
- it "should have a public_dir_for method" do
101
- public_path = <%= module_name %>.public_dir_for(:public)
102
- public_path.should == '/slices' / '<%= base_name %>'
103
- [:stylesheet, :javascript, :image].each do |type|
104
- <%= module_name %>.public_dir_for(type).should == public_path / "#{type}s"
105
- end
106
- end
107
-
108
- it "should have a public_path_for method" do
109
- public_path = <%= module_name %>.public_dir_for(:public)
110
- <%= module_name %>.public_path_for("path", "to", "file").should == public_path / "path" / "to" / "file"
111
- [:stylesheet, :javascript, :image].each do |type|
112
- <%= module_name %>.public_path_for(type, "path", "to", "file").should == public_path / "#{type}s" / "path" / "to" / "file"
113
- end
114
- end
115
-
116
- it "should have a app_path_for method" do
117
- <%= module_name %>.app_path_for("path", "to", "file").should == <%= module_name %>.app_dir_for(:root) / "path" / "to" / "file"
118
- <%= module_name %>.app_path_for(:controller, "path", "to", "file").should == <%= module_name %>.app_dir_for(:controller) / "path" / "to" / "file"
119
- end
7
+ it "should have proper specs"
120
8
 
121
- it "should have a slice_path_for method" do
122
- <%= module_name %>.slice_path_for("path", "to", "file").should == <%= module_name %>.dir_for(:root) / "path" / "to" / "file"
123
- <%= module_name %>.slice_path_for(:controller, "path", "to", "file").should == <%= module_name %>.dir_for(:controller) / "path" / "to" / "file"
124
- end
9
+ # To spec <%= module_name %> you need to hook it up to the router like this:
125
10
 
126
- it "should keep a list of path component types to use when copying files" do
127
- (<%= module_name %>.mirrored_components & <%= module_name %>.slice_paths.keys).length.should == <%= module_name %>.mirrored_components.length
128
- end
11
+ # before :all do
12
+ # Merb::Router.prepare { add_slice(:<%= module_name %>) } if standalone?
13
+ # end
14
+ #
15
+ # after :all do
16
+ # Merb::Router.reset! if standalone?
17
+ # end
129
18
 
130
19
  end