spec/grape/reload/dependency_map_spec.rb in grape-reload-0.0.2 vs spec/grape/reload/dependency_map_spec.rb in grape-reload-0.0.3
- old
+ new
@@ -8,23 +8,43 @@
declared: ['::Class1'],
used: [],
},
'file2' => {
declared: ['::Class2'],
- used: ['::Class1','::Class3'],
+ used: [['::Class1'],['::Class3']],
},
'file3' => {
declared: ['::Class3'],
- used: ['::Class2'],
+ used: [['::Class1']],
},
}
}
+ let!(:wrong_class_map) {
+ {
+ 'file1' => {
+ declared: ['::Class1'],
+ used: [],
+ },
+ 'file2' => {
+ declared: ['::Class2'],
+ used: [['::Class1'],['::Class3']],
+ },
+ 'file3' => {
+ declared: ['::Class3'],
+ used: [['::Class5']],
+ },
+ }
+ }
let!(:dm) { Grape::Reload::DependencyMap.new([]) }
it 'resolves dependent classes properly' do
allow(dm).to receive(:map).and_return(file_class_map)
- # map = instance_double(Grape::Reload::DependencyMap)
- # allow(map).to receive(:map).and_return(file_class_map)
+ dm.resolve_dependencies!
expect(dm.dependent_classes('file1')).to include('::Class2','::Class3')
+ end
+
+ it "raises error if dependencies can't be resolved" do
+ allow(dm).to receive(:map).and_return(wrong_class_map)
+ expect { dm.resolve_dependencies! }.to raise_error(Grape::Reload::UnresolvedDependenciesError)
end
end
\ No newline at end of file