kelredd-resourceful 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,6 +9,9 @@ module Resourceful
9
9
  end
10
10
 
11
11
  @@namespaces = [""]
12
+ def self.namespaces
13
+ @@namespaces.dup
14
+ end
12
15
  def self.add_namespace(ns)
13
16
  @@namespaces.unshift(ns)
14
17
  end
@@ -1,13 +1,61 @@
1
+ require 'resourceful/model/base'
2
+ require 'resourceful/extensions'
3
+
1
4
  module Resourceful
2
5
  module Shoulda
3
6
  module TestUnit
4
7
 
5
8
  def should_have_resourceful_attribute(name, opts={})
6
- clean_name = name.to_s.gsub(/\W/, '')
9
+ clean_name = ::Resourceful::Model::Base.cleanup_name(name)
7
10
  should_have_instance_methods clean_name, "#{clean_name}=", "_#{clean_name}"
8
11
  # TODO: Validate this attribute is of type opts[:type] if provided
9
12
  end unless Test::Unit::TestCase.method_defined? :should_have_resourceful_attribute
10
13
 
14
+ def should_have_namespace(ns)
15
+ klass = described_type
16
+ should "have the namespace '#{ns}' configured" do
17
+ assert klass.namespaces.include?(ns), "#{klass} does not have the '#{ns}' namespace"
18
+ end
19
+ end
20
+
21
+ def should_be_findable(index)
22
+ should_have_class_methods :find
23
+ klass = described_type
24
+ should "have '#{index}' as a findable index" do
25
+ assert_equal index, klass.findable_index, "#{klass} findable index is not '#{index}'"
26
+ end
27
+ end
28
+
29
+ def should_resourcefully_belong_to(name, opts={})
30
+ clean_name = ::Resourceful::Model::Base.cleanup_name(name)
31
+ should_have_instance_methods clean_name
32
+ # TODO: Validation :class config present, validation that a namespaced klass is defined
33
+ # TODO: Validate it returns something of that klass
34
+ end
35
+
36
+ def should_resourcefully_have_many(name, opts={})
37
+ clean_name = ::Resourceful::Model::Base.cleanup_name(name)
38
+ should_have_instance_methods clean_name
39
+ # TODO: Validation :class config present, validation that a namespaced klass is defined
40
+ # TODO: Validate returns an array of items of that klass
41
+ end
42
+
43
+ def should_resourcefully_contain_one(name, opts={})
44
+ clean_name = ::Resourceful::Model::Base.cleanup_name(name)
45
+ should_have_instance_methods clean_name
46
+ # TODO: Validation :class config present, validation that a namespaced klass is defined
47
+ # TODO: Validate it returns something of that klass
48
+ end
49
+
50
+ def should_resourcefully_contain_many(name, opts={})
51
+ clean_name = ::Resourceful::Model::Base.cleanup_name(name)
52
+ should_have_instance_methods clean_name
53
+ # TODO: Validation :class config present, validation that a namespaced klass is defined
54
+ # TODO: Validate returns an array of items of that klass
55
+ end
56
+
57
+ protected
58
+
11
59
  # Ripped from Shoulda::ActiveRecord::Macros
12
60
  def should_have_instance_methods(*methods)
13
61
  get_options!(methods)
@@ -19,6 +67,17 @@ module Resourceful
19
67
  end
20
68
  end unless Test::Unit::TestCase.method_defined? :should_have_instance_methods
21
69
 
70
+ # Ripped from Shoulda::ActiveRecord::Macros
71
+ def should_have_class_methods(*methods)
72
+ get_options!(methods)
73
+ klass = described_type
74
+ methods.each do |method|
75
+ should "respond to class method ##{method}" do
76
+ assert_respond_to klass, method, "#{klass.name} does not have class method #{method}"
77
+ end
78
+ end
79
+ end
80
+
22
81
  end
23
82
  end
24
83
  end
@@ -3,7 +3,7 @@ module Resourceful
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 7
6
- TINY = 0
6
+ TINY = 1
7
7
 
8
8
  def self.to_s # :nodoc:
9
9
  [MAJOR, MINOR, TINY].join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kelredd-resourceful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Redding
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-10 00:00:00 -07:00
12
+ date: 2009-09-11 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -110,7 +110,6 @@ files:
110
110
  - lib/resourceful.rb
111
111
  has_rdoc: false
112
112
  homepage: ""
113
- licenses:
114
113
  post_install_message:
115
114
  rdoc_options:
116
115
  - --main
@@ -132,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
131
  requirements: []
133
132
 
134
133
  rubyforge_project:
135
- rubygems_version: 1.3.5
134
+ rubygems_version: 1.2.0
136
135
  signing_key:
137
136
  specification_version: 3
138
137
  summary: A ruby gem to abstract web resource handling.