view_models 1.5.7 → 2.0.0.ruby19

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 (97) hide show
  1. data/lib/init.rb +1 -0
  2. data/lib/padrino/README.textile +3 -0
  3. data/lib/padrino/init.rb +10 -0
  4. data/lib/padrino/lib/helpers/collection.rb +27 -0
  5. data/lib/padrino/lib/padrino/view_models.rb +19 -0
  6. data/lib/padrino/lib/view_models/base.rb +65 -0
  7. data/lib/rails2/README.textile +3 -0
  8. data/{TODO.textile → lib/rails2/TODO.textile} +0 -0
  9. data/{generators → lib/rails2/generators}/view_models/USAGE +0 -0
  10. data/{generators → lib/rails2/generators}/view_models/templates/README +0 -0
  11. data/{generators → lib/rails2/generators}/view_models/templates/spec/view_model_spec.rb +0 -0
  12. data/{generators → lib/rails2/generators}/view_models/templates/view_models/view_model.rb +0 -0
  13. data/{generators → lib/rails2/generators}/view_models/templates/views/_empty.html.haml +0 -0
  14. data/{generators → lib/rails2/generators}/view_models/templates/views/view_models/collection/_collection.html.erb +0 -0
  15. data/{generators → lib/rails2/generators}/view_models/templates/views/view_models/collection/_collection.html.haml +0 -0
  16. data/{generators → lib/rails2/generators}/view_models/templates/views/view_models/collection/_collection.text.erb +0 -0
  17. data/{generators → lib/rails2/generators}/view_models/templates/views/view_models/collection/_list.html.erb +0 -0
  18. data/{generators → lib/rails2/generators}/view_models/templates/views/view_models/collection/_list.text.erb +0 -0
  19. data/{generators → lib/rails2/generators}/view_models/templates/views/view_models/collection/_pagination.html.haml +0 -0
  20. data/{generators → lib/rails2/generators}/view_models/templates/views/view_models/collection/_pagination.text.erb +0 -0
  21. data/{generators → lib/rails2/generators}/view_models/templates/views/view_models/collection/_table.html.haml +0 -0
  22. data/{generators → lib/rails2/generators}/view_models/templates/views/view_models/collection/_table.text.erb +0 -0
  23. data/{generators → lib/rails2/generators}/view_models/view_models_generator.rb +0 -0
  24. data/lib/rails2/init.rb +18 -0
  25. data/lib/{experimental → rails2/lib/experimental}/modules_in_render_hierarchy.rb +0 -0
  26. data/lib/{extensions → rails2/lib/extensions}/view.rb +0 -0
  27. data/lib/rails2/lib/helpers/collection.rb +27 -0
  28. data/lib/{helpers → rails2/lib/helpers}/view.rb +0 -0
  29. data/lib/rails2/lib/view_models.rb +1 -0
  30. data/lib/rails2/lib/view_models/base.rb +99 -0
  31. data/lib/{view_models → rails2/lib/view_models}/view.rb +5 -1
  32. data/lib/shared/README.textile +3 -0
  33. data/lib/shared/init.rb +11 -0
  34. data/lib/shared/lib/view_models.rb +4 -0
  35. data/lib/{view_models → shared/lib/view_models}/base.rb +46 -91
  36. data/lib/{view_models/controller_extractor.rb → shared/lib/view_models/context_extractor.rb} +4 -2
  37. data/lib/{extensions → shared/lib/view_models/extensions}/active_record.rb +2 -0
  38. data/lib/{extensions → shared/lib/view_models/extensions}/model_reader.rb +1 -1
  39. data/lib/{helpers → shared/lib/view_models/helpers}/collection.rb +1 -13
  40. data/lib/{helpers/rails.rb → shared/lib/view_models/helpers/mapping.rb} +5 -1
  41. data/lib/{view_models → shared/lib/view_models}/path_store.rb +0 -0
  42. data/lib/{view_models → shared/lib/view_models}/render_options.rb +4 -0
  43. data/lib/view_models.rb +5 -3
  44. metadata +60 -109
  45. data/CHANGELOG +0 -26
  46. data/MIT-LICENSE +0 -20
  47. data/README.textile +0 -40
  48. data/Rakefile +0 -49
  49. data/VERSION.yml +0 -4
  50. data/generators/view_models/templates/views/view_models/collection/_list.html.haml +0 -7
  51. data/lib/experimental/README.textile +0 -32
  52. data/rails/init.rb +0 -18
  53. data/spec/integration/integration_spec.rb +0 -281
  54. data/spec/integration/models/sub_subclass.rb +0 -14
  55. data/spec/integration/models/subclass.rb +0 -3
  56. data/spec/integration/view_models/module_for_rendering.rb +0 -7
  57. data/spec/integration/view_models/project.rb +0 -14
  58. data/spec/integration/view_models/sub_subclass.rb +0 -42
  59. data/spec/integration/view_models/subclass.rb +0 -1
  60. data/spec/integration/views/view_models/collection/_collection.html.erb +0 -1
  61. data/spec/integration/views/view_models/collection/_collection.text.erb +0 -6
  62. data/spec/integration/views/view_models/collection/_list.html.erb +0 -1
  63. data/spec/integration/views/view_models/collection/_list.text.erb +0 -6
  64. data/spec/integration/views/view_models/module_for_rendering/_not_found_in_sub_subclass_but_in_module.erb +0 -1
  65. data/spec/integration/views/view_models/sub_subclass/_capture_in_template.erb +0 -2
  66. data/spec/integration/views/view_models/sub_subclass/_capture_in_view_model.erb +0 -3
  67. data/spec/integration/views/view_models/sub_subclass/_collection_example.html.erb +0 -3
  68. data/spec/integration/views/view_models/sub_subclass/_collection_example.text.erb +0 -3
  69. data/spec/integration/views/view_models/sub_subclass/_collection_item.html.erb +0 -1
  70. data/spec/integration/views/view_models/sub_subclass/_collection_item.text.erb +0 -1
  71. data/spec/integration/views/view_models/sub_subclass/_exists.erb +0 -1
  72. data/spec/integration/views/view_models/sub_subclass/_exists.html.erb +0 -1
  73. data/spec/integration/views/view_models/sub_subclass/_exists.text.erb +0 -1
  74. data/spec/integration/views/view_models/sub_subclass/_exists_in_both.erb +0 -1
  75. data/spec/integration/views/view_models/sub_subclass/_inner.also_explicit.erb +0 -1
  76. data/spec/integration/views/view_models/sub_subclass/_inner.nesting.erb +0 -1
  77. data/spec/integration/views/view_models/sub_subclass/_list_example.html.erb +0 -3
  78. data/spec/integration/views/view_models/sub_subclass/_list_example.text.erb +0 -3
  79. data/spec/integration/views/view_models/sub_subclass/_list_item.html.erb +0 -1
  80. data/spec/integration/views/view_models/sub_subclass/_list_item.text.erb +0 -1
  81. data/spec/integration/views/view_models/sub_subclass/_outer.explicit.erb +0 -1
  82. data/spec/integration/views/view_models/sub_subclass/_outer.nesting.erb +0 -1
  83. data/spec/integration/views/view_models/sub_subclass/_part_that_is_dependent_on_the_view_model.erb +0 -1
  84. data/spec/integration/views/view_models/sub_subclass/show.html.erb +0 -1
  85. data/spec/integration/views/view_models/sub_subclass/show.text.erb +0 -1
  86. data/spec/integration/views/view_models/subclass/_exists_in_both.erb +0 -1
  87. data/spec/integration/views/view_models/subclass/_no_sub_subclass.erb +0 -1
  88. data/spec/integration/views/view_models/subclass/_not_found_in_sub_subclass.erb +0 -1
  89. data/spec/lib/extensions/active_record_spec.rb +0 -31
  90. data/spec/lib/extensions/model_reader_spec.rb +0 -93
  91. data/spec/lib/helpers/collection_spec.rb +0 -196
  92. data/spec/lib/helpers/rails_spec.rb +0 -84
  93. data/spec/lib/helpers/view_spec.rb +0 -20
  94. data/spec/lib/view_models/base_spec.rb +0 -102
  95. data/spec/lib/view_models/view_spec.rb +0 -9
  96. data/spec/spec_helper.rb +0 -14
  97. data/spec/spec_helper_extensions.rb +0 -13
@@ -1 +0,0 @@
1
- <ol class="collection"><%- collection.each do |item| -%><%- view_model = view_model_for item -%><li><%- options = (template_format ? { :format => template_format } : {}) -%><%= view_model.render_as template_name, options -%></li><%= separator unless item == collection.last %><%- end -%></ol>
@@ -1,6 +0,0 @@
1
- <% collection.each do |item| -%>
2
- <% view_model = view_model_for item -%>
3
- <%- options = (template_format ? { :format => template_format } : {}) -%>
4
- <%= view_model.render_as template_name, options -%>
5
- <%= separator || '\n' unless item == collection.entries.last -%>
6
- <% end -%>
@@ -1 +0,0 @@
1
- _not_found_in_sub_subclass_but_in_module.erb
@@ -1,2 +0,0 @@
1
- <%- @actor = capture do -%>A Pirate!<% end -%>
2
- Capturing: <%= @actor -%>
@@ -1,3 +0,0 @@
1
- Capturing: <%- view_model.capture_block do -%>
2
- <%= "A Pirate!" -%>
3
- <%- end -%>
@@ -1,3 +0,0 @@
1
- <%- ary = [SubSubclass.new, SubSubclass.new] -%>
2
- <%- cvm = collection_view_model_for ary -%>
3
- <%= cvm.collection -%>
@@ -1,3 +0,0 @@
1
- <%- ary = [SubSubclass.new, SubSubclass.new] -%>
2
- <%- cvm = collection_view_model_for ary -%>
3
- <%= cvm.collection -%>
@@ -1 +0,0 @@
1
- _collection_item.html.erb
@@ -1 +0,0 @@
1
- _collection_item.text.erb
@@ -1 +0,0 @@
1
- _exists.erb<%= " with #{local_name}" if defined?(local_name) %>
@@ -1 +0,0 @@
1
- _exists.html.erb<%= " with #{local_name}" if defined?(local_name) %>
@@ -1 +0,0 @@
1
- _exists.text.erb<%= " with #{local_name}" if defined?(local_name) %>
@@ -1 +0,0 @@
1
- _inner.also_explicit.erb
@@ -1 +0,0 @@
1
- _inner.nesting.erb
@@ -1,3 +0,0 @@
1
- <%- ary = [SubSubclass.new, SubSubclass.new] -%>
2
- <%- cvm = collection_view_model_for ary -%>
3
- <%= cvm.list -%>
@@ -1,3 +0,0 @@
1
- <%- ary = [SubSubclass.new, SubSubclass.new] -%>
2
- <%- cvm = collection_view_model_for ary -%>
3
- <%= cvm.list -%>
@@ -1 +0,0 @@
1
- _list_item.html.erb
@@ -1 +0,0 @@
1
- _list_item.text.erb
@@ -1 +0,0 @@
1
- <%= view_model.render_as(:inner, :format => :also_explicit) -%>
@@ -1 +0,0 @@
1
- <%= view_model.render_as :inner -%>
@@ -1 +0,0 @@
1
- _part_that_is_dependent_on_the_view_model.erb
@@ -1 +0,0 @@
1
- show.html.erb
@@ -1 +0,0 @@
1
- show.text.erb
@@ -1 +0,0 @@
1
- _no_sub_subclass.erb
@@ -1 +0,0 @@
1
- _not_found_in_sub_subclass.erb
@@ -1,31 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../spec_helper')
2
-
3
- describe ViewModels::Extensions::ActiveRecord do
4
-
5
- describe "to_param" do
6
- before(:each) do
7
- @model = stub :model
8
- @view_model = ViewModels::Base.new @model, nil
9
- @view_model.extend ViewModels::Extensions::ActiveRecord
10
- end
11
- it "should delegate to_param to the model" do
12
- @model.should_receive(:to_param).once
13
-
14
- @view_model.to_param
15
- end
16
-
17
- it "should delegate id to the model" do
18
- @model.should_receive(:id).once
19
-
20
- @view_model.id
21
- end
22
-
23
- it "should delegate dom_id to ActionController::RecordIdentifier" do
24
- ActionController::RecordIdentifier.should_receive(:dom_id).once
25
-
26
- @view_model.dom_id
27
- end
28
-
29
- end
30
-
31
- end
@@ -1,93 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../spec_helper')
2
-
3
- require 'extensions/model_reader'
4
-
5
- describe ViewModels::Extensions::ModelReader do
6
-
7
- class ModelReaderModel < Struct.new(:some_model_value); end
8
-
9
- describe ".model_reader" do
10
- before(:each) do
11
- @model = ModelReaderModel.new
12
- @view_model = ViewModels::Base.new(@model, nil)
13
- class << @view_model
14
- def a(s); s << 'a' end
15
- def b(s); s << 'b' end
16
- end
17
- @model.some_model_value = 's'
18
- end
19
- it "should call filters in a given pattern" do
20
- @view_model.class.model_reader :some_model_value, :filter_through => [:a, :b, :a, :a]
21
-
22
- @view_model.some_model_value.should == 'sabaa'
23
- end
24
- it "should pass through the model value if no filters are installed" do
25
- @view_model.class.model_reader :some_model_value
26
-
27
- @view_model.some_model_value.should == 's'
28
- end
29
- it "should call filters in a given pattern" do
30
- @view_model.class.model_reader [:some_model_value], :filter_through => [:a, :b, :a, :a]
31
-
32
- @view_model.some_model_value.should == 'sabaa'
33
- end
34
- it "should handle a single filter" do
35
- @view_model.class.model_reader :some_model_value, :filter_through => :a
36
-
37
- lambda { @view_model.some_model_value }.should_not raise_error
38
- end
39
- it "should handle an array of readers" do
40
- @view_model.class.model_reader [:some_model_value, :some_other_model_value], :filter_through => :a
41
-
42
- lambda { @view_model.some_model_value }.should_not raise_error
43
- end
44
- end
45
-
46
- describe 'FilteredDelegationInstaller' do
47
- before(:each) do
48
- @model = ModelReaderModel.new
49
- end
50
- context 'with filters' do
51
- before(:each) do
52
- @options = ViewModels::Extensions::ModelReader::Options.new :some_attribute_name, :filter_through => [:filter1, :filter2]
53
- @installer = ViewModels::Extensions::ModelReader::FilteredDelegationInstaller.new @model, @options
54
- end
55
- it 'should have a correct filter definition' do
56
- @installer.reader_definition_for(:some_attribute).should == 'def some_attribute; filter2(filter1(model.some_attribute)); end'
57
- end
58
- end
59
- context 'without filters' do
60
- before(:each) do
61
- @options = ViewModels::Extensions::ModelReader::Options.new :some_attribute_name
62
- @installer = ViewModels::Extensions::ModelReader::FilteredDelegationInstaller.new @model, @options
63
- end
64
- it 'should have a correct filter definition' do
65
- @installer.reader_definition_for(:some_attribute).should == 'def some_attribute; model.some_attribute; end'
66
- end
67
- end
68
- end
69
-
70
- describe 'Options' do
71
- context 'without filters' do
72
- before(:each) do
73
- @options = ViewModels::Extensions::ModelReader::Options.new :some_attribute_name
74
- end
75
- describe 'split' do
76
- it 'should return the right values' do
77
- @options.to_a.should == [[:some_attribute_name], []]
78
- end
79
- end
80
- end
81
- context 'with filters' do
82
- before(:each) do
83
- @options = ViewModels::Extensions::ModelReader::Options.new :some_attribute_name, :filter_through => [:filter1, :filter2]
84
- end
85
- describe 'split' do
86
- it 'should return the right values, with flipped options' do
87
- @options.to_a.should == [[:some_attribute_name], [:filter2, :filter1]]
88
- end
89
- end
90
- end
91
- end
92
-
93
- end
@@ -1,196 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../spec_helper')
2
-
3
- describe ViewModels::Helpers::Rails::Collection do
4
-
5
- before(:each) do
6
- @collection = stub :collection
7
- @context = stub :context
8
- @collection_view_model = ViewModels::Helpers::Rails::Collection.new @collection, @context
9
- end
10
-
11
- describe "list" do
12
- it "should call render_partial and return the rendered result" do
13
- @collection_view_model.stub! :render_partial => :result
14
-
15
- @collection_view_model.list.should == :result
16
- end
17
- it "should call render_partial with the right parameters" do
18
- default_options = {
19
- :collection => @collection,
20
- :template_name => :list_item,
21
- :separator => nil
22
- }
23
-
24
- @collection_view_model.should_receive(:render_partial).once.with :list, default_options
25
-
26
- @collection_view_model.list
27
- end
28
- it "should override the default options if specific options are given" do
29
- specific_options = {
30
- :collection => :a,
31
- :template_name => :c,
32
- :separator => :d
33
- }
34
-
35
- @collection_view_model.should_receive(:render_partial).once.with :list, specific_options
36
-
37
- @collection_view_model.list specific_options
38
- end
39
- end
40
-
41
- describe "collection" do
42
- it "should call render_partial and return the rendered result" do
43
- @collection_view_model.stub! :render_partial => :result
44
-
45
- @collection_view_model.collection.should == :result
46
- end
47
- it "should call render_partial with the right parameters" do
48
- default_options = {
49
- :collection => @collection,
50
- :template_name => :collection_item,
51
- :separator => nil
52
- }
53
- @collection_view_model.should_receive(:render_partial).once.with :collection, default_options
54
-
55
- @collection_view_model.collection
56
- end
57
- it "should override the default options if specific options are given" do
58
- specific_options = {
59
- :collection => :a,
60
- :template_name => :c,
61
- :separator => :d
62
- }
63
-
64
- @collection_view_model.should_receive(:render_partial).once.with :collection, specific_options
65
-
66
- @collection_view_model.collection specific_options
67
- end
68
- end
69
-
70
- describe "table" do
71
- it "should call render_partial and return the rendered result" do
72
- @collection_view_model.stub! :render_partial => :result
73
-
74
- @collection_view_model.table.should == :result
75
- end
76
- it "should call render_partial with the right parameters" do
77
- default_options = {
78
- :collection => @collection,
79
- :template_name => :table_row,
80
- :separator => nil
81
- }
82
-
83
- @collection_view_model.should_receive(:render_partial).once.with :table, default_options
84
-
85
- @collection_view_model.table
86
- end
87
- it "should override the default options if specific options are given" do
88
- specific_options = {
89
- :collection => :a,
90
- :template_name => :c,
91
- :separator => :d
92
- }
93
-
94
- @collection_view_model.should_receive(:render_partial).once.with :table, specific_options
95
-
96
- @collection_view_model.table(specific_options)
97
- end
98
- end
99
-
100
- describe "pagination" do
101
- it "should call render_partial and return the rendered result" do
102
- @collection_view_model.stub! :render_partial => :result
103
-
104
- @collection_view_model.pagination.should == :result
105
- end
106
- it "should call render_partial with the right parameters" do
107
- default_options = {
108
- :collection => @collection,
109
- :separator => '|'
110
- }
111
- @collection_view_model.should_receive(:render_partial).once.with :pagination, default_options
112
-
113
- @collection_view_model.pagination
114
- end
115
- it "should override the default options if specific options are given" do
116
- specific_options = {
117
- :collection => :a,
118
- :separator => :c
119
- }
120
- @collection_view_model.should_receive(:render_partial).once.with :pagination, specific_options
121
-
122
- @collection_view_model.pagination specific_options
123
- end
124
- end
125
-
126
- describe "render_partial" do
127
- it "should call instance eval on the context" do
128
- @context.should_receive(:instance_eval).once
129
-
130
- @collection_view_model.send :render_partial, :some_name, :some_params
131
- end
132
- it "should render the partial in the 'context' context" do
133
- @context.should_receive(:render).once
134
-
135
- @collection_view_model.send :render_partial, :some_name, :some_params
136
- end
137
- it "should call render partial on context with the passed through parameters" do
138
- @context.should_receive(:render).once.with(:partial => 'view_models/collection/some_name', :locals => { :a => :b })
139
-
140
- @collection_view_model.send :render_partial, :some_name, { :a => :b }
141
- end
142
- end
143
-
144
- describe "delegation" do
145
- describe "enumerable" do
146
- Enumerable.instance_methods.map(&:to_sym).each do |method|
147
- it "should delegate #{method} to the collection" do
148
- @collection.should_receive(method).once
149
-
150
- @collection_view_model.send method
151
- end
152
- end
153
- end
154
- describe "array" do
155
- describe "length" do
156
- it "should delegate to #length of the collection" do
157
- @collection.should_receive(:length).once
158
-
159
- @collection_view_model.length
160
- end
161
- it "should return the length of the collection" do
162
- @collection.should_receive(:length).and_return :this_length
163
-
164
- @collection_view_model.length.should == :this_length
165
- end
166
- it "should alias size" do
167
- @collection.should_receive(:size).and_return :this_length
168
-
169
- @collection_view_model.size.should == :this_length
170
- end
171
- end
172
- describe "empty?" do
173
- it "should delegate to #empty? of the collection" do
174
- @collection.should_receive(:empty?).once
175
-
176
- @collection_view_model.empty?
177
- end
178
- it "should return whatever #empty? of the collection returns" do
179
- @collection.should_receive(:empty?).and_return :true_or_false
180
-
181
- @collection_view_model.empty?.should == :true_or_false
182
- end
183
- end
184
- describe "each" do
185
- it "should delegate to #each of the collection" do
186
- proc = stub :proc
187
-
188
- @collection.should_receive(:each).with(proc).once
189
-
190
- @collection_view_model.each proc
191
- end
192
- end
193
- end
194
- end
195
-
196
- end
@@ -1,84 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '../../spec_helper')
2
-
3
- describe ViewModels::Helpers::Rails do
4
- include ViewModels::Helpers::Rails
5
-
6
- describe "collection_view_model_for" do
7
- it "should return kind of a ViewModels::Collection" do
8
- collection_view_model_for([]).should be_kind_of ViewModels::Helpers::Rails::Collection
9
- end
10
- it "should pass any parameters directly through" do
11
- collection = stub :collection
12
- context = stub :context
13
- ViewModels::Helpers::Rails::Collection.should_receive(:new).with(collection, context).once
14
- collection_view_model_for collection, context
15
- end
16
- end
17
-
18
- describe "view_model_for" do
19
- it "should just pass the params through to the view_model" do
20
- class SomeModelClazz; end
21
- class ViewModels::SomeModelClazz < ViewModels::Base; end
22
- context = stub :context
23
- self.stub! :default_view_model_class_for => ViewModels::SomeModelClazz
24
- model = SomeModelClazz.new
25
-
26
- ViewModels::SomeModelClazz.should_receive(:new).once.with model, context
27
-
28
- view_model_for model, context
29
- end
30
- describe "specific_view_model_mapping" do
31
- it "should return an empty hash by default" do
32
- specific_view_model_mapping.should == {}
33
- end
34
- it "should raise an ArgumentError on an non-mapped model" do
35
- class SomeViewModelClass; end
36
- specific_view_model_mapping[String] = SomeViewModelClass
37
- lambda {
38
- view_model_for("Some String")
39
- }.should raise_error(ArgumentError, "wrong number of arguments (2 for 0)")
40
- end
41
- end
42
- describe "no specific mapping" do
43
- it "should raise on an non-mapped model" do
44
- lambda {
45
- view_model_for(42)
46
- }.should raise_error(NameError, "uninitialized constant ViewModels::Fixnum")
47
- end
48
- it "should return a default view_model instance" do
49
- class SomeModelClazz; end
50
- class ViewModels::SomeModelClazz < ViewModels::Base; end
51
- view_model_for(SomeModelClazz.new).should be_instance_of ViewModels::SomeModelClazz
52
- end
53
- end
54
- describe "with specific mapping" do
55
- class SomeModelClazz; end
56
- class ViewModels::SomeSpecificClazz < ViewModels::Base; end
57
- before(:each) do
58
- self.should_receive(:specific_view_model_mapping).any_number_of_times.and_return SomeModelClazz => ViewModels::SomeSpecificClazz
59
- end
60
- it "should return a specifically mapped view_model instance" do
61
- view_model_for(SomeModelClazz.new).should be_instance_of ViewModels::SomeSpecificClazz
62
- end
63
- it "should not call #default_view_model_class_for" do
64
- mock(self).should_receive(:default_view_model_class_for).never
65
- view_model_for SomeModelClazz.new
66
- end
67
- end
68
- end
69
-
70
- describe "default_view_model_class_for" do
71
- it "should return a class with ViewModels:: prepended" do
72
- class Gaga; end # The model.
73
- class ViewModels::Gaga < ViewModels::Base; end
74
- default_view_model_class_for(Gaga.new).should == ViewModels::Gaga
75
- end
76
- it "should raise a NameError if the Presenter class does not exist" do
77
- class Brrzt; end # Just the model.
78
- lambda {
79
- default_view_model_class_for(Brrzt.new)
80
- }.should raise_error(NameError, "uninitialized constant ViewModels::Brrzt")
81
- end
82
- end
83
-
84
- end