-
Choose one of the following tracks:
-
Skim/Read through the associated links
-
Attempt to hook up and implement unit or feature js tests in your IdeaBox or this sample idea-bin project
-
Fork this gist
-
Respond with:
I had huge trouble with getting selenium up and running. I updated the selenium gem, I used approaches from stack overflow to configure selenium differently in the spec_helper. Only after downgrading firefox to the prior version (46 instead of the current 47), the driver worked and I could run my tests. I still ran into some issues that made me change my design of the page. Rspec/selenium wouldn't recognize glyphicons inside of button tags. I had to change them to a tags for rspec to run the test properly.
Yes, I was successful and I could test every feature I implemented with js. It was great to see what worked on the actual browser page and what didn't but it didn't help so much figuring out where the test failed. The message from rspec was still the best source for debugging. And the test suite gets really slow with this browser. I am thinking of trying a headless browser next time to see the difference.
RSpec.feature "user changes quality of idea" do scenario "user upvotes idea", js: true do idea = create(:idea) visit '/' expect(page).to have_content("swill") within("#idea-#{idea.id}") do find(".upvote").click end expect(page).to have_current_path('/') expect(page).to have_content("plausible") within("#idea-#{idea.id}") do find(".upvote").click end expect(page).to have_content("genius") within("#idea-#{idea.id}") do find(".upvote").click end expect(page).to have_content("genius") end
RSpec.feature "user deletes idea", :js => true do scenario "they no longer see the idea on the page" do create_list(:idea, 3) idea = Idea.first visit '/' within("li:first-child") { expect(page).to have_content(idea.title) expect(page).to have_content(idea.body) find(".delete-idea").click wait_for_ajax expect(page).not_to have_content(idea.title) expect(page).not_to have_content(idea.body) } end
end