page_record 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/page_record/class_methods.rb +8 -3
- data/lib/page_record/version.rb +1 -1
- data/spec/page_record_spec.rb +28 -6
- metadata +1 -1
data/Gemfile.lock
CHANGED
@@ -156,9 +156,14 @@ private
|
|
156
156
|
|
157
157
|
# @private
|
158
158
|
def self.set_type_name(base)
|
159
|
-
|
160
|
-
|
161
|
-
|
159
|
+
begin
|
160
|
+
@host_name = base.to_s.gsub('Page', '')
|
161
|
+
@type = @host_name.underscore
|
162
|
+
@host_class = @host_name.constantize
|
163
|
+
rescue NameError
|
164
|
+
@host_name = ''
|
165
|
+
@host_class = ''
|
166
|
+
end
|
162
167
|
end
|
163
168
|
|
164
169
|
# @private
|
data/lib/page_record/version.rb
CHANGED
data/spec/page_record_spec.rb
CHANGED
@@ -17,11 +17,19 @@ describe PageRecord::Base do
|
|
17
17
|
[ 'id' , 'name', 'points', 'ranking', 'goals']
|
18
18
|
end
|
19
19
|
end
|
20
|
-
class CamelCasePage < PageRecord::Base; end
|
21
20
|
end
|
22
21
|
|
22
|
+
after do
|
23
|
+
Object.send(:remove_const, :CamelCasePage)
|
24
|
+
end
|
25
|
+
|
26
|
+
|
23
27
|
context "no type given" do
|
24
28
|
|
29
|
+
before do
|
30
|
+
class CamelCasePage < PageRecord::Base; end
|
31
|
+
end
|
32
|
+
|
25
33
|
it "returns the internal type of the class " do
|
26
34
|
expect( CamelCasePage.type).to eq "camel_case"
|
27
35
|
end
|
@@ -170,13 +178,14 @@ describe PageRecord::Base do
|
|
170
178
|
|
171
179
|
describe ".host_class" do
|
172
180
|
|
181
|
+
before do
|
182
|
+
class FunnyRecord < PageRecord::Base
|
183
|
+
host_class Team
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
173
187
|
context "with a parameter" do
|
174
188
|
|
175
|
-
before do
|
176
|
-
class FunnyRecord < PageRecord::Base
|
177
|
-
host_class Team
|
178
|
-
end
|
179
|
-
end
|
180
189
|
|
181
190
|
# TODO refactor test
|
182
191
|
subject {FunnyRecord.new(1) }
|
@@ -536,5 +545,18 @@ describe PageRecord::Base do
|
|
536
545
|
pending
|
537
546
|
end
|
538
547
|
|
548
|
+
describe "found bugs" do
|
549
|
+
|
550
|
+
describe "class name contains word page but doens't exist" do
|
551
|
+
|
552
|
+
it "doesn'throw exception" do
|
553
|
+
expect { class RubbishPage < PageRecord::Base; end }.not_to raise_error
|
554
|
+
end
|
555
|
+
|
556
|
+
end
|
557
|
+
|
558
|
+
|
559
|
+
end
|
560
|
+
|
539
561
|
|
540
562
|
end
|