not_only_but_also 0.2.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -2,10 +2,10 @@ require 'rubygems'
2
2
  require 'rake/rdoctask'
3
3
  require 'rake/gempackagetask'
4
4
  require 'rubygems/specification'
5
- require 'spec/rake/spectask'
5
+ require 'rspec/core/rake_task'
6
6
 
7
7
  GEM_NAME = "not_only_but_also"
8
- GEM_VERSION = '0.2.0'
8
+ GEM_VERSION = '1.0.0'
9
9
  AUTHOR = "Adam Meehan"
10
10
  EMAIL = "adam.meehan@gmail.com"
11
11
  HOMEPAGE = "http://github.com/adzap/not_only_but_also"
@@ -32,19 +32,12 @@ end
32
32
  desc 'Default: run specs.'
33
33
  task :default => :spec
34
34
 
35
- spec_files = Rake::FileList["spec/**/*_spec.rb"]
36
-
37
35
  desc "Run specs"
38
- Spec::Rake::SpecTask.new do |t|
39
- t.spec_files = spec_files
40
- t.spec_opts = ["-c"]
41
- end
36
+ RSpec::Core::RakeTask.new(:spec)
42
37
 
43
38
  desc "Generate code coverage"
44
- Spec::Rake::SpecTask.new(:coverage) do |t|
45
- t.spec_files = spec_files
39
+ RSpec::Core::RakeTask.new(:coverage) do |t|
46
40
  t.rcov = true
47
- t.rcov_opts = ['--exclude', 'spec,/var/lib/gems']
48
41
  end
49
42
 
50
43
  desc 'Generate documentation for plugin.'
@@ -27,4 +27,4 @@ module NotOnlyButAlso
27
27
 
28
28
  end
29
29
 
30
- ActiveRecord::Base.extend NotOnlyButAlso::ClassMethods
30
+ Class.send :include, NotOnlyButAlso::ClassMethods
@@ -1,27 +1,48 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe NotOnlyButAlso do
4
-
5
4
  before do
6
5
  Object.send(:remove_const, :Post) if Object.const_defined?(:Post)
7
6
  Object.send(:remove_const, :Comment) if Object.const_defined?(:Comment)
8
7
  ActiveSupport::Dependencies.loaded = []
9
8
  end
10
9
 
11
- it 'should include only named context' do
12
- Post.class_eval do
13
- also_has :validations
10
+ describe ".not_only_but_also" do
11
+ context "with array of symbols" do
12
+ it 'should require symbols as file' do
13
+ NotOnlyButAlso::Helpers.should_receive(:require_context_file).with('Post', :validations)
14
+ Post.also_has :validations
15
+ end
16
+ end
17
+
18
+ context "with block" do
19
+ it 'should evaluate the block in the class context' do
20
+ Post.also_has do
21
+ def self.method_in_block; end
22
+ end
23
+ Post.should respond_to(:method_in_block)
24
+ end
14
25
  end
15
- Post.should respond_to(:test_validation_method)
16
- Post.should_not respond_to(:test_stuff_method)
17
26
  end
18
27
 
19
- it 'should include all named contexts' do
20
- Post.class_eval do
21
- also_has :validations, :stuff
28
+ describe NotOnlyButAlso::Helpers do
29
+ describe ".require_context_file" do
30
+ it 'should require context file in folder with underscored class name' do
31
+ NotOnlyButAlso::Helpers.should_receive(:require_dependency).with('post/validations')
32
+ Post.also_has :validations
33
+ end
22
34
  end
23
- Post.should respond_to(:test_validation_method)
24
- Post.should respond_to(:test_stuff_method)
25
35
  end
26
36
 
37
+ context "integration" do
38
+ it 'should load files from all contexts' do
39
+ Post.should_not respond_to(:validation_class_method)
40
+ Post.should_not respond_to(:stuff_class_method)
41
+
42
+ Post.also_has :validations, :stuff
43
+
44
+ Post.should respond_to(:validation_class_method)
45
+ Post.should respond_to(:stuff_class_method)
46
+ end
47
+ end
27
48
  end
@@ -1,4 +1,7 @@
1
1
  Post.also_has do
2
- def self.test_stuff_method
2
+ def self.stuff_class_method
3
+ end
4
+
5
+ def stuff_instance_method
3
6
  end
4
7
  end
@@ -1,4 +1,7 @@
1
1
  Post.also_has do
2
- def self.test_validation_method
2
+ def self.validation_class_method
3
+ end
4
+
5
+ def validation_instance_method
3
6
  end
4
7
  end
@@ -1,2 +1,2 @@
1
- class Post < ActiveRecord::Base
1
+ class Post
2
2
  end
data/spec/spec_helper.rb CHANGED
@@ -1,22 +1,9 @@
1
- $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- $:.unshift(File.join(File.dirname(__FILE__), '..', 'spec'))
3
-
4
1
  require 'rubygems'
5
- require 'spec/autorun'
2
+ require 'rspec'
6
3
 
7
- require 'active_record'
8
- require 'active_support'
4
+ require 'active_support/dependencies'
9
5
  require 'not_only_but_also'
10
6
 
11
7
  RAILS_ROOT = File.join(File.dirname(__FILE__), 'rails_root')
12
8
 
13
- ActiveRecord::Migration.verbose = false
14
- ActiveRecord::Base.establish_connection({:adapter => 'sqlite3', :database => ':memory:'})
15
-
16
- ActiveRecord::Schema.define(:version => 1) do
17
- create_table :posts, :force => true do |t|
18
- t.string :title
19
- end
20
- end
21
-
22
- ActiveSupport::Dependencies.load_paths = %W( #{RAILS_ROOT}/app #{RAILS_ROOT}/app/models )
9
+ ActiveSupport::Dependencies.autoload_paths = %W( #{RAILS_ROOT}/app #{RAILS_ROOT}/app/models )
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: not_only_but_also
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Adam Meehan
@@ -9,7 +15,7 @@ autorequire: not_only_but_also
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-11-13 00:00:00 +11:00
18
+ date: 2011-01-06 00:00:00 +11:00
13
19
  default_executable:
14
20
  dependencies: []
15
21
 
@@ -26,13 +32,13 @@ files:
26
32
  - README.rdoc
27
33
  - Rakefile
28
34
  - lib/not_only_but_also.rb
29
- - spec/rails_root/app/models/post.rb
35
+ - spec/not_only_but_also_spec.rb
30
36
  - spec/rails_root/app/models/post/stuff.rb
31
37
  - spec/rails_root/app/models/post/validations.rb
32
- - spec/not_only_but_also_spec.rb
38
+ - spec/rails_root/app/models/post.rb
33
39
  - spec/spec_helper.rb
34
- - generators/not_only_but_also/templates/context.erb
35
40
  - generators/not_only_but_also/not_only_but_also_generator.rb
41
+ - generators/not_only_but_also/templates/context.erb
36
42
  has_rdoc: true
37
43
  homepage: http://github.com/adzap/not_only_but_also
38
44
  licenses: []
@@ -43,21 +49,27 @@ rdoc_options: []
43
49
  require_paths:
44
50
  - lib
45
51
  required_ruby_version: !ruby/object:Gem::Requirement
52
+ none: false
46
53
  requirements:
47
54
  - - ">="
48
55
  - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
49
59
  version: "0"
50
- version:
51
60
  required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
52
62
  requirements:
53
63
  - - ">="
54
64
  - !ruby/object:Gem::Version
65
+ hash: 3
66
+ segments:
67
+ - 0
55
68
  version: "0"
56
- version:
57
69
  requirements: []
58
70
 
59
71
  rubyforge_project: not_only_but_also
60
- rubygems_version: 1.3.5
72
+ rubygems_version: 1.3.7
61
73
  signing_key:
62
74
  specification_version: 3
63
75
  summary: Rails plugin to split large models into separate files of concern. Like concerned_with but a little more convenient.