separate models and data boostraping
arnaud sellenet
committed Jun 03, 2014
commit fc35150dc5592ddaa2d7d007b938924ac3127b60
Showing 2
changed files with
19 additions
and 9 deletions
spec/spec_helper.rb
+1
-1
| @@ | @@ -25,7 +25,7 @@ RSpec.configure do |config| |
| config.before(:all) { remove_logs } | |
| config.before do | |
| reset! | |
| - | bootstrap_site |
| + | bootstrap_models |
| end | |
| config.after { reset! } | |
| end | |
spec/support/helpers.rb
+18
-8
| @@ | @@ -6,13 +6,21 @@ require_relative '../../lib/locomotive/steam/loaders/yml_loader' |
| module Spec | |
| module Helpers | |
| - | def bootstrap_site |
| - | adapter = Locomotive::Adapters::MemoryAdapter |
| - | mapper = Locomotive::Mapper.load_from_file! adapter, File.join(File.expand_path('lib/locomotive/steam/mapper.rb')) |
| - | mapper.load! |
| - | Locomotive::Steam::Loader::YmlLoader.new(site_path, mapper).load! |
| + | |
| + | def bootstrap_site_content |
| + | Locomotive::Steam::Loader::YmlLoader.new(default_fixture_site_path, mapper).load! |
| + | end |
| + | |
| + | def mapper |
| + | @mapper ||= begin |
| + | adapter = Locomotive::Adapters::MemoryAdapter |
| + | mapper = Locomotive::Mapper.load_from_file! adapter, File.join(File.expand_path('lib/locomotive/steam/mapper.rb')) |
| + | mapper.load! |
| + | end |
| end | |
| + | alias :bootstrap_models :mapper |
| + | |
| def reset! | |
| FileUtils.rm_rf(File.expand_path('../../../site', __FILE__)) | |
| end | |
| @@ | @@ -24,15 +32,17 @@ module Spec |
| def run_server | |
| Locomotive::Common.reset | |
| Locomotive::Common.configure do |config| | |
| - | path = File.join(site_path, 'log/locomotivecms.log') |
| + | path = File.join(default_fixture_site_path, 'log/locomotivecms.log') |
| config.notifier = Locomotive::Common::Logger.setup(path) | |
| end | |
| + | bootstrap_site_content |
| + | |
| Locomotive::Common::Logger.info 'Server started...' | |
| - | Locomotive::Steam::Server.new(path: site_path) |
| + | Locomotive::Steam::Server.new(path: default_fixture_site_path) |
| end | |
| - | def site_path |
| + | def default_fixture_site_path |
| File.expand_path('../../fixtures/default/', __FILE__) | |
| end | |
| end | |