Questions tagged [rack-test]

46 questions
2
votes
1 answer

Testing rack-timeout in sinatra and ruby

This is something that I thought would be straightforward but I'm having issues around testing the rack-timeout gem. I have a sinatra base class with an endpoint which does some logic. module MyModule class MySinatra < Sinatra::Base use…
Rooktone
  • 109
  • 1
  • 5
2
votes
1 answer

How to check if response is a file?

How do I test if the response of a controller action in Rails is a file? (rack-test or capybara) Should I use unit tests to do it? The scenario is simple: I have to test if the exported users from the database are the same contained in the generated…
thiagofm
  • 5,693
  • 4
  • 20
  • 26
1
vote
1 answer

Rails system test drivers can I still use rack_test?

Rails system tests use Capybara. Capybara uses rack_test driver by default, while System tests uses selenium by default. Capybara Drivers: rack_test is a small ruby api which works with Rack (a web stack underlying nearly all Ruby web…
notapatch
  • 6,569
  • 6
  • 41
  • 45
1
vote
1 answer

Can I test that a Sinatra post method successfully saves to a YAML store?

I can't find a basic explanation anywhere about how I can test, with Rack::Test, that a Ruby/Sinatra post method successfully saves data to a YAML store/file. (This explains testing get, which I can do(!), but not post; other mentions of testing…
globewalldesk
  • 544
  • 1
  • 3
  • 18
1
vote
3 answers

How do I use Rack/Test to test Sinatra redirects? The App works, but the test doesn't

It would appear that either I am missing something very basic, or Rack/Test can't cope with Sinatra doing a redirect. Presumably there is a way around this or Rack/Test would be useless. Can anyone tell me what I should be doing to get it to work…
Andy Jones
  • 1,074
  • 1
  • 10
  • 21
1
vote
1 answer

Middleware not always called in capybara feature test (with rack-test)

I have a gem I'm working on that uses a railtie to add a middleware. Very simple stuff, followed the rails guides section almost exactly. Works fine in development/staging/production. The middleware initializes a hash-like object in the env at a…
steve
  • 3,276
  • 27
  • 25
1
vote
1 answer

Cucumber with Capybara/Rack-Test not working with DELETE route

I'm trying to run a cucumber test involving Devise and the code below is failing: When /^I logout$/ do page.driver.submit :delete, destroy_user_session_path, {} end The error message I receive is: No route matches [GET] "/"…
Winston Kotzan
  • 1,979
  • 20
  • 25
1
vote
1 answer

Gathering Logs within Rack::Test

I have a rack application (specifically a Sinatra one, but I don't think that matters) which, when running normally, happily outputs a bunch of information about the requests which are being made of it to STDOUT eg: 127.0.0.1 - - [25/Jul/2013…
JP.
  • 5,507
  • 15
  • 59
  • 100
1
vote
3 answers

ruby on rails 3 - undefined method `has_content?' for "HomePages":String

i'm new to ruby and i just start my first project. when i'm trying to run my first test throught rspec i failed. this is my gemfile: source 'https://rubygems.org' gem 'rails', '3.2.12' gem 'bootstrap-sass', '2.3.0.1' gem 'bcrypt-ruby', '3.0.1' gem…
Nir
  • 2,497
  • 9
  • 42
  • 71
1
vote
1 answer

How to send delete request and inspect the Capybara::Session instead of the Rack::Response?

I'm testing with cucumber, capybara and rack-test. I want to send a delete request and then inspect the response. I've found that the method visit(url) store the response in the object page which is a Capybara::Session. Now I'm sending the delete…
Bishma Stornelli
  • 2,539
  • 4
  • 22
  • 30
1
vote
1 answer

Padrino/Sinatra Rack-Test POST does not fill in params

I'm trying to use Rack-Test to issue a post request to my padrino app: post '/sms', "name" => "Bryan" My route looks like this: post :index do puts params.inspect puts rack_input.inspect end rack_input is a method I wrote to parse the raw rack…
zombor
  • 3,247
  • 17
  • 30
0
votes
1 answer

Is there an alternative for `rack-test` for Ruby 3?

We're using rack-test for our Cucumber specs. We've been trying to migrate over to Ruby 3 for a while now and the current issue is that the Cucumber tests crash due to rack-test using both keyword/positional args in their internal methods. I'm up…
0
votes
2 answers

Intercept capybara chrome headless visits

We use Capybara along with Chrome Headless for integration testing. I'd like to write a linter, that checks some metrics on the HTML structure everytime chrome navigates to another page. Then I'd raise an error when something is against our…
23tux
  • 14,104
  • 15
  • 88
  • 187
0
votes
1 answer

Mocking a post request with binary data in Sinatra

I have an endpoint in my Sinatra application that will be receiving binary data as part of the body. The other application sending it data will have a Faraday request that looks like this: connection = Faraday.new(url:…
codeadventurer
  • 611
  • 2
  • 8
  • 17
0
votes
1 answer

Rails 5, RSpec with RackTest - deletion of a record feature test

I created a very simple Rails 5 demo application that has a bunch of categories (Category model). There is a _category.html.erb partial with a link to remove a category: <%= link_to 'Remove', category_path(category), data: {method: :delete, confirm:…