diff --git a/.gitignore b/.gitignore deleted file mode 100644 index a3909ce..0000000 --- a/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -doc/* -log/* -pkg/* diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc deleted file mode 100644 index 3e74c7a..0000000 --- a/CHANGELOG.rdoc +++ /dev/null @@ -1,3 +0,0 @@ -=== 0.1.0 / 2012-08-06 - -Updated integrations to keep up with MiniTest::Rails class name changes in 0.1.x series diff --git a/License.txt b/License.txt deleted file mode 100644 index c3e6b91..0000000 --- a/License.txt +++ /dev/null @@ -1,22 +0,0 @@ -(The MIT License) - -Copyright (c) 2012 Robert Bousquet, Rafal Wrzochol - -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. diff --git a/Manifest.txt b/Manifest.txt deleted file mode 100644 index 551012b..0000000 --- a/Manifest.txt +++ /dev/null @@ -1,14 +0,0 @@ -CHANGELOG.rdoc -License.txt -Manifest.txt -README.rdoc -Rakefile -lib/minitest-rails-shoulda.rb -lib/minitest/rails/shoulda.rb -lib/minitest/rails/shoulda/assertions.rb -lib/minitest/rails/shoulda/dsl.rb -lib/minitest/rails/shoulda/matchers.rb -minitest-rails-shoulda.gemspec -test/rails_helper.rb -test/test_assertions.rb -test/test_matchers.rb diff --git a/README.rdoc b/README.rdoc index 074e877..66b0ecd 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,3 +1,3 @@ -=== NOTE: +=== WE'VE MOVED: -This repository is no longer maintained. Please use https://github.com/bousquet/minitest-rails-shoulda +Please use https://github.com/newleaders/minitest-rails-shoulda diff --git a/Rakefile b/Rakefile deleted file mode 100644 index d5f31e9..0000000 --- a/Rakefile +++ /dev/null @@ -1,29 +0,0 @@ -# -*- ruby -*- - -require "rubygems" -require "hoe" - -Hoe.plugin :git -Hoe.plugin :gemspec -Hoe.plugin :travis -Hoe.plugins.delete :rubyforge - -Hoe.spec "minitest-rails-shoulda" do - developer "Robert Bousquet", "robert@robertbousquet.com" - developer "Rafal Wrzochol", "rafal@wrzochol.net" - developer "Mike Moore", "mike@blowmage.com" - - self.summary = "Shoulda DSL and Matchers in minitest-rails" - self.description = "Extenstion supporting the Shoulda DSL and Matchers in Rails tests using MiniTest" - self.urls = ["https://github.com/bousquet/minitest-rails-shoulda"] - - self.history_file = "CHANGELOG.rdoc" - self.readme_file = "README.rdoc" - self.testlib = :minitest - - dependency "minitest-rails", "~> 0.1" - dependency "minitest-matchers", ">= 1.2" - dependency "shoulda-matchers", "~> 1.2" -end - -# vim: syntax=ruby diff --git a/lib/minitest-rails-shoulda.rb b/lib/minitest-rails-shoulda.rb deleted file mode 100644 index d3cf930..0000000 --- a/lib/minitest-rails-shoulda.rb +++ /dev/null @@ -1,9 +0,0 @@ -require "minitest-rails" - -module MiniTest - module Rails - module Shoulda - VERSION = "0.1.0" - end - end -end diff --git a/lib/minitest/rails/shoulda.rb b/lib/minitest/rails/shoulda.rb deleted file mode 100644 index 0dce70a..0000000 --- a/lib/minitest/rails/shoulda.rb +++ /dev/null @@ -1,3 +0,0 @@ -require "minitest/rails/shoulda/assertions" -require "minitest/rails/shoulda/dsl" -require "minitest/rails/shoulda/matchers" diff --git a/lib/minitest/rails/shoulda/assertions.rb b/lib/minitest/rails/shoulda/assertions.rb deleted file mode 100644 index 236859d..0000000 --- a/lib/minitest/rails/shoulda/assertions.rb +++ /dev/null @@ -1,110 +0,0 @@ -require "minitest/unit" - -# Add Shoulda's assertions to MiniTest - -module MiniTest - 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 - - # Fails if two arrays contain the same elements. Essentially ==, but unordered. - # - # refute_same_elements([:a, :b, :c], [:c, :a, :d]) => passes - def refute_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 } - - refute_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) - pass - if options[:message] - assert_match options[:message], matcher.negative_failure_message - end - else - flunk matcher.failure_message - 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 - pass - if options[:message] - assert_match options[:message], matcher.failure_message - end - else - flunk matcher.negative_failure_message - end - end - - alias :refute_contains :assert_does_not_contain - alias :refute_does_not_contain :assert_contains - - alias :refute_accepts :assert_rejects - alias :refute_rejects :assert_accepts - end -end diff --git a/lib/minitest/rails/shoulda/dsl.rb b/lib/minitest/rails/shoulda/dsl.rb deleted file mode 100644 index 0f2d047..0000000 --- a/lib/minitest/rails/shoulda/dsl.rb +++ /dev/null @@ -1,28 +0,0 @@ -require "minitest/spec" - -# Duck punch MiniTest::Spec to behave more like Shoulda - -class MiniTest::Spec < MiniTest::Unit::TestCase - class << self - - # Add Shoulda DSL - alias :setup :before - alias :teardown :after - alias :context :describe - alias :should :it - - ## - # Define a named expectation to be skipped for now. - # The implementation may or may not be present. - # The test is listed but does not cause a failure. - # - # Add here so we have something to alias later... - def skip desc = "skipped", &block - it desc do - skip desc - end - end unless respond_to?(:skip) - - alias :should_eventually :skip - end -end diff --git a/lib/minitest/rails/shoulda/matchers.rb b/lib/minitest/rails/shoulda/matchers.rb deleted file mode 100644 index f019343..0000000 --- a/lib/minitest/rails/shoulda/matchers.rb +++ /dev/null @@ -1,69 +0,0 @@ -require "minitest/matchers" - -if defined?(ActiveRecord) - require "minitest/rails/active_support" - require "shoulda/matchers/active_record" - - Shoulda::Matchers::ActiveRecord.module_eval do - def self.included(base) - instance_methods.each do |name| - base.register_matcher name, name - end - end - end - - class MiniTest::Rails::ActiveSupport::TestCase - include Shoulda::Matchers::ActiveRecord - end -end - -if defined?(ActiveModel) - require "minitest/rails/active_support" - require "shoulda/matchers/active_model" - - Shoulda::Matchers::ActiveModel.module_eval do - def self.included(base) - instance_methods.each do |name| - base.register_matcher name, name - end - end - end - - class MiniTest::Rails::ActiveSupport::TestCase - include Shoulda::Matchers::ActiveModel - end -end - -if defined?(ActionController) - require "minitest/rails/action_controller" - require "shoulda/matchers/action_controller" - - Shoulda::Matchers::ActionController.module_eval do - def self.included(base) - instance_methods.each do |name| - base.register_matcher name, name - end - end - end - - class MiniTest::Rails::ActionController::TestCase - include Shoulda::Matchers::ActionController - end -end - -if defined?(ActionMailer) - require "minitest/rails/action_mailer" - require "shoulda/matchers/action_mailer" - - Shoulda::Matchers::ActionMailer.module_eval do - def self.included(base) - instance_methods.each do |name| - base.register_matcher name, name - end - end - end - - class MiniTest::Rails::ActionMailer::TestCase - include Shoulda::Matchers::ActionMailer - end -end diff --git a/minitest-rails-shoulda.gemspec b/minitest-rails-shoulda.gemspec deleted file mode 100644 index 1bfdc82..0000000 --- a/minitest-rails-shoulda.gemspec +++ /dev/null @@ -1,45 +0,0 @@ -# -*- encoding: utf-8 -*- - -Gem::Specification.new do |s| - s.name = "minitest-rails-shoulda" - s.version = "0.1.0.20120911220350" - - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Robert Bousquet", "Rafal Wrzochol", "Mike Moore"] - s.date = "2012-09-12" - s.description = "Extenstion supporting the Shoulda DSL and Matchers in Rails tests using MiniTest" - s.email = ["robert@robertbousquet.com", "rafal@wrzochol.net", "mike@blowmage.com"] - s.extra_rdoc_files = ["CHANGELOG.rdoc", "License.txt", "Manifest.txt", "README.rdoc"] - s.files = ["CHANGELOG.rdoc", "License.txt", "Manifest.txt", "README.rdoc", "Rakefile", "lib/minitest-rails-shoulda.rb", "lib/minitest/rails/shoulda.rb", "lib/minitest/rails/shoulda/assertions.rb", "lib/minitest/rails/shoulda/dsl.rb", "lib/minitest/rails/shoulda/matchers.rb", "minitest-rails-shoulda.gemspec", "test/rails_helper.rb", "test/test_assertions.rb", "test/test_matchers.rb", ".gemtest"] - s.homepage = "https://github.com/bousquet/minitest-rails-shoulda" - s.rdoc_options = ["--main", "README.rdoc"] - s.require_paths = ["lib"] - s.rubyforge_project = "minitest-rails-shoulda" - s.rubygems_version = "1.8.24" - s.summary = "Shoulda DSL and Matchers in minitest-rails" - s.test_files = ["test/test_assertions.rb", "test/test_matchers.rb"] - - if s.respond_to? :specification_version then - s.specification_version = 3 - - if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then - s.add_runtime_dependency(%q, ["~> 0.1"]) - s.add_runtime_dependency(%q, [">= 1.2"]) - s.add_runtime_dependency(%q, ["~> 1.2"]) - s.add_development_dependency(%q, ["~> 3.10"]) - s.add_development_dependency(%q, ["~> 3.0"]) - else - s.add_dependency(%q, ["~> 0.1"]) - s.add_dependency(%q, [">= 1.2"]) - s.add_dependency(%q, ["~> 1.2"]) - s.add_dependency(%q, ["~> 3.10"]) - s.add_dependency(%q, ["~> 3.0"]) - end - else - s.add_dependency(%q, ["~> 0.1"]) - s.add_dependency(%q, [">= 1.2"]) - s.add_dependency(%q, ["~> 1.2"]) - s.add_dependency(%q, ["~> 3.10"]) - s.add_dependency(%q, ["~> 3.0"]) - end -end diff --git a/test/rails_helper.rb b/test/rails_helper.rb deleted file mode 100644 index 3a60e2a..0000000 --- a/test/rails_helper.rb +++ /dev/null @@ -1,31 +0,0 @@ -require "minitest/autorun" -require "action_controller/railtie" - -class TestApp < Rails::Application - config.secret_token = "821c600ece97fc4ba952d67655b4b475" - initialize! - routes.draw do - root to: 'hello#world' - end -end -class HelloController < ActionController::Base - def world - render inline: "TestApp -

Hello World

- -

- - - " - end -end - -Rails.application = TestApp - -require "minitest/rails" -require "minitest/rails/shoulda" - -begin - require 'turn/autorun' - Turn.config.format = :progress -rescue LoadError; end diff --git a/test/test_assertions.rb b/test/test_assertions.rb deleted file mode 100644 index 13a30a7..0000000 --- a/test/test_assertions.rb +++ /dev/null @@ -1,47 +0,0 @@ -require "minitest/autorun" -require "minitest/rails/shoulda/dsl" -require "minitest/rails/shoulda/assertions" - -describe "Shoulda Style Assertions" do - - 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(MiniTest::Assertion) do - assert_does_not_contain @a, x - end - assert_contains @a, x - refute_does_not_contain @a, x - end - end - - should "not contain 'wtf'" do - assert_raises(MiniTest::Assertion) {assert_contains @a, 'wtf'} - assert_does_not_contain @a, 'wtf' - refute_contains @a, 'wtf' - end - - should "be the same as another array, ordered differently" do - assert_same_elements(@a, [3, "def", "abc"]) - - assert_raises(MiniTest::Assertion) do - assert_same_elements(@a, [3, 3, "def", "abc"]) - end - refute_same_elements(@a, [3, 3, "def", "abc"]) - - assert_same_elements([@a, "abc"].flatten, ["abc", 3, "def", "abc"]) - - assert_raises(MiniTest::Assertion) do - assert_same_elements([@a, "abc"].flatten, [3, 3, "def", "abc"]) - end - refute_same_elements([@a, "abc"].flatten, [3, 3, "def", "abc"]) - end - - end - -end diff --git a/test/test_matchers.rb b/test/test_matchers.rb deleted file mode 100644 index a2dbd72..0000000 --- a/test/test_matchers.rb +++ /dev/null @@ -1,187 +0,0 @@ -require "rails_helper" - -describe HelloController do - - context "index" do - setup do - get :world - end - - describe "assertions" do - it "should give us HTML" do - assert_respond_with_content_type(@controller, :html) - end - - it "should not give us XML" do - refute_respond_with_content_type(@controller, :xml) - end - end - - describe "with matchers" do - should "give us HTML" do - @controller.must respond_with_content_type(:html) - end - - should_eventually "give us JSON" - - # should_eventually "give us JSON" do - # @controller.must respond_with_content_type(:json) - # end - - should "not give us XML" do - @controller.wont respond_with_content_type(:xml) - end - end - - describe "with subject" do - subject { @controller } - - it { must respond_with_content_type(:html) } - it { wont respond_with_content_type(:xml) } - - must { respond_with_content_type(:html) } - wont { respond_with_content_type(:xml) } - end - end - - # describe "have_content" do - # it "has page with content" do - # visit root_path - # assert_have_content page, "Hello World" - # refute_have_content page, "Goobye All!" - # page.must_have_content "Hello World" - # page.wont_have_content "Goobye All!" - # end - - # describe "with subject" do - # before { visit(root_path) } - # subject { page } - - # it { must have_content("Hello World") } - # it { wont have_content("Goobye All!") } - # must { have_content("Hello World") } - # wont { have_content("Goobye All!") } - # end - # end - - # describe "have_selector" do - # it "has page with heading" do - # visit root_path - # assert_have_selector page, "h1" - # refute_have_selector page, "h3" - # page.must_have_selector "h1" - # page.wont_have_selector "h3" - # end - - # describe "with subject" do - # before { visit(root_path) } - # subject { page } - - # it { must have_selector("h1") } - # it { wont have_selector("h3") } - # must { have_selector("h1") } - # wont { have_selector("h3") } - # end - # end - - # describe "have_link" do - # it "has a link to home" do - # visit root_path - # assert_have_link page, "home" - # refute_have_link page, "away" - # page.must_have_link "home" - # page.wont_have_link "away" - # end - - # describe "with subject" do - # before { visit(root_path) } - # subject { page } - - # it { must have_link("home") } - # it { wont have_link("away") } - # must { have_link("home") } - # wont { have_link("away") } - # end - # end - - # describe "have_field" do - # it "has a button to submit" do - # visit root_path - # assert_have_field page, "Email Address" - # refute_have_field page, "Bank Account" - # page.must_have_field "Email Address" - # page.wont_have_field "Bank Account" - # end - - # describe "with subject" do - # before { visit(root_path) } - # subject { page } - - # it { must have_field("Email Address") } - # it { wont have_field("Bank Account") } - # must { have_field("Email Address") } - # wont { have_field("Bank Account") } - # end - # end - - # describe "have_button" do - # it "has a button to login" do - # visit root_path - # assert_have_button page, "random button" - # refute_have_button page, "missing button" - # page.must_have_button "random button" - # page.wont_have_button "missing button" - # end - - # describe "with subject" do - # before { visit(root_path) } - # subject { page } - - # it { must have_button("random button") } - # it { wont have_button("missing button") } - # must { have_button("random button") } - # wont { have_button("missing button") } - # end - # end - - # describe "have_checked_field" do - # it "has a button to submit" do - # visit root_path - # assert_have_checked_field page, "going" - # refute_have_checked_field page, "avoid" - # page.must_have_checked_field "going" - # page.wont_have_checked_field "avoid" - # end - - # describe "with subject" do - # before { visit(root_path) } - # subject { page } - - # it { must have_checked_field("going") } - # it { wont have_checked_field("avoid") } - # must { have_checked_field("going") } - # wont { have_checked_field("avoid") } - # end - # end - - # describe "have_unchecked_field" do - # it "has a button to submit" do - # visit root_path - # assert_have_unchecked_field page, "avoid" - # refute_have_unchecked_field page, "going" - # page.must_have_unchecked_field "avoid" - # page.wont_have_unchecked_field "going" - # end - - # describe "with subject" do - # before { visit(root_path) } - # subject { page } - - # it { must have_unchecked_field("avoid") } - # it { wont have_unchecked_field("going") } - # must { have_unchecked_field("avoid") } - # wont { have_unchecked_field("going") } - # end - # end - -end