assert_contain およびその他のアサーションはテスト/ユニットのメソッドです。それを要求し、テスト メソッド内から webrat を使用してみてください。
require 'test/unit'
class TC_MyTest < Test::Unit::TestCase
def test_fail
assert(false, 'Assertion was false.')
end
end
とにかく私はそれをテストしていませんが、これがあなたに興味を持っているなら、私は rspec の動作する spec_helper を持っています:
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
require 'spec/rails'
require "webrat"
Webrat.configure do |config|
config.mode = :rails
end
module Spec::Rails::Example
class IntegrationExampleGroup < ActionController::IntegrationTest
def initialize(defined_description, options={}, &implementation)
defined_description.instance_eval do
def to_s
self
end
end
super(defined_description)
end
Spec::Example::ExampleGroupFactory.register(:integration, self)
end
end
プラス仕様:
# remember to require the spec helper
describe "Your Context" do
it "should GET /url" do
visit "/url"
body.should =~ /some text/
end
end
私が最も気に入っているコード仕様の代わりにテキスト仕様 (機能) が必要ない場合、(キュウリや他の野菜よりも) 非常に便利だと思います。
ps rspec gemが必要で、spec を実行するための「spec」コマンドがインストールされます。