1
+ # Note: if segmentation fault with spork / imagemagick on mac os x, take a look at:
2
+ # http://stackoverflow.com/questions/2838307/why-is-this-rmagick-call-generating-a-segmentation-fault
3
+
4
+ require 'rubygems'
5
+ require 'spork'
6
+
1
7
# figure out where we are being loaded from
2
8
if $LOADED_FEATURES. grep ( /spec\/ spec_helper\. rb/ ) . any?
3
9
begin
21
27
end
22
28
end
23
29
24
- # This file is copied to spec/ when you run 'rails generate rspec:install'
25
- ENV [ "RAILS_ENV" ] ||= 'test'
26
- require File . expand_path ( '../../config/environment' , __FILE__ )
27
30
28
- require 'rspec/rails'
29
- require 'factory_girl'
31
+ Spork . prefork do
32
+ # Loading more in this block will cause your tests to run faster. However,
33
+ # if you change any configuration or code from libraries loaded here, you'll
34
+ # need to restart spork for it take effect.
30
35
31
- FactoryGirl . find_definitions
36
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
37
+ ENV [ "RAILS_ENV" ] ||= 'test'
38
+ require File . expand_path ( '../../config/environment' , __FILE__ )
32
39
33
- # Requires supporting ruby files with custom matchers and macros, etc,
34
- # in spec/support/ and its subdirectories.
35
- Dir [ Rails . root . join ( 'spec/support/**/*.rb' ) ] . each { |f | require f }
40
+ require 'rspec/rails'
41
+ require 'factory_girl'
36
42
37
- Locomotive . configure_for_test
43
+ FactoryGirl . find_definitions
38
44
39
- RSpec . configure do |config |
45
+ # Requires supporting ruby files with custom matchers and macros, etc,
46
+ # in spec/support/ and its subdirectories.
47
+ Dir [ Rails . root . join ( 'spec/support/**/*.rb' ) ] . each { |f | require f }
40
48
41
- config . include ( Locomotive :: RSpec :: Matchers )
49
+ Locomotive . configure_for_test
42
50
43
- # == Mock Framework
44
- #
45
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
46
- #
47
- config . mock_with :mocha
48
- # config.mock_with :flexmock
49
- # config.mock_with :rr
50
- # config.mock_with :rspec
51
+ RSpec . configure do |config |
51
52
52
- # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
53
- # config.fixture_path = "#{::Rails.root}/spec/fixtures"
53
+ config . include ( Locomotive ::RSpec ::Matchers )
54
54
55
- # If you're not using ActiveRecord, or you'd prefer not to run each of your
56
- # examples within a transaction, remove the following line or assign false
57
- # instead of true.
58
- # config.use_transactional_fixtures = true
55
+ config . mock_with :mocha
59
56
60
- config . before ( :each ) do
61
- Locomotive . config . heroku = false
62
- end
57
+ config . before ( :each ) do
58
+ Locomotive . config . heroku = false
59
+ end
63
60
64
- require 'database_cleaner'
65
- config . before ( :suite ) do
66
- DatabaseCleaner . strategy = :truncation
67
- DatabaseCleaner . orm = 'mongoid'
68
- end
61
+ require 'database_cleaner'
62
+ config . before ( :suite ) do
63
+ DatabaseCleaner . strategy = :truncation
64
+ DatabaseCleaner . orm = 'mongoid'
65
+ end
69
66
70
- config . before ( :each ) do
71
- if self . described_class != Locomotive ::Import ::Job
72
- DatabaseCleaner . clean
67
+ config . before ( :each ) do
68
+ if self . described_class != Locomotive ::Import ::Job
69
+ DatabaseCleaner . clean
70
+ end
73
71
end
74
- end
75
72
76
- config . before ( :all ) do
77
- if self . described_class == Locomotive ::Import ::Job
78
- DatabaseCleaner . clean
73
+ config . before ( :all ) do
74
+ if self . described_class == Locomotive ::Import ::Job
75
+ DatabaseCleaner . clean
76
+ end
79
77
end
80
78
end
79
+
81
80
end
81
+
82
+ Spork . each_run do
83
+ # This code will be run each time you run your specs.
84
+ Locomotive . configure_for_test ( true )
85
+ Dir [ Rails . root . join ( 'spec/support/**/*.rb' ) ] . each { |f | require f }
86
+
87
+ # loading ruby file directly breaks the tests
88
+ # Dir[Rails.root.join('app/models/*.rb')].each { |f| load f }
89
+ end
0 commit comments