capybara

Error in testing ruby on rails using rspec in tutorial

孤街浪徒 提交于 2019-12-23 05:04:05
问题 I am newbie for ruby on rails i am just reading the http://ruby.railstutorial.org/chapters/static-pages#top as the tutorial saying, i have created the sample_app bundle or project. Now in section 3.2.1 i am testing the app. first i run the following from the cmd $ rails generate integration_test static_pages This created the static_pages_spec.rb in the spec/requests directory. Now add the following code in spec/requests/static_pages_spec.rb require 'spec_helper' describe "Static pages" do

Error in testing ruby on rails using rspec in tutorial

…衆ロ難τιáo~ 提交于 2019-12-23 05:04:05
问题 I am newbie for ruby on rails i am just reading the http://ruby.railstutorial.org/chapters/static-pages#top as the tutorial saying, i have created the sample_app bundle or project. Now in section 3.2.1 i am testing the app. first i run the following from the cmd $ rails generate integration_test static_pages This created the static_pages_spec.rb in the spec/requests directory. Now add the following code in spec/requests/static_pages_spec.rb require 'spec_helper' describe "Static pages" do

Passing Custom Headers to Selenium from Capybara

三世轮回 提交于 2019-12-23 03:58:12
问题 We use custom headers to authenticate our web apps. An http proxy service intercepts requests, confirms the authenticity of the user and then injects custom headers into the request. In order to test the app, I need to write those headers into the request before it hits my ApplicationController methods. Right now, the current hack works for all my non-javascript tests: # in hooks.rb Before do require 'capybara/driver/rack_test_driver' module Capybara::Driver class Authentic < RackTest def env

capybaraWebKit is unable to visit webpages when running RSpec tests when :js => true

怎甘沉沦 提交于 2019-12-23 01:59:31
问题 On previous RSpec integration tests where :js => false (i.e., JavaScript was turned off), my tests were running just fine. However, for RSpec tests where :js => true (and therefore needing to use capybara WebKit), I consistently get the following error: Unable to load URL: http://my.server:5000/auth/identity because of error loading http://my.server:5000/auth/identity: Unknown error Noted this is happening on a line of code that was working just fine when :js => false (it is part of a method

Rails carrierwave testing - how to remove file after test?

人走茶凉 提交于 2019-12-23 01:16:32
问题 I am testing the carrierwave upload functionality using rspec and capybara. I have something like: describe "attachment" do let(:local_path) { "my/file/path" } before do attach_file('Attachment file', local_path) click_button "Save changes" end specify {user.attachment.should_not be_nil} it { should have_link('attachment', href: user.attachment_url) } end And this works great. The problem is that after testing the uploaded image remains in my public/uploads directory. How can I remove it

save_and_open_page has stopped serving up my css

人走茶凉 提交于 2019-12-23 01:12:45
问题 My testing setup was working very nicely serving up pages correctly formatted with css whenever I called save_and_open_page from within a test. I then set up some javascript tests and made a few changes to my setup (sorry I can't detail them all - I haven't documented things well enough). After making changes I now get unformatted html in the browser when I call save_and_open_page . Here's my spec/spec_helper.rb require 'rubygems' require 'spork' Spork.prefork do ENV["RAILS_ENV"] ||= 'test'

How to enable ChromeDriver logging in Ruby Capybara with Selenium?

旧时模样 提交于 2019-12-22 20:21:32
问题 I have tried to register Selenium chrome driver in ruby Capybara. But unfortunately, I didn`t find any information about enabling logging. I used options with added perfLoggingPrefs: {enableNetwork: true} and faced issue that i should enable logging. Does anyone know how can I enable logging for ChromeDriver in Ruby/Capybara? So here is my code now: Capybara.register_driver(:selenium_mobile) do |app| options = Selenium::WebDriver::Chrome::Options.new options.add_emulation(device_name: 'iPhone

Capybara cannot fill Stripe Checkout.js fields

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-22 19:42:02
问题 I am having a difficult time testing Stripe's Checkout.js product with Capybara. The problem is Stripe has some tricky client side validation that fools Capybara's javascript driver, so when I tell Capybara to fill in a field, like this: fill_in "card_number", with: "4242424242424242" Stripe field only fills up oly the first three digits then it automatically puts a space after those digits, and that breaks Capybara badly. How can I fix this? 回答1: I don't know exactly but when i get into

Rails: RSpec - undefined method `cookie_jar' for nil:NilClass

孤者浪人 提交于 2019-12-22 09:47:02
问题 Rails newbie. Trying to follow Michael Hartl's tutorial. Stuck trying to add a helper method to simulate log in an RSpec test: describe "when the a user has logged in and attempts to visit the page" do let(:user) { FactoryGirl.create :user } before do log_in user end it "should redirect the user to next page" do specify { response.should redirect_to loggedin_path } end end In my spec/support/utilities.rb: def log_in user visit root_path fill_in "Email", with: user.email fill_in "Password",

RSpec+Capybara request specs w/ JS not working

一曲冷凌霜 提交于 2019-12-22 09:32:55
问题 I cannot get request specs working when using Javascript. My specs pass if I run them without Javascript (the page is built to work with or without JS). Specifically, the specs fail when I do assertions like Post.should have(1).record . Capybara just doesn't pick up the records from the DB, and the database is not cleaned between runs. I've tried using DatabaseCleaner with transactional fixtures disabled - the common approach to this, I guess. No dice. I've also tried (and, would ideally