remockable 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +17 -2
- data/Appraisals +11 -0
- data/CHANGELOG.md +4 -0
- data/README.markdown +6 -6
- data/gemfiles/rails_4.2.gemfile +9 -0
- data/gemfiles/rails_4.2.gemfile.lock +67 -0
- data/gemfiles/rails_5.0.gemfile +9 -0
- data/gemfiles/rails_5.0.gemfile.lock +64 -0
- data/lib/remockable/active_record/have_column.rb +7 -1
- data/lib/remockable/active_record/have_default_scope.rb +1 -1
- data/lib/remockable/active_record/have_scope.rb +1 -1
- data/lib/remockable/version.rb +1 -1
- data/remockable.gemspec +4 -3
- data/spec/active_model/allow_values_for_spec.rb +2 -0
- data/spec/active_record/have_scope_spec.rb +20 -4
- data/spec/spec_helper.rb +20 -5
- data/spec/support/shared/a_validation_matcher.rb +6 -0
- metadata +46 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dad8f07d7c08c5c6eed18c23b3c9b0f969ecd05b
|
4
|
+
data.tar.gz: 2479532b5c0a6e75736ebfb98145866d17d727ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 184bae3a39850bc84632b23aa56f5c75ca7e1fcec943ecdf6949e27924f40d705a6da2bb8e93aa04b8847c2f11a5af32f23e1c8a44f8e8712d6b2a144a74144f
|
7
|
+
data.tar.gz: c4c5864043a9a1f5edb30e6bf2a3b17497426337af07ab02fb81aaa37a82e13b57f6f9a1c5cf8abd226c48aa92443a26e98bdbdd42855eb50f8f9392381ccd7d
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
language: ruby
|
2
2
|
script: bundle exec rspec
|
3
|
+
|
4
|
+
gemfile:
|
5
|
+
- gemfiles/rails_4.2.gemfile
|
6
|
+
- gemfiles/rails_5.0.gemfile
|
7
|
+
|
3
8
|
rvm:
|
4
|
-
- 2.0
|
5
|
-
- 2.1
|
9
|
+
- 2.0.0
|
10
|
+
- 2.1.10
|
11
|
+
- 2.2.6
|
12
|
+
- 2.3.3
|
13
|
+
- 2.4.0
|
14
|
+
|
15
|
+
matrix:
|
16
|
+
exclude:
|
17
|
+
- rvm: 2.0.0
|
18
|
+
gemfile: gemfiles/rails_5.0.gemfile
|
19
|
+
- rvm: 2.1.10
|
20
|
+
gemfile: gemfiles/rails_5.0.gemfile
|
data/Appraisals
ADDED
data/CHANGELOG.md
CHANGED
data/README.markdown
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
[![Build Status][travis-image]][travis] [![Dependency Status][gemnasium-image]][gemnasium] [![Gem Version][rubygems-image]][rubygems]
|
4
4
|
|
5
|
-
[travis]:
|
6
|
-
[travis-image]: https://
|
7
|
-
[gemnasium]: https://gemnasium.com/tylerhunt/remockable
|
8
|
-
[gemnasium-image]: https://gemnasium.com/tylerhunt/remockable.
|
9
|
-
[rubygems]:
|
10
|
-
[rubygems-image]: https://badge.fury.io/rb/remockable.
|
5
|
+
[travis]: https://travis-ci.org/tylerhunt/remockable
|
6
|
+
[travis-image]: https://travis-ci.org/tylerhunt/remockable.svg?branch=master
|
7
|
+
[gemnasium]: https://gemnasium.com/github.com/tylerhunt/remockable
|
8
|
+
[gemnasium-image]: https://gemnasium.com/badges/github.com/tylerhunt/remockable.svg
|
9
|
+
[rubygems]: https://badge.fury.io/rb/remockable
|
10
|
+
[rubygems-image]: https://badge.fury.io/rb/remockable.svg
|
11
11
|
|
12
12
|
A collection of RSpec 3 matchers to simplify your web app specs.
|
13
13
|
|
@@ -0,0 +1,67 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
remockable (0.3.1)
|
5
|
+
activemodel (>= 4.0, < 5.1)
|
6
|
+
activerecord (>= 4.0, < 5.1)
|
7
|
+
activesupport (>= 4.0, < 5.1)
|
8
|
+
rspec-core (~> 3.0)
|
9
|
+
rspec-expectations (~> 3.0)
|
10
|
+
rspec-mocks (~> 3.0)
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: https://rubygems.org/
|
14
|
+
specs:
|
15
|
+
activemodel (4.2.7.1)
|
16
|
+
activesupport (= 4.2.7.1)
|
17
|
+
builder (~> 3.1)
|
18
|
+
activerecord (4.2.7.1)
|
19
|
+
activemodel (= 4.2.7.1)
|
20
|
+
activesupport (= 4.2.7.1)
|
21
|
+
arel (~> 6.0)
|
22
|
+
activesupport (4.2.7.1)
|
23
|
+
i18n (~> 0.7)
|
24
|
+
json (~> 1.7, >= 1.7.7)
|
25
|
+
minitest (~> 5.1)
|
26
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
27
|
+
tzinfo (~> 1.1)
|
28
|
+
appraisal (2.1.0)
|
29
|
+
bundler
|
30
|
+
rake
|
31
|
+
thor (>= 0.14.0)
|
32
|
+
arel (6.0.4)
|
33
|
+
builder (3.2.3)
|
34
|
+
diff-lcs (1.2.5)
|
35
|
+
i18n (0.7.0)
|
36
|
+
json (1.8.6)
|
37
|
+
minitest (5.10.1)
|
38
|
+
rake (12.0.0)
|
39
|
+
rspec-core (3.5.4)
|
40
|
+
rspec-support (~> 3.5.0)
|
41
|
+
rspec-expectations (3.5.0)
|
42
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
+
rspec-support (~> 3.5.0)
|
44
|
+
rspec-mocks (3.5.0)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.5.0)
|
47
|
+
rspec-support (3.5.0)
|
48
|
+
sqlite3 (1.3.13)
|
49
|
+
thor (0.19.4)
|
50
|
+
thread_safe (0.3.5)
|
51
|
+
tzinfo (1.2.2)
|
52
|
+
thread_safe (~> 0.1)
|
53
|
+
|
54
|
+
PLATFORMS
|
55
|
+
ruby
|
56
|
+
|
57
|
+
DEPENDENCIES
|
58
|
+
activemodel (~> 4.2)
|
59
|
+
activerecord (~> 4.2)
|
60
|
+
activesupport (~> 4.2)
|
61
|
+
appraisal (~> 2.1)
|
62
|
+
rake
|
63
|
+
remockable!
|
64
|
+
sqlite3 (~> 1.3.4)
|
65
|
+
|
66
|
+
BUNDLED WITH
|
67
|
+
1.13.7
|
@@ -0,0 +1,64 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
remockable (0.3.1)
|
5
|
+
activemodel (>= 4.0, < 5.1)
|
6
|
+
activerecord (>= 4.0, < 5.1)
|
7
|
+
activesupport (>= 4.0, < 5.1)
|
8
|
+
rspec-core (~> 3.0)
|
9
|
+
rspec-expectations (~> 3.0)
|
10
|
+
rspec-mocks (~> 3.0)
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: https://rubygems.org/
|
14
|
+
specs:
|
15
|
+
activemodel (5.0.1)
|
16
|
+
activesupport (= 5.0.1)
|
17
|
+
activerecord (5.0.1)
|
18
|
+
activemodel (= 5.0.1)
|
19
|
+
activesupport (= 5.0.1)
|
20
|
+
arel (~> 7.0)
|
21
|
+
activesupport (5.0.1)
|
22
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
23
|
+
i18n (~> 0.7)
|
24
|
+
minitest (~> 5.1)
|
25
|
+
tzinfo (~> 1.1)
|
26
|
+
appraisal (2.1.0)
|
27
|
+
bundler
|
28
|
+
rake
|
29
|
+
thor (>= 0.14.0)
|
30
|
+
arel (7.1.4)
|
31
|
+
concurrent-ruby (1.0.4)
|
32
|
+
diff-lcs (1.2.5)
|
33
|
+
i18n (0.7.0)
|
34
|
+
minitest (5.10.1)
|
35
|
+
rake (12.0.0)
|
36
|
+
rspec-core (3.5.4)
|
37
|
+
rspec-support (~> 3.5.0)
|
38
|
+
rspec-expectations (3.5.0)
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
+
rspec-support (~> 3.5.0)
|
41
|
+
rspec-mocks (3.5.0)
|
42
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
+
rspec-support (~> 3.5.0)
|
44
|
+
rspec-support (3.5.0)
|
45
|
+
sqlite3 (1.3.13)
|
46
|
+
thor (0.19.4)
|
47
|
+
thread_safe (0.3.5)
|
48
|
+
tzinfo (1.2.2)
|
49
|
+
thread_safe (~> 0.1)
|
50
|
+
|
51
|
+
PLATFORMS
|
52
|
+
ruby
|
53
|
+
|
54
|
+
DEPENDENCIES
|
55
|
+
activemodel (~> 5.0)
|
56
|
+
activerecord (~> 5.0)
|
57
|
+
activesupport (~> 5.0)
|
58
|
+
appraisal (~> 2.1)
|
59
|
+
rake
|
60
|
+
remockable!
|
61
|
+
sqlite3 (~> 1.3.4)
|
62
|
+
|
63
|
+
BUNDLED WITH
|
64
|
+
1.13.7
|
@@ -11,7 +11,13 @@ RSpec::Matchers.define(:have_column) do
|
|
11
11
|
|
12
12
|
match do |actual|
|
13
13
|
if column
|
14
|
-
options.all? { |key, value|
|
14
|
+
options.all? { |key, value|
|
15
|
+
if key == :default
|
16
|
+
column.send(key) == value.to_s # SQLite3 uses string for default
|
17
|
+
else
|
18
|
+
column.send(key) == value
|
19
|
+
end
|
20
|
+
}
|
15
21
|
end
|
16
22
|
end
|
17
23
|
|
@@ -11,7 +11,7 @@ RSpec::Matchers.define(:have_default_scope) do
|
|
11
11
|
|
12
12
|
if scope.is_a?(ActiveRecord::Relation)
|
13
13
|
if relation
|
14
|
-
query_matches = scope.
|
14
|
+
query_matches = scope.to_sql == relation.to_sql
|
15
15
|
eager_load_matches = scope.eager_load_values == relation.eager_load_values
|
16
16
|
includes_matches = scope.includes_values == relation.includes_values
|
17
17
|
lock_matches = scope.lock_value == relation.lock_value
|
@@ -16,7 +16,7 @@ RSpec::Matchers.define(:have_scope) do |*name|
|
|
16
16
|
|
17
17
|
if scope.is_a?(ActiveRecord::Relation)
|
18
18
|
if relation
|
19
|
-
query_matches = scope.
|
19
|
+
query_matches = scope.to_sql == relation.to_sql
|
20
20
|
eager_load_matches = scope.eager_load_values == relation.eager_load_values
|
21
21
|
includes_matches = scope.includes_values == relation.includes_values
|
22
22
|
lock_matches = scope.lock_value == relation.lock_value
|
data/lib/remockable/version.rb
CHANGED
data/remockable.gemspec
CHANGED
@@ -8,12 +8,13 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.homepage = 'http://github.com/tylerhunt/remockable'
|
9
9
|
spec.license = 'MIT'
|
10
10
|
|
11
|
-
spec.add_dependency 'activemodel', '
|
12
|
-
spec.add_dependency 'activerecord', '
|
13
|
-
spec.add_dependency 'activesupport', '
|
11
|
+
spec.add_dependency 'activemodel', '>= 4.0', '< 5.1'
|
12
|
+
spec.add_dependency 'activerecord', '>= 4.0', '< 5.1'
|
13
|
+
spec.add_dependency 'activesupport', '>= 4.0', '< 5.1'
|
14
14
|
spec.add_dependency 'rspec-core', '~> 3.0'
|
15
15
|
spec.add_dependency 'rspec-expectations', '~> 3.0'
|
16
16
|
spec.add_dependency 'rspec-mocks', '~> 3.0'
|
17
|
+
spec.add_development_dependency 'appraisal', '~> 2.1'
|
17
18
|
spec.add_development_dependency 'rake'
|
18
19
|
spec.add_development_dependency 'sqlite3', '~> 1.3.4'
|
19
20
|
|
@@ -35,14 +35,30 @@ describe :have_scope do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
context 'with an eager_load value' do
|
38
|
+
let(:comment_model) { build_class(:Comment, ActiveRecord::Base) }
|
39
|
+
let(:post_model) { build_class(:Post, ActiveRecord::Base) }
|
40
|
+
|
41
|
+
before do
|
42
|
+
create_table :comments do |table|
|
43
|
+
table.integer :user_id
|
44
|
+
end
|
45
|
+
|
46
|
+
create_table :posts do |table|
|
47
|
+
table.integer :user_id
|
48
|
+
end
|
49
|
+
|
50
|
+
model.has_many :comments, anonymous_class: comment_model
|
51
|
+
model.has_many :posts, anonymous_class: post_model
|
52
|
+
end
|
53
|
+
|
38
54
|
it 'matches if the scope exists and the query matches' do
|
39
|
-
model.instance_eval { scope :loaded, -> { eager_load :
|
40
|
-
expect(model).to have_scope(:loaded).eager_load(:
|
55
|
+
model.instance_eval { scope :loaded, -> { eager_load :posts } }
|
56
|
+
expect(model).to have_scope(:loaded).eager_load(:posts)
|
41
57
|
end
|
42
58
|
|
43
59
|
it 'does not match if the query does not match' do
|
44
|
-
model.instance_eval { scope :loaded, -> { eager_load :
|
45
|
-
expect(model).to_not have_scope(:loaded).eager_load(:
|
60
|
+
model.instance_eval { scope :loaded, -> { eager_load :posts } }
|
61
|
+
expect(model).to_not have_scope(:loaded).eager_load(:comments)
|
46
62
|
end
|
47
63
|
end
|
48
64
|
|
data/spec/spec_helper.rb
CHANGED
@@ -4,12 +4,27 @@ require 'active_record'
|
|
4
4
|
require 'remockable'
|
5
5
|
|
6
6
|
# Require supporting files with custom matchers and macros, etc.
|
7
|
-
Dir[File.expand_path('
|
8
|
-
require(file)
|
9
|
-
end
|
7
|
+
Dir[File.expand_path('support/**/*.rb', __dir__)].each { |file| require file }
|
10
8
|
|
11
9
|
RSpec.configure do |config|
|
12
|
-
config.
|
13
|
-
config.filter_run focus: true
|
10
|
+
config.filter_run :focus
|
14
11
|
config.run_all_when_everything_filtered = true
|
12
|
+
config.example_status_persistence_file_path = 'spec/examples.txt'
|
13
|
+
|
14
|
+
if config.files_to_run.one?
|
15
|
+
config.default_formatter = 'doc'
|
16
|
+
end
|
17
|
+
|
18
|
+
config.order = :random
|
19
|
+
Kernel.srand config.seed
|
20
|
+
|
21
|
+
config.expect_with :rspec do |expectations|
|
22
|
+
expectations.syntax = :expect
|
23
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
24
|
+
end
|
25
|
+
|
26
|
+
config.mock_with :rspec do |mocks|
|
27
|
+
mocks.syntax = :expect
|
28
|
+
mocks.verify_partial_doubles = true
|
29
|
+
end
|
15
30
|
end
|
@@ -54,6 +54,12 @@ shared_examples_for 'a validation matcher' do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
context "with option #{option_name.inspect} with a procedure" do
|
57
|
+
before do
|
58
|
+
model.class_eval do
|
59
|
+
define_method(:skip_validations) {}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
57
63
|
let(:procedure) { ->(record) { record.skip_validations } }
|
58
64
|
|
59
65
|
let(:options) {
|
metadata
CHANGED
@@ -1,57 +1,75 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remockable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tyler Hunt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.1'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '4.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.1'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: activerecord
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- - "
|
37
|
+
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
33
39
|
version: '4.0'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '5.1'
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
37
46
|
requirements:
|
38
|
-
- - "
|
47
|
+
- - ">="
|
39
48
|
- !ruby/object:Gem::Version
|
40
49
|
version: '4.0'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '5.1'
|
41
53
|
- !ruby/object:Gem::Dependency
|
42
54
|
name: activesupport
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|
44
56
|
requirements:
|
45
|
-
- - "
|
57
|
+
- - ">="
|
46
58
|
- !ruby/object:Gem::Version
|
47
59
|
version: '4.0'
|
60
|
+
- - "<"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '5.1'
|
48
63
|
type: :runtime
|
49
64
|
prerelease: false
|
50
65
|
version_requirements: !ruby/object:Gem::Requirement
|
51
66
|
requirements:
|
52
|
-
- - "
|
67
|
+
- - ">="
|
53
68
|
- !ruby/object:Gem::Version
|
54
69
|
version: '4.0'
|
70
|
+
- - "<"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '5.1'
|
55
73
|
- !ruby/object:Gem::Dependency
|
56
74
|
name: rspec-core
|
57
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +112,20 @@ dependencies:
|
|
94
112
|
- - "~>"
|
95
113
|
- !ruby/object:Gem::Version
|
96
114
|
version: '3.0'
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: appraisal
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - "~>"
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '2.1'
|
122
|
+
type: :development
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - "~>"
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '2.1'
|
97
129
|
- !ruby/object:Gem::Dependency
|
98
130
|
name: rake
|
99
131
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,11 +163,16 @@ files:
|
|
131
163
|
- ".gitignore"
|
132
164
|
- ".rspec"
|
133
165
|
- ".travis.yml"
|
166
|
+
- Appraisals
|
134
167
|
- CHANGELOG.md
|
135
168
|
- Gemfile
|
136
169
|
- LICENSE
|
137
170
|
- README.markdown
|
138
171
|
- Rakefile
|
172
|
+
- gemfiles/rails_4.2.gemfile
|
173
|
+
- gemfiles/rails_4.2.gemfile.lock
|
174
|
+
- gemfiles/rails_5.0.gemfile
|
175
|
+
- gemfiles/rails_5.0.gemfile.lock
|
139
176
|
- lib/remockable.rb
|
140
177
|
- lib/remockable/active_model.rb
|
141
178
|
- lib/remockable/active_model/allow_values_for.rb
|
@@ -209,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
246
|
version: '0'
|
210
247
|
requirements: []
|
211
248
|
rubyforge_project:
|
212
|
-
rubygems_version: 2.
|
249
|
+
rubygems_version: 2.5.2
|
213
250
|
signing_key:
|
214
251
|
specification_version: 4
|
215
252
|
summary: A collection of RSpec matchers for web apps.
|