spec/spec_helper.rb in massimo-0.9.0 vs spec/spec_helper.rb in massimo-0.10.0

- old
+ new

@@ -1,25 +1,11 @@ -lib = File.expand_path('../../lib', __FILE__) -$:.unshift(lib) unless $:.include?(lib) +require "rubygems" +require "bundler/setup" +Bundler.require(:default, :development) +require "rack/test" +require "construct" -require 'rubygems' -require 'rspec' -require 'rr' -require 'construct' -require 'rack/test' -require 'unindent' -require 'sass' -require 'less' -require 'coffee-script' -require 'sprockets' -require 'jsmin' -require 'packr' -require 'yui/compressor' -require 'closure-compiler' -require 'growl' -require 'massimo' - # Requires supporting files with custom matchers and macros, etc, # in ./support/ and its subdirectories. Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } RSpec.configure do |config| @@ -27,11 +13,11 @@ config.include Rack::Test::Methods config.mock_with :rr config.before :each do stub($stdout).puts - stub(Growl).notify + stub_module("Growl").notify end config.after :each do Massimo.site = nil end @@ -60,6 +46,27 @@ end result end alias :silence :capture + + # Creates a blank module with the given name (creating base modules if necessary) + def blank_module(name) + name.split("::").inject(Object) do |memo, const| + if memo.const_defined?(const) + memo.const_get(const) + else + memo.const_set(const, Module.new) + end + end + end + + # Creates a blank module wraps it as a mock object in rr + def mock_module(name) + mock(blank_module(name)) + end + + # Creates a blank module wraps it as a stubbed object in rr + def stub_module(name) + stub(blank_module(name)) + end end \ No newline at end of file