spec/spec_helper.rb in radiant-0.6.9 vs spec/spec_helper.rb in radiant-0.7.0

- old
+ new

@@ -10,13 +10,24 @@ require File.expand_path(SPEC_ROOT + "/../config/environment") end end require 'spec' require 'spec/rails' - require 'scenarios' + require 'dataset' + require 'spec/integration' + module Kernel + def rputs(*args) + puts *["<pre>", args.collect {|a| CGI.escapeHTML(a.inspect)}, "</pre>"] + end + end + class Test::Unit::TestCase + include Dataset + datasets_directory "#{RADIANT_ROOT}/spec/datasets" + Dataset::ContextClassMethods.datasets_database_dump_path = File.expand_path(RAILS_ROOT + '/tmp/dataset') + class << self # Class method for test helpers def test_helper(*names) names.each do |name| name = name.to_s @@ -40,12 +51,44 @@ Dir[RADIANT_ROOT + '/spec/matchers/*_matcher.rb'].each do |matcher| require matcher end - Scenario.load_paths.unshift "#{RADIANT_ROOT}/spec/scenarios" + module Spec + module Application + module ExampleExtensions + def rails_log + log = IO.read(RAILS_ROOT + '/log/test.log') + log.should_not be_nil + log + end + end + + module IntegrationExampleExtensions + def login(user) + if user.nil? + get logout_path + else + user = users(user) if user.kind_of?(Symbol) + submit_to login_path, :user => {:login => user.login, :password => "password"} + end + end + + def current_user + controller.send :current_user + end + + def encode_credentials(email_password) + ActionController::HttpAuthentication::Basic.encode_credentials(*email_password) + end + end + end + end Spec::Runner.configure do |config| + config.include Spec::Application::ExampleExtensions + config.include Spec::Application::IntegrationExampleExtensions, :type => :integration + config.use_transactional_fixtures = true config.use_instantiated_fixtures = false config.fixture_path = RAILS_ROOT + '/spec/fixtures/' # You can declare fixtures for each behaviour like this: \ No newline at end of file