https://gist.github.com/metaskills/1172519

Using sleep, setTimeout, etc., to wait for something to be ready is almost
always a bad idea b/c it is bound to fail eventually (e.g. your computer is
in a bad mood that day) and then you have a mysterious failing test or
worse a broken app.


On 7 May 2014 22:01, Adam Konner <notifications@github.com> wrote:

> In spec/features/filters_spec.rb:
>
> >        end
> >      end
> > -    it 'should not show acceptance levels without "accepted" status' do
> > -      expect(page).to have_no_content "#{@ratifications[2].acceptance_level.name}"
> > +
> > +    context "sorting" do
> > +      context "with no sort selected or search query entered" do
> > +        it "should be sorted by obligation" do
> > +          expect(page).to have_select 'sort', selected: 'Obligation'
> > +          assert { first('.quote').text =~ /#{@quotes[2].quote}/ }
> > +        end
> > +      end
> > +
> > +      context "sorted by organization" do
> > +        before do
> > +          select 'Authoring Body', from: 'sort'
> > +          sleep 0.1
>
> Well, the reason is it didn't work without it, and with it it does :) .
> Capybara, when JS enabled, is supposed to keep trying for up to 2 seconds
> to find a selector. Maybe in this case it was finding it right away because
> the page was still showing the old stuff, failing, and not waiting to try
> again. I thought it would. Anyway, it's just a test. Got a better idea?
>
> --
> Reply to this email directly or view it on GitHub<https://github.com/thecartercenter/eos/pull/10/files#r12412948>
> .
>



-- 
Tom Smyth
Worker-Owner, Sassafras Tech Collective
Specializing in innovative, usable tech for social change
sassafras.coop *·* @sassafrastech