shoulda 3.5.0 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/.gitignore +7 -7
- data/.hound.yml +3 -0
- data/.hound/ruby.yml +1042 -0
- data/.rubocop.yml +13 -0
- data/.travis.yml +11 -7
- data/Appraisals +13 -10
- data/CONTRIBUTING.md +6 -1
- data/Gemfile +8 -1
- data/README.md +58 -73
- data/Rakefile +21 -12
- data/gemfiles/4.2.gemfile +17 -0
- data/gemfiles/4.2.gemfile.lock +174 -0
- data/gemfiles/5.0.gemfile +17 -0
- data/gemfiles/5.0.gemfile.lock +179 -0
- data/lib/shoulda/version.rb +1 -1
- data/shoulda.gemspec +23 -23
- data/test/acceptance/rails_integration_test.rb +76 -0
- data/test/acceptance_test_helper.rb +17 -0
- data/test/report_warnings.rb +7 -0
- data/test/support/acceptance/add_shoulda_to_project.rb +78 -0
- data/test/support/acceptance/helpers.rb +19 -0
- data/test/support/acceptance/helpers/active_model_helpers.rb +11 -0
- data/test/support/acceptance/helpers/array_helpers.rb +13 -0
- data/test/support/acceptance/helpers/base_helpers.rb +14 -0
- data/test/support/acceptance/helpers/command_helpers.rb +54 -0
- data/test/support/acceptance/helpers/file_helpers.rb +19 -0
- data/test/support/acceptance/helpers/gem_helpers.rb +31 -0
- data/test/support/acceptance/helpers/pluralization_helpers.rb +13 -0
- data/test/support/acceptance/helpers/step_helpers.rb +69 -0
- data/test/support/acceptance/matchers/have_output.rb +31 -0
- data/test/support/acceptance/matchers/indicate_number_of_tests_was_run_matcher.rb +54 -0
- data/test/support/acceptance/matchers/indicate_that_tests_were_run_matcher.rb +75 -0
- data/test/support/tests/bundle.rb +94 -0
- data/test/support/tests/command_runner.rb +230 -0
- data/test/support/tests/current_bundle.rb +61 -0
- data/test/support/tests/filesystem.rb +100 -0
- data/test/support/tests/version.rb +45 -0
- data/test/test_helper.rb +18 -0
- data/test/warnings_spy.rb +62 -0
- data/test/warnings_spy/filesystem.rb +45 -0
- data/test/warnings_spy/partitioner.rb +36 -0
- data/test/warnings_spy/reader.rb +53 -0
- data/test/warnings_spy/reporter.rb +88 -0
- metadata +80 -121
- data/features/rails_integration.feature +0 -87
- data/features/step_definitions/rails_steps.rb +0 -77
- data/features/support/env.rb +0 -14
- data/gemfiles/3.0.gemfile +0 -7
- data/gemfiles/3.0.gemfile.lock +0 -127
- data/gemfiles/3.1.gemfile +0 -9
- data/gemfiles/3.1.gemfile.lock +0 -148
- data/gemfiles/3.2.gemfile +0 -9
- data/gemfiles/3.2.gemfile.lock +0 -146
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "appraisal", "~> 2.1"
|
6
|
+
gem "rails", "5.0.1"
|
7
|
+
gem "pry"
|
8
|
+
gem "pry-byebug"
|
9
|
+
gem "sqlite3"
|
10
|
+
gem "minitest", "~> 5.0"
|
11
|
+
gem "minitest-reporters", "~> 1.0"
|
12
|
+
gem "m"
|
13
|
+
gem "listen"
|
14
|
+
gem "sass-rails"
|
15
|
+
gem "rspec", "~> 3.0"
|
16
|
+
gem "shoulda-context"
|
17
|
+
gem "shoulda-matchers", "~> 3.0"
|
@@ -0,0 +1,179 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actioncable (5.0.1)
|
5
|
+
actionpack (= 5.0.1)
|
6
|
+
nio4r (~> 1.2)
|
7
|
+
websocket-driver (~> 0.6.1)
|
8
|
+
actionmailer (5.0.1)
|
9
|
+
actionpack (= 5.0.1)
|
10
|
+
actionview (= 5.0.1)
|
11
|
+
activejob (= 5.0.1)
|
12
|
+
mail (~> 2.5, >= 2.5.4)
|
13
|
+
rails-dom-testing (~> 2.0)
|
14
|
+
actionpack (5.0.1)
|
15
|
+
actionview (= 5.0.1)
|
16
|
+
activesupport (= 5.0.1)
|
17
|
+
rack (~> 2.0)
|
18
|
+
rack-test (~> 0.6.3)
|
19
|
+
rails-dom-testing (~> 2.0)
|
20
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
21
|
+
actionview (5.0.1)
|
22
|
+
activesupport (= 5.0.1)
|
23
|
+
builder (~> 3.1)
|
24
|
+
erubis (~> 2.7.0)
|
25
|
+
rails-dom-testing (~> 2.0)
|
26
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
27
|
+
activejob (5.0.1)
|
28
|
+
activesupport (= 5.0.1)
|
29
|
+
globalid (>= 0.3.6)
|
30
|
+
activemodel (5.0.1)
|
31
|
+
activesupport (= 5.0.1)
|
32
|
+
activerecord (5.0.1)
|
33
|
+
activemodel (= 5.0.1)
|
34
|
+
activesupport (= 5.0.1)
|
35
|
+
arel (~> 7.0)
|
36
|
+
activesupport (5.0.1)
|
37
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
38
|
+
i18n (~> 0.7)
|
39
|
+
minitest (~> 5.1)
|
40
|
+
tzinfo (~> 1.1)
|
41
|
+
ansi (1.5.0)
|
42
|
+
appraisal (2.1.0)
|
43
|
+
bundler
|
44
|
+
rake
|
45
|
+
thor (>= 0.14.0)
|
46
|
+
arel (7.1.4)
|
47
|
+
builder (3.2.3)
|
48
|
+
byebug (9.0.6)
|
49
|
+
coderay (1.1.2)
|
50
|
+
concurrent-ruby (1.0.4)
|
51
|
+
diff-lcs (1.3)
|
52
|
+
erubis (2.7.0)
|
53
|
+
ffi (1.9.17)
|
54
|
+
globalid (0.3.7)
|
55
|
+
activesupport (>= 4.1.0)
|
56
|
+
i18n (0.7.0)
|
57
|
+
listen (3.1.5)
|
58
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
59
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
60
|
+
ruby_dep (~> 1.2)
|
61
|
+
loofah (2.0.3)
|
62
|
+
nokogiri (>= 1.5.9)
|
63
|
+
m (1.5.0)
|
64
|
+
method_source (>= 0.6.7)
|
65
|
+
rake (>= 0.9.2.2)
|
66
|
+
mail (2.6.4)
|
67
|
+
mime-types (>= 1.16, < 4)
|
68
|
+
method_source (0.8.2)
|
69
|
+
mime-types (3.1)
|
70
|
+
mime-types-data (~> 3.2015)
|
71
|
+
mime-types-data (3.2016.0521)
|
72
|
+
mini_portile2 (2.1.0)
|
73
|
+
minitest (5.10.1)
|
74
|
+
minitest-reporters (1.1.14)
|
75
|
+
ansi
|
76
|
+
builder
|
77
|
+
minitest (>= 5.0)
|
78
|
+
ruby-progressbar
|
79
|
+
nio4r (1.2.1)
|
80
|
+
nokogiri (1.7.0.1)
|
81
|
+
mini_portile2 (~> 2.1.0)
|
82
|
+
pry (0.11.0)
|
83
|
+
coderay (~> 1.1.0)
|
84
|
+
method_source (~> 0.8.1)
|
85
|
+
pry-byebug (3.4.2)
|
86
|
+
byebug (~> 9.0)
|
87
|
+
pry (~> 0.10)
|
88
|
+
rack (2.0.1)
|
89
|
+
rack-test (0.6.3)
|
90
|
+
rack (>= 1.0)
|
91
|
+
rails (5.0.1)
|
92
|
+
actioncable (= 5.0.1)
|
93
|
+
actionmailer (= 5.0.1)
|
94
|
+
actionpack (= 5.0.1)
|
95
|
+
actionview (= 5.0.1)
|
96
|
+
activejob (= 5.0.1)
|
97
|
+
activemodel (= 5.0.1)
|
98
|
+
activerecord (= 5.0.1)
|
99
|
+
activesupport (= 5.0.1)
|
100
|
+
bundler (>= 1.3.0, < 2.0)
|
101
|
+
railties (= 5.0.1)
|
102
|
+
sprockets-rails (>= 2.0.0)
|
103
|
+
rails-dom-testing (2.0.2)
|
104
|
+
activesupport (>= 4.2.0, < 6.0)
|
105
|
+
nokogiri (~> 1.6)
|
106
|
+
rails-html-sanitizer (1.0.3)
|
107
|
+
loofah (~> 2.0)
|
108
|
+
railties (5.0.1)
|
109
|
+
actionpack (= 5.0.1)
|
110
|
+
activesupport (= 5.0.1)
|
111
|
+
method_source
|
112
|
+
rake (>= 0.8.7)
|
113
|
+
thor (>= 0.18.1, < 2.0)
|
114
|
+
rake (12.0.0)
|
115
|
+
rb-fsevent (0.9.8)
|
116
|
+
rb-inotify (0.9.8)
|
117
|
+
ffi (>= 0.5.0)
|
118
|
+
rspec (3.5.0)
|
119
|
+
rspec-core (~> 3.5.0)
|
120
|
+
rspec-expectations (~> 3.5.0)
|
121
|
+
rspec-mocks (~> 3.5.0)
|
122
|
+
rspec-core (3.5.4)
|
123
|
+
rspec-support (~> 3.5.0)
|
124
|
+
rspec-expectations (3.5.0)
|
125
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
126
|
+
rspec-support (~> 3.5.0)
|
127
|
+
rspec-mocks (3.5.0)
|
128
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
129
|
+
rspec-support (~> 3.5.0)
|
130
|
+
rspec-support (3.5.0)
|
131
|
+
ruby-progressbar (1.8.1)
|
132
|
+
ruby_dep (1.5.0)
|
133
|
+
sass (3.4.23)
|
134
|
+
sass-rails (5.0.6)
|
135
|
+
railties (>= 4.0.0, < 6)
|
136
|
+
sass (~> 3.1)
|
137
|
+
sprockets (>= 2.8, < 4.0)
|
138
|
+
sprockets-rails (>= 2.0, < 4.0)
|
139
|
+
tilt (>= 1.1, < 3)
|
140
|
+
shoulda-context (1.2.2)
|
141
|
+
shoulda-matchers (3.1.1)
|
142
|
+
activesupport (>= 4.0.0)
|
143
|
+
sprockets (3.7.1)
|
144
|
+
concurrent-ruby (~> 1.0)
|
145
|
+
rack (> 1, < 3)
|
146
|
+
sprockets-rails (3.2.0)
|
147
|
+
actionpack (>= 4.0)
|
148
|
+
activesupport (>= 4.0)
|
149
|
+
sprockets (>= 3.0.0)
|
150
|
+
sqlite3 (1.3.13)
|
151
|
+
thor (0.19.4)
|
152
|
+
thread_safe (0.3.5)
|
153
|
+
tilt (2.0.6)
|
154
|
+
tzinfo (1.2.2)
|
155
|
+
thread_safe (~> 0.1)
|
156
|
+
websocket-driver (0.6.5)
|
157
|
+
websocket-extensions (>= 0.1.0)
|
158
|
+
websocket-extensions (0.1.2)
|
159
|
+
|
160
|
+
PLATFORMS
|
161
|
+
ruby
|
162
|
+
|
163
|
+
DEPENDENCIES
|
164
|
+
appraisal (~> 2.1)
|
165
|
+
listen
|
166
|
+
m
|
167
|
+
minitest (~> 5.0)
|
168
|
+
minitest-reporters (~> 1.0)
|
169
|
+
pry
|
170
|
+
pry-byebug
|
171
|
+
rails (= 5.0.1)
|
172
|
+
rspec (~> 3.0)
|
173
|
+
sass-rails
|
174
|
+
shoulda-context
|
175
|
+
shoulda-matchers (~> 3.0)
|
176
|
+
sqlite3
|
177
|
+
|
178
|
+
BUNDLED WITH
|
179
|
+
1.16.2
|
data/lib/shoulda/version.rb
CHANGED
data/shoulda.gemspec
CHANGED
@@ -2,29 +2,29 @@ $LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
|
|
2
2
|
require 'shoulda/version'
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
|
-
s.name
|
6
|
-
s.version
|
7
|
-
s.platform
|
8
|
-
s.authors
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
5
|
+
s.name = 'shoulda'
|
6
|
+
s.version = Shoulda::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = [
|
9
|
+
'Tammer Saleh',
|
10
|
+
'Joe Ferris',
|
11
|
+
'Ryan McGeary',
|
12
|
+
'Dan Croak',
|
13
|
+
'Matt Jankowski'
|
14
|
+
]
|
15
|
+
s.email = 'support@thoughtbot.com'
|
16
|
+
s.homepage = 'https://github.com/thoughtbot/shoulda'
|
17
|
+
s.summary = 'Making tests easy on the fingers and eyes'
|
18
|
+
s.description = 'Making tests easy on the fingers and eyes'
|
19
|
+
s.license = 'MIT'
|
15
20
|
|
16
|
-
s.files
|
17
|
-
s.test_files
|
18
|
-
s.executables
|
19
|
-
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map do |file|
|
24
|
+
File.basename(file)
|
25
|
+
end
|
26
|
+
s.require_paths = ['lib']
|
20
27
|
|
21
|
-
s.add_dependency(
|
22
|
-
s.add_dependency(
|
23
|
-
|
24
|
-
s.add_development_dependency('appraisal', '~> 0.4.0')
|
25
|
-
s.add_development_dependency("rails", "3.0.12")
|
26
|
-
s.add_development_dependency("sqlite3", "~> 1.3.2")
|
27
|
-
s.add_development_dependency("rspec-rails", "~> 2.7.0")
|
28
|
-
s.add_development_dependency("cucumber", "~> 1.1.0")
|
29
|
-
s.add_development_dependency("aruba", "~> 0.4.11")
|
28
|
+
s.add_dependency('shoulda-context', ['~> 1.0', '>= 1.0.1'])
|
29
|
+
s.add_dependency('shoulda-matchers', '~> 3.0')
|
30
30
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'acceptance_test_helper'
|
2
|
+
|
3
|
+
class ShouldaIntegratesWithRailsTest < AcceptanceTest
|
4
|
+
def test_works_in_a_project_that_uses_minitest
|
5
|
+
create_rails_application
|
6
|
+
|
7
|
+
write_file 'db/migrate/1_create_users.rb', <<-FILE
|
8
|
+
class CreateUsers < ActiveRecord::Migration
|
9
|
+
def self.up
|
10
|
+
create_table :users do |t|
|
11
|
+
t.string :name
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
FILE
|
16
|
+
|
17
|
+
run_rake_tasks!(['db:drop', 'db:create', 'db:migrate'])
|
18
|
+
|
19
|
+
write_file 'app/models/user.rb', <<-FILE
|
20
|
+
class User < ActiveRecord::Base
|
21
|
+
validates_presence_of :name
|
22
|
+
end
|
23
|
+
FILE
|
24
|
+
|
25
|
+
write_file 'app/controllers/examples_controller.rb', <<-FILE
|
26
|
+
class ExamplesController < ApplicationController
|
27
|
+
def index
|
28
|
+
@example = 'hello'
|
29
|
+
render nothing: true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
FILE
|
33
|
+
|
34
|
+
write_file 'config/routes.rb', <<-FILE
|
35
|
+
Rails.application.routes.draw do
|
36
|
+
resources :examples, only: [:index]
|
37
|
+
end
|
38
|
+
FILE
|
39
|
+
|
40
|
+
updating_bundle do
|
41
|
+
add_shoulda_to_project(
|
42
|
+
test_frameworks: [:minitest],
|
43
|
+
libraries: [:rails],
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
write_file 'test/unit/user_test.rb', <<-FILE
|
48
|
+
require 'test_helper'
|
49
|
+
|
50
|
+
class UserTest < ActiveSupport::TestCase
|
51
|
+
should validate_presence_of(:name)
|
52
|
+
end
|
53
|
+
FILE
|
54
|
+
|
55
|
+
write_file 'test/functional/examples_controller_test.rb', <<-FILE
|
56
|
+
require 'test_helper'
|
57
|
+
|
58
|
+
class ExamplesControllerTest < ActionController::TestCase
|
59
|
+
def setup
|
60
|
+
get :index
|
61
|
+
end
|
62
|
+
|
63
|
+
should respond_with(:success)
|
64
|
+
end
|
65
|
+
FILE
|
66
|
+
|
67
|
+
result = run_n_unit_test_suite
|
68
|
+
|
69
|
+
assert_accepts indicate_that_tests_were_run(unit: 1, functional: 1), result
|
70
|
+
assert_accepts(
|
71
|
+
have_output('User should validate that :name cannot be empty/falsy'),
|
72
|
+
result,
|
73
|
+
)
|
74
|
+
assert_accepts have_output('should respond with 200'), result
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative 'support/tests/current_bundle'
|
2
|
+
|
3
|
+
Tests::CurrentBundle.instance.assert_appraisal!
|
4
|
+
|
5
|
+
#---
|
6
|
+
|
7
|
+
require 'test_helper'
|
8
|
+
|
9
|
+
acceptance_test_support_files =
|
10
|
+
Pathname.new('../support/acceptance/**/*.rb').expand_path(__FILE__)
|
11
|
+
|
12
|
+
Dir.glob(acceptance_test_support_files).sort.each { |file| require file }
|
13
|
+
|
14
|
+
class AcceptanceTest < Minitest::Test
|
15
|
+
include AcceptanceTests::Helpers
|
16
|
+
include AcceptanceTests::Matchers
|
17
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
require File.expand_path('../warnings_spy', __FILE__)
|
2
|
+
|
3
|
+
# Adapted from <http://myronmars.to/n/dev-blog/2011/08/making-your-gem-warning-free>
|
4
|
+
|
5
|
+
warnings_spy = WarningsSpy.new('shoulda-matchers')
|
6
|
+
warnings_spy.capture_warnings
|
7
|
+
warnings_spy.report_warnings_at_exit
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require_relative 'helpers/base_helpers'
|
2
|
+
require_relative 'helpers/gem_helpers'
|
3
|
+
|
4
|
+
module AcceptanceTests
|
5
|
+
class AddShouldaToProject
|
6
|
+
def self.call(options)
|
7
|
+
new(options).call
|
8
|
+
end
|
9
|
+
|
10
|
+
include BaseHelpers
|
11
|
+
include GemHelpers
|
12
|
+
|
13
|
+
def initialize(options)
|
14
|
+
@options = options
|
15
|
+
end
|
16
|
+
|
17
|
+
def call
|
18
|
+
add_gem 'shoulda', gem_options
|
19
|
+
|
20
|
+
unless options[:with_configuration] === false
|
21
|
+
add_configuration_block_to_test_helper
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
protected
|
26
|
+
|
27
|
+
attr_reader :options
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def test_framework
|
32
|
+
options[:test_framework]
|
33
|
+
end
|
34
|
+
|
35
|
+
def libraries
|
36
|
+
options.fetch(:libraries, [])
|
37
|
+
end
|
38
|
+
|
39
|
+
def gem_options
|
40
|
+
gem_options = { path: fs.root_directory }
|
41
|
+
|
42
|
+
if options[:manually]
|
43
|
+
gem_options[:require] = false
|
44
|
+
end
|
45
|
+
|
46
|
+
gem_options
|
47
|
+
end
|
48
|
+
|
49
|
+
def add_configuration_block_to_test_helper
|
50
|
+
content = <<-EOT
|
51
|
+
Shoulda::Matchers.configure do |config|
|
52
|
+
config.integrate do |with|
|
53
|
+
#{test_framework_config}
|
54
|
+
#{library_config}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
EOT
|
58
|
+
|
59
|
+
if options[:manually]
|
60
|
+
content = "require 'shoulda'\n#{content}"
|
61
|
+
end
|
62
|
+
|
63
|
+
fs.append_to_file('test/test_helper.rb', content)
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_framework_config
|
67
|
+
if test_framework
|
68
|
+
"with.test_framework :#{test_framework}\n"
|
69
|
+
else
|
70
|
+
''
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def library_config
|
75
|
+
libraries.map { |library| "with.library :#{library}" }.join("\n")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative 'helpers/active_model_helpers'
|
2
|
+
require_relative 'helpers/base_helpers'
|
3
|
+
require_relative 'helpers/command_helpers'
|
4
|
+
require_relative 'helpers/gem_helpers'
|
5
|
+
require_relative 'helpers/step_helpers'
|
6
|
+
|
7
|
+
module AcceptanceTests
|
8
|
+
module Helpers
|
9
|
+
include ActiveModelHelpers
|
10
|
+
include BaseHelpers
|
11
|
+
include CommandHelpers
|
12
|
+
include GemHelpers
|
13
|
+
include StepHelpers
|
14
|
+
|
15
|
+
def setup
|
16
|
+
fs.clean
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|