spec/spec_helper.rb in rails-gallery-0.2.1 vs spec/spec_helper.rb in rails-gallery-0.3.0
- old
+ new
@@ -1,10 +1,46 @@
+# coding: utf-8
+require 'rubygems'
+require 'rails'
+require 'json'
+require 'active_support'
+require 'action_pack'
+require 'action_view'
+require 'action_controller'
+require 'action_view/template'
+
require 'rspec'
require 'rails-gallery'
-# Requires supporting files with custom matchers and macros, etc,
-# in ./support/ and its subdirectories.
-Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
+module ControllerTestHelpers
-RSpec.configure do |config|
+ def self.included(base)
+ base.class_eval do
+
+ include ActionView::Helpers,
+ ActionView::Helpers::CaptureHelper,
+ ActionView::Helpers::JavaScriptHelper,
+ ActionView::Helpers::AssetTagHelper
+ # allow tabs.create to run by stubbing an output_buffer
+ attr_accessor :output_buffer
+ @output_buffer = ""
+
+ # stub content_for for testing
+ def content_for(name, content = nil, &block)
+ # this doesn't exist, and causes errors
+ @_content_for = {} unless defined? @_content_for
+ # we've got to initialize this, so we can concat to it
+ @_content_for[name] = '' if @_content_for[name].nil?
+ # now the rest is the same as in rails
+ content = capture(&block) if block_given?
+ @_content_for[name] << content if content
+ @_content_for[name] unless content
+ end
+
+ def image_tag src, options = {}
+ content_tag :img, nil, options.merge(src: src)
+ end
+ end
+ end
+
end