-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrspec.rb
60 lines (47 loc) · 1.51 KB
/
rspec.rb
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
insert_into_file "spec/rails_helper.rb", :after => "require 'rspec/rails'\n" do
"require 'graphiti_spec_helpers/rspec'\n"
end
insert_into_file "spec/rails_helper.rb", :after => "RSpec.configure do |config|\n" do
<<-STR
# bootstrap database cleaner
config.before(:suite) do
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.clean_with(:truncation)
end
config.around(:each) do |example|
begin
DatabaseCleaner.cleaning do
example.run
end
ensure
DatabaseCleaner.clean
end
end
STR
end
insert_into_file "spec/rails_helper.rb", :after => "RSpec.configure do |config|\n" do
<<-STR
config.before :each do
handle_request_exceptions(false)
end
STR
end
insert_into_file "spec/rails_helper.rb", :after => "RSpec.configure do |config|\n" do
" config.include Graphiti::Rails::TestHelpers\n"
end
insert_into_file "spec/rails_helper.rb", :after => "RSpec.configure do |config|\n" do
" config.include GraphitiSpecHelpers::Sugar\n"
end
insert_into_file "spec/rails_helper.rb", :after => "RSpec.configure do |config|\n" do
" config.include GraphitiSpecHelpers::RSpec\n"
end
insert_into_file "spec/rails_helper.rb", :after => "RSpec.configure do |config|\n" do
" config.include FactoryBot::Syntax::Methods\n"
end
gsub_file "spec/rails_helper.rb", 'config.fixture_path = "#{::Rails.root}/spec/fixtures"' do |match|
"# #{match}"
end
gsub_file "spec/rails_helper.rb", 'config.use_transactional_fixtures = true' do |match|
"# #{match}"
end
run "mkdir spec/factories"