Sha256: 3a0b4134d5d72c027e034b7f568162438c7cdb33e8e52e8bc6da086d7af20940

Contents?: true

Size: 1.94 KB

Versions: 23

Compression:

Stored size: 1.94 KB

Contents

require File.expand_path('../../../load_paths', __FILE__)
require File.join(File.dirname(__FILE__), '..', '..', 'padrino-core', 'test', 'mini_shoulda')
require 'rack/test'
require 'webrat'
require 'padrino-helpers'
require 'active_support/time'

class MiniTest::Spec
  include Padrino::Helpers::OutputHelpers
  include Padrino::Helpers::TagHelpers
  include Padrino::Helpers::AssetTagHelpers
  include Rack::Test::Methods
  include Webrat::Methods
  include Webrat::Matchers

  Webrat.configure do |config|
    config.mode = :rack
  end

  def stop_time_for_test
    time = Time.now
    Time.stubs(:now).returns(time)
    return time
  end

  # assert_has_tag(:h1, :content => "yellow") { "<h1>yellow</h1>" }
  # In this case, block is the html to evaluate
  def assert_has_tag(name, attributes = {}, &block)
    html = block && block.call
    matcher = HaveSelector.new(name, attributes)
    raise "Please specify a block!" if html.blank?
    assert matcher.matches?(html), matcher.failure_message
  end

  # assert_has_no_tag, tag(:h1, :content => "yellow") { "<h1>green</h1>" }
  # In this case, block is the html to evaluate
  def assert_has_no_tag(name, attributes = {}, &block)
    html = block && block.call
    attributes.merge!(:count => 0)
    matcher = HaveSelector.new(name, attributes)
    raise "Please specify a block!" if html.blank?
    assert matcher.matches?(html), matcher.failure_message
  end

  # Asserts that a file matches the pattern
  def assert_match_in_file(pattern, file)
    assert File.exist?(file), "File '#{file}' does not exist!"
    assert_match pattern, File.read(file)
  end

  # mock_model("Business", :new_record? => true) => <Business>
  def mock_model(klazz, options={})
    options.reverse_merge!(:class => klazz, :new_record? => false, :id => 20, :errors => {})
    record = stub(options)
    record.stubs(:to_ary => [record])
    record
  end
end

module Webrat
  module Logging
    def logger # @private
      @logger = nil
    end
  end
end

Version data entries

23 entries across 23 versions & 3 rubygems

Version Path
middleman-core-3.1.0.rc.2 lib/vendored-middleman-deps/padrino-helpers-0.10.7/test/helper.rb
padrino-helpers-0.11.1 test/helper.rb
padrino-helpers-0.11.0 test/helper.rb
padrino-helpers-0.10.7 test/helper.rb
middleman-core-3.0.0.beta.2 lib/middleman-core/vendor/padrino-helpers-0.10.6/test/helper.rb
padrino-helpers-0.10.6 test/helper.rb
padrino-helpers-0.10.6.e test/helper.rb
padrino-helpers-0.10.6.d test/helper.rb
padrino-helpers-0.10.6.c test/helper.rb
padrino-helpers-0.10.6.b test/helper.rb
padrino-helpers-0.10.6.a test/helper.rb
middleman-core-3.0.0.beta.1 lib/middleman-core/vendor/padrino-helpers-0.10.5/test/helper.rb
middleman-core-3.0.0.alpha.9 lib/middleman-core/vendor/padrino-helpers-0.10.5/test/helper.rb
middleman-core-3.0.0.alpha.8 lib/middleman-core/vendor/padrino-helpers-0.10.5/test/helper.rb
middleman-core-3.0.0.alpha.7 lib/middleman-core/vendor/padrino-helpers-0.10.5/test/helper.rb
middleman-3.0.0.alpha.6 lib/middleman/vendor/padrino-helpers-0.10.5/test/helper.rb
middleman-3.0.0.alpha.5 lib/middleman/vendor/padrino-helpers-0.10.5/test/helper.rb
middleman-3.0.0.alpha.4 lib/middleman/vendor/padrino-helpers-0.10.5/test/helper.rb
middleman-3.0.0.alpha.3 lib/middleman/vendor/padrino-helpers-0.10.5/test/helper.rb
middleman-3.0.0.alpha.2 lib/middleman/vendor/padrino-helpers-0.10.5/test/helper.rb