mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
Use generic test framework for independent matchers test
This commit is contained in:
parent
190007155e
commit
ab91bbf123
4 changed files with 16 additions and 16 deletions
|
@ -2,14 +2,14 @@ require 'acceptance_spec_helper'
|
||||||
|
|
||||||
describe 'shoulda-matchers has independent matchers' do
|
describe 'shoulda-matchers has independent matchers' do
|
||||||
context 'specifically delegate_method' do
|
context 'specifically delegate_method' do
|
||||||
specify 'and integrates with a Ruby application that uses Minitest' do
|
specify 'and integrates with a Ruby application that uses the default test framework' do
|
||||||
create_generic_bundler_project
|
create_generic_bundler_project
|
||||||
|
|
||||||
updating_bundle do
|
updating_bundle do
|
||||||
add_minitest_to_project
|
add_minitest_to_project
|
||||||
add_shoulda_context_to_project(manually: true)
|
add_shoulda_context_to_project(manually: true)
|
||||||
add_shoulda_matchers_to_project(
|
add_shoulda_matchers_to_project(
|
||||||
test_frameworks: [:minitest],
|
test_frameworks: [default_test_framework],
|
||||||
manually: true
|
manually: true
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -35,11 +35,11 @@ describe 'shoulda-matchers has independent matchers' do
|
||||||
end
|
end
|
||||||
FILE
|
FILE
|
||||||
|
|
||||||
write_minitest_test 'test/courier_test.rb' do |test_case_superclass|
|
write_n_unit_test 'test/courier_test.rb' do |test_case_superclass|
|
||||||
<<-FILE
|
<<-FILE
|
||||||
require "test_helper"
|
require 'test_helper'
|
||||||
require "courier"
|
require 'courier'
|
||||||
require "post_office"
|
require 'post_office'
|
||||||
|
|
||||||
class CourierTest < #{test_case_superclass}
|
class CourierTest < #{test_case_superclass}
|
||||||
subject { Courier.new(post_office) }
|
subject { Courier.new(post_office) }
|
||||||
|
|
|
@ -4,14 +4,6 @@ module AcceptanceTests
|
||||||
module MinitestHelpers
|
module MinitestHelpers
|
||||||
include GemHelpers
|
include GemHelpers
|
||||||
|
|
||||||
def minitest_test_case_superclass
|
|
||||||
if minitest_version >= 5
|
|
||||||
'Minitest::Test'
|
|
||||||
else
|
|
||||||
'MiniTest::Unit::TestCase'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def minitest_version
|
def minitest_version
|
||||||
bundle_version_of('minitest')
|
bundle_version_of('minitest')
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,14 @@ module AcceptanceTests
|
||||||
module NUnitHelpers
|
module NUnitHelpers
|
||||||
include RailsVersionHelpers
|
include RailsVersionHelpers
|
||||||
|
|
||||||
|
def n_unit_test_case_superclass
|
||||||
|
case default_test_framework
|
||||||
|
when :test_unit then 'Test::Unit::TestCase'
|
||||||
|
when :minitest_4 then 'MiniTest::Unit::TestCase'
|
||||||
|
else 'Minitest::Test'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def default_test_framework
|
def default_test_framework
|
||||||
if rails_version =~ '< 4'
|
if rails_version =~ '< 4'
|
||||||
:test_unit
|
:test_unit
|
||||||
|
|
|
@ -45,8 +45,8 @@ module AcceptanceTests
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def write_minitest_test(path)
|
def write_n_unit_test(path)
|
||||||
contents = yield minitest_test_case_superclass
|
contents = yield n_unit_test_case_superclass
|
||||||
write_file(path, contents)
|
write_file(path, contents)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue