Capybara tests with first-child/last-child randomly fails so replaced with alternative method

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2013-11-27 15:00:57 +02:00
parent 3f94e14d96
commit 81eae5de89
No known key found for this signature in database
GPG Key ID: 2CEAFD2671262EC2
1 changed files with 18 additions and 10 deletions

View File

@ -107,15 +107,15 @@ describe "Issues" do
it 'sorts by newest' do
visit project_issues_path(project, sort: 'newest')
page.should have_selector("ul.issues-list li:first-child", text: 'foo')
page.should have_selector("ul.issues-list li:last-child", text: 'baz')
first_issue.should include("foo")
last_issue.should include("baz")
end
it 'sorts by oldest' do
visit project_issues_path(project, sort: 'oldest')
page.should have_selector("ul.issues-list li:first-child", text: 'baz')
page.should have_selector("ul.issues-list li:last-child", text: 'foo')
first_issue.should include("baz")
last_issue.should include("foo")
end
it 'sorts by most recently updated' do
@ -123,7 +123,7 @@ describe "Issues" do
baz.save
visit project_issues_path(project, sort: 'recently_updated')
page.should have_selector("ul.issues-list li:first-child", text: 'baz')
first_issue.should include("baz")
end
it 'sorts by least recently updated' do
@ -131,7 +131,7 @@ describe "Issues" do
baz.save
visit project_issues_path(project, sort: 'last_updated')
page.should have_selector("ul.issues-list li:first-child", text: 'baz')
first_issue.should include("baz")
end
describe 'sorting by milestone' do
@ -145,13 +145,13 @@ describe "Issues" do
it 'sorts by recently due milestone' do
visit project_issues_path(project, sort: 'milestone_due_soon')
page.should have_selector("ul.issues-list li:first-child", text: 'foo')
first_issue.should include("foo")
end
it 'sorts by least recently due milestone' do
visit project_issues_path(project, sort: 'milestone_due_later')
page.should have_selector("ul.issues-list li:first-child", text: 'bar')
first_issue.should include("bar")
end
end
@ -168,10 +168,18 @@ describe "Issues" do
it 'sorts with a filter applied' do
visit project_issues_path(project, sort: 'oldest', assignee_id: user2.id)
page.should have_selector("ul.issues-list li:first-child", text: 'bar')
page.should have_selector("ul.issues-list li:last-child", text: 'foo')
first_issue.should include("bar")
last_issue.should include("foo")
page.should_not have_content 'baz'
end
end
end
def first_issue
all("ul.issues-list li").first.text
end
def last_issue
all("ul.issues-list li").last.text
end
end