kelredd-useful 0.2.1 → 0.2.2

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.
data/README.rdoc CHANGED
@@ -4,9 +4,9 @@
4
4
 
5
5
  A collection of useful helpers for various ruby things. Includes
6
6
  ruby extensions that play nice with activesupport, helpers for
7
- sinatra/rails/activerecord/erb, etc...
7
+ rails/activerecord/erb, etc...
8
8
 
9
- You probably never want them all, all the time, but just require in
9
+ This is my tool belt. You probably never want them all, all the time, but just require in
10
10
  the pieces you are interested in.
11
11
 
12
12
  == Installation
@@ -22,8 +22,9 @@ the pieces you are interested in.
22
22
 
23
23
  require 'rubygems'
24
24
  require 'useful/ruby_extensions'
25
- require 'useful/sinatra_helpers'
26
25
 
26
+ # require in the code you need when you need it
27
+
27
28
  == License
28
29
 
29
30
  Copyright (c) 2009 Kelly Redding
@@ -1,58 +1,3 @@
1
- require 'useful/ruby_extensions/string' unless String.new.respond_to?(:constantize)
2
-
3
- module Useful; end
4
- module Useful::ShouldaMacros; end
5
-
6
- module Useful::ShouldaMacros::TestUnit
7
-
8
- protected
9
-
10
- # Ripped from Shoulda::ActiveRecord::Macros
11
- def should_have_instance_methods(*methods)
12
- get_options!(methods)
13
- klass = described_type
14
- methods.each do |method|
15
- should "respond to instance method ##{method}" do
16
- assert_respond_to((klass.new rescue subject), method, "#{klass.name} does not have instance method #{method}")
17
- end
18
- end
19
- end unless Test::Unit::TestCase.method_defined? :should_have_instance_methods
20
-
21
- # Ripped from Shoulda::ActiveRecord::Macros
22
- def should_have_class_methods(*methods)
23
- get_options!(methods)
24
- klass = described_type
25
- methods.each do |method|
26
- should "respond to class method ##{method}" do
27
- assert_respond_to klass, method, "#{klass.name} does not have class method #{method}"
28
- end
29
- end
30
- end unless Test::Unit::TestCase.method_defined? :should_have_class_methods
31
-
32
- def should_have_readers(*readers)
33
- get_options!(readers)
34
- klass = described_type
35
- readers.each do |reader|
36
- should_have_instance_methods reader
37
- end
38
- end unless Test::Unit::TestCase.method_defined? :should_have_readers
39
-
40
- def should_have_writers(*writers)
41
- get_options!(writers)
42
- klass = described_type
43
- writers.each do |writer|
44
- should_have_instance_methods "#{writer}="
45
- end
46
- end unless Test::Unit::TestCase.method_defined? :should_have_writers
47
-
48
- def should_have_accessors(*accessors)
49
- get_options!(accessors)
50
- klass = described_type
51
- accessors.each do |accessor|
52
- should_have_instance_methods accessor, "#{accessor}="
53
- end
54
- end unless Test::Unit::TestCase.method_defined? :should_have_accessors
55
-
1
+ Dir[File.join(File.dirname(__FILE__), "test_unit" ,"*.rb")].each do |file|
2
+ require "useful/shoulda_macros/test_unit/#{File.basename(file, ".rb")}"
56
3
  end
57
-
58
- Test::Unit::TestCase.extend(Useful::ShouldaMacros::TestUnit) if defined? Test::Unit::TestCase
@@ -0,0 +1,59 @@
1
+ require 'useful/ruby_extensions/string' unless String.new.respond_to?(:constantize)
2
+
3
+ module Useful; end
4
+ module Useful::ShouldaMacros; end
5
+ module Useful::ShouldaMacros::TestUnit; end
6
+
7
+ module Useful::ShouldaMacros::TestUnit::Classes
8
+
9
+ protected
10
+
11
+ # Ripped from Shoulda::ActiveRecord::Macros
12
+ def should_have_instance_methods(*methods)
13
+ get_options!(methods)
14
+ klass = described_type
15
+ methods.each do |method|
16
+ should "respond to instance method ##{method}" do
17
+ assert_respond_to((klass.new rescue subject), method, "#{klass.name} does not have instance method #{method}")
18
+ end
19
+ end
20
+ end unless Test::Unit::TestCase.method_defined? :should_have_instance_methods
21
+
22
+ # Ripped from Shoulda::ActiveRecord::Macros
23
+ def should_have_class_methods(*methods)
24
+ get_options!(methods)
25
+ klass = described_type
26
+ methods.each do |method|
27
+ should "respond to class method ##{method}" do
28
+ assert_respond_to klass, method, "#{klass.name} does not have class method #{method}"
29
+ end
30
+ end
31
+ end unless Test::Unit::TestCase.method_defined? :should_have_class_methods
32
+
33
+ def should_have_readers(*readers)
34
+ get_options!(readers)
35
+ klass = described_type
36
+ readers.each do |reader|
37
+ should_have_instance_methods reader
38
+ end
39
+ end unless Test::Unit::TestCase.method_defined? :should_have_readers
40
+
41
+ def should_have_writers(*writers)
42
+ get_options!(writers)
43
+ klass = described_type
44
+ writers.each do |writer|
45
+ should_have_instance_methods "#{writer}="
46
+ end
47
+ end unless Test::Unit::TestCase.method_defined? :should_have_writers
48
+
49
+ def should_have_accessors(*accessors)
50
+ get_options!(accessors)
51
+ klass = described_type
52
+ accessors.each do |accessor|
53
+ should_have_instance_methods accessor, "#{accessor}="
54
+ end
55
+ end unless Test::Unit::TestCase.method_defined? :should_have_accessors
56
+
57
+ end
58
+
59
+ Test::Unit::TestCase.extend(Useful::ShouldaMacros::TestUnit::Classes) if defined? Test::Unit::TestCase
@@ -0,0 +1,31 @@
1
+ require 'useful/ruby_extensions/string' unless String.new.respond_to?(:constantize)
2
+
3
+ module Useful; end
4
+ module Useful::ShouldaMacros; end
5
+ module Useful::ShouldaMacros::TestUnit; end
6
+
7
+ module Useful::ShouldaMacros::TestUnit::Files
8
+
9
+ protected
10
+
11
+ def should_have_files(*files)
12
+ the_files = files.flatten
13
+ if the_files.empty?
14
+ should "have @root_path" do
15
+ assert @root_path, "the variable @root_path is not defined"
16
+ assert File.exists?(@root_path), "'#{@root_path}' does not exist"
17
+ end
18
+ else
19
+ the_files.each do |file|
20
+ should "have the file '#{file}' in @root_path" do
21
+ assert @root_path, "the variable @root_path is not defined"
22
+ assert File.exists?(File.join(@root_path, file)), "'#{file}' does not exist in '#{@root_path}'"
23
+ end
24
+ end
25
+ end
26
+ end
27
+ alias_method :should_have_directories, :should_have_files
28
+
29
+ end
30
+
31
+ Test::Unit::TestCase.extend(Useful::ShouldaMacros::TestUnit::Files) if defined? Test::Unit::TestCase
@@ -3,7 +3,7 @@ module Useful
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 2
6
- TINY = 1
6
+ TINY = 2
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-useful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
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-11-07 00:00:00 -06:00
12
+ date: 2009-11-11 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -63,6 +63,8 @@ files:
63
63
  - lib/useful/ruby_extensions/true_class.rb
64
64
  - lib/useful/ruby_extensions.rb
65
65
  - lib/useful/ruby_extensions_with_activesupport.rb
66
+ - lib/useful/shoulda_macros/test_unit/classes.rb
67
+ - lib/useful/shoulda_macros/test_unit/files.rb
66
68
  - lib/useful/shoulda_macros/test_unit.rb
67
69
  - lib/useful/version.rb
68
70
  - lib/useful.rb