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
data/.rubocop.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
inherit_from: .hound/ruby.yml
|
2
|
+
Style/AlignParameters:
|
3
|
+
EnforcedStyle: with_fixed_indentation
|
4
|
+
Style/CollectionMethods:
|
5
|
+
PreferredMethods:
|
6
|
+
find: detect
|
7
|
+
reduce: inject
|
8
|
+
collect: map
|
9
|
+
find_all: select
|
10
|
+
Style/FrozenStringLiteralComment:
|
11
|
+
Enabled: false
|
12
|
+
Style/StringLiterals:
|
13
|
+
EnforcedStyle: single_quotes
|
data/.travis.yml
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
+
language: ruby
|
2
|
+
sudo: false
|
3
|
+
cache: bundler
|
4
|
+
script: "bundle exec rake"
|
1
5
|
rvm:
|
2
|
-
-
|
3
|
-
-
|
4
|
-
- 2.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
- 2.2.6
|
7
|
+
- 2.3.3
|
8
|
+
- 2.4.0
|
9
|
+
- 2.5.1
|
10
|
+
gemfile:
|
11
|
+
- gemfiles/4.2.gemfile
|
12
|
+
- gemfiles/5.0.gemfile
|
data/Appraisals
CHANGED
@@ -1,15 +1,18 @@
|
|
1
|
-
|
2
|
-
gem '
|
1
|
+
shared_dependencies = proc do
|
2
|
+
gem 'listen'
|
3
|
+
gem 'sass-rails'
|
4
|
+
gem 'sqlite3'
|
5
|
+
gem 'rspec', '~> 3.0'
|
6
|
+
gem 'shoulda-context'
|
7
|
+
gem 'shoulda-matchers', '~> 3.0'
|
3
8
|
end
|
4
9
|
|
5
|
-
appraise '
|
6
|
-
|
7
|
-
gem '
|
8
|
-
gem 'sass-rails'
|
10
|
+
appraise '4.2' do
|
11
|
+
instance_eval(&shared_dependencies)
|
12
|
+
gem 'rails', '4.2.10'
|
9
13
|
end
|
10
14
|
|
11
|
-
appraise '
|
12
|
-
|
13
|
-
gem '
|
14
|
-
gem 'sass-rails'
|
15
|
+
appraise '5.0' do
|
16
|
+
instance_eval(&shared_dependencies)
|
17
|
+
gem 'rails', '5.0.1'
|
15
18
|
end
|
data/CONTRIBUTING.md
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
We love pull requests.
|
1
|
+
We love pull requests from everyone. By participating in this project, you
|
2
|
+
agree to abide by the thoughtbot [code of conduct].
|
3
|
+
|
4
|
+
[code of conduct]: https://thoughtbot.com/open-source-code-of-conduct
|
5
|
+
|
6
|
+
Here's a quick guide:
|
2
7
|
|
3
8
|
1. Fork the repo.
|
4
9
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,103 +1,88 @@
|
|
1
|
-
#
|
1
|
+
# Shoulda [![Gem Version][version-badge]][rubygems] [![Build Status][travis-badge]][travis] ![Downloads][downloads-badge]
|
2
2
|
|
3
|
-
|
3
|
+
[version-badge]: http://img.shields.io/gem/v/shoulda.svg
|
4
|
+
[rubygems]: http://rubygems.org/gems/shoulda
|
5
|
+
[travis-badge]: http://img.shields.io/travis/thoughtbot/shoulda/master.svg
|
6
|
+
[travis]: http://travis-ci.org/thoughtbot/shoulda
|
7
|
+
[downloads-badge]: http://img.shields.io/gem/dtv/shoulda.svg
|
4
8
|
|
5
|
-
|
6
|
-
|
9
|
+
Shoulda helps you write more understandable, maintainable Rails-specific tests
|
10
|
+
using Minitest.
|
7
11
|
|
8
|
-
The
|
12
|
+
The `shoulda` gem doesn't contain any code of its own; it actually brings
|
13
|
+
behavior from two other gems:
|
9
14
|
|
10
|
-
|
11
|
-
|
15
|
+
* [Shoulda Context]
|
16
|
+
* [Shoulda Matchers]
|
12
17
|
|
13
|
-
|
18
|
+
See the READMEs for these projects for more information.
|
14
19
|
|
15
|
-
|
16
|
-
|
17
|
-
it { should belong_to(:user) }
|
18
|
-
it { should validate_presence_of(:title) }
|
19
|
-
end
|
20
|
-
```
|
21
|
-
|
22
|
-
The belong_to and validate_presence_of methods are the matchers.
|
23
|
-
All matchers are Rails 3-specific.
|
20
|
+
[Shoulda Context]: https://github.com/thoughtbot/shoulda-context
|
21
|
+
[Shoulda Matchers]: https://github.com/thoughtbot/shoulda-matchers
|
24
22
|
|
25
|
-
|
23
|
+
## Overview
|
26
24
|
|
27
25
|
```ruby
|
28
|
-
|
29
|
-
gem 'rspec-rails'
|
30
|
-
gem 'shoulda-matchers'
|
31
|
-
end
|
32
|
-
```
|
26
|
+
require "test_helper"
|
33
27
|
|
34
|
-
|
35
|
-
|
28
|
+
class UserTest < ActiveSupport::TestCase
|
29
|
+
context "associations" do
|
30
|
+
should have_many(:posts)
|
31
|
+
end
|
36
32
|
|
37
|
-
|
33
|
+
context "validations" do
|
34
|
+
should validate_presence_of(:email)
|
35
|
+
should allow_value("user@example.com").for(:email)
|
36
|
+
should_not allow_value("not-an-email").for(:email)
|
37
|
+
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
context "#name" do
|
40
|
+
should "consist of first and last name" do
|
41
|
+
user = User.new(first_name: "John", last_name: "Smith")
|
42
|
+
assert_equal "John Smith", user.name
|
43
|
+
end
|
44
|
+
end
|
43
45
|
end
|
44
46
|
```
|
45
47
|
|
46
|
-
|
47
|
-
|
48
|
+
Here, the `context` and `should` methods come from Shoulda Context; matchers
|
49
|
+
(e.g. `have_many`, `allow_value`) come from Shoulda Matchers.
|
48
50
|
|
49
|
-
|
51
|
+
## Compatibility
|
50
52
|
|
51
|
-
|
52
|
-
|
53
|
-
gem 'shoulda'
|
54
|
-
end
|
55
|
-
```
|
56
|
-
|
57
|
-
test/unit with shoulda-context
|
58
|
-
------------------------------
|
53
|
+
Shoulda is tested and supported against Ruby 2.2-2.4, Rails 4.2-5.0, and
|
54
|
+
Minitest 5.
|
59
55
|
|
60
|
-
|
61
|
-
you can use shoulda-context independently to write tests like:
|
56
|
+
## Contributing
|
62
57
|
|
63
|
-
|
64
|
-
|
65
|
-
context "a calculator" do
|
66
|
-
setup do
|
67
|
-
@calculator = Calculator.new
|
68
|
-
end
|
58
|
+
Shoulda is open source, and we are grateful for [everyone][contributors] who's
|
59
|
+
contributed so far.
|
69
60
|
|
70
|
-
|
71
|
-
|
72
|
-
|
61
|
+
If you'd like to contribute, please take a look at the
|
62
|
+
[instructions](CONTRIBUTING.md) for installing dependencies and crafting a good
|
63
|
+
pull request.
|
73
64
|
|
74
|
-
|
75
|
-
assert_equal 10, @calculator.product(2, 5)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
```
|
65
|
+
[contributors]: https://github.com/thoughtbot/shoulda/contributors
|
80
66
|
|
81
|
-
|
67
|
+
## Versioning
|
82
68
|
|
83
|
-
|
84
|
-
group :test do
|
85
|
-
gem 'shoulda-context'
|
86
|
-
end
|
87
|
-
```
|
69
|
+
Shoulda follows Semantic Versioning 2.0 as defined at <http://semver.org>.
|
88
70
|
|
89
|
-
|
90
|
-
-------
|
71
|
+
## License
|
91
72
|
|
92
|
-
|
73
|
+
Shoulda is copyright © 2006-2017 [thoughtbot, inc][thoughtbot]. It is free
|
74
|
+
software, and may be redistributed under the terms specified in the
|
75
|
+
[MIT-LICENSE](MIT-LICENSE) file.
|
93
76
|
|
94
|
-
|
77
|
+
## About thoughtbot
|
95
78
|
|
96
|
-
|
79
|
+
[<img src="http://presskit.thoughtbot.com/images/signature.svg" width="250" alt="thoughtbot logo">][thoughtbot]
|
97
80
|
|
98
|
-
|
81
|
+
Shoulda is maintained and funded by thoughtbot, inc. The names and logos for
|
82
|
+
thoughtbot are trademarks of thoughtbot, inc.
|
99
83
|
|
100
|
-
|
101
|
-
|
84
|
+
We are passionate about open source software. See [our other
|
85
|
+
projects][community]. We are [available for hire][thoughtbot].
|
102
86
|
|
103
|
-
|
87
|
+
[community]: https://thoughtbot.com/community?utm_source=github
|
88
|
+
[thoughtbot]: https://thoughtbot.com?utm_source=github
|
data/Rakefile
CHANGED
@@ -1,17 +1,26 @@
|
|
1
|
-
require 'bundler/setup'
|
2
|
-
require 'bundler/gem_tasks'
|
3
|
-
require 'cucumber/rake/task'
|
4
1
|
require 'appraisal'
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require_relative 'test/support/tests/current_bundle'
|
5
6
|
|
6
|
-
|
7
|
-
t.
|
8
|
-
t.
|
7
|
+
Rake::TestTask.new('test:acceptance') do |t|
|
8
|
+
t.libs << 'test'
|
9
|
+
# t.ruby_opts += ['-w', '-r', './test/report_warnings']
|
10
|
+
t.ruby_opts += ['-w']
|
11
|
+
t.pattern = 'test/acceptance/**/*_test.rb'
|
12
|
+
t.verbose = false
|
9
13
|
end
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
|
15
|
+
task :default do
|
16
|
+
if Tests::CurrentBundle.instance.appraisal_in_use?
|
17
|
+
sh 'rake test:acceptance --trace'
|
18
|
+
else
|
19
|
+
if ENV['CI']
|
20
|
+
exec "appraisal install && appraisal rake --trace"
|
21
|
+
else
|
22
|
+
appraisal = Tests::CurrentBundle.instance.latest_appraisal
|
23
|
+
exec "appraisal install && appraisal #{appraisal} rake --trace"
|
24
|
+
end
|
25
|
+
end
|
14
26
|
end
|
15
|
-
|
16
|
-
desc 'Default: run cucumber features'
|
17
|
-
task :default => [:all]
|
@@ -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", "4.2.10"
|
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,174 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actionmailer (4.2.10)
|
5
|
+
actionpack (= 4.2.10)
|
6
|
+
actionview (= 4.2.10)
|
7
|
+
activejob (= 4.2.10)
|
8
|
+
mail (~> 2.5, >= 2.5.4)
|
9
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
10
|
+
actionpack (4.2.10)
|
11
|
+
actionview (= 4.2.10)
|
12
|
+
activesupport (= 4.2.10)
|
13
|
+
rack (~> 1.6)
|
14
|
+
rack-test (~> 0.6.2)
|
15
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
16
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
17
|
+
actionview (4.2.10)
|
18
|
+
activesupport (= 4.2.10)
|
19
|
+
builder (~> 3.1)
|
20
|
+
erubis (~> 2.7.0)
|
21
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
22
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
23
|
+
activejob (4.2.10)
|
24
|
+
activesupport (= 4.2.10)
|
25
|
+
globalid (>= 0.3.0)
|
26
|
+
activemodel (4.2.10)
|
27
|
+
activesupport (= 4.2.10)
|
28
|
+
builder (~> 3.1)
|
29
|
+
activerecord (4.2.10)
|
30
|
+
activemodel (= 4.2.10)
|
31
|
+
activesupport (= 4.2.10)
|
32
|
+
arel (~> 6.0)
|
33
|
+
activesupport (4.2.10)
|
34
|
+
i18n (~> 0.7)
|
35
|
+
minitest (~> 5.1)
|
36
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
37
|
+
tzinfo (~> 1.1)
|
38
|
+
ansi (1.5.0)
|
39
|
+
appraisal (2.1.0)
|
40
|
+
bundler
|
41
|
+
rake
|
42
|
+
thor (>= 0.14.0)
|
43
|
+
arel (6.0.4)
|
44
|
+
builder (3.2.3)
|
45
|
+
byebug (9.0.6)
|
46
|
+
coderay (1.1.2)
|
47
|
+
concurrent-ruby (1.0.4)
|
48
|
+
crass (1.0.4)
|
49
|
+
diff-lcs (1.3)
|
50
|
+
erubis (2.7.0)
|
51
|
+
ffi (1.9.17)
|
52
|
+
globalid (0.4.1)
|
53
|
+
activesupport (>= 4.2.0)
|
54
|
+
i18n (0.9.5)
|
55
|
+
concurrent-ruby (~> 1.0)
|
56
|
+
listen (3.1.5)
|
57
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
58
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
59
|
+
ruby_dep (~> 1.2)
|
60
|
+
loofah (2.2.2)
|
61
|
+
crass (~> 1.0.2)
|
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.7.0)
|
67
|
+
mini_mime (>= 0.1.1)
|
68
|
+
method_source (0.8.2)
|
69
|
+
mini_mime (1.0.0)
|
70
|
+
mini_portile2 (2.3.0)
|
71
|
+
minitest (5.10.1)
|
72
|
+
minitest-reporters (1.1.14)
|
73
|
+
ansi
|
74
|
+
builder
|
75
|
+
minitest (>= 5.0)
|
76
|
+
ruby-progressbar
|
77
|
+
nokogiri (1.8.4)
|
78
|
+
mini_portile2 (~> 2.3.0)
|
79
|
+
pry (0.11.0)
|
80
|
+
coderay (~> 1.1.0)
|
81
|
+
method_source (~> 0.8.1)
|
82
|
+
pry-byebug (3.4.2)
|
83
|
+
byebug (~> 9.0)
|
84
|
+
pry (~> 0.10)
|
85
|
+
rack (1.6.5)
|
86
|
+
rack-test (0.6.3)
|
87
|
+
rack (>= 1.0)
|
88
|
+
rails (4.2.10)
|
89
|
+
actionmailer (= 4.2.10)
|
90
|
+
actionpack (= 4.2.10)
|
91
|
+
actionview (= 4.2.10)
|
92
|
+
activejob (= 4.2.10)
|
93
|
+
activemodel (= 4.2.10)
|
94
|
+
activerecord (= 4.2.10)
|
95
|
+
activesupport (= 4.2.10)
|
96
|
+
bundler (>= 1.3.0, < 2.0)
|
97
|
+
railties (= 4.2.10)
|
98
|
+
sprockets-rails
|
99
|
+
rails-deprecated_sanitizer (1.0.3)
|
100
|
+
activesupport (>= 4.2.0.alpha)
|
101
|
+
rails-dom-testing (1.0.9)
|
102
|
+
activesupport (>= 4.2.0, < 5.0)
|
103
|
+
nokogiri (~> 1.6)
|
104
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
105
|
+
rails-html-sanitizer (1.0.4)
|
106
|
+
loofah (~> 2.2, >= 2.2.2)
|
107
|
+
railties (4.2.10)
|
108
|
+
actionpack (= 4.2.10)
|
109
|
+
activesupport (= 4.2.10)
|
110
|
+
rake (>= 0.8.7)
|
111
|
+
thor (>= 0.18.1, < 2.0)
|
112
|
+
rake (12.0.0)
|
113
|
+
rb-fsevent (0.9.8)
|
114
|
+
rb-inotify (0.9.8)
|
115
|
+
ffi (>= 0.5.0)
|
116
|
+
rspec (3.5.0)
|
117
|
+
rspec-core (~> 3.5.0)
|
118
|
+
rspec-expectations (~> 3.5.0)
|
119
|
+
rspec-mocks (~> 3.5.0)
|
120
|
+
rspec-core (3.5.4)
|
121
|
+
rspec-support (~> 3.5.0)
|
122
|
+
rspec-expectations (3.5.0)
|
123
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
124
|
+
rspec-support (~> 3.5.0)
|
125
|
+
rspec-mocks (3.5.0)
|
126
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
127
|
+
rspec-support (~> 3.5.0)
|
128
|
+
rspec-support (3.5.0)
|
129
|
+
ruby-progressbar (1.8.1)
|
130
|
+
ruby_dep (1.5.0)
|
131
|
+
sass (3.4.23)
|
132
|
+
sass-rails (5.0.6)
|
133
|
+
railties (>= 4.0.0, < 6)
|
134
|
+
sass (~> 3.1)
|
135
|
+
sprockets (>= 2.8, < 4.0)
|
136
|
+
sprockets-rails (>= 2.0, < 4.0)
|
137
|
+
tilt (>= 1.1, < 3)
|
138
|
+
shoulda-context (1.2.2)
|
139
|
+
shoulda-matchers (3.1.1)
|
140
|
+
activesupport (>= 4.0.0)
|
141
|
+
sprockets (3.7.1)
|
142
|
+
concurrent-ruby (~> 1.0)
|
143
|
+
rack (> 1, < 3)
|
144
|
+
sprockets-rails (3.2.0)
|
145
|
+
actionpack (>= 4.0)
|
146
|
+
activesupport (>= 4.0)
|
147
|
+
sprockets (>= 3.0.0)
|
148
|
+
sqlite3 (1.3.13)
|
149
|
+
thor (0.19.4)
|
150
|
+
thread_safe (0.3.6)
|
151
|
+
tilt (2.0.6)
|
152
|
+
tzinfo (1.2.5)
|
153
|
+
thread_safe (~> 0.1)
|
154
|
+
|
155
|
+
PLATFORMS
|
156
|
+
ruby
|
157
|
+
|
158
|
+
DEPENDENCIES
|
159
|
+
appraisal (~> 2.1)
|
160
|
+
listen
|
161
|
+
m
|
162
|
+
minitest (~> 5.0)
|
163
|
+
minitest-reporters (~> 1.0)
|
164
|
+
pry
|
165
|
+
pry-byebug
|
166
|
+
rails (= 4.2.10)
|
167
|
+
rspec (~> 3.0)
|
168
|
+
sass-rails
|
169
|
+
shoulda-context
|
170
|
+
shoulda-matchers (~> 3.0)
|
171
|
+
sqlite3
|
172
|
+
|
173
|
+
BUNDLED WITH
|
174
|
+
1.16.2
|