forked from rspec/rspec-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsanity_check_spec.rb
47 lines (38 loc) · 1.28 KB
/
sanity_check_spec.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
require 'spec_helper'
require 'pathname'
RSpec.describe "Verify required rspec dependencies" do
tmp_root = Pathname.new(RSpec::Core::RubyProject.root).join("tmp")
before{ FileUtils.mkdir_p tmp_root }
it "fails when libraries are not required" do
script = tmp_root.join("fail_sanity_check")
File.open(script, "w") do |f|
f.write <<-EOF.gsub(/^\s+\|/, '')
|#!/usr/bin/env ruby
|RSpec::Support.require_rspec_core "project_initializer"
EOF
end
FileUtils.chmod 0777, script
Bundler.with_clean_env do
expect(`bundle exec #{script} 2>&1`).
to match(/uninitialized constant RSpec::Support/).
or match(/undefined method `require_rspec_core' for RSpec::Support:Module/)
expect($?.exitstatus).to eq(1)
end
end
it "passes when libraries are required" do
script = tmp_root.join("pass_sanity_check")
File.open(script, "w") do |f|
f.write <<-EOF.gsub(/^\s+\|/, '')
|#!/usr/bin/env ruby
|require 'rspec/core'
|require 'rspec/support'
|RSpec::Support.require_rspec_core "project_initializer"
EOF
end
FileUtils.chmod 0777, script
Bundler.with_clean_env do
expect(`bundle exec #{script} 2>&1`).to be_empty
expect($?.exitstatus).to eq(0)
end
end
end