remockable 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/.travis.yml +2 -3
- data/CHANGELOG.md +6 -0
- data/README.markdown +18 -4
- data/lib/remockable/active_model/allow_values_for.rb +14 -13
- data/lib/remockable/active_model/helpers.rb +7 -6
- data/lib/remockable/active_model/validate_acceptance_of.rb +9 -11
- data/lib/remockable/active_model/validate_confirmation_of.rb +9 -11
- data/lib/remockable/active_model/validate_exclusion_of.rb +9 -11
- data/lib/remockable/active_model/validate_format_of.rb +9 -11
- data/lib/remockable/active_model/validate_inclusion_of.rb +9 -11
- data/lib/remockable/active_model/validate_length_of.rb +32 -19
- data/lib/remockable/active_model/validate_numericality_of.rb +23 -12
- data/lib/remockable/active_model/validate_presence_of.rb +9 -11
- data/lib/remockable/active_record/accept_nested_attributes_for.rb +10 -13
- data/lib/remockable/active_record/belong_to.rb +21 -13
- data/lib/remockable/active_record/have_and_belong_to_many.rb +16 -13
- data/lib/remockable/active_record/have_column.rb +14 -11
- data/lib/remockable/active_record/have_default_scope.rb +38 -20
- data/lib/remockable/active_record/have_index.rb +12 -13
- data/lib/remockable/active_record/have_many.rb +22 -13
- data/lib/remockable/active_record/have_one.rb +21 -13
- data/lib/remockable/active_record/have_scope.rb +40 -25
- data/lib/remockable/active_record/helpers.rb +3 -0
- data/lib/remockable/active_record/validate_associated.rb +9 -11
- data/lib/remockable/active_record/validate_uniqueness_of.rb +19 -11
- data/lib/remockable/helpers.rb +58 -6
- data/lib/remockable/version.rb +1 -1
- data/remockable.gemspec +3 -3
- data/spec/active_model/allow_values_for_spec.rb +19 -13
- data/spec/active_model/validate_acceptance_of_spec.rb +0 -2
- data/spec/active_model/validate_confirmation_of_spec.rb +0 -2
- data/spec/active_model/validate_exclusion_of_spec.rb +7 -9
- data/spec/active_model/validate_format_of_spec.rb +9 -11
- data/spec/active_model/validate_inclusion_of_spec.rb +7 -9
- data/spec/active_model/validate_length_of_spec.rb +16 -18
- data/spec/active_model/validate_numericality_of_spec.rb +14 -16
- data/spec/active_model/validate_presence_of_spec.rb +0 -2
- data/spec/active_record/accept_nested_attributes_for_spec.rb +22 -18
- data/spec/active_record/belong_to_spec.rb +26 -26
- data/spec/active_record/have_and_belong_to_many_spec.rb +22 -20
- data/spec/active_record/have_column_spec.rb +32 -35
- data/spec/active_record/have_default_scope_spec.rb +54 -55
- data/spec/active_record/have_index_spec.rb +24 -27
- data/spec/active_record/have_many_spec.rb +10 -11
- data/spec/active_record/have_one_spec.rb +26 -25
- data/spec/active_record/have_scope_spec.rb +75 -75
- data/spec/active_record/validate_associated_spec.rb +11 -11
- data/spec/active_record/validate_uniqueness_of_spec.rb +11 -13
- data/spec/spec_helper.rb +2 -4
- data/spec/support/active_record_example_group.rb +3 -4
- data/spec/support/class_builder.rb +15 -11
- data/spec/support/shared/a_validation_matcher.rb +25 -25
- data/spec/support/shared/an_active_record_matcher.rb +14 -12
- metadata +60 -84
@@ -1,30 +1,33 @@
|
|
1
|
-
RSpec::Matchers.define(:have_and_belong_to_many) do
|
2
|
-
|
1
|
+
RSpec::Matchers.define(:have_and_belong_to_many) do
|
2
|
+
include Remockable::ActiveRecord::Helpers
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
valid_options %i(
|
5
|
+
association_foreign_key
|
6
|
+
autosave
|
7
|
+
class_name
|
8
|
+
foreign_key
|
9
|
+
join_table
|
10
|
+
validate
|
11
|
+
)
|
9
12
|
|
10
13
|
match do |actual|
|
11
|
-
if association = subject.class.reflect_on_association(
|
14
|
+
if association = subject.class.reflect_on_association(attribute)
|
12
15
|
macro_matches = association.macro == :has_and_belongs_to_many
|
13
|
-
options_match = association.options.slice(*
|
16
|
+
options_match = association.options.slice(*options.keys) == options
|
14
17
|
macro_matches && options_match
|
15
18
|
end
|
16
19
|
end
|
17
20
|
|
18
|
-
|
21
|
+
failure_message do |actual|
|
19
22
|
"Expected #{subject.class.name} to #{description}"
|
20
23
|
end
|
21
24
|
|
22
|
-
|
25
|
+
failure_message_when_negated do |actual|
|
23
26
|
"Did not expect #{subject.class.name} to #{description}"
|
24
27
|
end
|
25
28
|
|
26
29
|
description do
|
27
|
-
with = " with #{
|
28
|
-
"have and belong to #{
|
30
|
+
with = " with #{options.inspect}" if options.any?
|
31
|
+
"have and belong to #{attribute}#{with}"
|
29
32
|
end
|
30
33
|
end
|
@@ -1,27 +1,30 @@
|
|
1
|
-
RSpec::Matchers.define(:have_column) do
|
2
|
-
|
1
|
+
RSpec::Matchers.define(:have_column) do
|
2
|
+
include Remockable::ActiveRecord::Helpers
|
3
3
|
|
4
|
-
|
5
|
-
@column = column.shift
|
4
|
+
valid_options %i(default limit null precision scale type)
|
6
5
|
|
7
|
-
|
6
|
+
def column
|
7
|
+
@column ||= subject.class.columns.detect { |column|
|
8
|
+
column.name == attribute.to_s
|
9
|
+
}
|
10
|
+
end
|
8
11
|
|
9
12
|
match do |actual|
|
10
|
-
if column
|
11
|
-
|
13
|
+
if column
|
14
|
+
options.all? { |key, value| column.send(key) == value }
|
12
15
|
end
|
13
16
|
end
|
14
17
|
|
15
|
-
|
18
|
+
failure_message do |actual|
|
16
19
|
"Expected #{subject.class.name} to #{description}"
|
17
20
|
end
|
18
21
|
|
19
|
-
|
22
|
+
failure_message_when_negated do |actual|
|
20
23
|
"Did not expect #{subject.class.name} to #{description}"
|
21
24
|
end
|
22
25
|
|
23
26
|
description do
|
24
|
-
with = " with #{
|
25
|
-
"have column #{
|
27
|
+
with = " with #{options.inspect}" if options.any?
|
28
|
+
"have column #{attribute}#{with}"
|
26
29
|
end
|
27
30
|
end
|
@@ -1,23 +1,22 @@
|
|
1
|
-
RSpec::Matchers.define(:have_default_scope) do
|
2
|
-
|
1
|
+
RSpec::Matchers.define(:have_default_scope) do
|
2
|
+
include Remockable::ActiveRecord::Helpers
|
3
3
|
|
4
|
-
|
5
|
-
@relation = nil
|
4
|
+
attr_accessor :relation
|
6
5
|
|
7
|
-
valid_options %
|
6
|
+
valid_options %i()
|
8
7
|
|
9
8
|
match do |actual|
|
10
9
|
if subject.class.respond_to?(:all)
|
11
10
|
scope = subject.class.all
|
12
11
|
|
13
12
|
if scope.is_a?(ActiveRecord::Relation)
|
14
|
-
if
|
15
|
-
query_matches = scope.arel.to_sql ==
|
16
|
-
eager_load_matches = scope.eager_load_values ==
|
17
|
-
includes_matches = scope.includes_values ==
|
18
|
-
lock_matches = scope.lock_value ==
|
19
|
-
preload_matches = scope.preload_values ==
|
20
|
-
readonly_matches = scope.readonly_value ==
|
13
|
+
if relation
|
14
|
+
query_matches = scope.arel.to_sql == relation.arel.to_sql
|
15
|
+
eager_load_matches = scope.eager_load_values == relation.eager_load_values
|
16
|
+
includes_matches = scope.includes_values == relation.includes_values
|
17
|
+
lock_matches = scope.lock_value == relation.lock_value
|
18
|
+
preload_matches = scope.preload_values == relation.preload_values
|
19
|
+
readonly_matches = scope.readonly_value == relation.readonly_value
|
21
20
|
|
22
21
|
query_matches && eager_load_matches && includes_matches && lock_matches && preload_matches && readonly_matches
|
23
22
|
elsif subject.class.respond_to?(:default_scopes) # Rails 3.1
|
@@ -30,28 +29,47 @@ RSpec::Matchers.define(:have_default_scope) do |*expected|
|
|
30
29
|
end
|
31
30
|
|
32
31
|
def method_missing(method, *args, &block)
|
33
|
-
unsupported_query_methods = %(
|
34
|
-
|
32
|
+
unsupported_query_methods = %i(
|
33
|
+
create_with
|
34
|
+
eager_load
|
35
|
+
includes
|
36
|
+
lock
|
37
|
+
preload
|
38
|
+
readonly
|
39
|
+
)
|
35
40
|
|
36
|
-
|
37
|
-
|
38
|
-
|
41
|
+
query_methods = %i(
|
42
|
+
from
|
43
|
+
group
|
44
|
+
having
|
45
|
+
joins
|
46
|
+
limit
|
47
|
+
offset
|
48
|
+
order
|
49
|
+
reorder
|
50
|
+
select
|
51
|
+
where
|
52
|
+
)
|
53
|
+
|
54
|
+
if query_methods.include?(method)
|
55
|
+
self.relation ||= subject.class.unscoped
|
56
|
+
self.relation = relation.send(method, *args)
|
39
57
|
self
|
40
58
|
else
|
41
59
|
super
|
42
60
|
end
|
43
61
|
end
|
44
62
|
|
45
|
-
|
63
|
+
failure_message do |actual|
|
46
64
|
"Expected #{subject.class.name} to #{description}"
|
47
65
|
end
|
48
66
|
|
49
|
-
|
67
|
+
failure_message_when_negated do |actual|
|
50
68
|
"Did not expect #{subject.class.name} to #{description}"
|
51
69
|
end
|
52
70
|
|
53
71
|
description do
|
54
|
-
with = " with #{
|
72
|
+
with = " with #{options.inspect}" if options.any?
|
55
73
|
"have a default scope#{with}"
|
56
74
|
end
|
57
75
|
end
|
@@ -1,18 +1,17 @@
|
|
1
|
-
RSpec::Matchers.define(:have_index) do
|
2
|
-
|
1
|
+
RSpec::Matchers.define(:have_index) do
|
2
|
+
include Remockable::ActiveRecord::Helpers
|
3
3
|
|
4
|
-
|
5
|
-
@columns = columns
|
4
|
+
valid_options %i(name unique)
|
6
5
|
|
7
|
-
|
6
|
+
def column_names
|
7
|
+
@column_names ||= expected_as_array.flatten.collect(&:to_s)
|
8
|
+
end
|
8
9
|
|
9
10
|
match do |actual|
|
10
|
-
name =
|
11
|
-
unique =
|
11
|
+
name = options[:name]
|
12
|
+
unique = options[:unique]
|
12
13
|
indexes = ActiveRecord::Base.connection.indexes(subject.class.table_name)
|
13
14
|
|
14
|
-
column_names = @columns.flatten.collect(&:to_s)
|
15
|
-
|
16
15
|
index = indexes.detect do |index|
|
17
16
|
if column_names.any?
|
18
17
|
index.columns == column_names
|
@@ -33,16 +32,16 @@ RSpec::Matchers.define(:have_index) do |*columns|
|
|
33
32
|
index.name == name.to_s
|
34
33
|
end
|
35
34
|
|
36
|
-
|
35
|
+
failure_message do |actual|
|
37
36
|
"Expected #{subject.class.name} to #{description}"
|
38
37
|
end
|
39
38
|
|
40
|
-
|
39
|
+
failure_message_when_negated do |actual|
|
41
40
|
"Did not expect #{subject.class.name} to #{description}"
|
42
41
|
end
|
43
42
|
|
44
43
|
description do
|
45
|
-
with = " with #{
|
46
|
-
"have index on #{
|
44
|
+
with = " with #{options.inspect}" if options.any?
|
45
|
+
"have index on #{column_names.to_sentence}#{with}"
|
47
46
|
end
|
48
47
|
end
|
@@ -1,30 +1,39 @@
|
|
1
|
-
RSpec::Matchers.define(:have_many) do
|
2
|
-
|
1
|
+
RSpec::Matchers.define(:have_many) do
|
2
|
+
include Remockable::ActiveRecord::Helpers
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
valid_options %i(
|
5
|
+
as
|
6
|
+
autosave
|
7
|
+
class_name
|
8
|
+
counter_cache
|
9
|
+
dependent
|
10
|
+
foreign_key
|
11
|
+
inverse_of
|
12
|
+
primary_key
|
13
|
+
source
|
14
|
+
source_type
|
15
|
+
through
|
16
|
+
validate
|
17
|
+
)
|
9
18
|
|
10
19
|
match do |actual|
|
11
|
-
if association = subject.class.reflect_on_association(
|
20
|
+
if association = subject.class.reflect_on_association(attribute)
|
12
21
|
macro_matches = association.macro == :has_many
|
13
|
-
options_match = association.options.slice(*
|
22
|
+
options_match = association.options.slice(*options.keys) == options
|
14
23
|
macro_matches && options_match
|
15
24
|
end
|
16
25
|
end
|
17
26
|
|
18
|
-
|
27
|
+
failure_message do |actual|
|
19
28
|
"Expected #{subject.class.name} to #{description}"
|
20
29
|
end
|
21
30
|
|
22
|
-
|
31
|
+
failure_message_when_negated do |actual|
|
23
32
|
"Did not expect #{subject.class.name} to #{description}"
|
24
33
|
end
|
25
34
|
|
26
35
|
description do
|
27
|
-
with = " with #{
|
28
|
-
"have many #{
|
36
|
+
with = " with #{options.inspect}" if options.any?
|
37
|
+
"have many #{attribute}#{with}"
|
29
38
|
end
|
30
39
|
end
|
@@ -1,30 +1,38 @@
|
|
1
|
-
RSpec::Matchers.define(:have_one) do
|
2
|
-
|
1
|
+
RSpec::Matchers.define(:have_one) do
|
2
|
+
include Remockable::ActiveRecord::Helpers
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
valid_options %i(
|
5
|
+
class_name
|
6
|
+
dependent
|
7
|
+
foreign_key
|
8
|
+
primary_key
|
9
|
+
as
|
10
|
+
through
|
11
|
+
source
|
12
|
+
source_type
|
13
|
+
validate
|
14
|
+
autosave
|
15
|
+
inverse_of
|
16
|
+
)
|
9
17
|
|
10
18
|
match do |actual|
|
11
|
-
if association = subject.class.reflect_on_association(
|
19
|
+
if association = subject.class.reflect_on_association(attribute)
|
12
20
|
macro_matches = association.macro == :has_one
|
13
|
-
options_match = association.options.slice(*
|
21
|
+
options_match = association.options.slice(*options.keys) == options
|
14
22
|
macro_matches && options_match
|
15
23
|
end
|
16
24
|
end
|
17
25
|
|
18
|
-
|
26
|
+
failure_message do |actual|
|
19
27
|
"Expected #{subject.class.name} to #{description}"
|
20
28
|
end
|
21
29
|
|
22
|
-
|
30
|
+
failure_message_when_negated do |actual|
|
23
31
|
"Did not expect #{subject.class.name} to #{description}"
|
24
32
|
end
|
25
33
|
|
26
34
|
description do
|
27
|
-
with = " with #{
|
28
|
-
"have a #{
|
35
|
+
with = " with #{options.inspect}" if options.any?
|
36
|
+
"have a #{attribute}#{with}"
|
29
37
|
end
|
30
38
|
end
|
@@ -1,29 +1,27 @@
|
|
1
1
|
RSpec::Matchers.define(:have_scope) do |*name|
|
2
|
-
|
2
|
+
include Remockable::ActiveRecord::Helpers
|
3
3
|
|
4
|
-
|
5
|
-
@name = name.shift
|
6
|
-
@relation = nil
|
4
|
+
attr_accessor :relation
|
7
5
|
|
8
|
-
valid_options %
|
6
|
+
valid_options %i(with)
|
9
7
|
|
10
8
|
match do |actual|
|
11
|
-
if subject.class.respond_to?(
|
12
|
-
scope = if
|
13
|
-
with = [
|
14
|
-
subject.class.send(
|
9
|
+
if subject.class.respond_to?(attribute)
|
10
|
+
scope = if options.key?(:with)
|
11
|
+
with = [options[:with]] unless options[:with].is_a?(Array)
|
12
|
+
subject.class.send(attribute, *with)
|
15
13
|
else
|
16
|
-
subject.class.send(
|
14
|
+
subject.class.send(attribute)
|
17
15
|
end
|
18
16
|
|
19
17
|
if scope.is_a?(ActiveRecord::Relation)
|
20
|
-
if
|
21
|
-
query_matches = scope.arel.to_sql ==
|
22
|
-
eager_load_matches = scope.eager_load_values ==
|
23
|
-
includes_matches = scope.includes_values ==
|
24
|
-
lock_matches = scope.lock_value ==
|
25
|
-
preload_matches = scope.preload_values ==
|
26
|
-
readonly_matches = scope.readonly_value ==
|
18
|
+
if relation
|
19
|
+
query_matches = scope.arel.to_sql == relation.arel.to_sql
|
20
|
+
eager_load_matches = scope.eager_load_values == relation.eager_load_values
|
21
|
+
includes_matches = scope.includes_values == relation.includes_values
|
22
|
+
lock_matches = scope.lock_value == relation.lock_value
|
23
|
+
preload_matches = scope.preload_values == relation.preload_values
|
24
|
+
readonly_matches = scope.readonly_value == relation.readonly_value
|
27
25
|
|
28
26
|
query_matches && eager_load_matches && includes_matches && lock_matches && preload_matches && readonly_matches
|
29
27
|
else
|
@@ -35,27 +33,44 @@ RSpec::Matchers.define(:have_scope) do |*name|
|
|
35
33
|
|
36
34
|
def method_missing(method, *args, &block)
|
37
35
|
unsupported_query_methods = %(create_with)
|
38
|
-
query_methods = %w(eager_load from group having includes joins limit lock offset order preload readonly reorder select where)
|
39
36
|
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
query_methods = %i(
|
38
|
+
eager_load
|
39
|
+
from
|
40
|
+
group
|
41
|
+
having
|
42
|
+
includes
|
43
|
+
joins
|
44
|
+
limit
|
45
|
+
lock
|
46
|
+
offset
|
47
|
+
order
|
48
|
+
preload
|
49
|
+
readonly
|
50
|
+
reorder
|
51
|
+
select
|
52
|
+
where
|
53
|
+
)
|
54
|
+
|
55
|
+
if query_methods.include?(method)
|
56
|
+
self.relation ||= subject.class.all
|
57
|
+
self.relation = relation.send(method, *args)
|
43
58
|
self
|
44
59
|
else
|
45
60
|
super
|
46
61
|
end
|
47
62
|
end
|
48
63
|
|
49
|
-
|
64
|
+
failure_message do |actual|
|
50
65
|
"Expected #{subject.class.name} to #{description}"
|
51
66
|
end
|
52
67
|
|
53
|
-
|
68
|
+
failure_message_when_negated do |actual|
|
54
69
|
"Did not expect #{subject.class.name} to #{description}"
|
55
70
|
end
|
56
71
|
|
57
72
|
description do
|
58
|
-
with = " with #{
|
59
|
-
"have scope #{
|
73
|
+
with = " with #{options.inspect}" if options.any?
|
74
|
+
"have scope #{attribute}#{with}"
|
60
75
|
end
|
61
76
|
end
|
@@ -1,27 +1,25 @@
|
|
1
|
-
RSpec::Matchers.define(:validate_associated) do
|
2
|
-
|
1
|
+
RSpec::Matchers.define(:validate_associated) do
|
2
|
+
include Remockable::ActiveModel::Helpers
|
3
3
|
|
4
|
-
|
5
|
-
@expected = attribute.extract_options!
|
6
|
-
@attribute = attribute.shift
|
4
|
+
type :associated
|
7
5
|
|
8
|
-
valid_options %
|
6
|
+
valid_options %i(if message on unless)
|
9
7
|
|
10
8
|
match do |actual|
|
11
|
-
validator = validator_for(
|
9
|
+
validator = validator_for(attribute)
|
12
10
|
validator && options_match(validator) && conditionals_match(validator)
|
13
11
|
end
|
14
12
|
|
15
|
-
|
13
|
+
failure_message do |actual|
|
16
14
|
"Expected #{subject.class.name} to #{description}"
|
17
15
|
end
|
18
16
|
|
19
|
-
|
17
|
+
failure_message_when_negated do |actual|
|
20
18
|
"Did not expect #{subject.class.name} to #{description}"
|
21
19
|
end
|
22
20
|
|
23
21
|
description do
|
24
|
-
with = " with #{
|
25
|
-
"validate #{type} #{
|
22
|
+
with = " with #{options.inspect}" if options.any?
|
23
|
+
"validate #{type} #{attribute}#{with}"
|
26
24
|
end
|
27
25
|
end
|
@@ -1,27 +1,35 @@
|
|
1
|
-
|
2
|
-
extend Remockable::ActiveModel::Helpers
|
1
|
+
require 'rspec/expectations'
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
@attribute = attribute.shift
|
3
|
+
RSpec::Matchers.define :validate_uniqueness_of do |expected|
|
4
|
+
include Remockable::ActiveModel::Helpers
|
7
5
|
|
8
|
-
|
6
|
+
type :uniqueness
|
7
|
+
|
8
|
+
valid_options %i(
|
9
|
+
allow_blank
|
10
|
+
allow_nil
|
11
|
+
case_sensitive
|
12
|
+
if
|
13
|
+
message
|
14
|
+
scope
|
15
|
+
unless
|
16
|
+
)
|
9
17
|
|
10
18
|
match do |actual|
|
11
|
-
validator = validator_for(
|
19
|
+
validator = validator_for(attribute)
|
12
20
|
validator && options_match(validator) && conditionals_match(validator)
|
13
21
|
end
|
14
22
|
|
15
|
-
|
23
|
+
failure_message do |actual|
|
16
24
|
"Expected #{subject.class.name} to #{description}"
|
17
25
|
end
|
18
26
|
|
19
|
-
|
27
|
+
failure_message_when_negated do |actual|
|
20
28
|
"Did not expect #{subject.class.name} to #{description}"
|
21
29
|
end
|
22
30
|
|
23
31
|
description do
|
24
|
-
with = " with #{
|
25
|
-
"validate #{type} of #{
|
32
|
+
with = " with #{options.inspect}" if options.any?
|
33
|
+
"validate #{type} of #{attribute}#{with}"
|
26
34
|
end
|
27
35
|
end
|
data/lib/remockable/helpers.rb
CHANGED
@@ -1,16 +1,68 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
1
3
|
module Remockable
|
2
4
|
module Helpers
|
3
|
-
|
4
|
-
|
5
|
-
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
def type(type)
|
9
|
+
define_method :type do
|
10
|
+
type
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def unsupported_options(keys)
|
15
|
+
define_method :unsupported_options do
|
16
|
+
keys
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def valid_options(keys)
|
21
|
+
define_method :valid_options do
|
22
|
+
keys
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def attribute
|
28
|
+
@attribute ||= expected_as_array.first
|
29
|
+
end
|
30
|
+
|
31
|
+
def options
|
32
|
+
@options ||= expected_as_array.extract_options!
|
33
|
+
end
|
34
|
+
|
35
|
+
def matches?(actual)
|
36
|
+
validate_options!
|
37
|
+
super
|
38
|
+
end
|
39
|
+
|
40
|
+
def unsupported_options
|
41
|
+
[]
|
42
|
+
end
|
43
|
+
|
44
|
+
def valid_options
|
45
|
+
[]
|
46
|
+
end
|
47
|
+
|
48
|
+
def validate_options!
|
49
|
+
check_unsupported_options!
|
50
|
+
check_valid_options!
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def check_unsupported_options!
|
56
|
+
options.each_key do |key|
|
57
|
+
if unsupported_options.include?(key.to_sym)
|
6
58
|
raise ArgumentError.new("Unsupported option #{key.inspect}")
|
7
59
|
end
|
8
60
|
end
|
9
61
|
end
|
10
62
|
|
11
|
-
def
|
12
|
-
|
13
|
-
unless
|
63
|
+
def check_valid_options!
|
64
|
+
options.each_key do |key|
|
65
|
+
unless valid_options.include?(key.to_sym)
|
14
66
|
raise ArgumentError.new("Unknown option #{key.inspect}")
|
15
67
|
end
|
16
68
|
end
|
data/lib/remockable/version.rb
CHANGED
data/remockable.gemspec
CHANGED
@@ -11,9 +11,9 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.add_dependency 'activemodel', '~> 4.0'
|
12
12
|
spec.add_dependency 'activerecord', '~> 4.0'
|
13
13
|
spec.add_dependency 'activesupport', '~> 4.0'
|
14
|
-
spec.add_dependency 'rspec-core', '~>
|
15
|
-
spec.add_dependency 'rspec-expectations', '~>
|
16
|
-
spec.add_dependency 'rspec-mocks', '~>
|
14
|
+
spec.add_dependency 'rspec-core', '~> 3.0'
|
15
|
+
spec.add_dependency 'rspec-expectations', '~> 3.0'
|
16
|
+
spec.add_dependency 'rspec-mocks', '~> 3.0'
|
17
17
|
spec.add_development_dependency 'rake'
|
18
18
|
spec.add_development_dependency 'sqlite3', '~> 1.3.4'
|
19
19
|
|