Hi -- I'm trying to cuke up a Sinatra app (generated with the default monk generator), and having a few problems.
My current one, that I've no idea how to resolve, is that I can't access the response object that I so take for granted in Rails.
Here is my env.rb
<env.rb>
app_file = File.join(File.dirname(__FILE__), *%w[.. .. init.rb])
require app_file
# Force the application name because polyglot breaks the auto-detection logic.
Sinatra::Application.app_file = app_file
require 'spec/expectations'
require 'rack/test'
require 'webrat'
Webrat.configure do |config|
config.mode = :rack
end
class MyWorld
include Rack::Test::Methods
include Webrat::Methods
include Webrat::Matchers
Webrat::Methods.delegate_to_session :response_code, :response_body
def app
Sinatra::Application
end
end
World{MyWorld.new}
</env.rb>
Here is my feature file:
<test.feature>
Feature: Test
I want to see if I can get Cucumber working with Sinatra.
Scenario: Browsing to the root page
Given I have browsed to the root page
Then I should see "Hello, Cruel World!"
</test.feature>
And here is my steps file:
<test_steps.rb>
Given /^I have browsed to the root page$/ do
visit( "/" )
end
Then /^I should see "([^\"]*)"$/ do |value|
response.should contain( value )
end
</test_steps.rb>
The first step comes back green, but the second gives me the following error:
undefined local variable or method `response' for #<MyWorld:0x1023d1d98> (NameError)
features/test.feature:7:in `Then I should see "Hello, Cruel World!"'
Can anyone offer any advice on what to do to fix this, or where to look to gain more insight?
Thanks,
Doug.