test-belt 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,8 +6,7 @@ module TestBelt::ShouldaMacros::Classes
6
6
 
7
7
  # Ripped from Shoulda::ActiveRecord::Macros
8
8
  def should_have_class_methods(*methods)
9
- get_options!(methods)
10
- methods.each do |method|
9
+ handle_methods(methods) do |method|
11
10
  should "respond to class method ##{method}" do
12
11
  klass = construct_subject.class
13
12
  assert_respond_to klass, method, "#{klass.name} does not have class method #{method}"
@@ -16,12 +15,20 @@ module TestBelt::ShouldaMacros::Classes
16
15
  end
17
16
  alias_method :should_have_class_method, :should_have_class_methods
18
17
  protected :should_have_class_methods, :should_have_class_method
18
+ def skip_should_have_class_methods(*methods)
19
+ handle_methods(methods) do |method|
20
+ should "(skip) respond to class method ##{method}" do
21
+ skip
22
+ end
23
+ end
24
+ end
25
+ alias_method :skip_should_have_class_method, :skip_should_have_class_methods
26
+ protected :skip_should_have_class_methods, :skip_should_have_class_method
19
27
 
20
28
 
21
29
  # Ripped from Shoulda::ActiveRecord::Macros
22
30
  def should_have_instance_methods(*methods)
23
- get_options!(methods)
24
- methods.each do |method|
31
+ handle_methods(methods) do |method|
25
32
  should "respond to instance method ##{method}" do
26
33
  the_subject = construct_subject
27
34
  assert_respond_to(the_subject, method, "#{the_subject.class.name} does not have instance method #{method}")
@@ -30,6 +37,15 @@ module TestBelt::ShouldaMacros::Classes
30
37
  end
31
38
  alias_method :should_have_instance_method, :should_have_instance_methods
32
39
  protected :should_have_instance_methods, :should_have_instance_method
40
+ def skip_should_have_instance_methods(*methods)
41
+ handle_methods(methods) do |method|
42
+ should "(skip) respond to instance method ##{method}" do
43
+ skip
44
+ end
45
+ end
46
+ end
47
+ alias_method :skip_should_have_instance_method, :skip_should_have_instance_methods
48
+ protected :skip_should_have_instance_methods, :skip_should_have_instance_method
33
49
 
34
50
 
35
51
  def should_have_readers(*readers)
@@ -38,6 +54,12 @@ module TestBelt::ShouldaMacros::Classes
38
54
  end
39
55
  alias_method :should_have_reader, :should_have_readers
40
56
  protected :should_have_readers, :should_have_reader
57
+ def skip_should_have_readers(*readers)
58
+ get_options!(readers)
59
+ skip_should_have_instance_methods *readers
60
+ end
61
+ alias_method :skip_should_have_reader, :skip_should_have_readers
62
+ protected :skip_should_have_readers, :skip_should_have_reader
41
63
 
42
64
 
43
65
  def should_have_writers(*writers)
@@ -46,6 +68,12 @@ module TestBelt::ShouldaMacros::Classes
46
68
  end
47
69
  alias_method :should_have_writer, :should_have_writers
48
70
  protected :should_have_writers, :should_have_writer
71
+ def skip_should_have_writers(*writers)
72
+ get_options!(writers)
73
+ skip_should_have_instance_methods *(writers.collect{|w| "#{w}="})
74
+ end
75
+ alias_method :skip_should_have_writer, :skip_should_have_writers
76
+ protected :skip_should_have_writers, :skip_should_have_writer
49
77
 
50
78
 
51
79
  def should_have_accessors(*accessors)
@@ -55,6 +83,22 @@ module TestBelt::ShouldaMacros::Classes
55
83
  end
56
84
  alias_method :should_have_accessor, :should_have_accessors
57
85
  protected :should_have_accessors, :should_have_accessor
86
+ def skip_should_have_accessors(*accessors)
87
+ get_options!(accessors)
88
+ skip_should_have_instance_methods *accessors
89
+ skip_should_have_instance_methods *(accessors.collect{|a| "#{a}="})
90
+ end
91
+ alias_method :skip_should_have_accessor, :skip_should_have_accessors
92
+ protected :skip_should_have_accessors, :skip_should_have_accessor
93
+
94
+
95
+
96
+
97
+ def handle_methods(methods)
98
+ get_options!(methods)
99
+ methods.each {|m| yield m if block_given?}
100
+ end
101
+ private :handle_methods
58
102
 
59
103
  end
60
104
 
@@ -21,10 +21,28 @@ module TestBelt::ShouldaMacros::Files
21
21
  end
22
22
  end
23
23
  protected :should_have_files
24
+ def skip_should_have_files(*files)
25
+ the_files = files.flatten
26
+ if the_files.empty?
27
+ should "(skip) have @root_path" do
28
+ skip
29
+ end
30
+ else
31
+ the_files.each do |file|
32
+ should "(skip) have the file '#{file}' in @root_path" do
33
+ skip
34
+ end
35
+ end
36
+ end
37
+ end
38
+ protected :skip_should_have_files
24
39
 
25
40
  alias_method :should_have_file, :should_have_files
26
41
  alias_method :should_have_directories, :should_have_files
27
42
  alias_method :should_have_directory, :should_have_files
43
+ alias_method :skip_should_have_file, :skip_should_have_files
44
+ alias_method :skip_should_have_directories, :skip_should_have_files
45
+ alias_method :skip_should_have_directory, :skip_should_have_files
28
46
 
29
47
  end
30
48
 
@@ -1,3 +1,3 @@
1
1
  module TestBelt
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -6,6 +6,32 @@ class ClassesTest < Test::Unit::TestCase
6
6
  context "TestBelt Shoulda Macros for classes" do
7
7
  subject { Thing.new }
8
8
 
9
+ # should provide these macros
10
+ should "provide a set of macros" do
11
+ assert self.class.respond_to?(:should_have_instance_methods), "no :should_have_instance_methods macro"
12
+ assert self.class.respond_to?(:should_have_instance_method), "no :should_have_instance_method macro"
13
+ assert self.class.respond_to?(:should_have_class_methods), "no :should_have_class_methods macro"
14
+ assert self.class.respond_to?(:should_have_class_method), "no :should_have_class_method macro"
15
+ assert self.class.respond_to?(:should_have_readers), "no :should_have_readers macro"
16
+ assert self.class.respond_to?(:should_have_reader), "no :should_have_reader macro"
17
+ assert self.class.respond_to?(:should_have_writers), "no :should_have_writers macro"
18
+ assert self.class.respond_to?(:should_have_writer), "no :should_have_writer macro"
19
+ assert self.class.respond_to?(:should_have_accessors), "no :should_have_accessors macro"
20
+ assert self.class.respond_to?(:should_have_accessor), "no :should_have_accessor macro"
21
+
22
+ assert self.class.respond_to?(:skip_should_have_instance_methods), "no :skip_should_have_instance_methods macro"
23
+ assert self.class.respond_to?(:skip_should_have_instance_method), "no :skip_should_have_instance_method macro"
24
+ assert self.class.respond_to?(:skip_should_have_class_methods), "no :skip_should_have_class_methods macro"
25
+ assert self.class.respond_to?(:skip_should_have_class_method), "no :skip_should_have_class_method macro"
26
+ assert self.class.respond_to?(:skip_should_have_readers), "no :skip_should_have_readers macro"
27
+ assert self.class.respond_to?(:skip_should_have_reader), "no :skip_should_have_reader macro"
28
+ assert self.class.respond_to?(:skip_should_have_writers), "no :skip_should_have_writers macro"
29
+ assert self.class.respond_to?(:skip_should_have_writer), "no :skip_should_have_writer macro"
30
+ assert self.class.respond_to?(:skip_should_have_accessors), "no :skip_should_have_accessors macro"
31
+ assert self.class.respond_to?(:skip_should_have_accessor), "no :skip_should_have_accessor macro"
32
+ end
33
+
34
+
9
35
  should_have_instance_method :an_instance_meth
10
36
  should_have_instance_methods :instance1, :instance2
11
37
  should_have_class_method :a_class_meth
@@ -16,6 +42,17 @@ class ClassesTest < Test::Unit::TestCase
16
42
  should_have_writer :writer3
17
43
  should_have_accessors :accessor1, :accessor2
18
44
  should_have_accessor :accessor3
45
+
46
+ skip_should_have_instance_method :an_instance_meth
47
+ skip_should_have_instance_methods :instance1, :instance2
48
+ skip_should_have_class_method :a_class_meth
49
+ skip_should_have_class_methods :class1, :class2
50
+ skip_should_have_readers :reader1, :reader2
51
+ skip_should_have_reader :reader3
52
+ skip_should_have_writers :writer1, :writer2
53
+ skip_should_have_writer :writer3
54
+ skip_should_have_accessors :accessor1, :accessor2
55
+ skip_should_have_accessor :accessor3
19
56
  end
20
57
 
21
58
  end
@@ -16,13 +16,20 @@ module TestBelt::ShouldaMacros
16
16
  assert self.class.respond_to?(:should_have_directory), "no :should_have_directory macro"
17
17
  assert self.class.respond_to?(:should_have_files), "no :should_have_files macro"
18
18
  assert self.class.respond_to?(:should_have_file), "no :should_have_file macro"
19
+
20
+ assert self.class.respond_to?(:skip_should_have_directories), "no :should_have_directories macro"
21
+ assert self.class.respond_to?(:skip_should_have_directory), "no :should_have_directory macro"
22
+ assert self.class.respond_to?(:skip_should_have_files), "no :should_have_files macro"
23
+ assert self.class.respond_to?(:skip_should_have_file), "no :should_have_file macro"
19
24
  end
20
25
 
21
26
  # should find the @root_path directory
22
27
  should_have_directories
28
+ skip_should_have_directories
23
29
 
24
30
  #should find files in the @root_path directory
25
31
  should_have_files 'files_test.rb'
32
+ skip_should_have_files 'files_test.rb'
26
33
  end
27
34
 
28
35
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-belt
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kelly D. Redding
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-06 00:00:00 -06:00
18
+ date: 2011-03-02 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency