alephant 0.0.9.7-java → 0.0.9.8-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/lib/alephant/version.rb +1 -1
- data/spec/multi_renderer_spec.rb +30 -45
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9431f717738595e68a8a0c3b1bcd8f66cba57233
|
4
|
+
data.tar.gz: 1befa37fc85eb905ec085cdded713ce2192f1317
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c7f72b93b915b929ffc5aaae66326d89e7cafbdf6f0ce48348ba5d7b8d1276d7e8448e87deb0d97dc5edcb7994136aa7a5d4c8c352d9729e4b44ef26d04e502
|
7
|
+
data.tar.gz: c8ac8b48eb497dad1d0b43eee8daec450a800ca87367c509abb5b502f3c6f7d8a4a2c2667f6b1647deb798f57f34fca52d3d62b53355463658c2c36675ebd7a1
|
data/.travis.yml
CHANGED
data/lib/alephant/version.rb
CHANGED
data/spec/multi_renderer_spec.rb
CHANGED
@@ -1,15 +1,21 @@
|
|
1
|
-
|
2
1
|
require 'spec_helper'
|
3
2
|
|
4
3
|
describe Alephant::MultiRenderer do
|
5
4
|
let(:component_id) { :foo }
|
5
|
+
let(:data) {{ :foo => :bar }}
|
6
|
+
|
6
7
|
subject { Alephant::MultiRenderer }
|
7
8
|
|
9
|
+
before(:each) do
|
10
|
+
File.stub(:directory?).and_return(true)
|
11
|
+
end
|
12
|
+
|
8
13
|
describe "initialize(view_base_path)" do
|
9
14
|
context "view_base_path = invalid_path" do
|
10
15
|
it "should raise InvalidViewPath" do
|
16
|
+
File.stub(:directory?).and_return(false)
|
11
17
|
expect {
|
12
|
-
|
18
|
+
subject.new(component_id, './invalid_path')
|
13
19
|
}.to raise_error(
|
14
20
|
Alephant::Errors::InvalidViewPath
|
15
21
|
)
|
@@ -18,7 +24,6 @@ describe Alephant::MultiRenderer do
|
|
18
24
|
|
19
25
|
context "view_base_path = '.'" do
|
20
26
|
it "sets base_path" do
|
21
|
-
File.stub(:directory?).and_return(true)
|
22
27
|
expect(subject.new(component_id, '.').base_path).to eq("./#{component_id}")
|
23
28
|
end
|
24
29
|
end
|
@@ -31,73 +36,53 @@ describe Alephant::MultiRenderer do
|
|
31
36
|
end
|
32
37
|
|
33
38
|
describe "render_template(template_file, data, instance = nil)" do
|
34
|
-
before(:each) do
|
35
|
-
File.stub(:directory?).and_return(true)
|
36
|
-
end
|
37
|
-
|
38
39
|
context "instance is not nil" do
|
39
|
-
let(:data) {{ :foo => :bar }}
|
40
|
-
|
41
40
|
it "renders the specified template" do
|
42
41
|
Alephant::MultiRenderer.any_instance.stub(:create_instance)
|
43
42
|
Alephant::Renderer.any_instance.stub(:render).and_return('content')
|
44
43
|
|
45
44
|
expect(
|
46
45
|
subject.new(component_id, '.')
|
47
|
-
|
46
|
+
.render_template('foo', data)
|
48
47
|
).to eq('content')
|
49
48
|
end
|
50
49
|
end
|
51
50
|
end
|
52
51
|
|
53
52
|
describe "render(data)" do
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
templates = {
|
65
|
-
:foo => 'content',
|
66
|
-
:bar => 'content'
|
67
|
-
}
|
68
|
-
|
69
|
-
instance = subject.new(component_id, '.')
|
70
|
-
|
71
|
-
content = instance.render({ :foo => :bar })
|
72
|
-
|
73
|
-
expect(content.size).to eq(2)
|
74
|
-
|
75
|
-
content.each do |template_type, rendered_content|
|
76
|
-
expect(rendered_content).to eq(templates[template_type])
|
77
|
-
end
|
53
|
+
it "calls render_template for each template found" do
|
54
|
+
Alephant::MultiRenderer.any_instance.stub(:render_template)
|
55
|
+
Alephant::MultiRenderer.any_instance.stub(
|
56
|
+
:template_locations
|
57
|
+
).and_return(['foo', 'bar'])
|
58
|
+
|
59
|
+
expect(
|
60
|
+
subject.new(component_id, '.').render(data).size
|
61
|
+
).to eq(2)
|
78
62
|
end
|
79
63
|
end
|
80
64
|
|
81
65
|
describe "create_instance(template_file, data)" do
|
82
|
-
before(:each) do
|
83
|
-
File.stub(:directory?).and_return(true)
|
84
|
-
end
|
85
|
-
|
86
|
-
let(:data) {{ :key => :value }}
|
87
|
-
|
88
66
|
it "returns the model" do
|
89
|
-
|
90
|
-
|
67
|
+
model = subject.new(
|
68
|
+
component_id,
|
69
|
+
'fixtures/components'
|
70
|
+
).create_instance('foo', data)
|
71
|
+
|
91
72
|
model.should be_an Alephant::Views::Base
|
92
73
|
expect(model.data).to eq(data)
|
93
74
|
end
|
94
75
|
|
95
76
|
context "invalid model" do
|
96
77
|
it 'should raise ViewModelNotFound' do
|
97
|
-
instance = subject.new(component_id, @base_path)
|
98
|
-
|
99
78
|
expect {
|
100
|
-
|
79
|
+
subject.new(
|
80
|
+
component_id,
|
81
|
+
@base_path
|
82
|
+
).create_instance(
|
83
|
+
'invalid_model',
|
84
|
+
data
|
85
|
+
)
|
101
86
|
}.to raise_error(
|
102
87
|
Alephant::Errors::ViewModelNotFound
|
103
88
|
)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alephant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.9.
|
4
|
+
version: 0.0.9.8
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Robert Kenny
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|