这将是一个非常愚蠢的问题,我几乎讨厌自己提出这个问题,但现在这样.
当我运行我的Cucumber测试时,我得到一个"语法错误,意外的')'",使用以下代码:
在我的用户模型中:
def member?(gallery)
array = []
self.groups.each do |group|
array << group.id
end
if array.include?(gallery.group.id)
true
end
end
Run Code Online (Sandbox Code Playgroud)
在我看来:
<ul>
<% @galleries.each do |gallery| %>
<% if current_user.member?(gallery) %>
<li>
<%= link_to gallery.title, gallery %>
</li>
<% end %>
<% end %>
</ul>
Run Code Online (Sandbox Code Playgroud)
编辑:这是错误的重要部分:
~/Coding/Rails/galleryTest/app/views/galleries/index.html.erb:8: syntax error, unexpected ')', expecting keyword_then or ';' or '\n'
... current_user.member? gallery );@output_buffer.safe_concat('
... ^
~/Coding/Rails/galleryTest/app/views/galleries/index.html.erb:13: syntax error, unexpected keyword_end, expecting ')'
'); end
^
Run Code Online (Sandbox Code Playgroud)
编辑2:删除'='时出现以下错误:
Called id for nil, which would …
Run Code Online (Sandbox Code Playgroud) 所以我正在编写我的应用程序,使用Rails,Cucumber,RSpec进行功能优先的BDD.
我的客户要求在填写字段时计算总数.
我的问题是,这不是一个真正的功能,更多的是规范.这与创建发票的功能有关,但我认为这不符合整个集成测试的要求.
这只是javascript正在运行.
所以我的想法告诉我在视图规范中为此编写一个规范.它是否正确?是否有可能在rspec中测试这些javascript案例?
或者我应该进一步分离这一步并直接进行javascript测试框架?
我正在尝试用水豚和黄瓜测试一个帖子请求.我无法访问页面并按下链接发送请求,因为它有一个确认对话框,我没有使用javascript工作,所以我试图使用post方法,然后测试它是否重定向到适当的网址但是我得到了:
No response yet. Request a page first. (Rack::Test::Error)
Run Code Online (Sandbox Code Playgroud)
我的代码是:
page.driver.post url
page.driver.status_code.should be 302
follow_redirect!
Run Code Online (Sandbox Code Playgroud)
它工作正常,直到follow_redirect!
.我试过page.driver.follow_redirects!
但它也不起作用.
有帮助吗?
我想在我的方案数据中加注引号.当数据中包含引号时,它无法正常工作.从The Cucumber Book修改的一个例子是:
Then I should see the "<message>" message
Examples:
| type | message |
| Swiss | I love Swiss cheese |
| Blue | I love "Blue" cheese |
| Cheddar | I love Cheddar cheese |
Run Code Online (Sandbox Code Playgroud)
在我的特定情况下,由于上面第二个场景中的"蓝色",我得到一个未定义的步骤定义消息.有没有办法逃避报价?(我尝试过反斜杠,但没有任何区别.)
我在我的解决方案中设置了Cucumber-JS和Grunt-JS.
我的文件夹结构如下所示:
+ Project
+ features
- Search.feature
+ step_definitions
- Search_steps.js
+ support
- world.js
- package.json
- gruntfile.js
Run Code Online (Sandbox Code Playgroud)
我在gruntfile.js中添加了一个Cucumber-JS任务:
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
cucumberjs: {
src: 'features',
options: {
steps: 'features/step_definitions',
format: 'pretty'
}
}
});
grunt.loadNpmTasks('grunt-cucumber');
grunt.registerTask('default', ['cucumberjs']);
Run Code Online (Sandbox Code Playgroud)
我已经写出了我的功能文件:
Feature: Search
As a user of the website
I want to search
So that I can view items
Scenario: Searching for items
Given I am on the website
When I go to the homepage
Then I …
Run Code Online (Sandbox Code Playgroud) 我目前正在使用量角器,黄瓜和柴/柴作为我的自动化测试.我目前的代码是使用量角器1.8.0,我想将它更新到最新版本.问题是最新版本的量角器不支持黄瓜.
使用黄瓜作为框架,量角器(http://angular.github.io/protractor/#/frameworks)指向您使用量角器 - 黄瓜 - 框架(https://github.com/mattfritz/protractor-cucumber-framework).我已经尝试将它与我当前的代码和一些较小的示例项目集成,但没有运气让它们正常工作.我得到的主要错误是:
错误:在Timer.listOnTimeout(timers.js:92:15)5000毫秒后步进超时
我已尝试全局更改默认超时,因为黄瓜建议:// features/support/env.js
var configure = function () {
this.setDefaultTimeout(60 * 1000);
};
module.exports = configure;
Run Code Online (Sandbox Code Playgroud)
但我似乎错过了我的设置.
那么,有没有人知道一个很好的例子可以告诉我新的量角器/黄瓜框架的正确设置?如果没有,有没有人知道一个示例,说明如何全局更改默认超时?
我有两个@after标签,@ close-browser和@ screenshot.So,现在当我将两个标签用于特征文件时,它首先执行@ close-browser,并且在执行@screenshot方法后失败.有没有办法告诉黄瓜先在方法之后运行@screenshot?
请帮我解决这个问题
我在Capybara中有一个按钮:
<li id="main-menu-button" data-radium="true" style="flex: 0 0 auto; padding: 0px; box-sizing: border-box; color: rgb(158, 144, 212); display: flex; margin: 5px; border-radius: 5px; width: 50px; height: 50px; flex-flow: row nowrap; justify-content: center; position: relative; transition: background-color 100ms ease-out;">
<img src="/assets/images/branding/reachify-r-logo-white.png" alt="Logo" data-radium="true" style="width: 50px; height: 50px; padding: 10px; box-sizing: border-box; border-radius: 4px; background-color: rgba(0, 0, 0, 0.2);">
</li>
Run Code Online (Sandbox Code Playgroud)
我尝试使用:click_button“主菜单按钮”和find_button(“主菜单按钮”).click
但它给出了错误:
Unable to find button "Organization"
(Capybara::ElementNotFound)
Run Code Online (Sandbox Code Playgroud) 我正在寻找一种方法来获取在每个步骤中传递的所有参数,然后再输入我的功能文件中每个方案的实际方案.
示例功能文件:
Feature: Login action
Background:
When "{login url}" is open
Scenario: Registered user provides valid username and password
Given user enters username "{username}" and password "test password"
And user clicks on "btnLogin"
Then user is logged in
Run Code Online (Sandbox Code Playgroud)
我想得到的参数:
到目前为止我尝试了什么:
我尝试过使用一个常见的钩子,它将被我的所有场景自动使用:
public class ScenarioHook {
public ScenarioHook() {
}
@Before
public void setupScenario(Scenario scenario) throws InterruptedException {
//Here I am currently watching the {scenario} object and I can see all the …
Run Code Online (Sandbox Code Playgroud)我正在将黄瓜和水豚一起使用。我注意到,在安装捆绑软件之后,突然之间,我的测试失败了,新的换行符作为文本的一部分出现在字符串中。
错误示例:
RSpec::Expectations::ExpectationNotMetError: expected to find text "Longview Road Clase Swansea SA6 7JL" in "Skip to main content\nGOV.UK\nDigital tachograph card\n......."
Run Code Online (Sandbox Code Playgroud)
过去,那些换行符不存在。我正在努力寻找导致此问题的宝石。
有没有一种方法可以停止此操作,而无需在我从网页提取的每个字符串中都做一个剥离?
一些gem版本:
水豚-2.18 Rspec期望-3.7.0黄瓜-2.4.0
cucumber ×10
capybara ×3
javascript ×2
angularjs ×1
automation ×1
bdd ×1
cucumber-jvm ×1
feature-file ×1
gherkin ×1
gruntjs ×1
java ×1
junit ×1
protractor ×1
rake ×1
rspec ×1
ruby ×1
testing ×1