pax_global_header00006660000000000000000000000064126557621270014527gustar00rootroot0000000000000052 comment=8865a610be71f3308abe14d3806506ef4d6aa5d0 ruby-minitest-shared-description-1.0.0/000077500000000000000000000000001265576212700201255ustar00rootroot00000000000000ruby-minitest-shared-description-1.0.0/CHANGELOG000066400000000000000000000000611265576212700213340ustar00rootroot00000000000000=== 1.0.0 (2015-05-06) * Initial Public Release ruby-minitest-shared-description-1.0.0/MIT-LICENSE000066400000000000000000000020211265576212700215540ustar00rootroot00000000000000Copyright (c) 2015 Jeremy Evans 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 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. ruby-minitest-shared-description-1.0.0/README.rdoc000066400000000000000000000036341265576212700217410ustar00rootroot00000000000000= minitest-shared_description minitest-shared_description adds support for shared specs and shared spec subclasses to Minitest. Minitest supports shared specs by default using plain ruby modules, but does not support shared spec subclasses. In addition to making it possible to share subclasses, minitest-shared_desciption also provides a slightly nicer interface for sharing specs. = Installation gem install minitest-shared_description = Source Code Source code is available on GitHub at https://github.com/jeremyevans/minitest-shared_description = Usage require 'minitest/shared_description' SharedExamples = shared_description do # You can do regular specs it "should do something" do # something end # You can also have spec subclasses describe "nested specs" do # Called inside the before/after of the class that includes SharedExamples before {} after {} # Called inside the before/after of the class that includes SharedExamples # and the before/after in this class it "should do something else" do # something end end end describe "something" do include SharedExamples end You can also have shared descriptions that are included in other shared descriptions: SharedExample1 = shared_description do describe "nested specs 1" do before {} after {} it "should do something" do end end end SharedExample2 = shared_description do describe "nested specs 2" do before {} after {} it "should do something else" do end end end SharedExamples = shared_description do # Include shared description in shared description block include SharedExample1 describe "nested shared description use" do # Include shared description in shared description class include SharedExample2 end end = License MIT = Author Jeremy Evans ruby-minitest-shared-description-1.0.0/Rakefile000066400000000000000000000020031265576212700215650ustar00rootroot00000000000000require "rake" require "rake/clean" CLEAN.include ["minitest-shared_description-*.gem", "rdoc", "coverage"] desc "Build minitest-hooks gem" task :package=>[:clean] do |p| sh %{#{FileUtils::RUBY} -S gem build minitest-shared_description.gemspec} end ### Specs desc "Run specs" task :spec do sh %{#{FileUtils::RUBY} -I lib -rubygems ./spec/minitest-shared_description_spec.rb} end task :default=>:spec ### RDoc RDOC_DEFAULT_OPTS = ["--quiet", "--line-numbers", "--inline-source", '--title', 'minitest-shared_description: support for shared specs and shared spec subclasses'] begin gem 'hanna-nouveau' RDOC_DEFAULT_OPTS.concat(['-f', 'hanna']) rescue Gem::LoadError end rdoc_task_class = begin require "rdoc/task" RDoc::Task rescue LoadError require "rake/rdoctask" Rake::RDocTask end RDOC_OPTS = RDOC_DEFAULT_OPTS + ['--main', 'README.rdoc'] rdoc_task_class.new do |rdoc| rdoc.rdoc_dir = "rdoc" rdoc.options += RDOC_OPTS rdoc.rdoc_files.add %w"README.rdoc CHANGELOG MIT-LICENSE lib/**/*.rb" end ruby-minitest-shared-description-1.0.0/lib/000077500000000000000000000000001265576212700206735ustar00rootroot00000000000000ruby-minitest-shared-description-1.0.0/lib/minitest/000077500000000000000000000000001265576212700225275ustar00rootroot00000000000000ruby-minitest-shared-description-1.0.0/lib/minitest/shared_description.rb000066400000000000000000000042131265576212700267250ustar00rootroot00000000000000require 'minitest/spec' module Minitest::Spec::SharedDescription class DSL < Module include Minitest::Spec::DSL # An array of arguments and blocks to pass to describe for classes that # include the current module. attr_reader :shared_descriptions # Add a describe block that will be shared by all classes including the current module. # Example: # # EmptyBehavior = shared_description do # describe "empty" do # before do # @that = double # end # # it "must be empty?" do # @that.must_be :empty? # end # # it "must have size equal to 0" do # @that.size.must_equal 0 # end # end # end # # describe "array" do # def double; @this + @this end # # before do # @this = [] # end # # include EmptyBehavior # end # # describe "hash" do # def double; @this.merge(@this) end # # before do # @this = {} # end # # include EmptyBehavior # end def describe(*desc, &block) (@shared_descriptions ||= []) << [desc, block] end # If including another shared description module, copy the shared # description class definition blocks into the receiver's. def include(*mods) mods.each do |mod| if mod.is_a?(DSL) && mod.shared_descriptions (@shared_descriptions ||= []).concat(mod.shared_descriptions) end end super end end module TestMethods # If including a shared description module, create subclasses using # each of the shared description class definition blocks. def include(*mods) mods.each do |mod| if mod.is_a?(DSL) && mod.shared_descriptions mod.shared_descriptions.each do |desc, block| describe(*desc, &block) end end end super end Minitest::Spec.extend(self) end end module Kernel # Support creating shared descriptions anywhere. def shared_description(&block) Minitest::Spec::SharedDescription::DSL.new(&block) end end ruby-minitest-shared-description-1.0.0/metadata.yml000066400000000000000000000037561265576212700224430ustar00rootroot00000000000000--- !ruby/object:Gem::Specification name: minitest-shared_description version: !ruby/object:Gem::Version version: 1.0.0 platform: ruby authors: - Jeremy Evans autorequire: bindir: bin cert_chain: [] date: 2015-05-06 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: minitest requirement: !ruby/object:Gem::Requirement requirements: - - ">" - !ruby/object:Gem::Version version: '5' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">" - !ruby/object:Gem::Version version: '5' description: | minitest-shared_description adds support for shared specs and shared spec subclasses to Minitest. Minitest supports shared specs by default using plain ruby modules, but does not support shared spec subclasses. In addition to making it possible to share subclasses, minitest-shared_desciption also provides a slightly nicer interface for sharing specs. email: code@jeremyevans.net executables: [] extensions: [] extra_rdoc_files: - README.rdoc - CHANGELOG - MIT-LICENSE files: - CHANGELOG - MIT-LICENSE - README.rdoc - Rakefile - lib/minitest/shared_description.rb - spec/minitest-shared_description_spec.rb homepage: http://github.com/jeremyevans/minitest-shared_description licenses: - MIT metadata: {} post_install_message: rdoc_options: - "--quiet" - "--line-numbers" - "--inline-source" - "--title" - 'minitest-shared_description: support for shared specs and shared spec subclasses' - "--main" - README.rdoc 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.4.5 signing_key: specification_version: 4 summary: Support for shared specs and shared spec subclasses for Minitest test_files: [] ruby-minitest-shared-description-1.0.0/spec/000077500000000000000000000000001265576212700210575ustar00rootroot00000000000000ruby-minitest-shared-description-1.0.0/spec/minitest-shared_description_spec.rb000066400000000000000000000036501265576212700301250ustar00rootroot00000000000000require 'minitest/autorun' require 'minitest/shared_description' describe "minitest/shared_description" do def run_runnables(runnables) runnables.each do |runnable| runnable.runnable_methods.each do |method_name| Minitest.run_one_method(runnable, method_name) end end end before do @runnables = self.class.runnables.dup end it "should handle standard spec inclusion" do runs = [] x = shared_description do before{(@order ||= []) << :bx} after{@order << :ax; runs << [self.class.name, @order]} it("x"){@order << :x} end z = describe "z" do before{(@order ||= []) << :bz} after{@order << :az} it("z"){@order << :z} include x end new_runnables = self.class.runnables.dup - @runnables assert_equal %w'z', new_runnables.map(&:name) run_runnables(new_runnables) assert_equal [["z", [:bx, :bz, :x, :az, :ax]], ["z", [:bx, :bz, :z, :az, :ax]]], runs.sort_by{|a| a.flatten.map(&:to_s)} end it "should handle describe under shared_description" do runs = [] x = shared_description do describe "x" do before{@order << :bx} after{@order << :ax} it("x"){@order << :x} end end y = shared_description do include x describe "y" do include x before{@order << :by} after{@order << :ay} it("y"){@order << :y} end end z = describe "z" do before{(@order = []) << :bz} after{@order << :az; runs << [self.class.name, @order]} it("z"){@order << :z} include y end new_runnables = self.class.runnables.dup - @runnables assert_equal %w'z z::x z::y z::y::x', new_runnables.map(&:name).sort run_runnables(new_runnables) assert_equal [["z", [:bz, :z, :az]], ["z::x", [:bz, :bx, :x, :ax, :az]], ["z::y", [:bz, :by, :y, :ay, :az]], ["z::y::x", [:bz, :by, :bx, :x, :ax, :ay, :az]]], runs.sort end end