shoulda-context-1.2.0/ 0000755 0000041 0000041 00000000000 12316470655 014674 5 ustar www-data www-data shoulda-context-1.2.0/Rakefile 0000644 0000041 0000041 00000000722 12316470655 016342 0 ustar www-data www-data require 'bundler/setup'
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'appraisal'
$LOAD_PATH.unshift("lib")
load 'tasks/shoulda.rake'
Rake::TestTask.new do |t|
t.libs << 'lib' << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end
desc 'Test the plugin under all supported Rails versions.'
task :all => ['appraisal:cleanup', 'appraisal:install'] do
exec('rake appraisal test')
end
desc 'Default: run tests'
task :default => [:all]
shoulda-context-1.2.0/bin/ 0000755 0000041 0000041 00000000000 12316470655 015444 5 ustar www-data www-data shoulda-context-1.2.0/bin/convert_to_should_syntax 0000755 0000041 0000041 00000002505 12316470655 022542 0 ustar www-data www-data #!/usr/bin/env ruby
require 'fileutils'
require 'tmpdir'
TMP = Dir::tmpdir
def usage(msg = nil)
puts "Error: #{msg}" if msg
puts if msg
puts "Usage: #{File.basename(__FILE__)} normal_test_file.rb"
puts
puts "Will convert an existing test file with names like "
puts
puts " def test_should_do_stuff"
puts " ..."
puts " end"
puts
puts "to one using the new syntax: "
puts
puts " should \"be super cool\" do"
puts " ..."
puts " end"
puts
puts "A copy of the old file will be left under #{TMP} in case\nthis script just seriously screws up"
puts
exit (msg ? 2 : 0)
end
usage("Wrong number of arguments.") unless ARGV.size == 1
usage("Temp directory '#{TMP}' is not valid. Set TMPDIR environment variable to a writeable directory.") unless File.directory?(TMP) && File.writable?(TMP)
file = ARGV.shift
tmpfile = File.join(TMP, File.basename(file))
usage("File '#{file}' doesn't exist") unless File.exists?(file)
FileUtils.cp(file, tmpfile)
contents = File.read(tmpfile)
contents.gsub!(/def test_should_(\S+)/) {|line| "should \"#{$1.tr('_', ' ')}\" do"}
contents.gsub!(/def test_(\S+)/) {|line| "should \"RENAME ME: test #{$1.tr('_', ' ')}\" do"}
File.open(file, 'w') { |f| f.write(contents) }
puts "File '#{file}' has been converted to 'should' syntax. Old version has been stored in '#{tmpfile}'"
shoulda-context-1.2.0/Gemfile 0000644 0000041 0000041 00000000046 12316470655 016167 0 ustar www-data www-data source 'http://rubygems.org'
gemspec
shoulda-context-1.2.0/MIT-LICENSE 0000644 0000041 0000041 00000002116 12316470655 016330 0 ustar www-data www-data Copyright (c) 2006-2013, Tammer Saleh, thoughtbot, inc.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
shoulda-context-1.2.0/.ruby-version 0000644 0000041 0000041 00000000013 12316470655 017333 0 ustar www-data www-data 2.0.0-p247
shoulda-context-1.2.0/.travis.yml 0000644 0000041 0000041 00000000031 12316470655 016777 0 ustar www-data www-data rvm:
- 1.9.3
- 2.0.0
shoulda-context-1.2.0/lib/ 0000755 0000041 0000041 00000000000 12316470655 015442 5 ustar www-data www-data shoulda-context-1.2.0/lib/shoulda-context.rb 0000644 0000041 0000041 00000000032 12316470655 021103 0 ustar www-data www-data require "shoulda/context"
shoulda-context-1.2.0/lib/shoulda/ 0000755 0000041 0000041 00000000000 12316470655 017101 5 ustar www-data www-data shoulda-context-1.2.0/lib/shoulda/context/ 0000755 0000041 0000041 00000000000 12316470655 020565 5 ustar www-data www-data shoulda-context-1.2.0/lib/shoulda/context/autoload_macros.rb 0000644 0000041 0000041 00000003610 12316470655 024266 0 ustar www-data www-data module Shoulda # :nodoc:
# Call autoload_macros when you want to load test macros automatically in a non-Rails
# project (it's done automatically for Rails projects).
# You don't need to specify ROOT/test/shoulda_macros explicitly. Your custom macros
# are loaded automatically when you call autoload_macros.
#
# The first argument is the path to you application's root directory.
# All following arguments are directories relative to your root, which contain
# shoulda_macros subdirectories. These directories support the same kinds of globs as the
# Dir class.
#
# Basic usage (from a test_helper):
# Shoulda.autoload_macros(File.dirname(__FILE__) + '/..')
# will load everything in
# - your_app/test/shoulda_macros
#
# To load vendored macros as well:
# Shoulda.autoload_macros(APP_ROOT, 'vendor/*')
# will load everything in
# - APP_ROOT/vendor/*/shoulda_macros
# - APP_ROOT/test/shoulda_macros
#
# To load macros in an app with a vendor directory laid out like Rails':
# Shoulda.autoload_macros(APP_ROOT, 'vendor/{plugins,gems}/*')
# or
# Shoulda.autoload_macros(APP_ROOT, 'vendor/plugins/*', 'vendor/gems/*')
# will load everything in
# - APP_ROOT/vendor/plugins/*/shoulda_macros
# - APP_ROOT/vendor/gems/*/shoulda_macros
# - APP_ROOT/test/shoulda_macros
#
# If you prefer to stick testing dependencies away from your production dependencies:
# Shoulda.autoload_macros(APP_ROOT, 'vendor/*', 'test/vendor/*')
# will load everything in
# - APP_ROOT/vendor/*/shoulda_macros
# - APP_ROOT/test/vendor/*/shoulda_macros
# - APP_ROOT/test/shoulda_macros
def self.autoload_macros(root, *dirs)
dirs << File.join('test')
complete_dirs = dirs.map{|d| File.join(root, d, 'shoulda_macros')}
all_files = complete_dirs.inject([]){ |files, dir| files + Dir[File.join(dir, '*.rb')] }
all_files.each do |file|
require file
end
end
end
shoulda-context-1.2.0/lib/shoulda/context/context.rb 0000644 0000041 0000041 00000035514 12316470655 022606 0 ustar www-data www-data module Shoulda
module Context
class << self
def contexts # :nodoc:
@contexts ||= []
end
attr_writer :contexts
def current_context # :nodoc:
self.contexts.last
end
def add_context(context) # :nodoc:
self.contexts.push(context)
end
def remove_context # :nodoc:
self.contexts.pop
end
end
module ClassMethods
# == Should statements
#
# Should statements are just syntactic sugar over normal Test::Unit test
# methods. A should block contains all the normal code and assertions
# you're used to seeing, with the added benefit that they can be wrapped
# inside context blocks (see below).
#
# === Example:
#
# class UserTest < Test::Unit::TestCase
#
# def setup
# @user = User.new("John", "Doe")
# end
#
# should "return its full name"
# assert_equal 'John Doe', @user.full_name
# end
#
# end
#
# ...will produce the following test:
# * "test: User should return its full name. "
#
# Note: The part before should in the test name is gleamed from the name of the Test::Unit class.
#
# Should statements can also take a Proc as a :before option. This proc runs after any
# parent context's setups but before the current context's setup.
#
# === Example:
#
# context "Some context" do
# setup { puts("I run after the :before proc") }
#
# should "run a :before proc", :before => lambda { puts("I run before the setup") } do
# assert true
# end
# end
#
# Should statements can also wrap matchers, making virtually any matcher
# usable in a macro style. The matcher's description is used to generate a
# test name and failure message, and the test will pass if the matcher
# matches the subject.
#
# === Example:
#
# should validate_presence_of(:first_name).with_message(/gotta be there/)
#
def should(name_or_matcher, options = {}, &blk)
if Shoulda::Context.current_context
Shoulda::Context.current_context.should(name_or_matcher, options, &blk)
else
context_name = self.name.gsub(/Test/, "") if self.name
context = Shoulda::Context::Context.new(context_name, self) do
should(name_or_matcher, options, &blk)
end
context.build
end
end
# Allows negative tests using matchers. The matcher's description is used
# to generate a test name and negative failure message, and the test will
# pass unless the matcher matches the subject.
#
# === Example:
#
# should_not set_the_flash
def should_not(matcher)
if Shoulda::Context.current_context
Shoulda::Context.current_context.should_not(matcher)
else
context_name = self.name.gsub(/Test/, "") if self.name
context = Shoulda::Context::Context.new(context_name, self) do
should_not(matcher)
end
context.build
end
end
# == Before statements
#
# Before statements are should statements that run before the current
# context's setup. These are especially useful when setting expectations.
#
# === Example:
#
# class UserControllerTest < Test::Unit::TestCase
# context "the index action" do
# setup do
# @users = [Factory(:user)]
# User.stubs(:find).returns(@users)
# end
#
# context "on GET" do
# setup { get :index }
#
# should respond_with(:success)
#
# # runs before "get :index"
# before_should "find all users" do
# User.expects(:find).with(:all).returns(@users)
# end
# end
# end
# end
def before_should(name, &blk)
should(name, :before => blk) { assert true }
end
# Just like should, but never runs, and instead prints an 'X' in the Test::Unit output.
def should_eventually(name, options = {}, &blk)
context_name = self.name.gsub(/Test/, "")
context = Shoulda::Context::Context.new(context_name, self) do
should_eventually(name, &blk)
end
context.build
end
# == Contexts
#
# A context block groups should statements under a common set of setup/teardown methods.
# Context blocks can be arbitrarily nested, and can do wonders for improving the maintainability
# and readability of your test code.
#
# A context block can contain setup, should, should_eventually, and teardown blocks.
#
# class UserTest < Test::Unit::TestCase
# context "A User instance" do
# setup do
# @user = User.find(:first)
# end
#
# should "return its full name"
# assert_equal 'John Doe', @user.full_name
# end
# end
# end
#
# This code will produce the method "test: A User instance should return its full name. ".
#
# Contexts may be nested. Nested contexts run their setup blocks from out to in before each
# should statement. They then run their teardown blocks from in to out after each should statement.
#
# class UserTest < Test::Unit::TestCase
# context "A User instance" do
# setup do
# @user = User.find(:first)
# end
#
# should "return its full name"
# assert_equal 'John Doe', @user.full_name
# end
#
# context "with a profile" do
# setup do
# @user.profile = Profile.find(:first)
# end
#
# should "return true when sent :has_profile?"
# assert @user.has_profile?
# end
# end
# end
# end
#
# This code will produce the following methods
# * "test: A User instance should return its full name. "
# * "test: A User instance with a profile should return true when sent :has_profile?. "
#
# Just like should statements, a context block can exist next to normal def test_the_old_way; end
# tests. This means you do not have to fully commit to the context/should syntax in a test file.
def context(name, &blk)
if Shoulda::Context.current_context
Shoulda::Context.current_context.context(name, &blk)
else
context = Shoulda::Context::Context.new(name, self, &blk)
context.build
end
end
# Returns the class being tested, as determined by the test class name.
#
# class UserTest; described_type; end
# # => User
def described_type
@described_type ||= self.name.
gsub(/Test$/, '').
split('::').
inject(Object) { |parent, local_name| parent.const_get(local_name) }
end
# Sets the return value of the subject instance method:
#
# class UserTest < Test::Unit::TestCase
# subject { User.first }
#
# # uses the existing user
# should validate_uniqueness_of(:email)
# end
def subject(&block)
@subject_block = block
end
def subject_block # :nodoc:
@subject_block ||= nil
end
end
module InstanceMethods
# Returns an instance of the class under test.
#
# class UserTest
# should "be a user" do
# assert_kind_of User, subject # passes
# end
# end
#
# The subject can be explicitly set using the subject class method:
#
# class UserTest
# subject { User.first }
# should "be an existing user" do
# assert !subject.new_record? # uses the first user
# end
# end
#
# The subject is used by all macros that require an instance of the class
# being tested.
def subject
@shoulda_subject ||= construct_subject
end
def subject_block # :nodoc:
(@shoulda_context && @shoulda_context.subject_block) || self.class.subject_block
end
def get_instance_of(object_or_klass) # :nodoc:
if object_or_klass.is_a?(Class)
object_or_klass.new
else
object_or_klass
end
end
def instance_variable_name_for(klass) # :nodoc:
klass.to_s.split('::').last.underscore
end
private
def construct_subject
if subject_block
instance_eval(&subject_block)
else
get_instance_of(self.class.described_type)
end
end
end
class Context # :nodoc:
attr_accessor :name # my name
attr_accessor :parent # may be another context, or the original test::unit class.
attr_accessor :subcontexts # array of contexts nested under myself
attr_accessor :setup_blocks # blocks given via setup methods
attr_accessor :teardown_blocks # blocks given via teardown methods
attr_accessor :shoulds # array of hashes representing the should statements
attr_accessor :should_eventuallys # array of hashes representing the should eventually statements
# accessor with cache
def subject_block
return @subject_block if @subject_block
parent.subject_block
end
attr_writer :subject_block
def initialize(name, parent, &blk)
Shoulda::Context.add_context(self)
self.name = name
self.parent = parent
self.setup_blocks = []
self.teardown_blocks = []
self.shoulds = []
self.should_eventuallys = []
self.subcontexts = []
self.subject_block = nil
if block_given?
merge_block(&blk)
else
merge_block { warn " * WARNING: Block missing for context '#{full_name}'" }
end
Shoulda::Context.remove_context
end
def merge_block(&blk)
if self.respond_to?(:instance_exec)
self.instance_exec(&blk)
else
# deprecated in Rails 4.x
blk.bind(self).call
end
end
def context(name, &blk)
self.subcontexts << Context.new(name, self, &blk)
end
def setup(&blk)
self.setup_blocks << blk
end
def teardown(&blk)
self.teardown_blocks << blk
end
def should(name_or_matcher, options = {}, &blk)
if name_or_matcher.respond_to?(:description) && name_or_matcher.respond_to?(:matches?)
name = name_or_matcher.description
blk = lambda { assert_accepts name_or_matcher, subject }
else
name = name_or_matcher
end
if blk
self.shoulds << { :name => name, :before => options[:before], :block => blk }
else
self.should_eventuallys << { :name => name }
end
end
def should_not(matcher)
name = matcher.description
blk = lambda { assert_rejects matcher, subject }
self.shoulds << { :name => "not #{name}", :block => blk }
end
def should_eventually(name, &blk)
self.should_eventuallys << { :name => name, :block => blk }
end
def subject(&block)
self.subject_block = block
end
def full_name
parent_name = parent.full_name if am_subcontext?
return [parent_name, name].join(" ").strip
end
def am_subcontext?
parent.is_a?(self.class) # my parent is the same class as myself.
end
def test_unit_class
am_subcontext? ? parent.test_unit_class : parent
end
def test_methods
@test_methods ||= Hash.new { |h,k|
h[k] = Hash[k.instance_methods.map { |n| [n, true] }]
}
end
def create_test_from_should_hash(should)
test_name = [test_name_prefix, full_name, "should", "#{should[:name]}. "].flatten.join(' ').to_sym
if test_methods[test_unit_class][test_name.to_s] then
raise DuplicateTestError, "'#{test_name}' is defined more than once."
end
test_methods[test_unit_class][test_name.to_s] = true
context = self
test_unit_class.send(:define_method, test_name) do
@shoulda_context = context
begin
context.run_parent_setup_blocks(self)
if should[:before]
if self.respond_to?(:instance_exec)
self.instance_exec(&should[:before])
else
# deprecated in Rails 4.x
should[:before].bind(self).call
end
end
context.run_current_setup_blocks(self)
if self.respond_to?(:instance_exec)
self.instance_exec(&should[:block])
else
# deprecated in Rails 4.x
should[:block].bind(self).call
end
ensure
context.run_all_teardown_blocks(self)
end
end
end
def run_all_setup_blocks(binding)
run_parent_setup_blocks(binding)
run_current_setup_blocks(binding)
end
def run_parent_setup_blocks(binding)
self.parent.run_all_setup_blocks(binding) if am_subcontext?
end
def run_current_setup_blocks(binding)
setup_blocks.each do |setup_block|
if binding.respond_to?(:instance_exec)
binding.instance_exec(&setup_block)
else
# deprecated in Rails 4.x
setup_block.bind(binding).call
end
end
end
def run_all_teardown_blocks(binding)
teardown_blocks.reverse.each do |teardown_block|
if binding.respond_to?(:instance_exec)
binding.instance_exec(&teardown_block)
else
# deprecated in Rails 4.x
teardown_block.bind(binding).call
end
end
self.parent.run_all_teardown_blocks(binding) if am_subcontext?
end
def print_should_eventuallys
should_eventuallys.each do |should|
test_name = [full_name, "should", "#{should[:name]}. "].flatten.join(' ')
puts " * DEFERRED: " + test_name
end
end
def build
shoulds.each do |should|
create_test_from_should_hash(should)
end
subcontexts.each { |context| context.build }
print_should_eventuallys
end
def test_name_prefix
if defined?(Minitest) || defined?(MiniTest)
'test_:'
else
'test:'
end
end
def method_missing(method, *args, &blk)
test_unit_class.send(method, *args, &blk)
end
end
end
end
class DuplicateTestError < RuntimeError; end
shoulda-context-1.2.0/lib/shoulda/context/version.rb 0000644 0000041 0000041 00000000107 12316470655 022575 0 ustar www-data www-data module Shoulda
module Context
VERSION = '1.2.0'.freeze
end
end
shoulda-context-1.2.0/lib/shoulda/context/proc_extensions.rb 0000644 0000041 0000041 00000000565 12316470655 024342 0 ustar www-data www-data # Stolen straight from ActiveSupport
class Proc #:nodoc:
def bind(object)
block, time = self, Time.now
(class << object; self end).class_eval do
method_name = "__bind_#{time.to_i}_#{time.usec}"
define_method(method_name, &block)
method = instance_method(method_name)
remove_method(method_name)
method
end.bind(object)
end
end
shoulda-context-1.2.0/lib/shoulda/context/tasks/ 0000755 0000041 0000041 00000000000 12316470655 021712 5 ustar www-data www-data shoulda-context-1.2.0/lib/shoulda/context/tasks/yaml_to_shoulda.rake 0000644 0000041 0000041 00000001613 12316470655 025742 0 ustar www-data www-data namespace :shoulda do
# From http://blog.internautdesign.com/2007/11/2/a-yaml_to_shoulda-rake-task
# David.Lowenfels@gmail.com
desc "Converts a YAML file (FILE=./path/to/yaml) into a Shoulda skeleton"
task :from_yaml do
require 'yaml'
def yaml_to_context(hash, indent = 0)
indent1 = ' ' * indent
indent2 = ' ' * (indent + 1)
hash.each_pair do |context, shoulds|
puts indent1 + "context \"#{context}\" do"
puts
shoulds.each do |should|
yaml_to_context( should, indent + 1 ) and next if should.is_a?( Hash )
puts indent2 + "should_eventually \"" + should.gsub(/^should +/,'') + "\" do"
puts indent2 + "end"
puts
end
puts indent1 + "end"
end
end
puts("Please pass in a FILE argument.") and exit unless ENV['FILE']
yaml_to_context( YAML.load_file( ENV['FILE'] ) )
end
end
shoulda-context-1.2.0/lib/shoulda/context/tasks/list_tests.rake 0000644 0000041 0000041 00000001504 12316470655 024753 0 ustar www-data www-data namespace :shoulda do
desc "List the names of the test methods in a specification like format"
task :list do
$LOAD_PATH.unshift("test")
require 'test/unit'
require 'rubygems'
require 'active_support'
# bug in test unit. Set to true to stop from running.
Test::Unit.run = true
test_files = Dir.glob(File.join('test', '**', '*_test.rb'))
test_files.each do |file|
load file
klass = File.basename(file, '.rb').classify
unless Object.const_defined?(klass.to_s)
puts "Skipping #{klass} because it doesn't map to a Class"
next
end
klass = klass.constantize
puts klass.name.gsub('Test', '')
test_methods = klass.instance_methods.grep(/^test/).map {|s| s.gsub(/^test: /, '')}.sort
test_methods.each {|m| puts " " + m }
end
end
end
shoulda-context-1.2.0/lib/shoulda/context/test_framework_detection.rb 0000644 0000041 0000041 00000001525 12316470655 026207 0 ustar www-data www-data module Shoulda
module Context
module TestFrameworkDetection
def self.possible_test_frameworks
[
-> { ActiveSupport::TestCase },
-> { Minitest::Test },
-> { MiniTest::Unit::TestCase },
-> { Test::Unit::TestCase }
]
end
def self.resolve_framework(future_framework)
future_framework.call
rescue NameError
nil
end
def self.detected_test_framework_test_cases
possible_test_frameworks.
map { |future_framework| resolve_framework(future_framework) }.
compact
end
def self.test_framework_test_cases
@_test_framework_test_case ||= detected_test_framework_test_cases
end
end
def self.test_framework_test_cases
TestFrameworkDetection.test_framework_test_cases
end
end
end
shoulda-context-1.2.0/lib/shoulda/context/assertions.rb 0000644 0000041 0000041 00000007623 12316470655 023314 0 ustar www-data www-data module Shoulda # :nodoc:
module Context
module Assertions
# Asserts that two arrays contain the same elements, the same number of times. Essentially ==, but unordered.
#
# assert_same_elements([:a, :b, :c], [:c, :a, :b]) => passes
def assert_same_elements(a1, a2, msg = nil)
[:select, :inject, :size].each do |m|
[a1, a2].each {|a| assert_respond_to(a, m, "Are you sure that #{a.inspect} is an array? It doesn't respond to #{m}.") }
end
assert a1h = a1.inject({}) { |h,e| h[e] ||= a1.select { |i| i == e }.size; h }
assert a2h = a2.inject({}) { |h,e| h[e] ||= a2.select { |i| i == e }.size; h }
assert_equal(a1h, a2h, msg)
end
# Asserts that the given collection contains item x. If x is a regular expression, ensure that
# at least one element from the collection matches x. +extra_msg+ is appended to the error message if the assertion fails.
#
# assert_contains(['a', '1'], /\d/) => passes
# assert_contains(['a', '1'], 'a') => passes
# assert_contains(['a', '1'], /not there/) => fails
def assert_contains(collection, x, extra_msg = "")
collection = Array(collection)
msg = "#{x.inspect} not found in #{collection.to_a.inspect} #{extra_msg}"
case x
when Regexp
assert(collection.detect { |e| e =~ x }, msg)
else
assert(collection.include?(x), msg)
end
end
# Asserts that the given collection does not contain item x. If x is a regular expression, ensure that
# none of the elements from the collection match x.
def assert_does_not_contain(collection, x, extra_msg = "")
collection = Array(collection)
msg = "#{x.inspect} found in #{collection.to_a.inspect} " + extra_msg
case x
when Regexp
assert(!collection.detect { |e| e =~ x }, msg)
else
assert(!collection.include?(x), msg)
end
end
# Asserts that the given matcher returns true when +target+ is passed to #matches?
def assert_accepts(matcher, target, options = {})
if matcher.respond_to?(:in_context)
matcher.in_context(self)
end
if matcher.matches?(target)
safe_assert_block { true }
if options[:message]
message = matcher.respond_to?(:failure_message_for_should_not) ? matcher.failure_message_for_should_not : matcher.negative_failure_message
assert_match options[:message], message
end
else
message = matcher.respond_to?(:failure_message_for_should) ? matcher.failure_message_for_should : matcher.failure_message
safe_assert_block(message) { false }
end
end
# Asserts that the given matcher returns true when +target+ is passed to #does_not_match?
# or false when +target+ is passed to #matches? if #does_not_match? is not implemented
def assert_rejects(matcher, target, options = {})
if matcher.respond_to?(:in_context)
matcher.in_context(self)
end
not_match = matcher.respond_to?(:does_not_match?) ? matcher.does_not_match?(target) : !matcher.matches?(target)
if not_match
safe_assert_block { true }
if options[:message]
message = matcher.respond_to?(:failure_message_for_should) ? matcher.failure_message_for_should : matcher.failure_message
assert_match options[:message], message
end
else
message = matcher.respond_to?(:failure_message_for_should_not) ? matcher.failure_message_for_should_not : matcher.negative_failure_message
safe_assert_block(message) { false }
end
end
def safe_assert_block(message = "assert_block failed.", &block)
if respond_to?(:assert_block)
assert_block message, &block
else
assert yield, message
end
end
end
end
end
shoulda-context-1.2.0/lib/shoulda/context/tasks.rb 0000644 0000041 0000041 00000000123 12316470655 022233 0 ustar www-data www-data Dir[File.join(File.dirname(__FILE__), 'tasks', '*.rake')].each do |f|
load f
end
shoulda-context-1.2.0/lib/shoulda/context.rb 0000644 0000041 0000041 00000001133 12316470655 021110 0 ustar www-data www-data require 'shoulda/context/test_framework_detection'
require 'shoulda/context/version'
require 'shoulda/context/proc_extensions'
require 'shoulda/context/assertions'
require 'shoulda/context/context'
require 'shoulda/context/autoload_macros'
module ShouldaContextLoadable
def self.included(base)
base.class_eval do
include Shoulda::Context::Assertions
include Shoulda::Context::InstanceMethods
end
base.extend(Shoulda::Context::ClassMethods)
end
end
Shoulda::Context.test_framework_test_cases.each do |test_case|
test_case.class_eval { include ShouldaContextLoadable }
end
shoulda-context-1.2.0/gemfiles/ 0000755 0000041 0000041 00000000000 12316470655 016467 5 ustar www-data www-data shoulda-context-1.2.0/gemfiles/rails_4_1.gemfile 0000644 0000041 0000041 00000000310 12316470655 021570 0 ustar www-data www-data # This file was generated by Appraisal
source "http://rubygems.org"
gem "rails", :github=>"rails/rails", :branch=>"4-1-stable"
gem "jquery-rails"
gem "sass-rails"
gem "sqlite3"
gemspec :path=>"../" shoulda-context-1.2.0/gemfiles/rails_3_1.gemfile.lock 0000644 0000041 0000041 00000004566 12316470655 022537 0 ustar www-data www-data PATH
remote: ../
specs:
shoulda-context (1.1.6)
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.1.12)
actionpack (= 3.1.12)
mail (~> 2.4.4)
actionpack (3.1.12)
activemodel (= 3.1.12)
activesupport (= 3.1.12)
builder (~> 3.0.0)
erubis (~> 2.7.0)
i18n (~> 0.6)
rack (~> 1.3.6)
rack-cache (~> 1.2)
rack-mount (~> 0.8.2)
rack-test (~> 0.6.1)
sprockets (~> 2.0.4)
activemodel (3.1.12)
activesupport (= 3.1.12)
builder (~> 3.0.0)
i18n (~> 0.6)
activerecord (3.1.12)
activemodel (= 3.1.12)
activesupport (= 3.1.12)
arel (~> 2.2.3)
tzinfo (~> 0.3.29)
activeresource (3.1.12)
activemodel (= 3.1.12)
activesupport (= 3.1.12)
activesupport (3.1.12)
multi_json (~> 1.0)
appraisal (0.5.2)
bundler
rake
arel (2.2.3)
builder (3.0.4)
erubis (2.7.0)
hike (1.2.3)
i18n (0.6.9)
jquery-rails (3.1.0)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.1)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.25.1)
mocha (0.9.12)
multi_json (1.9.2)
polyglot (0.3.4)
rack (1.3.10)
rack-cache (1.2)
rack (>= 0.4)
rack-mount (0.8.3)
rack (>= 1.0.0)
rack-ssl (1.3.3)
rack
rack-test (0.6.2)
rack (>= 1.0)
rails (3.1.12)
actionmailer (= 3.1.12)
actionpack (= 3.1.12)
activerecord (= 3.1.12)
activeresource (= 3.1.12)
activesupport (= 3.1.12)
bundler (~> 1.0)
railties (= 3.1.12)
railties (3.1.12)
actionpack (= 3.1.12)
activesupport (= 3.1.12)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (10.2.1)
rdoc (3.12.2)
json (~> 1.4)
sass (3.3.4)
sass-rails (3.1.0)
actionpack (~> 3.1.0)
railties (~> 3.1.0)
sass (>= 3.1.4)
sprockets (2.0.4)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.9)
test-unit (2.1.2)
thor (0.14.6)
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.38)
PLATFORMS
ruby
DEPENDENCIES
appraisal (~> 0.5)
jquery-rails
mocha (~> 0.9.10)
rails (~> 3.1.0)
rake
sass-rails
shoulda-context!
sqlite3
test-unit (~> 2.1.0)
shoulda-context-1.2.0/gemfiles/minitest_4_x.gemfile 0000644 0000041 0000041 00000000164 12316470655 022430 0 ustar www-data www-data # This file was generated by Appraisal
source "http://rubygems.org"
gem "minitest", "~> 4.0"
gemspec :path=>"../" shoulda-context-1.2.0/gemfiles/test_unit.gemfile.lock 0000644 0000041 0000041 00000004030 12316470655 022763 0 ustar www-data www-data PATH
remote: ../
specs:
shoulda-context (1.1.6)
GEM
remote: http://rubygems.org/
specs:
actionmailer (4.0.3)
actionpack (= 4.0.3)
mail (~> 2.5.4)
actionpack (4.0.3)
activesupport (= 4.0.3)
builder (~> 3.1.0)
erubis (~> 2.7.0)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
activemodel (4.0.3)
activesupport (= 4.0.3)
builder (~> 3.1.0)
activerecord (4.0.3)
activemodel (= 4.0.3)
activerecord-deprecated_finders (~> 1.0.2)
activesupport (= 4.0.3)
arel (~> 4.0.0)
activerecord-deprecated_finders (1.0.3)
activesupport (4.0.3)
i18n (~> 0.6, >= 0.6.4)
minitest (~> 4.2)
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
appraisal (0.5.2)
bundler
rake
arel (4.0.2)
atomic (1.1.16)
builder (3.1.4)
erubis (2.7.0)
hike (1.2.3)
i18n (0.6.9)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.25.1)
minitest (4.7.5)
mocha (0.9.12)
multi_json (1.9.2)
polyglot (0.3.4)
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
rails (4.0.3)
actionmailer (= 4.0.3)
actionpack (= 4.0.3)
activerecord (= 4.0.3)
activesupport (= 4.0.3)
bundler (>= 1.3.0, < 2.0)
railties (= 4.0.3)
sprockets-rails (~> 2.0.0)
railties (4.0.3)
actionpack (= 4.0.3)
activesupport (= 4.0.3)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.2.1)
sprockets (2.12.0)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.0.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
test-unit (2.5.5)
thor (0.19.1)
thread_safe (0.3.1)
atomic (>= 1.1.7, < 2)
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.38)
PLATFORMS
ruby
DEPENDENCIES
appraisal (~> 0.5)
mocha (~> 0.9.10)
rails (>= 3.0)
rake
shoulda-context!
test-unit
shoulda-context-1.2.0/gemfiles/rails_3_0.gemfile.lock 0000644 0000041 0000041 00000003673 12316470655 022534 0 ustar www-data www-data PATH
remote: ../
specs:
shoulda-context (1.1.6)
GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.20)
actionpack (= 3.0.20)
mail (~> 2.2.19)
actionpack (3.0.20)
activemodel (= 3.0.20)
activesupport (= 3.0.20)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.5.0)
rack (~> 1.2.5)
rack-mount (~> 0.6.14)
rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
activemodel (3.0.20)
activesupport (= 3.0.20)
builder (~> 2.1.2)
i18n (~> 0.5.0)
activerecord (3.0.20)
activemodel (= 3.0.20)
activesupport (= 3.0.20)
arel (~> 2.0.10)
tzinfo (~> 0.3.23)
activeresource (3.0.20)
activemodel (= 3.0.20)
activesupport (= 3.0.20)
activesupport (3.0.20)
appraisal (0.5.2)
bundler
rake
arel (2.0.10)
builder (2.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
i18n (0.5.3)
json (1.8.1)
mail (2.2.20)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.25.1)
mocha (0.9.12)
polyglot (0.3.4)
rack (1.2.8)
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
rails (3.0.20)
actionmailer (= 3.0.20)
actionpack (= 3.0.20)
activerecord (= 3.0.20)
activeresource (= 3.0.20)
activesupport (= 3.0.20)
bundler (~> 1.0)
railties (= 3.0.20)
railties (3.0.20)
actionpack (= 3.0.20)
activesupport (= 3.0.20)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.4)
rake (10.2.1)
rdoc (3.12.2)
json (~> 1.4)
sqlite3 (1.3.9)
test-unit (2.1.2)
thor (0.14.6)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.38)
PLATFORMS
ruby
DEPENDENCIES
appraisal (~> 0.5)
mocha (~> 0.9.10)
rails (~> 3.0.0)
rake
shoulda-context!
sqlite3
test-unit (~> 2.1.0)
shoulda-context-1.2.0/gemfiles/minitest_5_x.gemfile 0000644 0000041 0000041 00000000164 12316470655 022431 0 ustar www-data www-data # This file was generated by Appraisal
source "http://rubygems.org"
gem "minitest", "~> 5.0"
gemspec :path=>"../" shoulda-context-1.2.0/gemfiles/minitest_4_x.gemfile.lock 0000644 0000041 0000041 00000004067 12316470655 023365 0 ustar www-data www-data PATH
remote: ../
specs:
shoulda-context (1.1.6)
GEM
remote: http://rubygems.org/
specs:
actionmailer (4.0.3)
actionpack (= 4.0.3)
mail (~> 2.5.4)
actionpack (4.0.3)
activesupport (= 4.0.3)
builder (~> 3.1.0)
erubis (~> 2.7.0)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
activemodel (4.0.3)
activesupport (= 4.0.3)
builder (~> 3.1.0)
activerecord (4.0.3)
activemodel (= 4.0.3)
activerecord-deprecated_finders (~> 1.0.2)
activesupport (= 4.0.3)
arel (~> 4.0.0)
activerecord-deprecated_finders (1.0.3)
activesupport (4.0.3)
i18n (~> 0.6, >= 0.6.4)
minitest (~> 4.2)
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
appraisal (0.5.2)
bundler
rake
arel (4.0.2)
atomic (1.1.16)
builder (3.1.4)
erubis (2.7.0)
hike (1.2.3)
i18n (0.6.9)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.25.1)
minitest (4.7.5)
mocha (0.9.12)
multi_json (1.9.2)
polyglot (0.3.4)
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
rails (4.0.3)
actionmailer (= 4.0.3)
actionpack (= 4.0.3)
activerecord (= 4.0.3)
activesupport (= 4.0.3)
bundler (>= 1.3.0, < 2.0)
railties (= 4.0.3)
sprockets-rails (~> 2.0.0)
railties (4.0.3)
actionpack (= 4.0.3)
activesupport (= 4.0.3)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.2.1)
sprockets (2.12.0)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.0.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
test-unit (2.1.2)
thor (0.19.1)
thread_safe (0.3.1)
atomic (>= 1.1.7, < 2)
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.38)
PLATFORMS
ruby
DEPENDENCIES
appraisal (~> 0.5)
minitest (~> 4.0)
mocha (~> 0.9.10)
rails (>= 3.0)
rake
shoulda-context!
test-unit (~> 2.1.0)
shoulda-context-1.2.0/gemfiles/rails_4_0.gemfile.lock 0000644 0000041 0000041 00000004464 12316470655 022534 0 ustar www-data www-data PATH
remote: ../
specs:
shoulda-context (1.1.6)
GEM
remote: http://rubygems.org/
specs:
actionmailer (4.0.3)
actionpack (= 4.0.3)
mail (~> 2.5.4)
actionpack (4.0.3)
activesupport (= 4.0.3)
builder (~> 3.1.0)
erubis (~> 2.7.0)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
activemodel (4.0.3)
activesupport (= 4.0.3)
builder (~> 3.1.0)
activerecord (4.0.3)
activemodel (= 4.0.3)
activerecord-deprecated_finders (~> 1.0.2)
activesupport (= 4.0.3)
arel (~> 4.0.0)
activerecord-deprecated_finders (1.0.3)
activesupport (4.0.3)
i18n (~> 0.6, >= 0.6.4)
minitest (~> 4.2)
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
appraisal (0.5.2)
bundler
rake
arel (4.0.2)
atomic (1.1.16)
builder (3.1.4)
erubis (2.7.0)
hike (1.2.3)
i18n (0.6.9)
jquery-rails (3.1.0)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.25.1)
minitest (4.7.5)
mocha (0.9.12)
multi_json (1.9.2)
polyglot (0.3.4)
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
rails (4.0.3)
actionmailer (= 4.0.3)
actionpack (= 4.0.3)
activerecord (= 4.0.3)
activesupport (= 4.0.3)
bundler (>= 1.3.0, < 2.0)
railties (= 4.0.3)
sprockets-rails (~> 2.0.0)
railties (4.0.3)
actionpack (= 4.0.3)
activesupport (= 4.0.3)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.2.1)
sass (3.3.4)
sass-rails (4.0.1)
railties (>= 4.0.0, < 5.0)
sass (>= 3.1.10)
sprockets-rails (~> 2.0.0)
sprockets (2.12.0)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.0.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
sqlite3 (1.3.9)
test-unit (2.1.2)
thor (0.19.1)
thread_safe (0.3.1)
atomic (>= 1.1.7, < 2)
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.38)
PLATFORMS
ruby
DEPENDENCIES
appraisal (~> 0.5)
jquery-rails
mocha (~> 0.9.10)
rails (~> 4.0.0)
rake
sass-rails
shoulda-context!
sqlite3
test-unit (~> 2.1.0)
shoulda-context-1.2.0/gemfiles/minitest_5_x.gemfile.lock 0000644 0000041 0000041 00000004166 12316470655 023366 0 ustar www-data www-data PATH
remote: ../
specs:
shoulda-context (1.1.6)
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.2.13)
actionpack (= 3.2.13)
mail (~> 2.5.3)
actionpack (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.5)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
activemodel (3.2.13)
activesupport (= 3.2.13)
builder (~> 3.0.0)
activerecord (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
activesupport (3.2.13)
i18n (= 0.6.1)
multi_json (~> 1.0)
appraisal (0.5.2)
bundler
rake
arel (3.0.3)
builder (3.0.4)
erubis (2.7.0)
hike (1.2.3)
i18n (0.6.1)
journey (1.0.4)
json (1.8.1)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.25.1)
minitest (5.3.1)
mocha (0.9.12)
multi_json (1.9.2)
polyglot (0.3.4)
rack (1.4.5)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.3)
rack
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.13)
actionmailer (= 3.2.13)
actionpack (= 3.2.13)
activerecord (= 3.2.13)
activeresource (= 3.2.13)
activesupport (= 3.2.13)
bundler (~> 1.0)
railties (= 3.2.13)
railties (3.2.13)
actionpack (= 3.2.13)
activesupport (= 3.2.13)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.2.1)
rdoc (3.12.2)
json (~> 1.4)
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
test-unit (2.1.2)
thor (0.19.1)
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.38)
PLATFORMS
ruby
DEPENDENCIES
appraisal (~> 0.5)
minitest (~> 5.0)
mocha (~> 0.9.10)
rails (>= 3.0)
rake
shoulda-context!
test-unit (~> 2.1.0)
shoulda-context-1.2.0/gemfiles/test_unit.gemfile 0000644 0000041 0000041 00000000153 12316470655 022036 0 ustar www-data www-data # This file was generated by Appraisal
source "http://rubygems.org"
gem "test-unit"
gemspec :path=>"../" shoulda-context-1.2.0/gemfiles/rails_3_2.gemfile.lock 0000644 0000041 0000041 00000004512 12316470655 022527 0 ustar www-data www-data PATH
remote: ../
specs:
shoulda-context (1.1.6)
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.2.13)
actionpack (= 3.2.13)
mail (~> 2.5.3)
actionpack (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.5)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
activemodel (3.2.13)
activesupport (= 3.2.13)
builder (~> 3.0.0)
activerecord (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.13)
activemodel (= 3.2.13)
activesupport (= 3.2.13)
activesupport (3.2.13)
i18n (= 0.6.1)
multi_json (~> 1.0)
appraisal (0.5.2)
bundler
rake
arel (3.0.3)
builder (3.0.4)
erubis (2.7.0)
hike (1.2.3)
i18n (0.6.1)
journey (1.0.4)
jquery-rails (3.1.0)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.1)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.25.1)
mocha (0.9.12)
multi_json (1.9.2)
polyglot (0.3.4)
rack (1.4.5)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.3)
rack
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.13)
actionmailer (= 3.2.13)
actionpack (= 3.2.13)
activerecord (= 3.2.13)
activeresource (= 3.2.13)
activesupport (= 3.2.13)
bundler (~> 1.0)
railties (= 3.2.13)
railties (3.2.13)
actionpack (= 3.2.13)
activesupport (= 3.2.13)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.2.1)
rdoc (3.12.2)
json (~> 1.4)
sass (3.3.4)
sass-rails (3.2.6)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.9)
test-unit (2.1.2)
thor (0.19.1)
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.38)
PLATFORMS
ruby
DEPENDENCIES
appraisal (~> 0.5)
jquery-rails
mocha (~> 0.9.10)
rails (~> 3.2.0)
rake
sass-rails
shoulda-context!
sqlite3
test-unit (~> 2.1.0)
shoulda-context-1.2.0/gemfiles/rails_4_1.gemfile.lock 0000644 0000041 0000041 00000005176 12316470655 022536 0 ustar www-data www-data GIT
remote: git://github.com/rails/rails.git
revision: 5ac4d6e8dd6f11b3291ce85d455ab5aff0abdbfe
branch: 4-1-stable
specs:
actionmailer (4.1.0.rc1)
actionpack (= 4.1.0.rc1)
actionview (= 4.1.0.rc1)
mail (~> 2.5.4)
actionpack (4.1.0.rc1)
actionview (= 4.1.0.rc1)
activesupport (= 4.1.0.rc1)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
actionview (4.1.0.rc1)
activesupport (= 4.1.0.rc1)
builder (~> 3.1)
erubis (~> 2.7.0)
activemodel (4.1.0.rc1)
activesupport (= 4.1.0.rc1)
builder (~> 3.1)
activerecord (4.1.0.rc1)
activemodel (= 4.1.0.rc1)
activesupport (= 4.1.0.rc1)
arel (~> 5.0.0)
activesupport (4.1.0.rc1)
i18n (~> 0.6, >= 0.6.9)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
rails (4.1.0.rc1)
actionmailer (= 4.1.0.rc1)
actionpack (= 4.1.0.rc1)
actionview (= 4.1.0.rc1)
activemodel (= 4.1.0.rc1)
activerecord (= 4.1.0.rc1)
activesupport (= 4.1.0.rc1)
bundler (>= 1.3.0, < 2.0)
railties (= 4.1.0.rc1)
sprockets-rails (~> 2.0.0)
railties (4.1.0.rc1)
actionpack (= 4.1.0.rc1)
activesupport (= 4.1.0.rc1)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
PATH
remote: ../
specs:
shoulda-context (1.1.6)
GEM
remote: http://rubygems.org/
specs:
appraisal (0.5.2)
bundler
rake
arel (5.0.0)
atomic (1.1.16)
builder (3.2.2)
erubis (2.7.0)
hike (1.2.3)
i18n (0.6.9)
jquery-rails (3.1.0)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.1)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.25.1)
minitest (5.3.1)
mocha (0.9.12)
multi_json (1.9.2)
polyglot (0.3.4)
rack (1.5.2)
rack-test (0.6.2)
rack (>= 1.0)
rake (10.2.1)
sass (3.3.4)
sass-rails (4.0.1)
railties (>= 4.0.0, < 5.0)
sass (>= 3.1.10)
sprockets-rails (~> 2.0.0)
sprockets (2.12.0)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets-rails (2.0.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
sqlite3 (1.3.9)
test-unit (2.1.2)
thor (0.19.1)
thread_safe (0.3.1)
atomic (>= 1.1.7, < 2)
tilt (1.4.1)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (1.1.0)
thread_safe (~> 0.1)
PLATFORMS
ruby
DEPENDENCIES
appraisal (~> 0.5)
jquery-rails
mocha (~> 0.9.10)
rails!
rake
sass-rails
shoulda-context!
sqlite3
test-unit (~> 2.1.0)
shoulda-context-1.2.0/gemfiles/rails_3_0.gemfile 0000644 0000041 0000041 00000000201 12316470655 021565 0 ustar www-data www-data # This file was generated by Appraisal
source "http://rubygems.org"
gem "rails", "~> 3.0.0"
gem "sqlite3"
gemspec :path=>"../" shoulda-context-1.2.0/gemfiles/rails_3_2.gemfile 0000644 0000041 0000041 00000000245 12316470655 021577 0 ustar www-data www-data # This file was generated by Appraisal
source "http://rubygems.org"
gem "rails", "~> 3.2.0"
gem "jquery-rails"
gem "sass-rails"
gem "sqlite3"
gemspec :path=>"../" shoulda-context-1.2.0/gemfiles/rails_4_0.gemfile 0000644 0000041 0000041 00000000245 12316470655 021576 0 ustar www-data www-data # This file was generated by Appraisal
source "http://rubygems.org"
gem "rails", "~> 4.0.0"
gem "jquery-rails"
gem "sass-rails"
gem "sqlite3"
gemspec :path=>"../" shoulda-context-1.2.0/gemfiles/rails_3_1.gemfile 0000644 0000041 0000041 00000000245 12316470655 021576 0 ustar www-data www-data # This file was generated by Appraisal
source "http://rubygems.org"
gem "rails", "~> 3.1.0"
gem "jquery-rails"
gem "sass-rails"
gem "sqlite3"
gemspec :path=>"../" shoulda-context-1.2.0/metadata.yml 0000644 0000041 0000041 00000011655 12316470655 017207 0 ustar www-data www-data --- !ruby/object:Gem::Specification
name: shoulda-context
version: !ruby/object:Gem::Version
version: 1.2.0
platform: ruby
authors:
- thoughtbot, inc.
- Tammer Saleh
- Joe Ferris
- Ryan McGeary
- Dan Croak
- Matt Jankowski
autorequire:
bindir: bin
cert_chain: []
date: 2014-03-31 00:00:00.000000000 Z
dependencies:
- !ruby/object:Gem::Dependency
name: appraisal
requirement: !ruby/object:Gem::Requirement
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '0.5'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - ~>
- !ruby/object:Gem::Version
version: '0.5'
- !ruby/object:Gem::Dependency
name: rails
requirement: !ruby/object:Gem::Requirement
requirements:
- - '>='
- !ruby/object:Gem::Version
version: '3.0'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - '>='
- !ruby/object:Gem::Version
version: '3.0'
- !ruby/object:Gem::Dependency
name: mocha
requirement: !ruby/object:Gem::Requirement
requirements:
- - ~>
- !ruby/object:Gem::Version
version: 0.9.10
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - ~>
- !ruby/object:Gem::Version
version: 0.9.10
- !ruby/object:Gem::Dependency
name: rake
requirement: !ruby/object:Gem::Requirement
requirements:
- - '>='
- !ruby/object:Gem::Version
version: '0'
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - '>='
- !ruby/object:Gem::Version
version: '0'
- !ruby/object:Gem::Dependency
name: test-unit
requirement: !ruby/object:Gem::Requirement
requirements:
- - ~>
- !ruby/object:Gem::Version
version: 2.1.0
type: :development
prerelease: false
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - ~>
- !ruby/object:Gem::Version
version: 2.1.0
description: Context framework extracted from Shoulda
email: support@thoughtbot.com
executables:
- convert_to_should_syntax
extensions: []
extra_rdoc_files: []
files:
- .gitignore
- .ruby-version
- .travis.yml
- Appraisals
- CONTRIBUTING.md
- Gemfile
- MIT-LICENSE
- README.md
- Rakefile
- bin/convert_to_should_syntax
- gemfiles/minitest_4_x.gemfile
- gemfiles/minitest_4_x.gemfile.lock
- gemfiles/minitest_5_x.gemfile
- gemfiles/minitest_5_x.gemfile.lock
- gemfiles/rails_3_0.gemfile
- gemfiles/rails_3_0.gemfile.lock
- gemfiles/rails_3_1.gemfile
- gemfiles/rails_3_1.gemfile.lock
- gemfiles/rails_3_2.gemfile
- gemfiles/rails_3_2.gemfile.lock
- gemfiles/rails_4_0.gemfile
- gemfiles/rails_4_0.gemfile.lock
- gemfiles/rails_4_1.gemfile
- gemfiles/rails_4_1.gemfile.lock
- gemfiles/test_unit.gemfile
- gemfiles/test_unit.gemfile.lock
- init.rb
- lib/shoulda-context.rb
- lib/shoulda/context.rb
- lib/shoulda/context/assertions.rb
- lib/shoulda/context/autoload_macros.rb
- lib/shoulda/context/context.rb
- lib/shoulda/context/proc_extensions.rb
- lib/shoulda/context/tasks.rb
- lib/shoulda/context/tasks/list_tests.rake
- lib/shoulda/context/tasks/yaml_to_shoulda.rake
- lib/shoulda/context/test_framework_detection.rb
- lib/shoulda/context/version.rb
- rails/init.rb
- shoulda-context.gemspec
- tasks/shoulda.rake
- test/fake_rails_root/test/shoulda_macros/custom_macro.rb
- test/fake_rails_root/vendor/gems/gem_with_macro-0.0.1/shoulda_macros/gem_macro.rb
- test/fake_rails_root/vendor/plugins/.keep
- test/fake_rails_root/vendor/plugins/plugin_with_macro/shoulda_macros/plugin_macro.rb
- test/shoulda/autoload_macro_test.rb
- test/shoulda/context_test.rb
- test/shoulda/convert_to_should_syntax_test.rb
- test/shoulda/helpers_test.rb
- test/shoulda/should_test.rb
- test/shoulda/test_framework_detection_test.rb
- test/test_helper.rb
homepage: http://thoughtbot.com/community/
licenses:
- MIT
metadata: {}
post_install_message:
rdoc_options: []
require_paths:
- lib
required_ruby_version: !ruby/object:Gem::Requirement
requirements:
- - '>='
- !ruby/object:Gem::Version
version: '0'
required_rubygems_version: !ruby/object:Gem::Requirement
requirements:
- - '>='
- !ruby/object:Gem::Version
version: '0'
requirements: []
rubyforge_project:
rubygems_version: 2.0.3
signing_key:
specification_version: 4
summary: Context framework extracted from Shoulda
test_files:
- test/fake_rails_root/test/shoulda_macros/custom_macro.rb
- test/fake_rails_root/vendor/gems/gem_with_macro-0.0.1/shoulda_macros/gem_macro.rb
- test/fake_rails_root/vendor/plugins/.keep
- test/fake_rails_root/vendor/plugins/plugin_with_macro/shoulda_macros/plugin_macro.rb
- test/shoulda/autoload_macro_test.rb
- test/shoulda/context_test.rb
- test/shoulda/convert_to_should_syntax_test.rb
- test/shoulda/helpers_test.rb
- test/shoulda/should_test.rb
- test/shoulda/test_framework_detection_test.rb
- test/test_helper.rb
shoulda-context-1.2.0/test/ 0000755 0000041 0000041 00000000000 12316470655 015653 5 ustar www-data www-data shoulda-context-1.2.0/test/shoulda/ 0000755 0000041 0000041 00000000000 12316470655 017312 5 ustar www-data www-data shoulda-context-1.2.0/test/shoulda/context_test.rb 0000644 0000041 0000041 00000020242 12316470655 022362 0 ustar www-data www-data require 'test_helper'
class ContextTest < Test::Unit::TestCase # :nodoc:
def self.context_macro(&blk)
context "with a subcontext made by a macro" do
setup { @context_macro = :foo }
merge_block(&blk)
end
end
context "context with setup block" do
setup do
@blah = "blah"
end
should "run the setup block" do
assert_equal "blah", @blah
end
should "have name set right" do
assert_match(/^test: context with setup block/, self.to_s)
end
context "and a subcontext" do
setup do
@blah = "#{@blah} twice"
end
should "be named correctly" do
assert_match(/^test: context with setup block and a subcontext should be named correctly/, self.to_s)
end
should "run the setup blocks in order" do
assert_equal @blah, "blah twice"
end
end
context_macro do
should "have name set right" do
assert_match(/^test: context with setup block with a subcontext made by a macro should have name set right/, self.to_s)
end
should "run the setup block of that context macro" do
assert_equal :foo, @context_macro
end
should "run the setup block of the main context" do
assert_equal "blah", @blah
end
end
end
context "another context with setup block" do
setup do
@blah = "foo"
end
should "have @blah == 'foo'" do
assert_equal "foo", @blah
end
should "have name set right" do
assert_match(/^test: another context with setup block/, self.to_s)
end
end
context "context with method definition" do
setup do
def hello; "hi"; end
end
should "be able to read that method" do
assert_equal "hi", hello
end
should "have name set right" do
assert_match(/^test: context with method definition/, self.to_s)
end
end
context "another context" do
should "not define @blah" do
assert !instance_variable_defined?(:@blah)
end
end
context "context with multiple setups and/or teardowns" do
cleanup_count = 0
2.times do |i|
setup { cleanup_count += 1 }
teardown { cleanup_count -= 1 }
end
2.times do |i|
should "call all setups and all teardowns (check ##{i + 1})" do
assert_equal 2, cleanup_count
end
end
context "subcontexts" do
2.times do |i|
setup { cleanup_count += 1 }
teardown { cleanup_count -= 1 }
end
2.times do |i|
should "also call all setups and all teardowns in parent and subcontext (check ##{i + 1})" do
assert_equal 4, cleanup_count
end
end
end
end
should_eventually "pass, since it's unimplemented" do
flunk "what?"
end
should_eventually "not require a block when using should_eventually"
should "pass without a block, as that causes it to piggyback to should_eventually"
context "context for testing should piggybacking" do
should "call should_eventually as we are not passing a block"
end
context "context" do
context "with nested subcontexts" do
should_eventually "only print this statement once for a should_eventually"
end
end
class ::SomeModel; end
context "given a test named after a class" do
setup do
self.class.stubs(:name).returns("SomeModelTest")
end
should "determine the described type" do
assert_equal SomeModel, self.class.described_type
end
should "return a new instance of the described type as the subject if none exists" do
assert_kind_of SomeModel, subject
end
context "with an explicit subject block" do
setup { @expected = SomeModel.new }
subject { @expected }
should "return the result of the block as the subject" do
assert_equal @expected, subject
end
context "nested context block without a subject block" do
should "return the result of the parent context's subject block" do
assert_equal @expected, subject
end
end
end
end
end
class ::Some
class NestedModel; end
end
class Some::NestedModelTest < Test::Unit::TestCase
should "determine the described type for a nested model" do
assert_equal Some::NestedModel, self.class.described_type
end
end
class ShouldMatcherTest < Test::Unit::TestCase
class FakeMatcher
attr_reader :subject
attr_accessor :fail
def description
"do something"
end
def matches?(subject)
@subject = subject
!@fail
end
def failure_message_for_should
"failure message for should"
end
def failure_message_for_should_not
"failure message for should not"
end
end
def run_test_suite
@test_suite.run(@test_result) { |event, name| }
end
def setup
@matcher = FakeMatcher.new
@test_result = Test::Unit::TestResult.new
class << @test_result
def failure_messages
@failures.map { |failure| failure.message }
end
end
end
def create_test_suite(&definition)
test_class = Class.new(Test::Unit::TestCase, &definition)
test_class.suite
end
def assert_failed_with(message, test_result)
assert_equal 1, test_result.failure_count
assert_equal [message], test_result.failure_messages
end
def assert_passed(test_result)
assert_equal 0, test_result.failure_count
end
def assert_test_named(expected_name, test_suite)
name = test_suite.tests.map { |test| test.method_name }.first
assert name.include?(expected_name), "Expected #{name} to include #{expected_name}"
end
def self.should_use_positive_matcher
should "generate a test using the matcher's description" do
assert_test_named "should #{@matcher.description}", @test_suite
end
should "pass with a passing matcher" do
@matcher.fail = false
run_test_suite
assert_passed @test_result
end
should "fail with a failing matcher" do
@matcher.fail = true
run_test_suite
assert_failed_with "failure message for should", @test_result
end
should "provide the subject" do
@matcher.fail = false
run_test_suite
assert_equal 'a subject', @matcher.subject
end
end
def self.should_use_negative_matcher
should "generate a test using the matcher's description" do
assert_test_named "should not #{@matcher.description}", @test_suite
end
should "pass with a failing matcher" do
@matcher.fail = true
run_test_suite
assert_passed @test_result
end
should "fail with a passing matcher" do
@matcher.fail = false
run_test_suite
assert_failed_with "failure message for should not", @test_result
end
should "provide the subject" do
@matcher.fail = false
run_test_suite
assert_equal 'a subject', @matcher.subject
end
end
context "a should block with a matcher" do
setup do
matcher = @matcher
@test_suite = create_test_suite do
subject { 'a subject' }
should matcher
end
end
should_use_positive_matcher
end
context "a should block with a matcher within a context" do
setup do
matcher = @matcher
@test_suite = create_test_suite do
context "in context" do
subject { 'a subject' }
should matcher
end
end
end
should_use_positive_matcher
end
context "a should_not block with a matcher" do
setup do
matcher = @matcher
@test_suite = create_test_suite do
subject { 'a subject' }
should_not matcher
end
end
should_use_negative_matcher
end
context "a should_not block with a matcher within a context" do
setup do
matcher = @matcher
@test_suite = create_test_suite do
context "in context" do
subject { 'a subject' }
should_not matcher
end
end
end
should_use_negative_matcher
end
end
class Subject; end
class SubjectTest < Test::Unit::TestCase
def setup
@expected = Subject.new
end
subject { @expected }
should "return a specified subject" do
assert_equal @expected, subject
end
end
class SubjectLazinessTest < Test::Unit::TestCase
subject { Subject.new }
should "only build the subject once" do
assert_equal subject, subject
end
end
shoulda-context-1.2.0/test/shoulda/autoload_macro_test.rb 0000644 0000041 0000041 00000000713 12316470655 023670 0 ustar www-data www-data require 'test_helper'
class AutoloadMacroTest < Test::Unit::TestCase # :nodoc:
context "The macro auto-loader" do
should "load macros from the plugins" do
assert self.class.respond_to?('plugin_macro')
end
should "load macros from the gems" do
assert self.class.respond_to?('gem_macro')
end
should "load custom macros from ROOT/test/shoulda_macros" do
assert self.class.respond_to?('custom_macro')
end
end
end
shoulda-context-1.2.0/test/shoulda/convert_to_should_syntax_test.rb 0000644 0000041 0000041 00000002431 12316470655 026044 0 ustar www-data www-data require 'test/unit'
class ConvertToShouldSyntaxTest < Test::Unit::TestCase # :nodoc:
BEFORE_FIXTURE = <<-EOS
class DummyTest < Test::Unit::TestCase
should "Not change this_word_with_underscores" do
end
def test_should_be_working
assert true
end
def test_some_cool_stuff
assert true
end
def non_test_method
end
end
EOS
AFTER_FIXTURE = <<-EOS
class DummyTest < Test::Unit::TestCase
should "Not change this_word_with_underscores" do
end
should "be working" do
assert true
end
should "RENAME ME: test some cool stuff" do
assert true
end
def non_test_method
end
end
EOS
FIXTURE_PATH = "./convert_to_should_syntax_fixture.dat"
RUBY = ENV['RUBY'] || 'ruby'
def test_convert_to_should_syntax
File.open(FIXTURE_PATH, "w") {|f| f.write(BEFORE_FIXTURE)}
cmd = "#{RUBY} #{File.join(File.dirname(__FILE__), '../../bin/convert_to_should_syntax')} #{FIXTURE_PATH}"
output = `#{cmd}`
File.unlink($1) if output.match(/has been stored in '([^']+)/)
assert_match(/has been converted/, output)
result = IO.read(FIXTURE_PATH)
assert_equal result, AFTER_FIXTURE
end
def teardown
File.unlink(FIXTURE_PATH)
end
end
shoulda-context-1.2.0/test/shoulda/helpers_test.rb 0000644 0000041 0000041 00000013323 12316470655 022342 0 ustar www-data www-data require 'test_helper'
class HelpersTest < Test::Unit::TestCase # :nodoc:
context "an array of values" do
setup do
@a = ['abc', 'def', 3]
end
[/b/, 'abc', 3].each do |x|
should "contain #{x.inspect}" do
assert_raises(Test::Unit::AssertionFailedError) do
assert_does_not_contain @a, x
end
assert_contains @a, x
end
end
should "not contain 'wtf'" do
assert_raises(Test::Unit::AssertionFailedError) {assert_contains @a, 'wtf'}
assert_does_not_contain @a, 'wtf'
end
should "be the same as another array, ordered differently" do
assert_same_elements(@a, [3, "def", "abc"])
assert_raises(Test::Unit::AssertionFailedError) do
assert_same_elements(@a, [3, 3, "def", "abc"])
end
assert_same_elements([@a, "abc"].flatten, ["abc", 3, "def", "abc"])
assert_raises(Test::Unit::AssertionFailedError) do
assert_same_elements([@a, "abc"].flatten, [3, 3, "def", "abc"])
end
end
should "only count the number of occurrences once for each unique value" do
a1 = [@a, "abc"].flatten
a1.expects(:select).times(3).returns(["abc", "abc"], ["def"], [3])
assert_same_elements(a1, ["abc", 3, "def", "abc"])
end
end
context "a matching matcher" do
setup do
@matcher = stub('matcher', :matches? => true,
:failure_message_for_should => 'bad failure message',
:failure_message_for_should_not => 'big time failure')
end
should "pass when given to assert_accepts with no message expectation" do
assert_accepts @matcher, 'target'
end
should "pass when given to assert_accepts with a matching message" do
assert_accepts @matcher, 'target', :message => /big time/
end
should "fail when given to assert_accepts with non-matching message" do
assert_raise Test::Unit::AssertionFailedError do
assert_accepts @matcher, 'target', :message => /small time/
end
end
context "when given to assert_rejects" do
context "and matcher has :does_not_match?" do
setup do
@error = nil
begin
@matcher.stubs(:matches?).returns(false)
@matcher.stubs(:does_not_match?).returns(true)
assert_rejects @matcher, 'target'
rescue Test::Unit::AssertionFailedError => @error
end
end
should "pass" do
assert_nil @error
end
end
context "and matcher does not have :does_not_match?" do
setup do
@error = nil
begin
assert_rejects @matcher, 'target'
rescue Test::Unit::AssertionFailedError => @error
end
end
should "fail" do
assert_not_nil @error
end
should "use the error message from the matcher" do
assert_equal 'big time failure', @error.message
end
end
end
end
context "a non-matching matcher" do
setup do
@matcher = stub('matcher', :matches? => false,
:failure_message_for_should => 'big time failure',
:failure_message_for_should_not => 'bad failure message')
end
should "pass when given to assert_rejects with no message expectation" do
assert_rejects @matcher, 'target'
end
should "pass when given to assert_rejects with a matching message" do
assert_rejects @matcher, 'target', :message => /big time/
end
should "fail when given to assert_rejects with a non-matching message" do
assert_raise Test::Unit::AssertionFailedError do
assert_rejects @matcher, 'target', :message => /small time/
end
end
context "when given to assert_accepts" do
setup do
begin
assert_accepts @matcher, 'target'
rescue Test::Unit::AssertionFailedError => @error
end
end
should "fail" do
assert_not_nil @error
end
should "use the error message from the matcher" do
assert_equal 'big time failure', @error.message
end
end
end
context "a matcher using antiquated syntax" do
setup do
@matcher = stub('matcher', :matches? => false,
:failure_message => 'big time failure',
:negative_failure_message => 'bad failure message')
end
should "pass when given to assert_rejects with no message expectation" do
assert_rejects @matcher, 'target'
end
should "pass when given to assert_rejects with a matching message" do
assert_rejects @matcher, 'target', :message => /big time/
end
should "fail when given to assert_rejects with a non-matching message" do
assert_raise Test::Unit::AssertionFailedError do
assert_rejects @matcher, 'target', :message => /small time/
end
end
context "when given to assert_accepts" do
setup do
begin
assert_accepts @matcher, 'target'
rescue Test::Unit::AssertionFailedError => @error
end
end
should "fail" do
assert_not_nil @error
end
should "use the error message from the matcher" do
assert_equal 'big time failure', @error.message
end
end
end
should "assign context to a support matching on assert_accepts" do
matcher = stub('matcher', :matches? => true)
matcher.expects(:in_context).with(self)
assert_accepts matcher, nil
end
should "assign context to a support matching on assert_rejects" do
matcher = stub('matcher', :matches? => false)
matcher.expects(:in_context).with(self)
assert_rejects matcher, nil
end
end
shoulda-context-1.2.0/test/shoulda/test_framework_detection_test.rb 0000644 0000041 0000041 00000010610 12316470655 025766 0 ustar www-data www-data require 'test_helper'
require 'tempfile'
class TestFrameworkDetectionTest < Test::Unit::TestCase
if CURRENT_APPRAISAL_NAME == 'rails_4_1'
should 'detect Minitest 5.x w/ Rails 4.1' do
assert_integration_with_rails_and 'Minitest::Test', 'Minitest::Unit::TestCase'
end
end
if CURRENT_APPRAISAL_NAME == 'rails_4_0'
should 'detect ActiveSupport::TestCase and Minitest 4.x w/ Rails 4.0' do
assert_integration_with_rails_and 'MiniTest::Unit::TestCase'
end
end
if CURRENT_APPRAISAL_NAME == 'rails_3_2'
should 'detect ActiveSupport::TestCase and Test::Unit::TestCase w/ Rails 3.2' do
assert_integration_with_rails_and 'Test::Unit::TestCase'
end
end
if CURRENT_APPRAISAL_NAME == 'rails_3_1'
should 'detect ActiveSupport::TestCase and Test::Unit::TestCase w/ Rails 3.1' do
assert_integration_with_rails_and 'Test::Unit::TestCase'
end
end
if CURRENT_APPRAISAL_NAME == 'rails_3_0'
should 'detect ActiveSupport::TestCase and Test::Unit::TestCase w/ Rails 3.0' do
assert_integration_with_rails_and 'Test::Unit::TestCase'
end
end
if CURRENT_APPRAISAL_NAME == 'minitest_5_x'
should 'detect Minitest 5.x when it is loaded standalone' do
assert_integration_with 'Minitest::Test', 'Minitest::Unit::TestCase',
setup: <<-RUBY
require 'minitest/autorun'
RUBY
end
end
if CURRENT_APPRAISAL_NAME == 'minitest_4_x'
should 'detect Minitest 4.x when it is loaded standalone' do
assert_integration_with 'MiniTest::Unit::TestCase',
setup: <<-RUBY
require 'minitest/autorun'
RUBY
end
end
if CURRENT_APPRAISAL_NAME == 'test_unit'
should 'detect the test-unit gem when it is loaded standalone' do
assert_integration_with 'Test::Unit::TestCase',
setup: <<-RUBY
require 'test/unit'
RUBY
end
end
def assert_integration_with(*test_cases)
assert_test_cases_are_detected(*test_cases)
assert_our_api_is_available_in_test_cases(*test_cases)
end
def assert_integration_with_rails_and(*test_cases)
test_cases = ['ActiveSupport::TestCase'] | test_cases
options = test_cases.last.is_a?(Hash) ? test_cases.pop : {}
options[:setup] = <<-RUBY
require 'rails/all'
require 'rails/test_help'
ActiveRecord::Base.establish_connection(
adapter: 'sqlite3',
database: ':memory:'
)
RUBY
args = test_cases + [options]
assert_integration_with(*args)
end
def assert_test_cases_are_detected(*expected_test_cases)
options = expected_test_cases.last.is_a?(Hash) ? expected_test_cases.pop : {}
setup = options[:setup] || ''
output = execute(file_that_detects_test_framework_test_cases([setup]))
actual_test_cases = output.split("\n").first.split(', ')
assert_equal expected_test_cases, actual_test_cases
end
def file_that_detects_test_framework_test_cases(mixins)
<<-RUBY
#{require_gems(mixins)}
require 'yaml'
test_cases = Shoulda::Context.test_framework_test_cases.map { |test_case| test_case.to_s }
puts test_cases.join(', ')
RUBY
end
def require_gems(mixins)
<<-RUBY
ENV['BUNDLE_GEMFILE'] = "#{PROJECT_DIR}/gemfiles/#{CURRENT_APPRAISAL_NAME}.gemfile"
require 'bundler'
Bundler.setup
#{mixins.join("\n")}
require 'shoulda-context'
RUBY
end
def assert_our_api_is_available_in_test_cases(*test_cases)
options = test_cases.last.is_a?(Hash) ? test_cases.pop : {}
setup = options[:setup] || ''
test_cases.each do |test_case|
output = execute(file_that_runs_a_test_within_test_case(test_case, [setup]))
assert_match /1 (tests|runs)/, output
assert_match /1 assertions/, output
assert_match /0 failures/, output
assert_match /0 errors/, output
end
end
def file_that_runs_a_test_within_test_case(test_case, mixins)
<<-RUBY
#{require_gems(mixins)}
class FrameworkIntegrationTest < #{test_case}
context 'a context' do
should 'have a test' do
assert_equal true, true
end
end
end
RUBY
end
def execute(code)
tempfile = Tempfile.new('shoulda-context-test')
tempfile.write(code)
tempfile.close
if ENV['DEBUG']
puts 'Code:'
puts code
end
output = `RUBYOPT='' ruby #{tempfile.path} 2>&1`
if ENV['DEBUG']
puts 'Output:'
puts output
end
output
end
end
shoulda-context-1.2.0/test/shoulda/should_test.rb 0000644 0000041 0000041 00000017437 12316470655 022210 0 ustar www-data www-data require 'test_helper'
class ShouldTest < Test::Unit::TestCase # :nodoc:
should "be able to define a should statement outside of a context" do
assert true
end
should "see the name of my class as ShouldTest" do
assert_equal "ShouldTest", self.class.name
end
def self.should_see_class_methods
should "be able to see class methods" do
assert true
end
end
def self.should_be_able_to_setup_a_should_eventually_in_a_class_method
should "be able to setup a should eventually in a class method"
end
def self.should_see_a_context_block_like_a_Test_Unit_class
should "see a context block as a Test::Unit class" do
assert_equal "ShouldTest", self.class.name
end
end
def self.should_see_blah
should "see @blah through a macro" do
assert @blah
end
end
def self.should_not_see_blah
should "not see @blah through a macro" do
assert !instance_variable_defined?(:@blah)
end
end
def self.should_be_able_to_make_context_macros(prefix = nil)
context "a macro" do
should "have the tests named correctly" do
assert_match(/^test: #{prefix}a macro should have the tests named correctly/, self.to_s)
end
end
end
context "Context" do
should_see_class_methods
should_see_a_context_block_like_a_Test_Unit_class
should_be_able_to_make_context_macros("Context ")
should_be_able_to_setup_a_should_eventually_in_a_class_method
should "not define @blah" do
assert ! self.instance_variables.include?("@blah")
end
should_not_see_blah
should "be able to define a should statement" do
assert true
end
should "see the name of my class as ShouldTest" do
assert_equal "ShouldTest", self.class.name
end
context "with a subcontext" do
should_be_able_to_make_context_macros("Context with a subcontext ")
end
end
context "Context with setup block" do
setup do
@blah = "blah"
end
should "have @blah == 'blah'" do
assert_equal "blah", @blah
end
should_see_blah
should "have name set right" do
assert_match(/^test: Context with setup block/, self.to_s)
end
context "and a subcontext" do
setup do
@blah = "#{@blah} twice"
end
should "be named correctly" do
assert_match(/^test: Context with setup block and a subcontext should be named correctly/, self.to_s)
end
should "run the setup methods in order" do
assert_equal @blah, "blah twice"
end
should_see_blah
end
end
context "Another context with setup block" do
setup do
@blah = "foo"
end
should "have @blah == 'foo'" do
assert_equal "foo", @blah
end
should "have name set right" do
assert_match(/^test: Another context with setup block/, self.to_s)
end
should_see_blah
end
should_eventually "pass, since it's a should_eventually" do
flunk "what?"
end
# Context creation and naming
def test_should_create_a_new_context
assert_nothing_raised do
Shoulda::Context::Context.new("context name", self) do; end
end
end
def test_should_create_a_new_context_even_if_block_is_omitted
old_verbose, $VERBOSE = $VERBOSE, nil
assert_nothing_raised do
Shoulda::Context::Context.new("context without a block", self)
end
ensure
$VERBOSE = old_verbose
end
def test_should_create_a_nested_context
assert_nothing_raised do
parent = Shoulda::Context::Context.new("Parent", self) do; end
child = Shoulda::Context::Context.new("Child", parent) do; end
raise unless child.instance_of? Shoulda::Context::Context
end
end
def test_should_name_a_contexts_correctly
parent = Shoulda::Context::Context.new("Parent", self) do; end
child = Shoulda::Context::Context.new("Child", parent) do; end
grandchild = Shoulda::Context::Context.new("GrandChild", child) do; end
assert_equal "Parent", parent.full_name
assert_equal "Parent Child", child.full_name
assert_equal "Parent Child GrandChild", grandchild.full_name
end
def test_should_raise_on_duplicate_naming
tu_class = Test::Unit::TestCase
context = Shoulda::Context::Context.new("DupContext", tu_class) do
should "dup" do; end
should "dup" do; end
end
assert_raise DuplicateTestError do
context.build
end
end
# Should statements
def test_should_have_should_hashes_when_given_should_statements
context = Shoulda::Context::Context.new("name", self) do
should "be good" do; end
should "another" do; end
end
names = context.shoulds.map {|s| s[:name]}
assert_equal ["another", "be good"], names.sort
end
# setup and teardown
def test_should_capture_setup_and_teardown_blocks
context = Shoulda::Context::Context.new("name", self) do
setup do; "setup"; end
teardown do; "teardown"; end
end
assert_equal "setup", context.setup_blocks.first.call
assert_equal "teardown", context.teardown_blocks.first.call
end
# building
def test_should_create_shoulda_test_for_each_should_on_build
context = Shoulda::Context::Context.new("name", self) do
should "one" do; end
should "two" do; end
end
context.expects(:create_test_from_should_hash).with(has_entry(:name => "one"))
context.expects(:create_test_from_should_hash).with(has_entry(:name => "two"))
context.build
end
def test_should_create_test_methods_on_build
tu_class = Test::Unit::TestCase
context = Shoulda::Context::Context.new("A Context", tu_class) do
should "define the test" do; end
end
tu_class.expects(:define_method).with(:"test: A Context should define the test. ")
context.build
end
def test_should_create_test_methods_on_build_when_subcontext
tu_class = Test::Unit::TestCase
context = Shoulda::Context::Context.new("A Context", tu_class) do
context "with a child" do
should "define the test" do; end
end
end
tu_class.expects(:define_method).with(:"test: A Context with a child should define the test. ")
context.build
end
# Test::Unit integration
def test_should_create_a_new_context_and_build_it_on_Test_Unit_context
c = mock("context")
c.expects(:build)
Shoulda::Context::Context.expects(:new).with("foo", kind_of(Class)).returns(c)
self.class.context "foo" do; end
end
def test_should_create_a_one_off_context_and_build_it_on_Test_Unit_should
s = mock("test")
Shoulda::Context::Context.any_instance.expects(:should).with("rock", {}).returns(s)
Shoulda::Context::Context.any_instance.expects(:build)
self.class.should "rock" do; end
end
def test_should_create_a_one_off_context_and_build_it_on_Test_Unit_should_eventually
s = mock("test")
Shoulda::Context::Context.any_instance.expects(:should_eventually).with("rock").returns(s)
Shoulda::Context::Context.any_instance.expects(:build)
self.class.should_eventually "rock" do; end
end
should "run a :before proc", :before => lambda { @value = "before" } do
assert_equal "before", @value
end
context "A :before proc" do
setup do
assert_equal "before", @value
@value = "setup"
end
should "run before the current setup", :before => lambda { @value = "before" } do
assert_equal "setup", @value
end
end
context "a before statement" do
setup do
assert_equal "before", @value
@value = "setup"
end
before_should "run before the current setup" do
@value = "before"
end
end
context "A context" do
setup do
@value = "outer"
end
context "with a subcontext and a :before proc" do
before = lambda do
assert "outer", @value
@value = "before"
end
should "run after the parent setup", :before => before do
assert_equal "before", @value
end
end
end
end
shoulda-context-1.2.0/test/test_helper.rb 0000644 0000041 0000041 00000001017 12316470655 020515 0 ustar www-data www-data require 'fileutils'
require 'test/unit'
require 'mocha'
if ENV['BUNDLE_GEMFILE'].to_s.empty?
raise "No Appraisal is specified. Please re-run your tests with BUNDLE_GEMFILE set."
end
PROJECT_DIR = File.expand_path('../..', __FILE__)
CURRENT_APPRAISAL_NAME = File.basename(ENV['BUNDLE_GEMFILE'], '.gemfile')
$LOAD_PATH << File.join(PROJECT_DIR, 'lib')
require 'shoulda/context'
Shoulda.autoload_macros File.join(File.dirname(__FILE__), 'fake_rails_root'),
File.join("vendor", "{plugins,gems}", "*")
shoulda-context-1.2.0/test/fake_rails_root/ 0000755 0000041 0000041 00000000000 12316470655 021016 5 ustar www-data www-data shoulda-context-1.2.0/test/fake_rails_root/vendor/ 0000755 0000041 0000041 00000000000 12316470655 022313 5 ustar www-data www-data shoulda-context-1.2.0/test/fake_rails_root/vendor/gems/ 0000755 0000041 0000041 00000000000 12316470655 023246 5 ustar www-data www-data shoulda-context-1.2.0/test/fake_rails_root/vendor/gems/gem_with_macro-0.0.1/ 0000755 0000041 0000041 00000000000 12316470655 026664 5 ustar www-data www-data shoulda-context-1.2.0/test/fake_rails_root/vendor/gems/gem_with_macro-0.0.1/shoulda_macros/ 0000755 0000041 0000041 00000000000 12316470655 031667 5 ustar www-data www-data ././@LongLink 0000000 0000000 0000000 00000000150 00000000000 011561 L ustar root root shoulda-context-1.2.0/test/fake_rails_root/vendor/gems/gem_with_macro-0.0.1/shoulda_macros/gem_macro.rb shoulda-context-1.2.0/test/fake_rails_root/vendor/gems/gem_with_macro-0.0.1/shoulda_macros/gem_macro0000644 0000041 0000041 00000000121 12316470655 033535 0 ustar www-data www-data module GemMacro
def gem_macro
end
end
Test::Unit::TestCase.extend(GemMacro)
shoulda-context-1.2.0/test/fake_rails_root/vendor/plugins/ 0000755 0000041 0000041 00000000000 12316470655 023774 5 ustar www-data www-data shoulda-context-1.2.0/test/fake_rails_root/vendor/plugins/plugin_with_macro/ 0000755 0000041 0000041 00000000000 12316470655 027506 5 ustar www-data www-data shoulda-context-1.2.0/test/fake_rails_root/vendor/plugins/plugin_with_macro/shoulda_macros/ 0000755 0000041 0000041 00000000000 12316470655 032511 5 ustar www-data www-data ././@LongLink 0000000 0000000 0000000 00000000153 00000000000 011564 L ustar root root shoulda-context-1.2.0/test/fake_rails_root/vendor/plugins/plugin_with_macro/shoulda_macros/plugin_macro.rb shoulda-context-1.2.0/test/fake_rails_root/vendor/plugins/plugin_with_macro/shoulda_macros/plugin_ma0000644 0000041 0000041 00000000132 12316470655 034403 0 ustar www-data www-data module PluginMacro
def plugin_macro
end
end
Test::Unit::TestCase.extend(PluginMacro)
shoulda-context-1.2.0/test/fake_rails_root/vendor/plugins/.keep 0000644 0000041 0000041 00000000000 12316470655 024707 0 ustar www-data www-data shoulda-context-1.2.0/test/fake_rails_root/test/ 0000755 0000041 0000041 00000000000 12316470655 021775 5 ustar www-data www-data shoulda-context-1.2.0/test/fake_rails_root/test/shoulda_macros/ 0000755 0000041 0000041 00000000000 12316470655 025000 5 ustar www-data www-data shoulda-context-1.2.0/test/fake_rails_root/test/shoulda_macros/custom_macro.rb 0000644 0000041 0000041 00000000132 12316470655 030014 0 ustar www-data www-data module CustomMacro
def custom_macro
end
end
Test::Unit::TestCase.extend(CustomMacro)
shoulda-context-1.2.0/init.rb 0000644 0000041 0000041 00000000073 12316470655 016164 0 ustar www-data www-data require File.join(File.dirname(__FILE__), 'rails', 'init')
shoulda-context-1.2.0/.gitignore 0000644 0000041 0000041 00000000124 12316470655 016661 0 ustar www-data www-data .bundle
Gemfile.lock
vendor/ruby
vendor/cache
doc
coverage
pkg
*.swp
*.swo
tags
tmp
shoulda-context-1.2.0/shoulda-context.gemspec 0000644 0000041 0000041 00000002207 12316470655 021363 0 ustar www-data www-data # -*- encoding: utf-8 -*-
$LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
require 'shoulda/context/version'
Gem::Specification.new do |s|
s.name = %q{shoulda-context}
s.version = Shoulda::Context::VERSION.dup
s.platform = Gem::Platform::RUBY
s.authors = ["thoughtbot, inc.", "Tammer Saleh", "Joe Ferris",
"Ryan McGeary", "Dan Croak", "Matt Jankowski"]
s.email = %q{support@thoughtbot.com}
s.homepage = %q{http://thoughtbot.com/community/}
s.summary = %q{Context framework extracted from Shoulda}
s.description = %q{Context framework extracted from Shoulda}
s.license = %q{MIT}
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
s.add_development_dependency("appraisal", "~> 0.5")
s.add_development_dependency("rails", ">= 3.0")
s.add_development_dependency("mocha", "~> 0.9.10")
s.add_development_dependency("rake")
s.add_development_dependency("test-unit", "~> 2.1.0")
end
shoulda-context-1.2.0/tasks/ 0000755 0000041 0000041 00000000000 12316470655 016021 5 ustar www-data www-data shoulda-context-1.2.0/tasks/shoulda.rake 0000644 0000041 0000041 00000000126 12316470655 020323 0 ustar www-data www-data load File.join(File.dirname(__FILE__), "..", "lib", "shoulda", "context", "tasks.rb")
shoulda-context-1.2.0/CONTRIBUTING.md 0000644 0000041 0000041 00000002470 12316470655 017130 0 ustar www-data www-data We love pull requests. Here's a quick guide:
1. Fork the repo.
2. Run the tests. We only take pull requests with passing tests, and it's great
to know that you have a clean slate: `bundle && rake`
3. Add a test for your change. Only refactoring and documentation changes
require no new tests. If you are adding functionality or fixing a bug, we need
a test!
4. Make the test pass.
5. Push to your fork and submit a pull request.
At this point you're waiting on us. We like to at least comment on, if not
accept, pull requests within three business days (and, typically, one business
day). We may suggest some changes or improvements or alternatives.
Some things that will increase the chance that your pull request is accepted,
taken straight from the Ruby on Rails guide:
* Use Rails idioms and helpers
* Include tests that fail without your code, and pass with it
* Update the documentation, the surrounding one, examples elsewhere, guides,
whatever is affected by your contribution
Syntax:
* Two spaces, no tabs.
* No trailing whitespace. Blank lines should not have any space.
* Prefer &&/|| over and/or.
* MyClass.my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
* a = b and not a=b.
* Follow the conventions you see used in the source already.
And in case we didn't emphasize it enough: we love tests!
shoulda-context-1.2.0/rails/ 0000755 0000041 0000041 00000000000 12316470655 016006 5 ustar www-data www-data shoulda-context-1.2.0/rails/init.rb 0000644 0000041 0000041 00000000210 12316470655 017267 0 ustar www-data www-data if RAILS_ENV == 'test'
require "shoulda/context"
Shoulda.autoload_macros RAILS_ROOT, File.join("vendor", "{plugins,gems}", "*")
end
shoulda-context-1.2.0/Appraisals 0000644 0000041 0000041 00000001310 12316470655 016711 0 ustar www-data www-data appraise 'rails_3_0' do
gem 'rails', '~> 3.0.0'
gem 'sqlite3'
end
appraise 'rails_3_1' do
gem 'rails', '~> 3.1.0'
gem 'jquery-rails'
gem 'sass-rails'
gem 'sqlite3'
end
appraise 'rails_3_2' do
gem 'rails', '~> 3.2.0'
gem 'jquery-rails'
gem 'sass-rails'
gem 'sqlite3'
end
appraise 'rails_4_0' do
gem 'rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'sass-rails'
gem 'sqlite3'
end
appraise 'rails_4_1' do
gem 'rails', github: 'rails/rails', branch: '4-1-stable'
gem 'jquery-rails'
gem 'sass-rails'
gem 'sqlite3'
end
appraise 'minitest_4_x' do
gem 'minitest', '~> 4.0'
end
appraise 'minitest_5_x' do
gem 'minitest', '~> 5.0'
end
appraise 'test_unit' do
gem 'test-unit'
end
shoulda-context-1.2.0/checksums.yaml.gz 0000444 0000041 0000041 00000000414 12316470655 020161 0 ustar www-data www-data 9Se;R0D"tt@,*&ǡzvy{z|ސªIuKhTd:/ȯ_n,=Qcp_]c
,clmiU^hI)ܾvz.&46BxV8Tnސjd#RA[a"J Tq W{8Ft*$DbP+
oScseq<.lSLTcO -N2%#xaf*V! shoulda-context-1.2.0/README.md 0000644 0000041 0000041 00000004017 12316470655 016155 0 ustar www-data www-data # shoulda-context [](http://badge.fury.io/rb/shoulda-context) [](https://travis-ci.org/thoughtbot/shoulda-context)
[Official Documentation](http://rubydoc.info/github/thoughtbot/shoulda-context/master/frames)
Shoulda's contexts make it easy to write understandable and maintainable tests for Test::Unit.
It's fully compatible with your existing tests in Test::Unit, and requires no retooling to use.
Refer to the [shoulda](https://github.com/thoughtbot/shoulda) gem if you want to know more
about using shoulda with Rails or RSpec.
## Contexts
Instead of writing Ruby methods with `lots_of_underscores`, shoulda-context adds
context, setup, and should blocks...
class CalculatorTest < Test::Unit::TestCase
context "a calculator" do
setup do
@calculator = Calculator.new
end
should "add two numbers for the sum" do
assert_equal 4, @calculator.sum(2, 2)
end
should "multiply two numbers for the product" do
assert_equal 10, @calculator.product(2, 5)
end
end
end
... which combine to produce the following test methods:
"test: a calculator should add two numbers for the sum."
"test: a calculator should multiply two numbers for the product."
## Assertions
It also has two additional Test::Unit assertions for working with Ruby's Array:
assert_same_elements([:a, :b, :c], [:c, :a, :b])
assert_contains(['a', '1'], /\d/)
assert_contains(['a', '1'], 'a')
## Credits
Shoulda is maintained and funded by [thoughtbot](http://thoughtbot.com/community).
shoulda-context is maintained by [Travis Jeffery](https://github.com/travisjeffery).
Thank you to all the [contributors](https://github.com/thoughtbot/shoulda-context/contributors).
## License
Shoulda is Copyright © 2006-2013 thoughtbot, inc.
It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.