免责声明:我仍然是Rails / Cucumber的新手,但我正在努力学习。我正在使用“web_steps”用于Cucumber,同时我正在阅读RailsInAction书,并且我已经尝试编写自己的步骤。我明白为什么他们被带走了,我会到那儿。
在我的一个Cucumber场景中,我填充了一些数据并尝试使用该数据来填充下拉列表。数据肯定是插入的,我知道这是因为我写了一个步骤来测试数据是否确实存在并且确实存在。
当DropDown被假设填充并且我尝试从该DropDown中“选择”时,我得到错误“*无法选择选项,在选择框'result_winner'(Capybara :: ElementNotFound)*中没有带文本'Steven'的选项*”
我确信我遗漏了一些基本的东西,但我现在已经失去了一个小时,我只需要一些帮助。
测试:
When I follow "Record new Result"
And the users "Steven, Joshua" exist
And I select "Steven" from "result_winner"
测试步骤:
When /^the users "([^"]*)" exist$/ do |playerNames|
@names = playerNames.scan(/[\w']+/)
for name in @names
@newPlayer = Player.new
@newPlayer.name = name
@newPlayer.save
end
end
然后是_form.html.erb中的视图代码:
<p>
<%= f.label :winner %>
<%= select("result", "winner", @players.map {|p| [p.name, p.id]}) %>
</p>
控制器:
def new
@result = Result.new
@players = Player.find(:all)
end
如果我手动使用名称填充开发数据库并将其加载到浏览器中,则下拉列表中会填充数据并完美运行。我很确定我误解了测试数据何时/何处可见,或者如何测试和从下拉列表中选择数据。
非常感谢任何帮助。
答案 0 :(得分:3)
在我看来,这就像步骤序列的一个简单问题。您正在访问该页面,然后填充数据库,但不会重新加载该页面以考虑新的数据库值。如果您交换前两个步骤的顺序,我希望能解决它。
要明确的是,黄瓜一次只能逐行完成你的情景:
答案 1 :(得分:0)
您的“用户“ Steven,Joshua”存在“应该在给定步骤中。
它描述了执行操作之前的状态。
Severity Code Description Project File Line Suppression State
Error ADB0010: Unexpected install output: Error: Unknown option: -d
usage: pm list packages [-f] [-d] [-e] [-s] [-3] [-i] [-u] [FILTER]
pm list permission-groups
pm list permissions [-g] [-f] [-d] [-u] [GROUP]
pm list instrumentation [-f] [TARGET-PACKAGE]
pm list features
pm list libraries
pm path PACKAGE
pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] [-s] [-f]
[--algo <algorithm name> --key <key-in-hex> --iv <IV-in-hex>] PATH
pm uninstall [-k] PACKAGE
pm clear PACKAGE
pm enable PACKAGE_OR_COMPONENT
pm disable PACKAGE_OR_COMPONENT
pm disable-user PACKAGE_OR_COMPONENT
pm grant PACKAGE PERMISSION
pm revoke PACKAGE PERMISSION
pm set-install-location [0/auto] [1/internal] [2/external]
pm get-install-location
pm set-permission-enforced PERMISSION [true|false]
pm list packages: prints all packages, optionally only
those whose package name contains the text in FILTER. Options:
-f: see their associated file.
-d: filter to only show disbled packages.
-e: filter to only show enabled packages.
-s: filter to only show system packages.
-3: filter to only show third party packages.
-i: see the installer for the packages.
-u: also include uninstalled packages.
pm list permission-groups: prints all known permission groups.
pm list permissions: prints all known permissions, optionally only
those in GROUP. Options:
-g: organize by group.
-f: print all information.
-s: short summary.
-d: only list dangerous permissions.
-u: list only the permissions users will see.
pm list instrumentation: use to list all test packages; optionally
supply <TARGET-PACKAGE> to list the test packages for a particular
application. Options:
-f: list the .apk file for the test package.
pm list features: prints all features of the system.
pm path: print the path to the .apk of the given PACKAGE.
pm install: installs a package to the system. Options:
-l: install the package with FORWARD_LOCK.
-r: reinstall an exisiting app, keeping its data.
-t: allow test .apks to be installed.
-i: specify the installer package name.
-s: install package on sdcard.
-f: install package on internal flash.
pm uninstall: removes a package from the system. Options:
-k: keep the data and cache directories around after package removal.
pm clear: deletes all data associated with a package.
pm enable, disable, disable-user: these commands change the enabled state
of a given package or component (written as "package/class").
pm grant, revoke: these commands either grant or revoke permissions
to applications. Only optional permissions the application has
declared can be granted or revoked.
pm get-install-location: returns the current install location.
0 [auto]: Let system decide the best location
1 [internal]: Install on internal device storage
2 [external]: Install on external media
pm set-install-location: changes the default install location.
NOTE: this is only intended for debugging; using this can cause
applications to break and other undersireable behavior.
0 [auto]: Let system decide the best location
1 [internal]: Install on internal device storage
2 [external]: Install on external media
at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) in E:\A\_work\293\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 345
at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass95_0.<InstallPackage>b__0(Task`1 t) in E:\A\_work\293\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 753
at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute() 0
Severity Code Description Project File Line Suppression State
Error ADB0000: Deployment failed
Mono.AndroidTools.InstallFailedException: Unexpected install output: Error: Unknown option: -d
usage: pm list packages [-f] [-d] [-e] [-s] [-3] [-i] [-u] [FILTER]
pm list permission-groups
pm list permissions [-g] [-f] [-d] [-u] [GROUP]
pm list instrumentation [-f] [TARGET-PACKAGE]
pm list features
pm list libraries
pm path PACKAGE
pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] [-s] [-f]
[--algo <algorithm name> --key <key-in-hex> --iv <IV-in-hex>] PATH
pm uninstall [-k] PACKAGE
pm clear PACKAGE
pm enable PACKAGE_OR_COMPONENT
pm disable PACKAGE_OR_COMPONENT
pm disable-user PACKAGE_OR_COMPONENT
pm grant PACKAGE PERMISSION
pm revoke PACKAGE PERMISSION
pm set-install-location [0/auto] [1/internal] [2/external]
pm get-install-location
pm set-permission-enforced PERMISSION [true|false]
pm list packages: prints all packages, optionally only
those whose package name contains the text in FILTER. Options:
-f: see their associated file.
-d: filter to only show disbled packages.
-e: filter to only show enabled packages.
-s: filter to only show system packages.
-3: filter to only show third party packages.
-i: see the installer for the packages.
-u: also include uninstalled packages.
pm list permission-groups: prints all known permission groups.
pm list permissions: prints all known permissions, optionally only
those in GROUP. Options:
-g: organize by group.
-f: print all information.
-s: short summary.
-d: only list dangerous permissions.
-u: list only the permissions users will see.
pm list instrumentation: use to list all test packages; optionally
supply <TARGET-PACKAGE> to list the test packages for a particular
application. Options:
-f: list the .apk file for the test package.
pm list features: prints all features of the system.
pm path: print the path to the .apk of the given PACKAGE.
pm install: installs a package to the system. Options:
-l: install the package with FORWARD_LOCK.
-r: reinstall an exisiting app, keeping its data.
-t: allow test .apks to be installed.
-i: specify the installer package name.
-s: install package on sdcard.
-f: install package on internal flash.
pm uninstall: removes a package from the system. Options:
-k: keep the data and cache directories around after package removal.
pm clear: deletes all data associated with a package.
pm enable, disable, disable-user: these commands change the enabled state
of a given package or component (written as "package/class").
pm grant, revoke: these commands either grant or revoke permissions
to applications. Only optional permissions the application has
declared can be granted or revoked.
pm get-install-location: returns the current install location.
0 [auto]: Let system decide the best location
1 [internal]: Install on internal device storage
2 [external]: Install on external media
pm set-install-location: changes the default install location.
NOTE: this is only intended for debugging; using this can cause
applications to break and other undersireable behavior.
0 [auto]: Let system decide the best location
1 [internal]: Install on internal device storage
2 [external]: Install on external media
at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) in E:\A\_work\293\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 345
at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass95_0.<InstallPackage>b__0(Task`1 t) in E:\A\_work\293\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 753
at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute() 0