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)
8484 end
8585
8686 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+
87101 def command_name
88102 "test"
89103 end
Original file line number Diff line number Diff line change @@ -56,4 +56,19 @@ class CommandsTest < ActiveSupport::TestCase
5656 assert_equal "test" , command . env ( [ "test:models" ] )
5757 assert_nil command . env ( [ "test_foo" ] )
5858 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
5974end
You can’t perform that action at this time.
0 commit comments