orange 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. data/lib/orange/application.rb +1 -1
  2. data/lib/orange/carton.rb +55 -27
  3. data/lib/orange/cartons/site_carton.rb +4 -1
  4. data/lib/orange/core.rb +10 -2
  5. data/lib/orange/magick.rb +11 -0
  6. data/lib/orange/middleware/access_control.rb +16 -7
  7. data/lib/orange/middleware/base.rb +40 -1
  8. data/lib/orange/middleware/flex_router.rb +59 -0
  9. data/lib/orange/middleware/route_context.rb +2 -2
  10. data/lib/orange/middleware/route_site.rb +1 -1
  11. data/lib/orange/middleware/show_exceptions.rb +3 -1
  12. data/lib/orange/middleware/site_load.rb +14 -1
  13. data/lib/orange/middleware/static.rb +0 -2
  14. data/lib/orange/middleware/template.rb +3 -1
  15. data/lib/orange/resources/admin_resource.rb +25 -0
  16. data/lib/orange/resources/mapper.rb +3 -0
  17. data/lib/orange/resources/model_resource.rb +15 -9
  18. data/lib/orange/resources/page_parts.rb +0 -7
  19. data/lib/orange/resources/parser.rb +5 -4
  20. data/lib/orange/resources/singleton_model_resource.rb +7 -0
  21. data/lib/orange/resources/sitemap_resource.rb +96 -0
  22. data/lib/orange/stack.rb +5 -5
  23. data/spec/{application_spec.rb → orange/application_spec.rb} +0 -0
  24. data/spec/orange/carton_spec.rb +136 -0
  25. data/spec/{core_spec.rb → orange/core_spec.rb} +10 -0
  26. data/spec/{magick_spec.rb → orange/magick_spec.rb} +11 -0
  27. data/spec/orange/middleware/access_control_spec.rb +3 -0
  28. data/spec/orange/middleware/base_spec.rb +37 -0
  29. data/spec/orange/middleware/database_spec.rb +3 -0
  30. data/spec/orange/middleware/globals_spec.rb +3 -0
  31. data/spec/orange/middleware/recapture_spec.rb +3 -0
  32. data/spec/orange/middleware/rerouter_spec.rb +3 -0
  33. data/spec/orange/middleware/restful_router_spec.rb +3 -0
  34. data/spec/orange/middleware/route_context_spec.rb +3 -0
  35. data/spec/orange/middleware/route_site_spec.rb +3 -0
  36. data/spec/orange/middleware/show_exceptions_spec.rb +3 -0
  37. data/spec/orange/middleware/site_load_spec.rb +26 -0
  38. data/spec/orange/middleware/static_file_spec.rb +3 -0
  39. data/spec/orange/middleware/static_spec.rb +3 -0
  40. data/spec/orange/middleware/template_spec.rb +3 -0
  41. data/spec/{mock → orange/mock}/mock_app.rb +0 -0
  42. data/spec/orange/mock/mock_carton.rb +43 -0
  43. data/spec/{mock → orange/mock}/mock_core.rb +0 -0
  44. data/spec/{mock → orange/mock}/mock_middleware.rb +8 -0
  45. data/spec/{mock → orange/mock}/mock_mixins.rb +0 -0
  46. data/spec/{mock → orange/mock}/mock_model_resource.rb +4 -0
  47. data/spec/{mock → orange/mock}/mock_pulp.rb +0 -0
  48. data/spec/{mock → orange/mock}/mock_resource.rb +0 -0
  49. data/spec/{mock → orange/mock}/mock_router.rb +0 -0
  50. data/spec/{orange_spec.rb → orange/orange_spec.rb} +0 -0
  51. data/spec/{packet_spec.rb → orange/packet_spec.rb} +0 -0
  52. data/spec/{resource_spec.rb → orange/resource_spec.rb} +0 -0
  53. data/spec/orange/resources/admin_resource_spec.rb +16 -0
  54. data/spec/{resources → orange/resources}/mapper_spec.rb +0 -0
  55. data/spec/{resources → orange/resources}/model_resource_spec.rb +104 -0
  56. data/spec/{resources → orange/resources}/parser_spec.rb +0 -0
  57. data/spec/{resources → orange/resources}/routable_resource_spec.rb +0 -0
  58. data/spec/orange/resources/singleton_model_resource_spec.rb +4 -0
  59. data/spec/{resources/flex_router_spec.rb → orange/resources/sitemap_resource_spec.rb} +1 -1
  60. data/spec/orange/spec_helper.rb +51 -0
  61. data/spec/{stack_spec.rb → orange/stack_spec.rb} +0 -0
  62. metadata +45 -40
  63. data/lib/orange/resources/flex_router.rb +0 -13
  64. data/spec/carton_spec.rb +0 -5
  65. data/spec/middleware/access_control_spec.rb +0 -0
  66. data/spec/middleware/base_spec.rb +0 -0
  67. data/spec/middleware/database_spec.rb +0 -0
  68. data/spec/middleware/globals_spec.rb +0 -0
  69. data/spec/middleware/recapture_spec.rb +0 -0
  70. data/spec/middleware/rerouter_spec.rb +0 -0
  71. data/spec/middleware/restful_router_spec.rb +0 -0
  72. data/spec/middleware/route_context_spec.rb +0 -0
  73. data/spec/middleware/route_site_spec.rb +0 -0
  74. data/spec/middleware/show_exceptions_spec.rb +0 -0
  75. data/spec/middleware/site_load_spec.rb +0 -0
  76. data/spec/middleware/static_file_spec.rb +0 -0
  77. data/spec/middleware/static_spec.rb +0 -0
  78. data/spec/middleware/template_spec.rb +0 -0
  79. data/spec/mock/mock_carton.rb +0 -15
  80. data/spec/spec_helper.rb +0 -20
@@ -43,7 +43,6 @@ module Orange::Middleware
43
43
  @urls = options[:urls] || ["/favicon.ico", "/assets/public"]
44
44
  @root = options[:root] || File.join(orange.app_dir, 'assets')
45
45
  @lib_urls = core.statics
46
-
47
46
  @file_server = Orange::Middleware::StaticFile.new(@root)
48
47
  end
49
48
 
@@ -51,7 +50,6 @@ module Orange::Middleware
51
50
  path = packet.env["PATH_INFO"]
52
51
  can_serve_lib = @lib_urls.select{ |url, server| path.index(url) == 0 }.first
53
52
  can_serve = @urls.any?{|url| path.index(url) == 0 }
54
-
55
53
  if can_serve_lib
56
54
  lib_url = can_serve_lib.first
57
55
  packet['file.root'] = can_serve_lib.last
@@ -24,8 +24,10 @@ module Orange::Middleware
24
24
  status, headers, content = pass packet
25
25
  if needs_wrapped?(packet)
26
26
  content = wrap(packet, content)
27
+ packet[:content] = content.first
27
28
  end
28
- [status, headers, content]
29
+ orange.fire(:wrapped, packet)
30
+ [status, headers, packet.content]
29
31
  end
30
32
 
31
33
  def needs_wrapped?(packet)
@@ -0,0 +1,25 @@
1
+ module Orange
2
+ # Admin resource is a resource to help in building administration
3
+ # panels.
4
+ class AdminResource < Resource
5
+ def afterLoad
6
+ @links = {}
7
+ end
8
+
9
+ def add_link(section, *args)
10
+ opts = args.extract_with_defaults(:position => 0)
11
+ @links[section] = [] unless @links.has_key?(section)
12
+ @links[section].insert(opts.delete(:position), opts)
13
+ @links[section].compact!
14
+ @links[section].uniq!
15
+ end
16
+
17
+ def links(packet)
18
+ @links.each do |k,section|
19
+ section.each {|link|
20
+ link[:href] = orange[:mapper].route_to(packet, link[:resource], link[:resource_args])
21
+ }
22
+ end
23
+ end
24
+ end
25
+ end
@@ -8,6 +8,7 @@ module Orange
8
8
  end
9
9
 
10
10
  def route_to(packet, resource, *args)
11
+ packet = DefaultHash.new unless packet
11
12
  context = packet['route.context', nil]
12
13
  site = packet['route.faked_site'] ? packet['route.site_url', nil] : nil
13
14
  args.unshift(resource)
@@ -44,6 +45,8 @@ module Orange
44
45
  # Parsing for orange urls or something
45
46
  when :orange
46
47
  packet.route_to(packet['reroute.to'])
48
+ else
49
+ packet['reroute.to']
47
50
  end
48
51
  end
49
52
 
@@ -72,7 +72,7 @@ module Orange
72
72
  opts = args.extract_options!.with_defaults({:path => ''})
73
73
  props = model_class.form_props(packet['route.context'])
74
74
  resource_id = opts[:id] || packet['route.resource_id'] || false
75
- all_opts = {:props => props, :resource => self.class.to_s, :model_name => @my_orange_name}.merge!(opts)
75
+ all_opts = {:props => props, :resource => self, :model_name => @my_orange_name}.merge!(opts)
76
76
  all_opts.with_defaults! :model => find_one(packet, mode, resource_id) unless is_list
77
77
  all_opts.with_defaults! :list => find_list(packet, mode) if is_list
78
78
  all_opts.with_defaults! find_extras(packet, mode)
@@ -119,12 +119,13 @@ module Orange
119
119
  packet.reroute(@my_orange_name, :orange)
120
120
  end
121
121
 
122
- # Deletes an object specified by packet['route.resource_id'], then reroutes to main
122
+ # Deletes an object specified by packet['route.resource_id'], then reroutes to main.
123
+ # The request must come in as a delete. Rack::MethodOverride can be used to do this.
123
124
  # @param [Orange::Packet] packet the packet being routed
124
125
  def delete(packet, *opts)
125
126
  if packet.request.delete?
126
127
  m = model_class.get(packet['route.resource_id'])
127
- m.destroy! if m
128
+ m.destroy if m
128
129
  end
129
130
  packet.reroute(@my_orange_name, :orange)
130
131
  end
@@ -136,7 +137,6 @@ module Orange
136
137
  m = model_class.get(packet['route.resource_id'])
137
138
  if m
138
139
  m.update(packet.request.params[@my_orange_name.to_s])
139
- else
140
140
  end
141
141
  end
142
142
  packet.reroute(@my_orange_name, :orange)
@@ -196,13 +196,14 @@ module Orange
196
196
  # @param [String, false] confirm text of the javascript confirm (false for none [default])
197
197
  # @param [optional, Array] args array of optional arguments, only opts[:method] defined
198
198
  # @option opts [String] method method name (Should be 'DELETE', 'PUT' or 'POST')
199
- def form_link(text, link, confirm = false, *args)
200
- opts = args.extract_options!
199
+ def form_link(text, link, confirm = false, opts = {})
200
+ text = "<img src='#{opts[:img]}' alt='#{text}' />" if opts[:img]
201
+ css = opts[:class]? opts[:class] : 'form_button_link'
201
202
  meth = (opts[:method]? "<input type='hidden' name='_method' value='#{opts[:method]}' />" : '')
202
203
  if confirm
203
- "<form action='#{link}' method='post' class='mini' onsubmit='return confirm(\"#{confirm}\")'><button class='link_button'><a href='#'>#{text}</a></button>#{meth}</form>"
204
+ "<form action='#{link}' method='post' class='mini' onsubmit='return confirm(\"#{confirm}\")'><button class='link_button'><a href='#' class='#{css}'>#{text}</a></button>#{meth}</form>"
204
205
  else
205
- "<form action='#{link}' method='post' class='mini'><button class='link_button'><a href='#'>#{text}</a></button>#{meth}</form>"
206
+ "<form action='#{link}' method='post' class='mini'><button class='link_button'><a href='#' class='#{css}'>#{text}</a></button>#{meth}</form>"
206
207
  end
207
208
  end
208
209
 
@@ -218,6 +219,7 @@ module Orange
218
219
  label = args[:label] || false
219
220
  show = args[:show] || false
220
221
  name = prop[:name]
222
+ human_readable_name = name.to_s.split('_').each{|w| w.capitalize!}.join(' ')
221
223
  unless show
222
224
  case prop[:type]
223
225
  when :title
@@ -226,10 +228,14 @@ module Orange
226
228
  ret = "<input type='text' value='#{val}' name='#{model_name}[#{name}]' />"
227
229
  when :fulltext
228
230
  ret = "<textarea name='#{model_name}[#{name}]'>#{val}</textarea>"
231
+ when :boolean
232
+ human_readable_name = human_readable_name + '?'
233
+ ret = "<input type='hidden' name='#{model_name}[#{name}]' value='0' /><input type='checkbox' name='#{model_name}[#{name}]' value='1' #{'checked="checked"' if (val && val != '')}/>"
229
234
  else
230
235
  ret = "<input type='text' value='#{val}' name='#{model_name}[#{name}]' />"
231
236
  end
232
- ret = "<label for=''>#{name}</label><br />" + ret if label
237
+ display_name = prop[:display_name] || human_readable_name
238
+ ret = "<label for=''>#{display_name}</label><br />" + ret if label
233
239
  else
234
240
  case prop[:type]
235
241
  when :title
@@ -18,13 +18,6 @@ module Orange
18
18
  # Feels like part should be plural, no?
19
19
  def parts; part; end
20
20
 
21
- def admin_sidebar_link(section, *args)
22
- args = args.extract_options!.with_defaults(:position => 0)
23
- sidebar = part[:admin_sidebar, {}]
24
- sidebar[section] = [] unless sidebar.has_key?(section)
25
- sidebar[section].insert(args[:position], {:href => args[:link], :text => args[:text]})
26
- part[:admin_sidebar] = sidebar
27
- end
28
21
 
29
22
  def add_css(file, opts = {})
30
23
  ie = opts[:ie] || false
@@ -18,20 +18,21 @@ module Orange
18
18
  def haml(file, packet, *vars, &block)
19
19
  opts = vars.extract_options!
20
20
  temp = opts.delete(:template)
21
- resource = (opts[:resource] || '').downcase
21
+ opts[:resource_name] = opts[:resource].orange_name.to_s if
22
+ opts[:resource] && opts[:resource].respond_to?(:orange_name)
23
+ resource = (opts[:resource_name] || '').downcase
22
24
  opts.merge :orange => orange
23
25
 
24
26
  templates_dir = File.join(orange.core_dir, 'templates')
25
27
  views_dir = File.join(orange.core_dir, 'views')
26
- default_dir = File.join(views_dir, 'default_resource')
27
-
28
28
  string = false
29
29
  string ||= read_if_exists('templates', file) if temp
30
30
  string ||= read_if_exists(templates_dir, file) if temp
31
31
  string ||= read_if_exists('views', resource, file) if resource
32
32
  string ||= read_if_exists('views', file)
33
- string ||= read_if_exists(views_dir, file)
33
+ string ||= read_if_exists(views_dir, resource, file) if resource
34
34
  string ||= read_if_exists(views_dir, 'default_resource', file)
35
+ string ||= read_if_exists(views_dir, file)
35
36
  raise LoadError, "Couldn't find haml file '#{file}" unless string
36
37
 
37
38
  haml_engine = Haml::Engine.new(string)
@@ -0,0 +1,7 @@
1
+ module Orange
2
+ # Singleton Model Resource acts similar to model resource, but doesn't have
3
+ # a list view, and instead only shows a single object
4
+ class SingletonModelResource < ModelResource
5
+
6
+ end
7
+ end
@@ -0,0 +1,96 @@
1
+ require 'orange/core'
2
+ require 'orange/resources/model_resource'
3
+ require 'orange/cartons/site_carton'
4
+ require 'dm-is-awesome_set'
5
+ module Orange
6
+ class Route < SiteCarton
7
+ id
8
+ admin do
9
+ text :slug
10
+ text :link_text
11
+ boolean :show_in_nav, :default => false, :display_name => 'Show?'
12
+ end
13
+ orange do
14
+ string :resource
15
+ string :resource_id
16
+ end
17
+ include DataMapper::Transaction::Resource # Make sure Transactions are included
18
+ is :awesome_set, :scope => [:orange_site_id]
19
+
20
+ end
21
+
22
+ class SitemapResource < ModelResource
23
+ use Orange::Route
24
+ def afterLoad
25
+ orange[:admin, true].add_link('Content', :resource => @my_orange_name, :text => 'Sitemap')
26
+ end
27
+
28
+ # Creates a new model object and saves it (if a post), then reroutes to the main page
29
+ # @param [Orange::Packet] packet the packet being routed
30
+ def new(packet, *opts)
31
+ if packet.request.post?
32
+ params = packet.request.params[@my_orange_name.to_s]
33
+ params.merge!(:orange_site_id => packet['site'].id)
34
+ a = model_class.new(params)
35
+ a.move(:into => home(packet))
36
+ end
37
+ packet.reroute(@my_orange_name, :orange)
38
+ end
39
+
40
+ def higher(packet, opts = {})
41
+ if packet.request.post?
42
+ me = find_one(packet, :higher, packet['route.resource_id'])
43
+ me.move(:higher) if me
44
+ end
45
+ packet.reroute(@my_orange_name, :orange)
46
+ end
47
+
48
+ def lower(packet, opts = {})
49
+ if packet.request.post?
50
+ me = find_one(packet, :lower, packet['route.resource_id'])
51
+ me.move(:lower) if me
52
+ end
53
+ packet.reroute(@my_orange_name, :orange)
54
+ end
55
+
56
+ def outdent(packet, opts = {})
57
+ if packet.request.post?
58
+ me = find_one(packet, :outdent, packet['route.resource_id'])
59
+ me.move(:outdent) if me
60
+ end
61
+ packet.reroute(@my_orange_name, :orange)
62
+ end
63
+
64
+ def indent(packet, opts = {})
65
+ if packet.request.post?
66
+ me = find_one(packet, :indent, packet['route.resource_id'])
67
+ me.move(:indent) if me
68
+ end
69
+ packet.reroute(@my_orange_name, :orange)
70
+ end
71
+
72
+ def top_nav
73
+
74
+ end
75
+
76
+ def home(packet)
77
+ site_id = packet['site'].id
78
+ home_for_site(site_id) || create_home_for_site(site_id)
79
+ end
80
+
81
+ def home_for_site(site_id)
82
+ model_class.first(:slug => '_index_', :orange_site_id => site_id, :order => :lft.asc)
83
+ end
84
+
85
+ def create_home_for_site(site_id)
86
+ home = model_class.new({:orange_site_id => site_id, :slug => '_index_'})
87
+ home.move(:root)
88
+ home.save
89
+ home
90
+ end
91
+
92
+ def find_list(packet, mode)
93
+ Orange::Route.all(:order => :lft) || []
94
+ end
95
+ end
96
+ end
@@ -24,7 +24,7 @@ module Orange
24
24
  # other stacks that can be used.
25
25
  #
26
26
  # @param [Orange::Application] app_class the class of the main application
27
- # @param [prebuilt] prebuilt the optional prebuilt stack, if one isn't passed as block
27
+ # @param [Symbol] prebuilt the optional prebuilt stack, if one isn't passed as block
28
28
  def initialize(app_class = nil, prebuilt = :none, &block)
29
29
  @build = Rack::Builder.new
30
30
  @core = Orange::Core.new
@@ -114,13 +114,13 @@ module Orange
114
114
  #
115
115
  def prerouting(*args)
116
116
  opts = args.extract_options!
117
- stack Orange::Middleware::Rerouter, opts
118
- stack Orange::Middleware::Static, opts
117
+ stack Orange::Middleware::Rerouter, opts.dup
118
+ stack Orange::Middleware::Static, opts.dup
119
119
  use Rack::AbstractFormat unless opts[:no_abstract_format]
120
120
  # Must be used before non-destructive route altering done by Orange,
121
121
  # since all orange stuff is non-destructive
122
- stack Orange::Middleware::RouteSite, opts
123
- stack Orange::Middleware::RouteContext, opts
122
+ stack Orange::Middleware::RouteSite, opts.dup
123
+ stack Orange::Middleware::RouteContext, opts.dup
124
124
  end
125
125
 
126
126
  # A shortcut for enabling restful routing via Orange::Middleware::RestfulRouter
@@ -0,0 +1,136 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Orange::Carton do
4
+ it "should call property with :id, Serial on #self.id" do
5
+ MockCartonBlank.should_receive(:property).with(:id, DataMapper::Types::Serial)
6
+ MockCartonBlank.id
7
+ end
8
+
9
+ it "should call self.init after calling id" do
10
+ MockCartonBlankTwo.should_receive(:init)
11
+ MockCartonBlankTwo.id
12
+ end
13
+
14
+ it "should give form properties" do
15
+ MockCarton.form_props(:live).length.should >= 1
16
+ MockCarton.form_props(:admin).length.should >= 2
17
+ MockCarton.form_props(:orange).length.should >= 3
18
+ MockCarton.form_props(:banana).should have(0).items
19
+ end
20
+
21
+ it "should call instance eval on admin block" do
22
+ MockCartonBlank.should_receive(:instance_eval)
23
+ MockCartonBlank.admin {}
24
+ end
25
+
26
+ it "should call instance eval on orange block" do
27
+ MockCartonBlank.should_receive(:instance_eval)
28
+ MockCartonBlank.orange {}
29
+ end
30
+
31
+ it "should call instance eval on front block" do
32
+ MockCartonBlank.should_receive(:instance_eval)
33
+ MockCartonBlank.front {}
34
+ end
35
+
36
+ it "should change props when calling front_property" do
37
+ lambda {
38
+ MockCarton.front_property :foo, String
39
+ }.should change(MockCarton, :form_props)
40
+
41
+ end
42
+
43
+ it "should change admin props when calling admin_property (but not front props)" do
44
+ old_props = MockCarton.form_props(:admin)
45
+ lambda {
46
+ MockCarton.admin_property :foo, String
47
+ }.should_not change(MockCarton, :form_props)
48
+ old_props.should_not == MockCarton.form_props(:admin)
49
+ end
50
+
51
+ it "should change orange props when calling orange_property (but not front/admin props)" do
52
+ admin_props = MockCarton.form_props(:admin)
53
+ old_props = MockCarton.form_props(:orange)
54
+ lambda {
55
+ MockCarton.orange_property :foo, String
56
+ }.should_not change(MockCarton, :form_props)
57
+ admin_props.should == MockCarton.form_props(:admin)
58
+ old_props.should_not == MockCarton.form_props(:orange)
59
+ end
60
+
61
+ it "should change the levels var when using front block" do
62
+ MockCartonBlank.should_receive(:test_levels){|me| me.levels.should include(:live)}
63
+ MockCartonBlank.front{ test_levels(self) }
64
+ MockCartonBlank.levels.should == false
65
+ end
66
+
67
+ it "should change the levels var when using admin block" do
68
+ MockCartonBlank.should_receive(:test_levels){|me|
69
+ me.levels.should_not include(:front)
70
+ me.levels.should include(:admin)
71
+ }
72
+ MockCartonBlank.admin{ test_levels(self) }
73
+ MockCartonBlank.levels.should == false
74
+ end
75
+
76
+ it "should change the levels var when using orange block" do
77
+ MockCartonBlank.should_receive(:test_levels){|me|
78
+ me.levels.should_not include(:front)
79
+ me.levels.should_not include(:admin)
80
+ me.levels.should include(:orange)
81
+ }
82
+ MockCartonBlank.orange{ test_levels(self) }
83
+ MockCartonBlank.levels.should == false
84
+ end
85
+
86
+ it "should have a front property after calling #front" do
87
+ front = MockCarton.scaffold_properties.select{|i| i[:name] == :front}
88
+ front.should have_at_least(1).items
89
+ front.first[:levels].should include(:live)
90
+ end
91
+
92
+ it "should have an admin property after calling #admin" do
93
+ front = MockCarton.scaffold_properties.select{|i| i[:name] == :admin}
94
+ front.should have_at_least(1).items
95
+ front.first[:levels].should_not include(:live)
96
+ front.first[:levels].should include(:admin)
97
+ end
98
+
99
+ it "should have an orange property after calling #orange" do
100
+ front = MockCarton.scaffold_properties.select{|i| i[:name] == :orange}
101
+ front.should have_at_least(1).items
102
+ front.first[:levels].should_not include(:live)
103
+ front.first[:levels].should_not include(:admin)
104
+ front.first[:levels].should include(:orange)
105
+ end
106
+
107
+ it "should call property on title" do
108
+ MockCarton.should_receive(:property).with(an_instance_of(Symbol), String, anything())
109
+ MockCarton.title(:wibble)
110
+ end
111
+
112
+ it "should call property on text" do
113
+ MockCarton.should_receive(:property).with(an_instance_of(Symbol), String, anything())
114
+ MockCarton.text(:wobble)
115
+ end
116
+
117
+ it "should call property on string" do
118
+ MockCarton.should_receive(:property).with(an_instance_of(Symbol), String, anything())
119
+ MockCarton.string(:wubble)
120
+ end
121
+
122
+ it "should call property on fulltext" do
123
+ MockCarton.should_receive(:property).with(an_instance_of(Symbol), DataMapper::Types::Text, anything())
124
+ MockCarton.fulltext(:cudge)
125
+ end
126
+
127
+ it "should define a constant (resource class)" do
128
+ lambda{
129
+ MockCartonBlankTwo_Resource.nil?
130
+ }.should raise_error(NameError)
131
+ MockCartonBlankTwo.as_resource
132
+ lambda{
133
+ MockCartonBlankTwo_Resource.nil?
134
+ }.should_not raise_error
135
+ end
136
+ end