11module ForestLiana
22 describe Bootstrapper do
3+ before do
4+ allow ( ForestLiana ) . to receive ( :env_secret ) . and_return ( nil )
5+ end
6+
37 describe 'setup_forest_liana_meta' do
48 it "should put statistic data related to user stack on a dedicated object" do
59 expect ( ForestLiana . meta [ :stack ] )
@@ -9,6 +13,50 @@ module ForestLiana
913 end
1014 end
1115
16+ describe 'models' do
17+ let ( :expected_models ) do
18+ [
19+ Island ,
20+ Location ,
21+ Owner ,
22+ Product ,
23+ Reference ,
24+ Tree ,
25+ User
26+ ]
27+ end
28+
29+ it 'should populate the models correctly' do
30+ ForestLiana ::Bootstrapper . new
31+ rails_models = [ ActiveRecord ::InternalMetadata , ActiveRecord ::SchemaMigration ]
32+
33+ expect ( ForestLiana . models ) . to match_array ( ForestLiana . models . uniq )
34+ expect ( ForestLiana . models ) . to match_array ( expected_models + rails_models )
35+ end
36+
37+ it 'should generate serializers for all models' do
38+ factory = instance_double ( ForestLiana ::SerializerFactory , serializer_for : nil )
39+ allow ( ForestLiana ::SerializerFactory ) . to receive ( :new ) . and_return ( factory )
40+
41+ ForestLiana ::Bootstrapper . new
42+
43+ expected_models . each do |model |
44+ expect ( factory ) . to have_received ( :serializer_for ) . with ( model ) . once
45+ end
46+ end
47+
48+ it 'should generate controllers for all models' do
49+ factory = instance_double ( ForestLiana ::ControllerFactory , controller_for : nil )
50+ allow ( ForestLiana ::ControllerFactory ) . to receive ( :new ) . and_return ( factory )
51+
52+ ForestLiana ::Bootstrapper . new
53+
54+ expected_models . each do |model |
55+ expect ( factory ) . to have_received ( :controller_for ) . with ( model ) . once
56+ end
57+ end
58+ end
59+
1260 describe 'generate_action_hooks' do
1361 schema = '{
1462 "collections": [
@@ -102,7 +150,6 @@ module ForestLiana
102150
103151
104152 it "Should return actions hooks empty for the island collection" do
105- allow ( ForestLiana ) . to receive ( :env_secret ) . and_return ( nil )
106153 bootstrapper = Bootstrapper . new
107154 content = JSON . parse ( schema )
108155 bootstrapper . instance_variable_set ( :@collections_sent , content [ 'collections' ] )
0 commit comments