我之前从未使用过ruby和rspec。
我写了几行代码,用户可以从他们的mac中删除钥匙串。
$ ./node_modules/.bin/wdio --spec ./test_js/specs/features/aggregated/dataAccessControl.feature.js
----------
selenium-standalone installation starting
----------
---
selenium install:
from: https://selenium-release.storage.googleapis.com/3.9/selenium-server-standalone-3.9.1.jar
to: /PROJECT_PATH/node_modules/selenium-standalone/.selenium/selenium-server/3.9.1-server.jar
---
chrome install:
from: https://chromedriver.storage.googleapis.com/2.35/chromedriver_mac64.zip
to: /PROJECT_PATH/node_modules/selenium-standalone/.selenium/chromedriver/2.35-x64-chromedriver
---
File from https://selenium-release.storage.googleapis.com/3.9/selenium-server-standalone-3.9.1.jar has already been downloaded
---
File from https://chromedriver.storage.googleapis.com/2.35/chromedriver_mac64.zip has already been downloaded
-----
selenium-standalone installation finished
-----
A service failed in the 'onPrepare' hook
Error: Unable to connect to selenium
at Timeout.hasStarted [as _onTimeout] (/PROJECT_PATH/node_modules/selenium-standalone/lib/check-started.js:17:10)
at ontimeout (timers.js:475:11)
at tryOnTimeout (timers.js:310:5)
at Timer.listOnTimeout (timers.js:270:5)
Continue...
ERROR: session not created exception
from disconnected: unable to connect to renderer
chrome
at new RuntimeError (/PROJECT_PATH/node_modules/webdriverio/build/lib/utils/ErrorHandler.js:144:12)
at Request._callback (/PROJECT_PATH/node_modules/webdriverio/build/lib/utils/RequestHandler.js:313:39)
at Request.self.callback (/PROJECT_PATH/node_modules/request/request.js:186:22)
at emitTwo (events.js:126:13)
at Request.emit (events.js:214:7)
at Request.<anonymous> (/PROJECT_PATH/node_modules/request/request.js:1163:10)
at emitOne (events.js:116:13)
at Request.emit (events.js:211:7)
at IncomingMessage.<anonymous> (/PROJECT_PATH/node_modules/request/request.js:1085:12)
at Object.onceWrapper (events.js:313:30)
代码工作正常,但我需要使用rspec添加unittest。
如何将 elsif params[:name]
# get default keychains list
default_path = Fastlane::Actions.sh("security list-keychains", log: false).split
# iterate to find any of the items in the list matches with parameter name
does_keychain_exists = true
default_path.each do |path_to_keychain|
# sometimes keychain saved as name.keychain-db, check that case too
if path_to_keychain.include?(params[:name]) == true || path_to_keychain.include?("#{params[:name]}-db") == true
keychain_path = FastlaneCore::Helper.keychain_path(params[:name])
if File.exist?(keychain_path)
complete_delete(original, keychain_path)
else
does_keychain_exists = false
end
else
does_keychain_exists = false
end
end
存根,以便default_path变量获得类似
default_path = Fastlane::Actions.sh("security list-keychains", log: false).split
或~/Library/Keychains/test.keychain
我正在尝试编辑的单元测试是:
user/username/Library/Keychains/test.keychain
答案 0 :(得分:1)
你可以这样做:
keychains = double("keychains")
allow(keychains).to receive(:split).and_return(["~/Library/Keychains/test.keychain", "user/username/Library/Keychains/test.keychain"]
allow(Fastlane::Actions).to receive(:sh).with("security list-keychains", log: false)).and_return(keychains)