File tree Expand file tree Collapse file tree 4 files changed +49
-3
lines changed Expand file tree Collapse file tree 4 files changed +49
-3
lines changed Original file line number Diff line number Diff line change @@ -156,7 +156,7 @@ preferred environment variables project-wide using a tool like
156156
157157
158158* ** CYPRESS_RAILS_DIR** (default: ` Dir.pwd ` ) the directory of your Rails project
159- * ** CYPRESS_DIR ** (default: ` Dir.pwd ` ) the directory of your Cypress project
159+ * ** CYPRESS_RAILS_CYPRESS_DIR ** (default: _ same value as ` rails_dir ` _ ) the directory of your Cypress project
160160* ** CYPRESS_RAILS_HOST** (default: ` "127.0.0.1" ` ) the hostname to bind to
161161* ** CYPRESS_RAILS_PORT** (default: _ a random available port_ ) the port to run
162162 the Rails test server on
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ class Config
66
77 def initialize (
88 rails_dir : Env . fetch ( "CYPRESS_RAILS_DIR" , default : Dir . pwd ) ,
9- cypress_dir : Env . fetch ( "CYPRESS_DIR " , default : Dir . pwd ) ,
9+ cypress_dir : Env . fetch ( "CYPRESS_RAILS_CYPRESS_DIR " , default : rails_dir ) ,
1010 host : Env . fetch ( "CYPRESS_RAILS_HOST" , default : "127.0.0.1" ) ,
1111 port : Env . fetch ( "CYPRESS_RAILS_PORT" ) ,
1212 base_path : Env . fetch ( "CYPRESS_RAILS_BASE_PATH" , default : "/" ) ,
@@ -28,7 +28,7 @@ def to_s
2828 cypress-rails configuration:
2929 ============================
3030 CYPRESS_RAILS_DIR.....................#{ rails_dir . inspect }
31- CYPRESS_DIR.............. .............#{ cypress_dir . inspect }
31+ CYPRESS_RAILS_CYPRESS_DIR .............#{ cypress_dir . inspect }
3232 CYPRESS_RAILS_HOST....................#{ host . inspect }
3333 CYPRESS_RAILS_PORT....................#{ port . inspect }
3434 CYPRESS_RAILS_BASE_PATH...............#{ base_path . inspect }
Original file line number Diff line number Diff line change @@ -15,5 +15,7 @@ echo "---> Running tests"
1515bundle exec rake
1616./script/test_example_app
1717
18+ bundle exec rake test
19+
1820echo " ---> Job's done!"
1921
Original file line number Diff line number Diff line change 1+ require_relative "test_helper"
2+
3+ class ConfigTest < Minitest ::Test
4+ def test_that_rails_dir_and_cypress_dir_use_default_directory
5+ config = CypressRails ::Config . new
6+ expected_directory_path = Dir . pwd
7+
8+ assert_equal ( expected_directory_path , config . rails_dir )
9+ assert_equal ( expected_directory_path , config . cypress_dir )
10+ end
11+
12+ def test_that_rails_dir_and_cypress_dir_can_be_independently_set
13+ mock_env (
14+ "CYPRESS_RAILS_DIR" => "path/to/cypress-rails" ,
15+ "CYPRESS_RAILS_CYPRESS_DIR" => "path/to/another/cypress/directory"
16+ ) do
17+ config = CypressRails ::Config . new
18+
19+ assert_equal ( "path/to/cypress-rails" , config . rails_dir )
20+ assert_equal ( "path/to/another/cypress/directory" , config . cypress_dir )
21+ end
22+ end
23+
24+ def test_that_cypress_dir_uses_same_directory_as_rails_dir_when_not_set
25+ mock_env ( "CYPRESS_RAILS_DIR" => "path/to/cypress-rails" ) do
26+ config = CypressRails ::Config . new
27+
28+ assert_nil ( ENV [ "CYPRESS_RAILS_CYPRESS_DIR" ] )
29+ assert_equal ( "path/to/cypress-rails" , config . cypress_dir )
30+ end
31+ end
32+
33+ private
34+
35+ def mock_env ( partial_env_hash )
36+ old = ENV . to_hash
37+ ENV . update partial_env_hash
38+ begin
39+ yield
40+ ensure
41+ ENV . replace old
42+ end
43+ end
44+ end
You can’t perform that action at this time.
0 commit comments