seanhussey-woulda 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +0 -0
- data/Rakefile +5 -5
- data/shoulda_macros/should_act_as_paranoid.rb +33 -0
- metadata +5 -34
- data/README.textile +0 -22
- data/lib/woulda/acts_as_ferret/macros.rb +0 -23
- data/lib/woulda/acts_as_ferret.rb +0 -6
- data/lib/woulda/acts_as_list/macros.rb +0 -19
- data/lib/woulda/acts_as_list.rb +0 -6
- data/lib/woulda/acts_as_paranoid/macros.rb +0 -39
- data/lib/woulda/acts_as_paranoid.rb +0 -6
- data/lib/woulda/acts_as_taggable_on_steroids/macros.rb +0 -17
- data/lib/woulda/acts_as_taggable_on_steroids.rb +0 -6
- data/lib/woulda/attachment_fu/macros.rb +0 -27
- data/lib/woulda/attachment_fu.rb +0 -6
- data/lib/woulda/enumerations_mixin/macros.rb +0 -26
- data/lib/woulda/enumerations_mixin.rb +0 -6
- data/lib/woulda/paperclip/macros.rb +0 -21
- data/lib/woulda/paperclip.rb +0 -6
- data/lib/woulda/will_paginate/macros.rb +0 -18
- data/lib/woulda/will_paginate.rb +0 -6
- data/lib/woulda.rb +0 -8
- data/shoulda_macros/woulda_macros.rb +0 -1
data/README
ADDED
File without changes
|
data/Rakefile
CHANGED
@@ -5,19 +5,19 @@ require 'rake/gempackagetask'
|
|
5
5
|
|
6
6
|
spec = Gem::Specification.new do |s|
|
7
7
|
s.name = "woulda"
|
8
|
-
s.version = "0.0
|
8
|
+
s.version = "0.1.0"
|
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}/**/*"]
|
14
14
|
|
15
15
|
# s.has_rdoc = true
|
16
16
|
# s.extra_rdoc_files = ["README.rdoc", "CONTRIBUTION_GUIDELINES.rdoc"]
|
17
17
|
# s.rdoc_options = ["--line-numbers", "--inline-source", "--main", "README.rdoc"]
|
18
18
|
|
19
|
-
s.
|
20
|
-
s.email
|
19
|
+
s.author = "Sean Hussey"
|
20
|
+
s.email = "sean@seanhussey.com"
|
21
21
|
|
22
22
|
s.add_dependency "thoughtbot-shoulda", ">= 2.0.0"
|
23
23
|
end
|
@@ -32,4 +32,4 @@ task :gemspec do
|
|
32
32
|
File.open("#{spec.name}.gemspec", 'w') do |f|
|
33
33
|
f.write spec.to_ruby
|
34
34
|
end
|
35
|
-
end
|
35
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class Test::Unit::TestCase
|
2
|
+
def self.should_act_as_paranoid
|
3
|
+
klass = model_class
|
4
|
+
|
5
|
+
context "A #{klass.name}" do
|
6
|
+
should "be paranoid (it will not be deleted from the database)" do
|
7
|
+
klass.paranoid?
|
8
|
+
end
|
9
|
+
|
10
|
+
should "not have a value for deleted_at" do
|
11
|
+
assert object = klass.find(:first)
|
12
|
+
assert_nil object.deleted_at
|
13
|
+
end
|
14
|
+
|
15
|
+
context "when destroyed" do
|
16
|
+
setup do
|
17
|
+
assert object = klass.find(:first)
|
18
|
+
@deleted_id = object.id
|
19
|
+
object.destroy
|
20
|
+
end
|
21
|
+
|
22
|
+
should "not be found" do
|
23
|
+
assert_raise(ActiveRecord::RecordNotFound) { klass.find(@deleted_id) }
|
24
|
+
end
|
25
|
+
|
26
|
+
should "still exist in the database" do
|
27
|
+
deleted_object = klass.find_with_deleted(@deleted_id)
|
28
|
+
assert_not_nil deleted_object.deleted_at
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seanhussey-woulda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Hussey
|
8
|
-
- Josh Nichols
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
11
|
|
13
|
-
date: 2008-09-
|
12
|
+
date: 2008-09-21 00:00:00 -07:00
|
14
13
|
default_executable:
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
@@ -23,9 +22,7 @@ dependencies:
|
|
23
22
|
version: 2.0.0
|
24
23
|
version:
|
25
24
|
description:
|
26
|
-
email:
|
27
|
-
- sean@seanhussey.com
|
28
|
-
- josh@technicalpickles.com
|
25
|
+
email: sean@seanhussey.com
|
29
26
|
executables: []
|
30
27
|
|
31
28
|
extensions: []
|
@@ -35,34 +32,8 @@ extra_rdoc_files: []
|
|
35
32
|
files:
|
36
33
|
- LICENSE
|
37
34
|
- Rakefile
|
38
|
-
- README
|
39
|
-
- shoulda_macros/
|
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
|
35
|
+
- README
|
36
|
+
- shoulda_macros/should_act_as_paranoid.rb
|
66
37
|
has_rdoc: false
|
67
38
|
homepage: http://github.com/seanhussey/woulda
|
68
39
|
post_install_message:
|
data/README.textile
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
h1. woulda
|
2
|
-
|
3
|
-
Testing is love. Especially when done
|
4
|
-
|
5
|
-
h2. Installing
|
6
|
-
|
7
|
-
Github: "Page":http://github.com/seanhussey/woulda/tree/master "Clone":git://github.com/seanhussey/woulda.git
|
8
|
-
|
9
|
-
Gem: <pre>gem install seanhussey-woulda --source http://gems.github.com</pre>
|
10
|
-
|
11
|
-
woulda requires "shoulda":http://github.com/thoughtbot/shoulda/tree/master >= 2.0.0.
|
12
|
-
|
13
|
-
h2. Included Macros
|
14
|
-
|
15
|
-
should_act_as_paranoid # acts_as_paranoid_
|
16
|
-
should_have_attachment # attachment_fu
|
17
|
-
should_act_as_enumerated # enumeration_mixin
|
18
|
-
|
19
|
-
|
20
|
-
Written by "Sean Hussey":mailto:sean@seanhussey.com and "Josh Nichols":http://technicalpickles.com
|
21
|
-
|
22
|
-
Copyright 2008 Sean Hussey and Josh Nichols.
|
@@ -1,23 +0,0 @@
|
|
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
|
@@ -1,19 +0,0 @@
|
|
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
|
data/lib/woulda/acts_as_list.rb
DELETED
@@ -1,39 +0,0 @@
|
|
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
|
@@ -1,17 +0,0 @@
|
|
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
|
@@ -1,27 +0,0 @@
|
|
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
|
data/lib/woulda/attachment_fu.rb
DELETED
@@ -1,26 +0,0 @@
|
|
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
|
@@ -1,21 +0,0 @@
|
|
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
|
data/lib/woulda/paperclip.rb
DELETED
@@ -1,18 +0,0 @@
|
|
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
|
data/lib/woulda/will_paginate.rb
DELETED
data/lib/woulda.rb
DELETED
@@ -1,8 +0,0 @@
|
|
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
|
@@ -1 +0,0 @@
|
|
1
|
-
require 'woulda'
|