shoulda 4.0.0.rc2 → 5.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/{MIT-LICENSE → LICENSE} +1 -1
  3. data/README.md +39 -32
  4. data/lib/shoulda/version.rb +1 -1
  5. data/shoulda.gemspec +18 -15
  6. metadata +19 -63
  7. data/.autotest +0 -13
  8. data/.gitignore +0 -13
  9. data/.hound.yml +0 -3
  10. data/.rubocop.yml +0 -192
  11. data/.ruby-version +0 -1
  12. data/.travis.yml +0 -34
  13. data/Appraisals +0 -116
  14. data/CONTRIBUTING.md +0 -43
  15. data/Gemfile +0 -16
  16. data/Rakefile +0 -31
  17. data/gemfiles/rails_4_2.gemfile +0 -34
  18. data/gemfiles/rails_4_2.gemfile.lock +0 -240
  19. data/gemfiles/rails_5_0.gemfile +0 -32
  20. data/gemfiles/rails_5_0.gemfile.lock +0 -232
  21. data/gemfiles/rails_5_1.gemfile +0 -33
  22. data/gemfiles/rails_5_1.gemfile.lock +0 -247
  23. data/gemfiles/rails_5_2.gemfile +0 -35
  24. data/gemfiles/rails_5_2.gemfile.lock +0 -266
  25. data/gemfiles/rails_6_0.gemfile +0 -37
  26. data/gemfiles/rails_6_0.gemfile.lock +0 -291
  27. data/script/install_gems_in_all_appraisals +0 -16
  28. data/script/run_all_tests +0 -16
  29. data/script/supported_ruby_versions +0 -7
  30. data/script/update_gem_in_all_appraisals +0 -17
  31. data/script/update_gems_in_all_appraisals +0 -16
  32. data/test/acceptance/integrates_with_rails_test.rb +0 -580
  33. data/test/acceptance_test_helper.rb +0 -43
  34. data/test/support/acceptance/add_shoulda_to_project.rb +0 -73
  35. data/test/support/acceptance/helpers/array_helpers.rb +0 -13
  36. data/test/support/acceptance/helpers/pluralization_helpers.rb +0 -13
  37. data/test/support/acceptance/matchers/have_output.rb +0 -33
  38. data/test/support/acceptance/matchers/indicate_that_tests_were_run.rb +0 -109
  39. data/test/support/acceptance/rails_application_with_shoulda.rb +0 -47
  40. data/test/support/current_bundle.rb +0 -61
  41. data/test/support/snowglobe.rb +0 -5
  42. data/test/test_helper.rb +0 -23
@@ -1,13 +0,0 @@
1
- module AcceptanceTests
2
- module PluralizationHelpers
3
- def pluralize(count, singular_version, plural_version = nil)
4
- plural_version ||= singular_version + 's'
5
-
6
- if count == 1
7
- "#{count} #{singular_version}"
8
- else
9
- "#{count} #{plural_version}"
10
- end
11
- end
12
- end
13
- end
@@ -1,33 +0,0 @@
1
- module AcceptanceTests
2
- module Matchers
3
- # rubocop:disable Naming/PredicateName
4
- def have_output(output)
5
- HaveOutputMatcher.new(output)
6
- end
7
- # rubocop:enable Naming/PredicateName
8
-
9
- class HaveOutputMatcher
10
- def initialize(output)
11
- @output = output
12
- end
13
-
14
- def matches?(runner)
15
- @runner = runner
16
- runner.has_output?(output)
17
- end
18
-
19
- def failure_message
20
- "Expected command to have output, but did not.\n\n" +
21
- "Command: #{runner.formatted_command}\n\n" +
22
- "Expected output:\n" +
23
- output.inspect + "\n\n" +
24
- "Actual output:\n" +
25
- runner.output
26
- end
27
-
28
- protected
29
-
30
- attr_reader :output, :runner
31
- end
32
- end
33
- end
@@ -1,109 +0,0 @@
1
- require_relative '../helpers/array_helpers'
2
- require_relative '../helpers/pluralization_helpers'
3
-
4
- module AcceptanceTests
5
- module Matchers
6
- def indicate_that_tests_were_run(series)
7
- IndicateThatTestsWereRunMatcher.new(series)
8
- end
9
-
10
- class IndicateThatTestsWereRunMatcher
11
- include ArrayHelpers
12
- include PluralizationHelpers
13
-
14
- def initialize(expected_numbers)
15
- @expected_numbers = expected_numbers
16
- end
17
-
18
- def matches?(runner)
19
- @runner = runner
20
- Set.new(expected_numbers).subset?(Set.new(actual_numbers))
21
- end
22
-
23
- def failure_message
24
- "Expected output to indicate that #{some_tests_were_run}.\n" +
25
- "#{formatted_expected_numbers}\n" +
26
- "#{formatted_actual_numbers}\n\n" +
27
- "Output:\n\n" +
28
- actual_output
29
- end
30
-
31
- protected
32
-
33
- attr_reader :expected_numbers, :runner
34
-
35
- private
36
-
37
- def some_tests_were_run
38
- if some_tests_were_run_clauses.size > 1
39
- "#{to_sentence(some_tests_were_run_clauses)} were run"
40
- else
41
- "#{some_tests_were_run_clauses} was run"
42
- end
43
- end
44
-
45
- def some_tests_were_run_clauses
46
- expected_numbers.map do |type, number|
47
- if number == 1
48
- "#{number} #{type.to_s.chop}"
49
- else
50
- "#{number} #{type}"
51
- end
52
- end
53
- end
54
-
55
- def formatted_expected_numbers
56
- "Expected numbers: #{format_hash(expected_numbers)}"
57
- end
58
-
59
- def formatted_actual_numbers
60
- report_line = find_report_line_in(actual_output)
61
-
62
- if report_line
63
- "Actual numbers: #{report_line.inspect}"
64
- else
65
- 'Actual numbers: (n/a)'
66
- end
67
- end
68
-
69
- def actual_numbers
70
- numbers = parse(
71
- actual_output,
72
- [:tests, :assertions, :failures, :errors, :skips],
73
- )
74
- numbers || {}
75
- end
76
-
77
- def actual_output
78
- runner.output
79
- end
80
-
81
- def parse(text, pieces)
82
- report_line = find_report_line_in(text)
83
-
84
- if report_line
85
- pieces.inject({}) do |hash, piece|
86
- number = report_line.match(/(\d+) #{piece}/)[1].to_i
87
- hash.merge(piece => number)
88
- end
89
- end
90
- end
91
-
92
- def find_report_line_in(text)
93
- lines = text.split(/\n/)
94
-
95
- index_of_line_with_time = lines.find_index do |line|
96
- line =~ /\AFinished in \d\.\d+s\Z/
97
- end
98
-
99
- if index_of_line_with_time
100
- lines[index_of_line_with_time + 1]
101
- end
102
- end
103
-
104
- def format_hash(hash)
105
- '{' + hash.map { |k, v| "#{k}: #{v.inspect}" }.join(', ') + '}'
106
- end
107
- end
108
- end
109
- end
@@ -1,47 +0,0 @@
1
- require_relative 'add_shoulda_to_project'
2
- require_relative '../snowglobe'
3
-
4
- module AcceptanceTests
5
- class RailsApplicationWithShoulda < Snowglobe::RailsApplication
6
- def create
7
- super
8
-
9
- bundle.updating do
10
- bundle.add_gem 'minitest-reporters'
11
- AddShouldaToProject.call(
12
- self,
13
- test_framework: :minitest,
14
- libraries: [:rails],
15
- )
16
- end
17
-
18
- fs.append_to_file 'test/test_helper.rb', <<-FILE
19
- require 'minitest/autorun'
20
- require 'minitest/reporters'
21
-
22
- Minitest::Reporters.use!(Minitest::Reporters::SpecReporter.new)
23
-
24
- begin
25
- require "rails/test_unit/reporter"
26
-
27
- # Patch Rails' reporter for Minitest so that it looks for the test
28
- # correctly under Minitest 5.11
29
- # See: <https://github.com/rails/rails/pull/31624>
30
- Rails::TestUnitReporter.class_eval do
31
- def format_rerun_snippet(result)
32
- location, line = if result.respond_to?(:source_location)
33
- result.source_location
34
- else
35
- result.method(result.name).source_location
36
- end
37
-
38
- "\#{executable} \#{relative_path_for(location)}:\#{line}"
39
- end
40
- end
41
- rescue LoadError
42
- # Okay, rails/test_unit/reporter isn't a thing, no big deal
43
- end
44
- FILE
45
- end
46
- end
47
- end
@@ -1,61 +0,0 @@
1
- require 'bundler'
2
- require 'appraisal'
3
-
4
- module Tests
5
- class CurrentBundle
6
- AppraisalNotSpecified = Class.new(ArgumentError)
7
-
8
- include Singleton
9
-
10
- def assert_appraisal!
11
- unless appraisal_in_use?
12
- message = <<MSG
13
-
14
-
15
- Please run tests starting with `appraisal <appraisal_name>`.
16
- Possible appraisals are: #{available_appraisals}
17
-
18
- MSG
19
- raise AppraisalNotSpecified, message
20
- end
21
- end
22
-
23
- def appraisal_in_use?
24
- path.dirname == root.join('gemfiles')
25
- end
26
-
27
- def current_or_latest_appraisal
28
- current_appraisal || latest_appraisal
29
- end
30
-
31
- def latest_appraisal
32
- available_appraisals.max
33
- end
34
-
35
- private
36
-
37
- def available_appraisals
38
- appraisals = []
39
-
40
- Appraisal::AppraisalFile.each do |appraisal|
41
- appraisals << appraisal.name
42
- end
43
-
44
- appraisals
45
- end
46
-
47
- def current_appraisal
48
- if appraisal_in_use?
49
- File.basename(path, '.gemfile')
50
- end
51
- end
52
-
53
- def path
54
- Bundler.default_gemfile
55
- end
56
-
57
- def root
58
- Pathname.new('../../..').expand_path(__FILE__)
59
- end
60
- end
61
- end
@@ -1,5 +0,0 @@
1
- require 'snowglobe'
2
-
3
- Snowglobe.configure do |config|
4
- config.project_name = 'shoulda'
5
- end
data/test/test_helper.rb DELETED
@@ -1,23 +0,0 @@
1
- require 'bundler/setup'
2
- require 'pry'
3
- require 'pry-byebug'
4
- require 'minitest/autorun'
5
- require 'minitest/reporters'
6
- require 'warnings_logger'
7
-
8
- require_relative '../lib/shoulda'
9
-
10
- Minitest::Reporters.use!(Minitest::Reporters::SpecReporter.new)
11
-
12
- WarningsLogger::Spy.call(
13
- project_name: 'shoulda',
14
- project_directory: Pathname.new('../..').expand_path(__FILE__),
15
- )
16
-
17
- Shoulda::Matchers.configure do |config|
18
- config.integrate do |with|
19
- with.test_framework :minitest
20
- end
21
- end
22
-
23
- $VERBOSE = true