File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,20 @@ def extract_environment(args)
84
84
end
85
85
86
86
class RailsTest < Rails
87
+ def env ( args )
88
+ environment = "test"
89
+
90
+ args . each . with_index do |arg , i |
91
+ if arg =~ /--environment=(\w +)/
92
+ environment = $1
93
+ elsif i > 0 && args [ i - 1 ] == "-e"
94
+ environment = arg
95
+ end
96
+ end
97
+
98
+ environment
99
+ end
100
+
87
101
def command_name
88
102
"test"
89
103
end
Original file line number Diff line number Diff line change @@ -56,4 +56,19 @@ class CommandsTest < ActiveSupport::TestCase
56
56
assert_equal "test" , command . env ( [ "test:models" ] )
57
57
assert_nil command . env ( [ "test_foo" ] )
58
58
end
59
+
60
+ test 'RailsTest#command defaults to test rails environment' do
61
+ command = Spring ::Commands ::RailsTest . new
62
+ assert_equal 'test' , command . env ( [ ] )
63
+ end
64
+
65
+ test 'RailsTest#command sets rails environment from --environment option' do
66
+ command = Spring ::Commands ::RailsTest . new
67
+ assert_equal 'foo' , command . env ( [ '--environment=foo' ] )
68
+ end
69
+
70
+ test 'RailsTest#command sets rails environment from -e option' do
71
+ command = Spring ::Commands ::RailsTest . new
72
+ assert_equal 'foo' , command . env ( [ '-e' , 'foo' ] )
73
+ end
59
74
end
You can’t perform that action at this time.
0 commit comments