-
Notifications
You must be signed in to change notification settings - Fork 340
/
Copy pathcommands_test.rb
56 lines (47 loc) · 2.03 KB
/
commands_test.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
require_relative "../helper"
require "spring/commands"
class CommandsTest < ActiveSupport::TestCase
test 'rails command sets rails environment from -e option' do
command = Spring::Commands::Rails.new
assert_equal 'test', command.env(['-e', 'test'])
assert_equal 'test', command.env(['-e=test'])
end
test 'rails command sets rails environment from --environment option' do
command = Spring::Commands::Rails.new
assert_equal 'test', command.env(['--environment', 'test'])
assert_equal 'test', command.env(['--environment=test'])
end
test 'rails command ignores first argument if it is a flag except -e and --environment' do
command = Spring::Commands::Rails.new
assert_nil command.env(['--sandbox'])
end
test 'rails command uses last environment option' do
command = Spring::Commands::Rails.new
assert_equal 'development', command.env(['-e', 'test', '--environment=development'])
end
test 'rails command ignores additional arguments' do
command = Spring::Commands::Rails.new
assert_equal 'test', command.env(['-e', 'test', 'puts 1+1'])
end
test "rake command has configurable environments" do
command = Spring::Commands::Rake.new
assert_nil command.env(["foo"])
assert_equal "test", command.env(["test"])
assert_equal "test", command.env(["test:models"])
assert_nil command.env(["test_foo"])
end
test 'RailsTest#env defaults to test rails environment' do
command = Spring::Commands::RailsTest.new
assert_equal 'test', command.env([])
end
test 'RailsTest#env sets rails environment from --environment option' do
command = Spring::Commands::RailsTest.new
assert_equal 'development', command.env(['--environment', 'development'])
assert_equal 'development', command.env(['--environment=development'])
end
test 'RailsTest#env sets rails environment from -e option' do
command = Spring::Commands::RailsTest.new
assert_equal 'development', command.env(['-e', 'development'])
assert_equal 'development', command.env(['-e=development'])
end
end