seanhussey-woulda 0.0.1 → 0.0.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/Rakefile CHANGED
@@ -5,12 +5,12 @@ require 'rake/gempackagetask'
5
5
 
6
6
  spec = Gem::Specification.new do |s|
7
7
  s.name = "woulda"
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
  s.summary = "woulda is a home for shoulda macros that don't belong in the main shoulda library"
10
10
  s.homepage = "http://github.com/seanhussey/woulda"
11
11
  s.rubyforge_project = "woulda"
12
12
 
13
- s.files = FileList["[A-Z]*", "{shoulda_macros}/**/*"]
13
+ s.files = FileList["[A-Z]*", "{shoulda_macros}/**/*", "lib/**/*"]
14
14
 
15
15
  # s.has_rdoc = true
16
16
  # s.extra_rdoc_files = ["README.rdoc", "CONTRIBUTION_GUIDELINES.rdoc"]
data/lib/woulda.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'woulda/acts_as_ferret' if defined? ActsAsFerret
2
+ require 'woulda/acts_as_list' if defined? ActiveRecord::Acts::List
3
+ require 'woulda/acts_as_paranoid' if defined? Caboose::Acts::Paranoid
4
+ require 'woulda/acts_as_taggable_on_steroids' if defined? ActiveRecord::Acts::Taggable
5
+ require 'woulda/attachment_fu' if defined? Technoweenie::AttachmentFu
6
+ require 'woulda/enumerations_mixin' if defined? ActiveRecord::Acts::Enumerated
7
+ require 'woulda/paperclip' if defined? Paperclip
8
+ require 'woulda/will_paginate' if defined? WillPaginate
@@ -0,0 +1,6 @@
1
+ require 'shoulda'
2
+ require 'woulda/acts_as_ferret/macros'
3
+
4
+ Test::Unit::TestCase.class_eval do
5
+ extend Woulda::ActsAsFerret::Macros
6
+ end
@@ -0,0 +1,23 @@
1
+ module Woulda
2
+ module ActsAsFerret
3
+ module Macros
4
+ # should_act_as_ferret :any, :fields, :i_may, :have, :specified
5
+ def should_act_as_ferret(*fields)
6
+ klass = self.name.gsub(/Test$/, '').constantize
7
+
8
+ should "include ActsAsFerret methods" do
9
+ assert klass.extended_by.include?(ActsAsFerret::ClassMethods)
10
+ assert klass.include?(ActsAsFerret::InstanceMethods)
11
+ assert klass.include?(ActsAsFerret::MoreLikeThis::InstanceMethods)
12
+ assert klass.include?(ActsAsFerret::ResultAttributes)
13
+ end
14
+
15
+ fields.each do |f|
16
+ should "create an index for field named #{f}" do
17
+ assert klass.aaf_configuration[:fields].include?(f)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,6 @@
1
+ require 'shoulda'
2
+ require 'woulda/acts_as_list/macros'
3
+
4
+ Test::Unit::TestCase.class_eval do
5
+ extend Woulda::ActsAsList::Macros
6
+ end
@@ -0,0 +1,19 @@
1
+ module Woulda
2
+ module ActsAsList
3
+ module Macros
4
+ def should_act_as_list
5
+ klass = self.name.gsub(/Test$/, '').constantize
6
+
7
+ context "To support acts_as_list" do
8
+ should_have_db_column('position', :type => :integer)
9
+ end
10
+
11
+ should "include ActsAsList methods" do
12
+ assert klass.include?(ActiveRecord::Acts::List::InstanceMethods)
13
+ end
14
+
15
+ should_have_instance_methods :acts_as_list_class, :position_column, :scope_condition
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,6 @@
1
+ require 'shoulda'
2
+ require 'woulda/acts_as_paranoid/macros'
3
+
4
+ Test::Unit::TestCase.class_eval do
5
+ extend Woulda::ActsAsParanoid::Macros
6
+ end
@@ -0,0 +1,39 @@
1
+ module Woulda
2
+ module ActsAsParanoid
3
+ module Macros
4
+ def should_act_as_paranoid
5
+ klass = model_class
6
+ should_have_db_column :deleted_at
7
+
8
+ context "A #{klass.name}" do
9
+ should "be paranoid (it will not be deleted from the database)" do
10
+ assert klass.paranoid?
11
+ assert klass.included_modules.include?(Caboose::Acts::Paranoid)
12
+ end
13
+
14
+ should "not have a value for deleted_at" do
15
+ assert object = klass.find(:first)
16
+ assert_nil object.deleted_at
17
+ end
18
+
19
+ context "when destroyed" do
20
+ setup do
21
+ assert object = klass.find(:first), "This context requires there to be an existing #{klass}"
22
+ @deleted_id = object.id
23
+ object.destroy
24
+ end
25
+
26
+ should "not be found" do
27
+ assert_raise(ActiveRecord::RecordNotFound) { klass.find(@deleted_id) }
28
+ end
29
+
30
+ should "still exist in the database" do
31
+ deleted_object = klass.find_with_deleted(@deleted_id)
32
+ assert_not_nil deleted_object.deleted_at
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,6 @@
1
+ require 'shoulda'
2
+ require 'woulda/acts_as_taggable_on_steroids'
3
+
4
+ Test::Unit::TestCase.class_eval do
5
+ extend Woulda::ActsAsTaggableOnSteroids::Macros
6
+ end
@@ -0,0 +1,17 @@
1
+ module Woulda
2
+ module ActsAsTaggableOnSteroids
3
+ module Macros
4
+ def should_act_as_taggable_on_steroids
5
+ klass = self.name.gsub(/Test$/, '').constantize
6
+
7
+ should "include ActsAsTaggableOnSteroids methods" do
8
+ assert klass.extended_by.include?(ActiveRecord::Acts::Taggable::ClassMethods)
9
+ assert klass.extended_by.include?(ActiveRecord::Acts::Taggable::SingletonMethods)
10
+ assert klass.include?(ActiveRecord::Acts::Taggable::InstanceMethods)
11
+ end
12
+
13
+ should_have_many :taggings, :tags
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,6 @@
1
+ require 'shoulda'
2
+ require 'woulda/attachment_fu/macros'
3
+
4
+ Test::Unit::TestCase.class_eval do
5
+ extend Woulda::AttachmentFu::Macros
6
+ end
@@ -0,0 +1,27 @@
1
+ module Woulda
2
+ module AttachmentFu
3
+ module Macros
4
+ def should_have_attachment(options = {})
5
+ klass = model_class
6
+
7
+ should_have_db_columns :size, :content_type, :filename
8
+ if options[:content_type] == :image
9
+ should_have_db_columns :height, :width
10
+ end
11
+
12
+ should "define AttachmentFu class methods" do
13
+ # breakpoint
14
+ class_modules = (class << klass; included_modules; end)
15
+ assert class_modules.include?(Technoweenie::AttachmentFu::ClassMethods),
16
+ "#{klass} doesn't define AttachmentFu class methods"
17
+ end
18
+
19
+ should "define AttachmentFu instance methods" do
20
+ instance_modules = klass.included_modules
21
+ assert instance_modules.include?(Technoweenie::AttachmentFu::InstanceMethods),
22
+ "#{klass} doesn't define AttachmentFu instance methods"
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,6 @@
1
+ require 'shoulda'
2
+ require 'woulda/enumerations_mixin/macros'
3
+
4
+ Test::Unit::TestCase.class_eval do
5
+ extend Woulda::EnumerationsMixin::Macros
6
+ end
@@ -0,0 +1,26 @@
1
+ module Woulda
2
+ module EnumerationsMixin
3
+ module Macros
4
+ def should_act_as_enumerated(options = {})
5
+ klass = model_class
6
+
7
+ should_have_db_columns :name
8
+
9
+ should "define Enumerated macro methods" do
10
+ class_modules = (class << klass; included_modules; end)
11
+ assert class_modules.include?(ActiveRecord::Acts::Enumerated::MacroMethods), "#{klass} doesn't define Enumerated macro methods"
12
+ end
13
+
14
+ should "define Enumerated class methods" do
15
+ class_modules = (class << klass; included_modules; end)
16
+ assert class_modules.include?(ActiveRecord::Acts::Enumerated::ClassMethods), "#{klass} doesn't define Enumerated class methods"
17
+ end
18
+
19
+ should "define Enumerated instance methods" do
20
+ instance_modules = klass.included_modules
21
+ assert instance_modules.include?(ActiveRecord::Acts::Enumerated::InstanceMethods), "#{klass} doesn't define Enumerated instance methods"
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,6 @@
1
+ require 'shoulda'
2
+ require 'woulda/paperclip/macros'
3
+
4
+ Tet::Unit::TestCase.class_eval do
5
+ extend Woulda::Paperclip::Macros
6
+ end
@@ -0,0 +1,21 @@
1
+ module Woulda
2
+ module Paperclip
3
+ module Macros
4
+ def should_have_attached_file(attachment)
5
+ klass = self.name.gsub(/Test$/, '').constantize
6
+
7
+ context "To support a paperclip attachment named #{attachment}, #{klass}" do
8
+ should_have_db_column("#{attachment}_file_name", :type => :string)
9
+ should_have_db_column("#{attachment}_content_type", :type => :string)
10
+ should_have_db_column("#{attachment}_file_size", :type => :integer)
11
+ end
12
+
13
+ should "have a paperclip attachment named ##{attachment}" do
14
+ assert klass.new.respond_to?(attachment.to_sym),
15
+ "@#{klass.name.underscore} doesn't have a paperclip field named #{attachment}"
16
+ assert_equal Paperclip::Attachment, klass.new.send(attachment.to_sym).class
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,6 @@
1
+ require 'shoulda'
2
+ require 'woulda/will_paginate/macros'
3
+
4
+ Test::Unit::TestCase.class_eval do
5
+ extend Woulda::WillPaginate::Macros
6
+ end
@@ -0,0 +1,18 @@
1
+ module Woulda
2
+ module WillPaginate
3
+ module Macros
4
+ def should_have_per_page(count)
5
+ klass = self.name.gsub(/Test$/, '').constantize
6
+ context "#{klass}" do
7
+ should "respond to per_page" do
8
+ assert klass.respond_to?(:per_page), "#{klass} does not respond to :per_page"
9
+ end
10
+
11
+ should "have #{count} per page" do
12
+ assert_equal count, klass.per_page
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1 @@
1
+ require 'woulda'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seanhussey-woulda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Hussey
@@ -36,7 +36,33 @@ files:
36
36
  - LICENSE
37
37
  - Rakefile
38
38
  - README.textile
39
- - shoulda_macros/should_act_as_paranoid.rb
39
+ - shoulda_macros/woulda_macros.rb
40
+ - lib/woulda
41
+ - lib/woulda/acts_as_ferret
42
+ - lib/woulda/acts_as_ferret/macros.rb
43
+ - lib/woulda/acts_as_ferret.rb
44
+ - lib/woulda/acts_as_list
45
+ - lib/woulda/acts_as_list/macros.rb
46
+ - lib/woulda/acts_as_list.rb
47
+ - lib/woulda/acts_as_paranoid
48
+ - lib/woulda/acts_as_paranoid/macros.rb
49
+ - lib/woulda/acts_as_paranoid.rb
50
+ - lib/woulda/acts_as_taggable_on_steroids
51
+ - lib/woulda/acts_as_taggable_on_steroids/macros.rb
52
+ - lib/woulda/acts_as_taggable_on_steroids.rb
53
+ - lib/woulda/attachment_fu
54
+ - lib/woulda/attachment_fu/macros.rb
55
+ - lib/woulda/attachment_fu.rb
56
+ - lib/woulda/enumerations_mixin
57
+ - lib/woulda/enumerations_mixin/macros.rb
58
+ - lib/woulda/enumerations_mixin.rb
59
+ - lib/woulda/paperclip
60
+ - lib/woulda/paperclip/macros.rb
61
+ - lib/woulda/paperclip.rb
62
+ - lib/woulda/will_paginate
63
+ - lib/woulda/will_paginate/macros.rb
64
+ - lib/woulda/will_paginate.rb
65
+ - lib/woulda.rb
40
66
  has_rdoc: false
41
67
  homepage: http://github.com/seanhussey/woulda
42
68
  post_install_message:
@@ -1 +0,0 @@
1
- require 'woulda/acts_as_paranoid' if defined? Caboose::Acts::Paranoid