Commit 81eae5de89d13e6079ee5a9d975216d1a460d8d0

Authored by Dmitriy Zaporozhets
1 parent 3f94e14d

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

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing 1 changed file with 18 additions and 10 deletions   Show diff stats
spec/features/issues_spec.rb
... ... @@ -107,15 +107,15 @@ describe &quot;Issues&quot; do
107 107 it 'sorts by newest' do
108 108 visit project_issues_path(project, sort: 'newest')
109 109  
110   - page.should have_selector("ul.issues-list li:first-child", text: 'foo')
111   - page.should have_selector("ul.issues-list li:last-child", text: 'baz')
  110 + first_issue.should include("foo")
  111 + last_issue.should include("baz")
112 112 end
113 113  
114 114 it 'sorts by oldest' do
115 115 visit project_issues_path(project, sort: 'oldest')
116 116  
117   - page.should have_selector("ul.issues-list li:first-child", text: 'baz')
118   - page.should have_selector("ul.issues-list li:last-child", text: 'foo')
  117 + first_issue.should include("baz")
  118 + last_issue.should include("foo")
119 119 end
120 120  
121 121 it 'sorts by most recently updated' do
... ... @@ -123,7 +123,7 @@ describe &quot;Issues&quot; do
123 123 baz.save
124 124 visit project_issues_path(project, sort: 'recently_updated')
125 125  
126   - page.should have_selector("ul.issues-list li:first-child", text: 'baz')
  126 + first_issue.should include("baz")
127 127 end
128 128  
129 129 it 'sorts by least recently updated' do
... ... @@ -131,7 +131,7 @@ describe &quot;Issues&quot; do
131 131 baz.save
132 132 visit project_issues_path(project, sort: 'last_updated')
133 133  
134   - page.should have_selector("ul.issues-list li:first-child", text: 'baz')
  134 + first_issue.should include("baz")
135 135 end
136 136  
137 137 describe 'sorting by milestone' do
... ... @@ -145,13 +145,13 @@ describe &quot;Issues&quot; do
145 145 it 'sorts by recently due milestone' do
146 146 visit project_issues_path(project, sort: 'milestone_due_soon')
147 147  
148   - page.should have_selector("ul.issues-list li:first-child", text: 'foo')
  148 + first_issue.should include("foo")
149 149 end
150 150  
151 151 it 'sorts by least recently due milestone' do
152 152 visit project_issues_path(project, sort: 'milestone_due_later')
153 153  
154   - page.should have_selector("ul.issues-list li:first-child", text: 'bar')
  154 + first_issue.should include("bar")
155 155 end
156 156 end
157 157  
... ... @@ -168,10 +168,18 @@ describe &quot;Issues&quot; do
168 168 it 'sorts with a filter applied' do
169 169 visit project_issues_path(project, sort: 'oldest', assignee_id: user2.id)
170 170  
171   - page.should have_selector("ul.issues-list li:first-child", text: 'bar')
172   - page.should have_selector("ul.issues-list li:last-child", text: 'foo')
  171 + first_issue.should include("bar")
  172 + last_issue.should include("foo")
173 173 page.should_not have_content 'baz'
174 174 end
175 175 end
176 176 end
  177 +
  178 + def first_issue
  179 + all("ul.issues-list li").first.text
  180 + end
  181 +
  182 + def last_issue
  183 + all("ul.issues-list li").last.text
  184 + end
177 185 end
... ...