/
rails_spec.rb
73 lines (56 loc) · 2.12 KB
/
rails_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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
require 'spec_helper'
module Zeus
describe Rails do
subject(:rails) { Rails.new }
context "#test_helper" do
before(:each) do
rails.should_receive(:require).with("minitest/unit")
end
it "when ENV['RAILS_TEST_HELPER'] is set helper is loaded from variable" do
ENV['RAILS_TEST_HELPER'] = "a_test_helper"
rails.should_receive(:require).with("a_test_helper")
rails.test_helper
ENV.clear
end
it "requires rails_helper when using rspec 3.0+" do
mock_file_existence(ROOT_PATH + "/spec/rails_helper.rb", true)
rails.should_receive(:require).with("rails_helper")
rails.test_helper
end
it "when spec_helper exists spec_helper is required" do
mock_file_existence(ROOT_PATH + "/spec/rails_helper.rb", false)
mock_file_existence(ROOT_PATH + "/spec/spec_helper.rb", true)
rails.should_receive(:require).with("spec_helper")
rails.test_helper
end
it "when minitest_helper exists minitest_helper is required" do
mock_file_existence(ROOT_PATH + "/spec/rails_helper.rb", false)
mock_file_existence(ROOT_PATH + "/spec/spec_helper.rb", false)
mock_file_existence(ROOT_PATH + "/test/minitest_helper.rb", true)
rails.should_receive(:require).with("minitest_helper")
rails.test_helper
end
it "when there is no rspec helpers or minitest_helper, test_helper is required" do
mock_file_existence(ROOT_PATH + "/spec/rails_helper.rb", false)
mock_file_existence(ROOT_PATH + "/spec/spec_helper.rb", false)
mock_file_existence(ROOT_PATH + "/test/minitest_helper.rb", false)
rails.should_receive(:require).with("test_helper")
rails.test_helper
end
end
context "#gem_is_bundled?" do
it "returns gem version from Gemfile.lock" do
File.stub(:read).and_return("
GEM
remote: https://rubygems.org/
specs:
exception_notification-rake (0.0.6)
exception_notification (~> 3.0.1)
rake (>= 0.9.0)
rake (10.0.4)
")
gem_is_bundled?('rake').should == '10.0.4'
end
end
end
end