aboutsummaryrefslogtreecommitdiffstats
path: root/spec/support/referential.rb
blob: 0d3a7b89a1b20c44133fcbcf75eb2339c5dfa750 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
module ReferentialHelper

  def first_referential
    Referential.find_by_slug("first")
  end

  def self.included(base)
    base.class_eval do
      extend ClassMethods
      alias_method :referential, :first_referential
    end
  end

  module ClassMethods

    def assign_referential
      before(:each) do
        assign :referential, referential
      end
    end

  end

end

RSpec.configure do |config|
  config.include ReferentialHelper

  config.before(:suite) do
    Referential.find_or_create_by_slug FactoryGirl.attributes_for(:referential, :slug => "first")
    # FIXME in Rails 3.2 :
    # Referential.where(:slug => 'first').first_or_create(FactoryGirl.attributes_for(:referential))
  end

  config.before(:each) do
    first_referential.switch
  end

end