无论页面内容如何,Cucumber/capybara功能始终通过
我有以下情况:无论页面内容如何,Cucumber/capybara功能始终通过,cucumber,capybara,Cucumber,Capybara,我有以下情况: Background: Given the following roles exist: | id | name | | 1 | janitor | And the following users exist: | username | password | email | role_ids | | janitor | Cleaning31 | janitor@example.com | 1 |
Background:
Given the following roles exist:
| id | name |
| 1 | janitor |
And the following users exist:
| username | password | email | role_ids |
| janitor | Cleaning31 | janitor@example.com | 1 |
And I am logged in as "janitor" with password "Cleaning31"
And the following articles exist:
| id | title | slug | content |
| 1 | Article One | article-one | Article one. |
Scenario: Seeing link for deleting an article
When I view the article list
Then I should see the "Delete" link for article 1
…以及最后一步的定义:
Then /^I should (not )?see the "([^"]*)" link (?:in|under|for) article (\d+)$/ do |negation, content, article_id|
page.should have_selector("\#article_#{article_id}") do |article|
if negation
article.should_not have_css('a', text: content)
else
article.should have_css('a', text: content)
end
end
end
即使我在特性或视图中将“Delete”一词改为“thisnownedwork”,特性也总是通过。但是,在浏览器中,“删除”链接仅正确显示在具有“看门人”角色的用户的文章上
Cucumber的“向我展示页面”和“向我展示响应”似乎没有定义,尽管有大量文章建议应该这样做。(我的)
其他功能似乎如预期的那样工作。有人能看出我在这方面出了什么问题吗 我在您的测试中没有看到断言。尝试将
article.should\u not'u css('a',text:content)
更改为assert article.should\u not'u css('a',text:content)
,依此类推
编辑:
结果如何
element = page.find("\#article_#{article_id}")
if negation
element.should_not have_css('a', text: content)
else
element.should have_css('a', text: content)
end
我想您应该使用find helper,然后对找到的元素进行断言。我想知道你在块中有什么作为“文章”可用。我在你的测试中没有看到断言。尝试将
article.should\u not'u css('a',text:content)
更改为assert article.should\u not'u css('a',text:content)
,依此类推
编辑:
结果如何
element = page.find("\#article_#{article_id}")
if negation
element.should_not have_css('a', text: content)
else
element.should have_css('a', text: content)
end
我想您应该使用find helper,然后对找到的元素进行断言。我想知道你在区块中有什么作为“文章”提供。谢谢,但那没有任何区别;无论内容如何,它仍然会通过。所有其他功能都是以相同的风格编写的,并且工作正常,当然。不应该,也应该是断言本身吗?这很有效,谢谢!我想知道我是不是在尝试将Webrat风格用于水豚?对不起,我对Webrat的经验很少,因为我很快发现水豚远远优于Webrat,并在那之后很快做出了改变:)谢谢,但这没有任何区别;无论内容如何,它仍然会通过。所有其他功能都是以相同的风格编写的,并且工作正常,当然。不应该,也应该是断言本身吗?这很有效,谢谢!我想知道我是不是在尝试将Webrat风格与Capybara结合使用?很抱歉,我对Webrat没有多少经验,因为我很快发现,Capybara远远优于Webrat,并在那之后很快做出了改变:)