Sha256: d808422c954e5907a5c2bda336f1f84f341ec9ae022561a25464b93ba47ef106
Contents?: true
Size: 1.26 KB
Versions: 3
Compression:
Stored size: 1.26 KB
Contents
# encoding: utf-8 # Rspecの内部でflextures関数を使える様にする module RSpec module Core module Hooks def flextures *_ before { Flextures::Loader::flextures *_ } end end end module Rails module FlextureSupport @@configs={ load_count: 0 } def self.included(m) # 一番外側のdescribeにだけ追加 #m.after { Flextures::init_tables } if @@configs[:load_count]==0 @@configs[:load_count] += 1 end end end RSpec.configure do |c| c.include RSpec::Rails::FlextureSupport end end # 既存のsetup_fixturesの機能を上書きする必要があったのでこちらを作成 module ActiveRecord module TestFixtures @@flextures_config = { count: 0 } alias :flextures_backup_setup_fixtures :setup_fixtures def setup_fixtures Flextures::init_load Flextures::init_tables if @@flextures_config[:count] == 0 @@flextures_config[:count] += 1 flextures_backup_setup_fixtures end alias :flextures_backup_teardown_fixtures :teardown_fixtures def teardown_fixtures Flextures::init_tables if Flextures::Config.init_all_tables flextures_backup_teardown_fixtures end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
flextures-1.9.7 | lib/flextures/rspec_flextures_support.rb |
flextures-1.9.6 | lib/flextures/rspec_flextures_support.rb |
flextures-1.9.5 | lib/flextures/rspec_flextures_support.rb |