Capybara.app_server = false gives Rack::Test error when running more than one Scenario

Showing 1-11 of 11 messages
Capybara.app_server = false gives Rack::Test error when running more than one Scenario Jesper Rønn-Jensen 9/21/10 6:02 AM
Very strange error when running capybara/webdriver
I set   Capybara.run_server = false

I am using jruby to fire up cucumber.
It seems that rack-test is fired up, but why is it that when i am
running app_server = false?

Any ideas why this is happening?


Using the wip profile...
Feature: Login
  In order to a simple login to our test server
  As a frustrated impatient developer
  I want to know my installation of cucumber, maven, webdriver works

  @wip
  Scenario: log in Danish customer                    # features
\login.feature:7
    Given I go to the login page                      # features/
step_definitions/web_steps.rb:23
    When I fill in "customerNumber" with "9912580212" # features/
step_definitions/web_steps.rb:39
    And I press "Ny plan"                 # features/step_definitions/
web_steps.rb:27
    Then I should see "1a Kunde"                      # features/
step_definitions/web_steps.rb:107
    And I should see "Plan"                     # features/
step_definitions/web_steps.rb:107

  @wip
  Scenario: log in to corporate                       # features
\login.feature:16
    Given I go to the login page                      # features/
step_definitions/web_steps.rb:23
      rack-test requires a rack application, but none was given
(ArgumentError)
      ./features/step_definitions/web_steps.rb:24:in `/^(?:|I )go to (.
+)$/'
      features\login.feature:17:in `Given I go to the login page'
    When I fill in "customerNumber" with "9912580212" # features/
step_definitions/web_steps.rb:39
    And I select "Corporate" from "application"       # features/
step_definitions/web_steps.rb:70
    And I press "Ny plan"                 # features/step_definitions/
web_steps.rb:27
    Then I should see "Plan Erhverv"            # features/
step_definitions/web_steps.rb:107
      rack-test requires a rack application, but none was given
(ArgumentError)
      c:/bin/jruby-1.5.2/lib/ruby/gems/1.8/gems/capybara-0.3.9/lib/
capybara/driver/rack_test_driver.rb:193:in `initializ
e'
      c:/bin/jruby-1.5.2/lib/ruby/gems/1.8/gems/capybara-0.3.9/lib/
capybara/session.rb:29:in `new'
      c:/bin/jruby-1.5.2/lib/ruby/gems/1.8/gems/capybara-0.3.9/lib/
capybara/session.rb:29:in `driver'
      c:/bin/jruby-1.5.2/lib/ruby/gems/1.8/gems/capybara-0.3.9/lib/
capybara/dsl.rb:35:in `reset_sessions!'
      c:/bin/jruby-1.5.2/lib/ruby/gems/1.8/gems/capybara-0.3.9/lib/
capybara/dsl.rb:35:in `each'
      c:/bin/jruby-1.5.2/lib/ruby/gems/1.8/gems/capybara-0.3.9/lib/
capybara/dsl.rb:35:in `reset_sessions!'
      c:/bin/jruby-1.5.2/lib/ruby/gems/1.8/gems/capybara-0.3.9/lib/
capybara/cucumber.rb:7:in `After'

Failing Scenarios:
cucumber -p wip features\login.feature:16 # Scenario: log in to
corporate

2 scenarios (1 failed, 1 passed)
10 steps (1 failed, 4 skipped, 5 passed)
0m9.319s






C:\project\integrationtest>jgem list

*** LOCAL GEMS ***

bouncy-castle-java (1.5.0145.2)
builder (2.1.2)
bundler (1.0.0)
capybara (0.3.9)
columnize (0.3.1)
cucumber (0.9.0, 0.8.5)
culerity (0.2.12)
diff-lcs (1.1.2)
ffi (0.6.3 java)
gherkin (2.2.3 java, 2.1.5 java)
jruby-openssl (0.7.1)
json (1.4.6 java)
json_pure (1.4.6)
mime-types (1.16)
nokogiri (1.4.3.1 java)
rack (1.2.1)
rack-test (0.5.4)
rake (0.8.7)
rspec (2.0.0.beta.22)
rspec-core (2.0.0.beta.22)
rspec-expectations (2.0.0.beta.22)
rspec-mocks (2.0.0.beta.22)
ruby-debug (0.10.3)
ruby-debug-base (0.10.3.2 java)
rubygems-update (1.3.7)
rubyzip (0.9.4)
selenium-client (1.2.18)
selenium-webdriver (0.0.28)
sources (0.0.1)
term-ansicolor (1.0.5)
trollop (1.16.2)
weakling (0.0.4 java)
Re: Capybara.app_server = false gives Rack::Test error when running more than one Scenario Jesper Rønn-Jensen 9/22/10 6:45 AM
I tried this with the most recent Capybara sourcecode (jnicklas-
capybara-d584bb3), but the issue is still there:
(from the second test and every consecutive test).

Why on earth is does it want to start a rack-test when I explicitly
tells it Capybara.run_server=false ??



Feature: Login
  In order to a simple login to our test server
  As a frustrated impatient developer
  I want to know my installation of cucumber, maven, webdriver works

  Scenario: log in Danish customer                    # features
\login.feature:6
    Given I go to the login page                      # features/
step_definitions/web_steps.rb:23
      rack-test requires a rack application, but none was given
(ArgumentError)
      ./features/step_definitions/web_steps.rb:24:in `/^(?:|I )go to (.
+)$/'
      features\login.feature:7:in `Given I go to the login page'
    When I fill in "customerNumber" with "9912580212" # features/
step_definitions/web_steps.rb:39
    And I press "Ny investeringsplan"                 # features/
step_definitions/web_steps.rb:27
    Then I should see "1a Kunde"                      # features/
step_definitions/web_steps.rb:107
    And I should see "Plan"                     # features/
step_definitions/web_steps.rb:107
      rack-test requires a rack application, but none was given
(ArgumentError)
      c:/bin/jruby-1.5.2/lib/ruby/gems/1.8/gems/capybara-0.3.9.1/lib/
capybara/driver/rack_test_driver.rb:185:in `initial
ize'
      c:/bin/jruby-1.5.2/lib/ruby/gems/1.8/gems/capybara-0.3.9.1/lib/
capybara.rb:101:in `new'
      c:/bin/jruby-1.5.2/lib/ruby/gems/1.8/gems/capybara-0.3.9.1/lib/
capybara.rb:101
      c:/bin/jruby-1.5.2/lib/ruby/gems/1.8/gems/capybara-0.3.9.1/lib/
capybara/session.rb:51:in `call'
      c:/bin/jruby-1.5.2/lib/ruby/gems/1.8/gems/capybara-0.3.9.1/lib/
capybara/session.rb:51:in `driver'
      c:/bin/jruby-1.5.2/lib/ruby/gems/1.8/gems/capybara-0.3.9.1/lib/
capybara/session.rb:60:in `reset!'
      c:/bin/jruby-1.5.2/lib/ruby/gems/1.8/gems/capybara-0.3.9.1/lib/
capybara/dsl.rb:58:in `reset_sessions!'
      c:/bin/jruby-1.5.2/lib/ruby/gems/1.8/gems/capybara-0.3.9.1/lib/
capybara/dsl.rb:58:in `each'
      c:/bin/jruby-1.5.2/lib/ruby/gems/1.8/gems/capybara-0.3.9.1/lib/
capybara/dsl.rb:58:in `reset_sessions!'
      c:/bin/jruby-1.5.2/lib/ruby/gems/1.8/gems/capybara-0.3.9.1/lib/
capybara/cucumber.rb:7:in `After'
Re: [Capybara] Re: Capybara.app_server = false gives Rack::Test error when running more than one Scenario jnicklas 9/22/10 7:37 AM
RackTest isn't affected by Capybara.run_server at all. Only those
drivers that actually need a server to run locally will ever look at
it. Selenium, Culerity, Akephalos, etc. will not start a server if you
set it to false.

What exactly are you trying to achieve?

/Jonas

2010/9/22 Jesper Rønn-Jensen <jesp...@gmail.com>:

Re: Capybara.app_server = false gives Rack::Test error when running more than one Scenario Jesper Rønn-Jensen 9/22/10 8:13 AM
Jonas Nicklas wrote:
>
> What exactly are you trying to achieve?
>

I simply want a test suite up and running. I have generated example
with cucumber-rails (in order to get web_steps.rb). Then i have
modified env.rb

All of this, I have put into cuke4duke example project, in order to
have a pom.xml that I can trigger to run the tests via maven/jruby


Is there a better (simpler) way to get started?





Contents of my env.rb


  require 'capybara/cucumber'
  Capybara.current_driver = :selenium

    app_host = 'http://www.google.com'



    Capybara.app_host = app_host
    Capybara.run_server = false
    #Capybara.default_wait_time = 20
    #Capybara.ignore_hidden_elements = true

    Capybara.default_selector = :css
Re: [Capybara] Re: Capybara.app_server = false gives Rack::Test error when running more than one Scenario jnicklas 9/22/10 10:22 AM
well, you can't use rack-test against a remote application, it
requires a rack app. You'll need to use selenium, akephalos, culerity
or mechanize.

/Jonas

2010/9/22 Jesper Rønn-Jensen <jesp...@gmail.com>:

Re: Capybara.app_server = false gives Rack::Test error when running more than one Scenario Jesper Rønn-Jensen 9/22/10 11:42 AM
Jonas wrote:
> well, you can't use rack-test against a remote application, it
> requires a rack app. You'll need to use selenium, akephalos, culerity
> or mechanize.

I want to use selenium, actually, that is what I thought I was doing.
My problem is that "something" is using rack-test. I can't figure out
why that happens.

I _am_ using selenium for my test. Isnt that what I declare with the
line Capybara.current_driver = :selenium


I will happily contribute with an example when this works

Thanks for your help so far :)
Re: [Capybara] Re: Capybara.app_server = false gives Rack::Test error when running more than one Scenario jarra 9/22/10 11:59 AM
Hi Jesper,

I'm testing a non-rails / non-ruby site with Capybara and Selenium right
now with Ubuntu and Firefox, and my env.rb looks like this:

http://gist.github.com/592281

Mind the line:
Capybara.run_server = false


HTH,

Jarra

Re: Capybara.app_server = false gives Rack::Test error when running more than one Scenario Jesper Rønn-Jensen 9/22/10 1:21 PM
Jarra  wrote:
> Hi Jesper,
>
> I'm testing a non-rails / non-ruby site with Capybara and Selenium right
> now with Ubuntu and Firefox, and my env.rb looks like this:
>
> http://gist.github.com/592281

Thanks a lot for your example.
Compared to your env.rb, mine seems with not as many lines. In
particular you have:
Capybara.default_driver = :selenium
vs my:
Capybara.current_driver = :selenium

This exact line makes the difference! So I am changing my example from
<tt>current_driver :selenium</tt> to <tt>default_driver :selenium</tt>

Now it works for me too :) So the error was, that I did not set a
default driver (and it probably defaulted to rack-test)


Some other notes to your code.
I could safely remove these lines, and it still worked as it should:

 # require 'capybara'
 # require 'spec'
 # require 'selenium-webdriver' <--removed from env.rb
 # Selenium::WebDriver.for :firefox <--removed from env.rb



Re: [Capybara] Re: Capybara.app_server = false gives Rack::Test error when running more than one Scenario jarra 9/22/10 1:26 PM
Thanks, I removed these lines and indeed it still works fine.
And glad that helped!
Re: Capybara.app_server = false gives Rack::Test error when running more than one Scenario Jesper Rønn-Jensen 9/22/10 2:10 PM
I updated the example from cuke4duke/examples/java-webdriver

I created 'capybara' branch in my cuke4duke fork which will run my
setup, which is:

maven > cuke4duke > cucumber > capybara > selenium-webdriver to
external webpage

I am sharing here for further exploration:
http://github.com/jesperronn/cuke4duke/tree/capybara/examples/java-webdriver/


Thanks Jarra and Jonas for your helpful replies :)
Re: Capybara.app_server = false gives Rack::Test error when running more than one Scenario biot023 5/23/12 2:41 PM
Weird -- that just worked for me, too! :)
Thanks everyone!