require 'test_helper' class NavigationTest < ActiveSupport::IntegrationCase def wait_and_finish Streamit.finish! end def register_new_user visit "/users/new" fill_in "Name", :with => "davis" click_button "Create User" wait_and_finish end should "fetch limited number of streams" do register_new_user register_new_user register_new_user register_new_user wait_and_finish visit "/streamit/fetch?limit=2" assert page.has_selector?("li.stream", :count => 2), "Expected 2 streams, Got:\n#{page.body.inspect}" end should "fetch streams in last ? seconds" do Timecop.freeze(Time.now - 31.seconds) do register_new_user end register_new_user register_new_user wait_and_finish visit "/streamit/fetch?ago=30" assert page.has_selector?("li.stream", :count => 2), "Expected 2 streams, Got:\n#{page.body.inspect}" end should "fetch limited number of streams in last ? seconds" do Timecop.freeze(Time.now - 31.seconds) do register_new_user end register_new_user register_new_user register_new_user wait_and_finish visit "/streamit/fetch?ago=30&limit=2" assert page.has_selector?("li.stream", :count => 2), "Expected 2 streams, Got:\n#{page.body.inspect}" end end