How do you POST to a URL in Capybara?

More recently I found this great blog post. Which is great for the cases like Tony and where you really want to post something in your cuke: For my case this became: def send_log(file, project) proj = Project.find(:first, :conditions => “name=”#{project}””) f = File.new(File.join(::Rails.root.to_s, file)) page.driver.post(“projects/” + proj.id.to_s + “/log?upload_path=” + f.to_path) page.driver.status_code.should eql 200 … Read more

Ensure an element is not present with Capybara

You can do this by making use of capybaras has_no_selector? method combined with rspecs magic matchers. You can then use it in this way: page.should have_no_selector(:xpath, “//input[@type=”#{type}” and @name=”#{name}”]”) You can see more details of the assertions you can perform on the capybara documentation page here under the section entitled Querying

Capybara: Unable to find css

I had the exact issue yesterday. Capybara was automatically ignoring the input due to it being invisible. I solved it with the following: find(‘#agreement’, :visible => false).click You can also add the following to env.rb to enable Capybara to interact with all hidden elements: Capybara.ignore_hidden_elements = false

How to assert on number of html table rows in ruby using capybara + cucumber

Even though have_css? will do the trick, your tests should tell you how they failed, rather than just saying some condition was supposed to be true and it was false. With this in mind, the first example below reads much better than the second: # IF FAILED => “expected 10, got 7” page.all(‘table#myTable tr’).count.should == … Read more

Rspec/Capybara loading in progress, circular require considered harmful

Remove –warnings from .rspec. The generator in rspec 3.0.0 included this setting, but we’ve realized it was a mistake — while it’s good to encourage users to write warning-free code, it’s confusing for users to get these warnings without being sure why. For more info: https://github.com/rspec/rspec-core/issues/1571

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)