Webrat and Rails 2.3.12

Im trying to integrate webrat in a rails 2.3.12:

I get this OUTPUT:
1)
NoMethodError in ‘Campaign in first step testing request’
undefined method `visit’ for
#Spec::Rails::Example::ModelExampleGroup::Subclass_1::Subclass_1:0x7f3dbd04f720
/home/matias/livechains/branches/test/livechains/spec/models/
campaign_spec.rb:16:

Finished in 6.518574 seconds

2 examples, 1 failure

My app is like this:

Gemfile
group :development, :test do
#gem ‘fiveruns_tuneup’
#autotest-rails, test_notifier, ZenTest, (sudo apt-get installlinux
libnotify-bin), autotest-notification,
gem “rspec”, “1.3.0”
gem “rspec-rails”, “1.3.2”
#necesita lib-notify e inotify en linux
gem “guard-rspec” #GitHub - guard/guard-rspec: Guard::RSpec automatically run your specs (much like autotest)
gem ‘ffi’
gem ‘libnotify’
gem ‘factory_girl’
gem ‘webrat’
gem ‘test-unit’, ‘1.2.3’
gem ‘hoe’, ‘2.8.0’
end

spec_helper.rb
ENV[“RAILS_ENV”] ||= ‘test’
require
File.expand_path(File.join(File.dirname(FILE),‘…’,‘config’,‘environment’))
require ‘spec/autorun’
require ‘spec/rails’
require ‘webrat’

Uncomment the next line to use webrat’s matchers

#require ‘webrat/integrations/rspec-rails’

Requires supporting files with custom matchers and macros, etc,

in ./support/ and its subdirectories.

Dir[File.expand_path(File.join(File.dirname(FILE),‘support’,‘**’,‘*.rb’))].each
{|f| require f}

Spec::Runner.configure do |config|

If you’re not using ActiveRecord you should remove these

lines, delete config/database.yml and disable :active_record

in your config/boot.rb

config.use_transactional_fixtures = true
config.use_instantiated_fixtures = false
config.fixture_path = RAILS_ROOT + ‘/spec/fixtures/’

include Webrat::Methods

#config.include Webrat::Matchers, :type => :views

end

Webrat.configure do |config|
config.mode = :rails
config.open_error_files = false # prevents webrat from opening the
browser
end

spec/models/campaign_spec.rb

require ‘spec_helper’

describe “Campaign” do

describe “in first step” do
before(:each) do
@user = Factory(:user)
@campaign = Factory(:campaign, :owner => @user)
end

it "should have an owner" do
  @campaign.owner.should == @user
end

it "testing request" do
  visit "/"
end

end
end

On 9 Aug 2011, at 01:37, Matias wrote:

Im trying to integrate webrat in a rails 2.3.12:

I get this OUTPUT:
1)
NoMethodError in ‘Campaign in first step testing request’
undefined method `visit’ for

#Spec::Rails::Example::ModelExampleGroup::Subclass_1::Subclass_1:0x7f3dbd04f720

/home/matias/livechains/branches/test/livechains/spec/models/
campaign_spec.rb:16:

You’re running a model spec here. A model spec is for testing a model
class directly, not for simulating requests to your app. If you want to
run requests, you need to be writing an integration spec.

Chris