Questions tagged [rack-test]

46 questions
0
votes
1 answer

Can I use rack-test for deployment tests?

I've built a simple api in Sinatra, with the purpose of setting up a deployment pipeline using Docker. I'm at a stage where I could easily switch Sinatra for something else and there's currently one reason why I might do so. I once wrote an api…
Erik B
  • 40,889
  • 25
  • 119
  • 135
0
votes
2 answers

Configuring rack-test to start the server indirectly

Here is my rack application: class MainAppLogic def initialize Rack::Server.start(:app =>Server, :server => "WEBrick", :Port => "8080") end end class Server def self.call(env) return [200, {},["Hello, World"]] …
thesecretmaster
  • 1,950
  • 1
  • 27
  • 39
0
votes
1 answer

Capybara feature specs only working if js: true

My test code in the spec/features/posts_spec.rb looks like this require 'spec_helper' feature 'Posts' do scenario 'Editing of Micropost', js: true do visit '/signin' fill_in 'Email', with: 'user@example.com ... The code works fine with…
Obromios
  • 15,408
  • 15
  • 72
  • 127
0
votes
1 answer

Resizing the window in Capybara with rack_test

I'm using rack_test as my driver for Capybara and I'm trying to resize the window. The best example I could find on this was this gist, but the resize method does not seem to work for rack_test > Capybara.current_driver => :rack_test >…
user2490003
  • 10,706
  • 17
  • 79
  • 155
0
votes
1 answer

Rack::Test::Methods setting id when using get method

I'm struggling with API methods from Rack::Test. Providing the resource parametets, makes sense for the post method, but for get, seems, it doesn't. When I want to fetch the resource with definite id, I'm trying to make the request: get…
DreamWalker
  • 1,327
  • 1
  • 11
  • 19
0
votes
0 answers

POST request with Capybara/Cucumber and Rack/Test

I have the same problem as follows: In "support/env.rb": module CapybaraApp def app; Capybara.app; end end World(CapybaraApp) World(Rack::Test::Methods) In "step_definitions/restUtils.rb": Quando /^Send POST request to "([^\"]*)" with:$/ do |url,…
0
votes
1 answer

Sinatra Rack Test "0 Tests" run

I'm trying to get some unit tests written for a small Sinatra app. When I run ruby test.rb, the terminal reports that it is "running tests" but it is not actually picking up my unit tests. The app itself runs fine whether by locally typing ruby…
jdussault
  • 427
  • 5
  • 12
0
votes
1 answer

Running two tests simultaneously in RSpec / Rack::Test / Sinatra

Given the example sinatra app post '/1' do sleep(1) until @2 0 end post '/2' do @2 = true 0 end and the example RSpec test describe 'test' do it 'does /1' do post '/1' expect(last_response.body) to eq?(0) end it 'does /2' …
VULPINE
  • 31
  • 3
0
votes
2 answers

When writing Rails controller tests, why use #post vs #get vs #delete?

I'm realizing I don't understand the rationale for why Rails controller tests / specs are structured the way they are. When writing controller tests, we're encouraged to more or less treat the controller as a unit and write unit tests accordingly,…
Topher Hunt
  • 4,404
  • 2
  • 27
  • 51
0
votes
0 answers

How to set the variable "app" in Rack Test?

I have an Rack app: def app Rack::Builder.new{ run MyApp }.to_app end This works fine, but I want to change app to something else, because there is an model named App. How to set Rack Test to run against an app with another name?…
B Seven
  • 44,484
  • 66
  • 240
  • 385
0
votes
1 answer

Ruby load module in test

I am running a padrino application and have started with the included mailers. I want to test that a mail is sent and had previously had no trouble accessing the Mail::TestMailer object to look at the mails delivered during the test. That is the…
Peter Saxton
  • 4,466
  • 5
  • 33
  • 51
0
votes
0 answers

Rails 4.1 + Rspec + rack-test : undefined method `app'

I've been working on a Rails 4.1.1 app and I am setting up Rspec. I want to test a controller using the rask-test last_response method. I followed the instructions and here is my spec_helper.rb file require 'rack/test' require…
0
votes
1 answer

minitest racktest

Does anybody have any examples of using minitest and reacktest together to create request specs? I want to be able to request a resource: get '/api/resource', format: :json And then test the response.
dagda1
  • 26,856
  • 59
  • 237
  • 450
0
votes
2 answers

Why does rspec fail?

i want to check page's title through rspec. in chrome i see the expected result but rspec claim the title is empty(in chrome view source it also ok). here some code: application.html.rb site | <%= yield(:title)…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/ruby-on-rails-3" class="post-tag grid--cell" title="show questions tagged 'ruby-on-rails-3'" rel="tag">ruby-on-rails-3</a> <a href="../../questions/tagged/rspec" class="post-tag grid--cell" title="show questions tagged 'rspec'" rel="tag">rspec</a> <a href="../../questions/tagged/rspec2" class="post-tag grid--cell" title="show questions tagged 'rspec2'" rel="tag">rspec2</a> <a href="../../questions/tagged/rack-test" class="post-tag grid--cell" title="show questions tagged 'rack-test'" rel="tag">rack-test</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Feb 27 '13 at 17:21">asked Feb 27 '13 at 17:21</time> <a href="../../users/719001/nir" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/719001.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Nir" /> </a> <div class="s-user-card--info"> <a href="../../users/719001/nir" class="s-user-card--link">Nir</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">2,497</li> <li class="s-award-bling s-award-bling__gold" title="9 gold badges">9</li> <li class="s-award-bling s-award-bling__silver" title="42 silver badges">42</li> <li class="s-award-bling s-award-bling__bronze" title="71 bronze badges">71</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-13594057"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>0</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/13594057/capybara-racktest-cannot-click-or-find-button-but-selenium-can" class="question-hyperlink">Capybara RackTest cannot click or find button but Selenium can</a></h3> <div class="excerpt">I'm having trouble with a Cucumber test using Capybara (2.0.0). Here's the (valid) html generated by page.html when running in RackTest: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/capybara" class="post-tag grid--cell" title="show questions tagged 'capybara'" rel="tag">capybara</a> <a href="../../questions/tagged/selenium-webdriver" class="post-tag grid--cell" title="show questions tagged 'selenium-webdriver'" rel="tag">selenium-webdriver</a> <a href="../../questions/tagged/rack-test" class="post-tag grid--cell" title="show questions tagged 'rack-test'" rel="tag">rack-test</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Nov 27 '12 at 22:10">asked Nov 27 '12 at 22:10</time> <a href="../../users/1827312/david-t" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/1827312.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="David T" /> </a> <div class="s-user-card--info"> <a href="../../users/1827312/david-t" class="s-user-card--link">David T</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">765</li> <li class="s-award-bling s-award-bling__silver" title="6 silver badges">6</li> <li class="s-award-bling s-award-bling__bronze" title="18 bronze badges">18</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="s-pagination pager fr"> <a class="s-pagination--item" href="../../questions/tagged/rack-test_page=2" rel="prev" title="Go to page 2">Prev </a> <a class="s-pagination--item" href="../../questions/tagged/rack-test_page=1" rel="" title="Go to page 1">1</a> <a class="s-pagination--item" href="../../questions/tagged/rack-test_page=2" rel="" title="Go to page 2">2</a> <div class="s-pagination--item is-selected">3</div> <a class="s-pagination--item" href="../../questions/tagged/rack-test_page=4" rel="" title="Go to page 4">4</a> <a class="s-pagination--item" href="../../questions/tagged/rack-test_page=4" rel="next" title="Go to page 4"> Next</a> </div> </div> </div> </div> </div> <script src="../../static/js/stack-icons.js"></script> <script src="../../static/js/fromnow.js"></script> </body> </html>