spec/spec_helper.rb in nesta-0.9.13 vs spec/spec_helper.rb in nesta-0.10.0

- old
+ new

@@ -1,14 +1,12 @@ -require 'rubygems' -require 'spec' -require 'spec/interop/test' +require 'rspec' require 'rack/test' -require 'rspec_hpricot_matchers' require 'sinatra' +require 'test/unit' +require 'webrat' +require 'webrat/core/matchers' -Test::Unit::TestCase.send :include, Rack::Test::Methods - module Nesta class App < Sinatra::Base set :environment, :test set :reload_templates, true end @@ -18,29 +16,29 @@ require File.expand_path('../lib/nesta/app', File.dirname(__FILE__)) module ConfigSpecHelper def stub_yaml_config @config = {} - Nesta::Config.stub!(:yaml_exists?).and_return(true) - Nesta::Config.stub!(:yaml_conf).and_return(@config) + Nesta::Config.stub(:yaml_exists?).and_return(true) + Nesta::Config.stub(:yaml_conf).and_return(@config) end def stub_config_key(key, value, options = {}) stub_yaml_config unless @config - if options[:rack_env] + if options[:for_environment] @config['test'] ||= {} @config['test'][key] = value else @config[key] = value end end - + def stub_configuration(options = {}) stub_config_key('title', 'My blog', options) stub_config_key('subtitle', 'about stuff', options) stub_config_key( - 'content', temp_path('content'), options.merge(:rack_env => true)) + 'content', temp_path('content'), options.merge(rack_env: true)) end end module TempFileHelper TEMP_DIR = File.expand_path('tmp', File.dirname(__FILE__)) @@ -48,29 +46,46 @@ def create_temp_directory FileUtils.mkdir_p(TempFileHelper::TEMP_DIR) end def remove_temp_directory - FileUtils.rm_r(TempFileHelper::TEMP_DIR, :force => true) + FileUtils.rm_r(TempFileHelper::TEMP_DIR, force: true) end - + def temp_path(base) File.join(TempFileHelper::TEMP_DIR, base) end end -Spec::Runner.configure do |config| - config.include(RspecHpricotMatchers) - +RSpec.configure do |config| config.include(ConfigSpecHelper) config.include(TempFileHelper) + config.include(Rack::Test::Methods) end module RequestSpecHelper + include Webrat::Matchers + def app Nesta::App end - + def body last_response.body + end + + def assert_xpath(*args) + body.should have_xpath(*args) + end + + def assert_not_xpath(*args) + body.should_not have_xpath(*args) + end + + def assert_selector(*args) + body.should have_selector(*args) + end + + def assert_not_selector(*args) + body.should_not have_selector(*args) end end