prailroady 1.5.3

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.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.travis.yml +3 -0
  4. data/AUTHORS.rdoc +23 -0
  5. data/Gemfile +2 -0
  6. data/Gemfile.lock +33 -0
  7. data/Guardfile +49 -0
  8. data/LICENSE.rdoc +340 -0
  9. data/README.md +34 -0
  10. data/Rakefile +12 -0
  11. data/bin/prailroady +58 -0
  12. data/lib/prailroady.rb +5 -0
  13. data/lib/prailroady/aasm_diagram.rb +105 -0
  14. data/lib/prailroady/app_diagram.rb +103 -0
  15. data/lib/prailroady/controllers_diagram.rb +103 -0
  16. data/lib/prailroady/diagram_graph.rb +125 -0
  17. data/lib/prailroady/models_diagram.rb +357 -0
  18. data/lib/prailroady/options_struct.rb +204 -0
  19. data/lib/prailroady/railtie.rb +11 -0
  20. data/lib/prailroady/version.rb +3 -0
  21. data/prailroady.gemspec +25 -0
  22. data/tasks/prailroady.rake +139 -0
  23. data/test/file_fixture/app/controllers/application_controller.rb +2 -0
  24. data/test/file_fixture/app/controllers/dummy1_controller.rb +0 -0
  25. data/test/file_fixture/app/controllers/dummy2_controller.rb +0 -0
  26. data/test/file_fixture/app/controllers/sub-dir/sub_dummy_controller.rb +0 -0
  27. data/test/file_fixture/app/models/concerns/author_settings.rb +12 -0
  28. data/test/file_fixture/app/models/concerns/taggable.rb +0 -0
  29. data/test/file_fixture/app/models/dummy1.rb +0 -0
  30. data/test/file_fixture/app/models/dummy2.rb +0 -0
  31. data/test/file_fixture/app/models/sub-dir/sub_dummy.rb +0 -0
  32. data/test/file_fixture/lib/app/controllers/dummy/dummy_controller.rb +0 -0
  33. data/test/file_fixture/lib/app/models/dummy1.rb +0 -0
  34. data/test/lib/railroady/aasm_diagram_spec.rb +54 -0
  35. data/test/lib/railroady/app_diagram_spec.rb +14 -0
  36. data/test/lib/railroady/controllers_diagram_spec.rb +56 -0
  37. data/test/lib/railroady/core_ext_spec.rb +13 -0
  38. data/test/lib/railroady/diagram_graph_spec.rb +53 -0
  39. data/test/lib/railroady/models_diagram_spec.rb +162 -0
  40. data/test/spec_helper.rb +5 -0
  41. metadata +159 -0
@@ -0,0 +1,11 @@
1
+ require 'prailroady'
2
+ require 'rails'
3
+ module PrailRoady
4
+ class Railtie < Rails::Railtie
5
+ rake_tasks do
6
+ f = File.join(File.dirname(__FILE__), '..', '..', 'tasks', 'prailroady.rake')
7
+ load f
8
+ # load 'tasks/prailroady.rake'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module PrailRoady
2
+ VERSION = '1.5.3'
3
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'prailroady/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'prailroady'
8
+ spec.version = PrailRoady::VERSION
9
+ spec.authors = ['SaKKo']
10
+ spec.description = "Plantuml Ruby on Rails 3/4/5 model class diagram generator. Originally based on the 'preston/railroady' plugin and contributions of many others."
11
+ spec.email = ['saklism@gmail.com']
12
+ spec.summary = 'Ruby on Rails 3/4/5 model UML class diagram generator.'
13
+ spec.homepage = 'http://github.com/sakko/prailroady'
14
+ spec.license = 'GPL-2.0'
15
+
16
+ spec.files = `git ls-files`.split("\n")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler'
22
+ spec.add_development_dependency 'rake'
23
+ spec.add_development_dependency 'minitest'
24
+ spec.add_development_dependency 'activesupport'
25
+ end
@@ -0,0 +1,139 @@
1
+ # This suite of tasks generate graphical diagrams via code analysis.
2
+ # A UNIX-like environment is required as well as:
3
+ #
4
+ # * The railroady gem. (http://github.com/preston/railroady)
5
+ # * The graphviz package which includes the `dot` and `neato` command-line utilities. MacPorts users can install in via `sudo port install graphviz`.
6
+ # * The `sed` command-line utility, which should already be available on all sane UNIX systems.
7
+ #
8
+ # Author: Preston Lee, http://railroady.prestonlee.com
9
+
10
+ # wrap helper methods so they don't conflict w/ methods on Object
11
+
12
+ require 'rbconfig'
13
+
14
+ module PrailRoady
15
+ class RakeHelpers
16
+ def self.format
17
+ @@DIAGRAM_FORMAT ||= 'svg'
18
+ end
19
+
20
+ # Returns an absolute path for the following file.
21
+ def self.full_path(name = 'test.txt')
22
+ f = File.join(Rails.root.to_s.gsub(' ', '\ '), 'doc', name)
23
+ f.to_s
24
+ end
25
+
26
+ def self.sed
27
+ regex = 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g'
28
+ case RbConfig::CONFIG['host_os']
29
+ when /linux/
30
+ return "sed -r '#{regex}'"
31
+ when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
32
+ return "sed -r \"#{regex}\""
33
+ when /mac|darwin|bsd/
34
+ return "sed -E '#{regex}'"
35
+ else
36
+ fail NotImplementedError
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ namespace :diagram do
43
+ @MODELS_ALL = PrailRoady::RakeHelpers.full_path("models_complete.#{PrailRoady::RakeHelpers.format}").freeze
44
+ @MODELS_BRIEF = PrailRoady::RakeHelpers.full_path("models_brief.#{PrailRoady::RakeHelpers.format}").freeze
45
+ @CONTROLLERS_ALL = PrailRoady::RakeHelpers.full_path("controllers_complete.#{PrailRoady::RakeHelpers.format}").freeze
46
+ @CONTROLLERS_BRIEF = PrailRoady::RakeHelpers.full_path("controllers_brief.#{PrailRoady::RakeHelpers.format}").freeze
47
+ @SED = PrailRoady::RakeHelpers.sed
48
+
49
+ namespace :setup do
50
+ desc 'Perform any setup needed for the gem'
51
+ task :create_new_doc_folder_if_needed do
52
+ Dir.mkdir('doc') unless File.exist?('doc')
53
+ end
54
+ end
55
+
56
+ namespace :models do
57
+ desc 'Generates brief and complete class diagrams for all models.'
58
+ task all: ['diagram:setup:create_new_doc_folder_if_needed', 'diagram:models:complete', 'diagram:models:brief']
59
+
60
+ desc 'Generates a class diagram for all models.'
61
+ task :complete do
62
+ f = @MODELS_ALL
63
+ puts "Generating #{f}"
64
+ sh "prailroady -lamM | #{@SED} | dot -T#{PrailRoady::RakeHelpers.format} > #{f}"
65
+ end
66
+
67
+ desc 'Generates an abbreviated class diagram for all models.'
68
+ task :brief do
69
+ f = @MODELS_BRIEF
70
+ puts "Generating #{f}"
71
+ sh "prailroady -blamM | #{@SED} | dot -T#{PrailRoady::RakeHelpers.format} > #{f}"
72
+ end
73
+
74
+ desc 'Generates a class diagram for all models including those in engines'
75
+ task :complete_with_engines do
76
+ f = @MODELS_ALL
77
+ puts "Generating #{f}"
78
+ sh "prailroady -ilamzM | #{@SED} | dot -T#{PrailRoady::RakeHelpers.format} > #{f}"
79
+ end
80
+
81
+ desc 'Generates an abbreviated class diagram for all models including those in engines'
82
+ task :brief_with_engines do
83
+ f = @MODELS_BRIEF
84
+ puts "Generating #{f}"
85
+ sh "prailroady -bilamzM | #{@SED} | dot -T#{PrailRoady::RakeHelpers.format} > #{f}"
86
+ end
87
+ end
88
+
89
+ namespace :controllers do
90
+ desc 'Generates brief and complete class diagrams for all controllers.'
91
+ task all: ['diagram:setup:create_new_doc_folder_if_needed', 'diagram:controllers:complete', 'diagram:controllers:brief']
92
+
93
+ desc 'Generates a class diagram for all controllers.'
94
+ task :complete do
95
+ f = @CONTROLLERS_ALL
96
+ puts "Generating #{f}"
97
+ sh "prailroady -lC | #{@SED} | neato -T#{PrailRoady::RakeHelpers.format} > #{f}"
98
+ end
99
+
100
+ desc 'Generates an abbreviated class diagram for all controllers.'
101
+ task :brief do
102
+ f = @CONTROLLERS_BRIEF
103
+ puts "Generating #{f}"
104
+ sh "prailroady -blC | #{@SED} | neato -T#{PrailRoady::RakeHelpers.format} > #{f}"
105
+ end
106
+
107
+ desc 'Generates a class diagram for all controllers including those in engines'
108
+ task :complete_with_engines do
109
+ f = @CONTROLLERS_ALL
110
+ puts "Generating #{f}"
111
+ sh "prailroady -ilC --engine-controllers | #{@SED} | neato -T#{PrailRoady::RakeHelpers.format} > #{f}"
112
+ end
113
+
114
+ desc 'Generates an abbreviated class diagram for all controllers including those in engines.'
115
+ task :brief_with_engines do
116
+ f = @CONTROLLERS_BRIEF
117
+ puts "Generating #{f}"
118
+ sh "prailroady -bilC --engine-controllers | #{@SED} | neato -T#{PrailRoady::RakeHelpers.format} > #{f}"
119
+ end
120
+ end
121
+
122
+ desc 'Generates all class diagrams.'
123
+ task all: [
124
+ 'diagram:setup:create_new_doc_folder_if_needed',
125
+ 'diagram:models:complete',
126
+ 'diagram:models:brief',
127
+ 'diagram:controllers:complete',
128
+ 'diagram:controllers:brief'
129
+ ]
130
+
131
+ desc 'Generates all class diagrams including those in engines'
132
+ task all_with_engines: [
133
+ 'diagram:setup:create_new_doc_folder_if_needed',
134
+ 'diagram:models:complete_with_engines',
135
+ 'diagram:models:brief_with_engines',
136
+ 'diagram:controllers:complete_with_engines',
137
+ 'diagram:controllers:brief_with_engines'
138
+ ]
139
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationController < ActionController::Base
2
+ end
@@ -0,0 +1,12 @@
1
+ module AuthorSettings
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ before_validation :set_up_author
6
+ end
7
+
8
+ def set_up_author
9
+ self.created_by = 'Admin'
10
+ self.updated_by = 'Admin'
11
+ end
12
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,54 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
2
+
3
+ describe AasmDiagram do
4
+ describe 'file processing' do
5
+ it 'should select all the files under the models dir' do
6
+ ad = AasmDiagram.new
7
+ files = ad.get_files('test/file_fixture/')
8
+ files.size.must_equal 3
9
+ end
10
+
11
+ it 'should include concerns if specified' do
12
+ options = OptionsStruct.new(include_concerns: true)
13
+ ad = AasmDiagram.new(options)
14
+ files = ad.get_files('test/file_fixture/')
15
+ files.size.must_equal 5
16
+ end
17
+
18
+ it 'should exclude a specific file' do
19
+ options = OptionsStruct.new(exclude: ['test/file_fixture/app/models/dummy1.rb'])
20
+ ad = AasmDiagram.new(options)
21
+ files = ad.get_files('test/file_fixture/')
22
+ files.size.must_equal 2
23
+ end
24
+
25
+ it 'should exclude a glob pattern of files' do
26
+ options = OptionsStruct.new(exclude: ['test/file_fixture/app/models/*/*.rb'])
27
+ ad = AasmDiagram.new(options)
28
+ files = ad.get_files('test/file_fixture/')
29
+ files.size.must_equal 2
30
+ end
31
+
32
+ it 'should include only specific file' do
33
+ options = OptionsStruct.new(specify: ['test/file_fixture/app/models/sub-dir/sub_dummy.rb'])
34
+ ad = AasmDiagram.new(options)
35
+ files = ad.get_files('test/file_fixture/')
36
+ files.size.must_equal 1
37
+ end
38
+
39
+ it 'should include only specified files' do
40
+ options = OptionsStruct.new(specify: ['test/file_fixture/app/models/{dummy1.rb,sub-dir/sub_dummy.rb}'])
41
+ ad = AasmDiagram.new(options)
42
+ files = ad.get_files('test/file_fixture/')
43
+ files.size.must_equal 2
44
+ end
45
+
46
+ it 'should include only specified files and exclude specified files' do
47
+ options = OptionsStruct.new(specify: ['test/file_fixture/app/models/{dummy1.rb,sub-dir/sub_dummy.rb}'],
48
+ exclude: ['test/file_fixture/app/models/sub-dir/sub_dummy.rb'])
49
+ ad = AasmDiagram.new(options)
50
+ files = ad.get_files('test/file_fixture/')
51
+ files.size.must_equal 1
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,14 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
2
+
3
+ describe AppDiagram do
4
+ describe 'file name processing' do
5
+ it 'should extract a simple name' do
6
+ ad = AppDiagram.new
7
+ name = ad.instance_eval { extract_class_name('app/models/test_this.rb') }
8
+ name.must_equal 'TestThis'
9
+ end
10
+ it 'should constantize a name' do
11
+ 'String'.constantize.must_equal String
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,56 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
2
+
3
+ describe ControllersDiagram do
4
+ describe 'file processing' do
5
+ it 'should select all the files under the controllers dir' do
6
+ cd = ControllersDiagram.new
7
+ files = cd.get_files('test/file_fixture/')
8
+ files.size.must_equal 4
9
+ end
10
+
11
+ it 'should exclude a specific file' do
12
+ options = OptionsStruct.new(exclude: ['test/file_fixture/app/controllers/dummy1_controller.rb'])
13
+ cd = ControllersDiagram.new(options)
14
+ files = cd.get_files('test/file_fixture/')
15
+ files.size.must_equal 3
16
+ end
17
+
18
+ it 'should exclude a glob pattern of files' do
19
+ options = OptionsStruct.new(exclude: ['test/file_fixture/app/controllers/sub-dir/*.rb'])
20
+ cd = ControllersDiagram.new(options)
21
+ files = cd.get_files('test/file_fixture/')
22
+ files.size.must_equal 3
23
+ end
24
+
25
+ it 'should include only specific file' do
26
+ options = OptionsStruct.new(specify: ['test/file_fixture/app/controllers/sub-dir/sub_dummy_controller.rb'])
27
+ cd = ControllersDiagram.new(options)
28
+ files = cd.get_files('test/file_fixture/')
29
+ files.size.must_equal 1
30
+ end
31
+
32
+ it 'should include only specified files' do
33
+ options = OptionsStruct.new(specify: ['test/file_fixture/app/controllers/{dummy1_*.rb,sub-dir/sub_dummy_controller.rb}'])
34
+ cd = ControllersDiagram.new(options)
35
+ files = cd.get_files('test/file_fixture/')
36
+ files.size.must_equal 2
37
+ end
38
+
39
+ it 'should include only specified files and exclude specified files' do
40
+ options = OptionsStruct.new(specify: ['test/file_fixture/app/controllers/{dummy1_*.rb,sub-dir/sub_dummy_controller.rb}'],
41
+ exclude: ['test/file_fixture/app/controllers/sub-dir/sub_dummy_controller.rb'])
42
+ cd = ControllersDiagram.new(options)
43
+ files = cd.get_files('test/file_fixture/')
44
+ files.size.must_equal 1
45
+ end
46
+
47
+ it 'should include engine files' do
48
+ options = OptionsStruct.new(engine_controllers: true)
49
+ md = ControllersDiagram.new(options)
50
+ engines = [OpenStruct.new(root: 'test/file_fixture/lib')]
51
+ md.stub(:engines, engines) do
52
+ md.get_files.must_include('test/file_fixture/lib/app/controllers/dummy/dummy_controller.rb')
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,13 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
2
+
3
+ describe String do
4
+ describe '#camelize' do
5
+ it 'should upper-camelcase a lower case and underscored word' do
6
+ 'lower_case_and_underscored_word'.camelize.must_equal 'LowerCaseAndUnderscoredWord'
7
+ end
8
+
9
+ it 'should lower-camelcase a lower case and underscored word when the :lower parameter is passed' do
10
+ 'lower_case_and_underscored_word'.camelize(:lower).must_equal 'lowerCaseAndUnderscoredWord'
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,53 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
2
+
3
+ module CustomDotMatchers
4
+ class HaveDotOptions
5
+ def initialize(expected)
6
+ @expected = expected
7
+ end
8
+
9
+ def matches?(target)
10
+ @target = target
11
+ return false unless @target =~ /\[(.*)\]/
12
+ @options = Regexp.last_match(1)
13
+ @options == @expected
14
+ end
15
+
16
+ def failure_message
17
+ "expected '#{@target.strip}' to have options '[#{@expected}]'"
18
+ end
19
+
20
+ def negative_failure_message
21
+ "expected '#{@target.strip}' to not have options '[#{@expected}]'"
22
+ end
23
+
24
+ def description
25
+ 'have dot options'
26
+ end
27
+ end
28
+ def have_dot_options(expected)
29
+ HaveDotOptions.new expected
30
+ end
31
+ end
32
+
33
+ describe DiagramGraph do
34
+ include CustomDotMatchers
35
+
36
+ before do
37
+ @diagram_graph = DiagramGraph.new
38
+ end
39
+
40
+ # describe ".dot_edge" do
41
+ # context "has_a/belongs_to" do
42
+ # it { @diagram_graph.send(:dot_edge, "one-one", "source", "target").must_include "arrowtail=odot, arrowhead=dot, dir=both" }
43
+ # end
44
+
45
+ # context "has_many/belongs_to" do
46
+ # it { @diagram_graph.send(:dot_edge, "one-many", "source", "target").must_include "arrowtail=odot, arrowhead=crow, dir=both" }
47
+ # end
48
+
49
+ # context "habtm" do
50
+ # it { @diagram_graph.send(:dot_edge, "many-many", "source", "target").must_include "arrowtail=crow, arrowhead=crow, dir=both" }
51
+ # end
52
+ # end
53
+ end
@@ -0,0 +1,162 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
2
+
3
+ describe ModelsDiagram do
4
+ describe 'file processing' do
5
+ it 'should select all the files under the models dir' do
6
+ md = ModelsDiagram.new
7
+ files = md.get_files('test/file_fixture/')
8
+ files.size.must_equal 3
9
+ end
10
+
11
+ it 'should include concerns if specified' do
12
+ options = OptionsStruct.new(include_concerns: true)
13
+ ad = ModelsDiagram.new(options)
14
+ files = ad.get_files('test/file_fixture/')
15
+ files.size.must_equal 5
16
+ end
17
+
18
+ it 'should exclude a specific file' do
19
+ options = OptionsStruct.new(exclude: ['test/file_fixture/app/models/dummy1.rb'])
20
+ md = ModelsDiagram.new(options)
21
+ files = md.get_files('test/file_fixture/')
22
+ files.size.must_equal 2
23
+ end
24
+
25
+ it 'should exclude a glob pattern of files' do
26
+ options = OptionsStruct.new(exclude: ['test/file_fixture/app/models/*/*.rb'])
27
+ md = ModelsDiagram.new(options)
28
+ files = md.get_files('test/file_fixture/')
29
+ files.size.must_equal 2
30
+ end
31
+
32
+ it 'should include only specific file' do
33
+ options = OptionsStruct.new(specify: ['test/file_fixture/app/models/sub-dir/sub_dummy.rb'])
34
+ md = ModelsDiagram.new(options)
35
+ files = md.get_files('test/file_fixture/')
36
+ files.size.must_equal 1
37
+ end
38
+
39
+ it 'should include only specified files' do
40
+ options = OptionsStruct.new(specify: ['test/file_fixture/app/models/{dummy1.rb,sub-dir/sub_dummy.rb}'])
41
+ md = ModelsDiagram.new(options)
42
+ files = md.get_files('test/file_fixture/')
43
+ files.size.must_equal 2
44
+ end
45
+
46
+ it 'should include only specified files and exclude specified files' do
47
+ options = OptionsStruct.new(specify: ['test/file_fixture/app/models/{dummy1.rb,sub-dir/sub_dummy.rb}'],
48
+ exclude: ['test/file_fixture/app/models/sub-dir/sub_dummy.rb'])
49
+ md = ModelsDiagram.new(options)
50
+ files = md.get_files('test/file_fixture/')
51
+ files.size.must_equal 1
52
+ end
53
+
54
+ it 'should include engine files' do
55
+ options = OptionsStruct.new(engine_models: true)
56
+ md = ModelsDiagram.new(options)
57
+ engines = [OpenStruct.new(root: 'test/file_fixture/lib')]
58
+ md.stub(:engines, engines) do
59
+ md.get_files.must_include('test/file_fixture/lib/app/models/dummy1.rb')
60
+ end
61
+ end
62
+ end
63
+
64
+ describe '#extract_class_name' do
65
+ describe 'class can be found' do
66
+ describe 'module without namespace' do
67
+ module AuthorSettings
68
+ end
69
+
70
+ it 'does not take every models subdirectory as a namespace' do
71
+ md = ModelsDiagram.new(OptionsStruct.new)
72
+
73
+ md.extract_class_name('test/file_fixture/app/models/concerns/author_settings.rb').must_equal 'AuthorSettings'
74
+ end
75
+ end
76
+
77
+ describe 'module with parent namespace / class' do
78
+ class User
79
+ module Authentication
80
+ end
81
+ end
82
+
83
+ it 'does not take every models subdirectory as a namespace' do
84
+ md = ModelsDiagram.new(OptionsStruct.new)
85
+
86
+ md.extract_class_name('test/file_fixture/app/models/concerns/user/authentication.rb').must_equal 'User::Authentication'
87
+ end
88
+ end
89
+ end
90
+
91
+ describe 'class cannot be found' do
92
+ it 'returns the full class name' do
93
+ md = ModelsDiagram.new(OptionsStruct.new)
94
+
95
+ md.extract_class_name('test/file_fixture/app/models/concerns/dummy.rb').must_equal 'Concerns::Dummy'
96
+ end
97
+ end
98
+ end
99
+
100
+ describe '#include_inheritance?' do
101
+ after do
102
+ Object.send(:remove_const, :Child)
103
+ end
104
+ describe 'when class inherits from another app class' do
105
+ before do
106
+ class Parent; end;
107
+ class Child < Parent; end;
108
+ end
109
+ it 'returns true' do
110
+ md = ModelsDiagram.new(OptionsStruct.new)
111
+ md.include_inheritance?(Child).must_equal true
112
+ end
113
+ after do
114
+ Object.send(:remove_const, :Parent)
115
+ end
116
+ end
117
+
118
+ describe 'when class inherits from Object' do
119
+ before do
120
+ class Child < Object; end;
121
+ end
122
+ it 'returns false' do
123
+ md = ModelsDiagram.new(OptionsStruct.new)
124
+ md.include_inheritance?(Child).must_equal false
125
+ end
126
+ end
127
+
128
+ describe 'when class inherits from ActiveRecord::Base' do
129
+ before do
130
+ module ActiveRecord
131
+ class Base; end;
132
+ end
133
+ class Child < ActiveRecord::Base; end;
134
+ end
135
+ it 'returns false' do
136
+ md = ModelsDiagram.new(OptionsStruct.new)
137
+ md.include_inheritance?(Child).must_equal false
138
+ end
139
+ after do
140
+ Object.send(:remove_const, :ActiveRecord)
141
+ end
142
+ end
143
+
144
+ describe 'when class inherits from CouchRest::Model::Base' do
145
+ before do
146
+ module CouchRest
147
+ module Model
148
+ class Base; end;
149
+ end
150
+ end
151
+ class Child < CouchRest::Model::Base; end;
152
+ end
153
+ it 'returns false' do
154
+ md = ModelsDiagram.new(OptionsStruct.new)
155
+ md.include_inheritance?(Child).must_equal false
156
+ end
157
+ after do
158
+ Object.send(:remove_const, :CouchRest)
159
+ end
160
+ end
161
+ end
162
+ end