remarkable 3.0.4 → 3.0.5
Sign up to get free protection for your applications and to get access to all the features.
@@ -119,9 +119,14 @@ module Remarkable
|
|
119
119
|
methods.each do |method|
|
120
120
|
bool, hash = send(method)
|
121
121
|
|
122
|
-
unless bool
|
123
|
-
|
124
|
-
|
122
|
+
unless bool
|
123
|
+
parent_scope = matcher_i18n_scope.split('.')
|
124
|
+
matcher_name = parent_scope.pop
|
125
|
+
lookup = :"expectations.#{method.to_s.gsub(/(\?|\!)$/, '')}"
|
126
|
+
|
127
|
+
hash = { :scope => parent_scope, :default => lookup }.merge(hash || {})
|
128
|
+
@expectation ||= Remarkable.t "#{matcher_name}.#{lookup}", default_i18n_options.merge(hash)
|
129
|
+
|
125
130
|
return false
|
126
131
|
end
|
127
132
|
end
|
@@ -116,25 +116,38 @@ module Remarkable
|
|
116
116
|
message.strip!
|
117
117
|
|
118
118
|
optionals = self.class.matcher_optionals.map do |optional|
|
119
|
-
scope = matcher_i18n_scope + ".optionals.#{optional}"
|
120
|
-
|
121
119
|
if @options.key?(optional)
|
122
120
|
value = @options[optional]
|
123
121
|
defaults = [ (value ? :positive : :negative) ]
|
124
122
|
|
125
123
|
# If optional is a symbol and it's not any to any of the reserved symbols, search for it also
|
126
|
-
defaults.unshift(value) if value.is_a?(Symbol) && !OPTIONAL_KEYS.include?(value)
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
124
|
+
defaults.unshift(value) if value.is_a?(Symbol) && !OPTIONAL_KEYS.include?(value)
|
125
|
+
defaults << ''
|
126
|
+
|
127
|
+
options = { :default => defaults, :inspect => value.inspect, :value => value.to_s }
|
128
|
+
translate_optionals_with_namespace(optional, defaults.shift, options)
|
129
|
+
else
|
130
|
+
translate_optionals_with_namespace(optional, :not_given, :default => '')
|
131
|
+
end
|
133
132
|
end.compact
|
134
133
|
|
135
134
|
message << ' ' << array_to_sentence(optionals)
|
136
135
|
message.strip!
|
137
136
|
message
|
137
|
+
end
|
138
|
+
|
139
|
+
def translate_optionals_with_namespace(optional, key, options={}) #:nodoc:
|
140
|
+
scope = "#{matcher_i18n_scope}.optionals.#{optional}"
|
141
|
+
|
142
|
+
translation = Remarkable.t key, options.merge!(:scope => scope)
|
143
|
+
return translation unless translation.empty?
|
144
|
+
|
145
|
+
parent_scope = scope.split('.')
|
146
|
+
parent_scope.delete_at(-3)
|
147
|
+
translation = Remarkable.t key, options.merge!(:scope => parent_scope)
|
148
|
+
return translation unless translation.empty?
|
149
|
+
|
150
|
+
nil
|
138
151
|
end
|
139
152
|
|
140
153
|
end
|
data/lib/remarkable/version.rb
CHANGED
data/spec/dsl/optionals_spec.rb
CHANGED
@@ -38,5 +38,16 @@ describe Remarkable::DSL::Optionals do
|
|
38
38
|
|
39
39
|
@matcher.allow_nil(false)
|
40
40
|
@matcher.description.should == 'contain 1 not allowing nil and with blank equal true'
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should provide a description with optionals through namespace lookup' do
|
44
|
+
@matcher = Remarkable::Specs::Matchers::CollectionContainMatcher.new(1)
|
45
|
+
@matcher.description.should == 'contain 1'
|
46
|
+
|
47
|
+
@matcher.allow_nil(true)
|
48
|
+
@matcher.description.should == 'contain 1 allowing nil'
|
49
|
+
|
50
|
+
@matcher.allow_nil(false)
|
51
|
+
@matcher.description.should == 'contain 1 not allowing nil'
|
41
52
|
end
|
42
53
|
end
|
data/spec/locale/en.yml
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
en:
|
2
2
|
remarkable:
|
3
|
-
specs:
|
3
|
+
specs:
|
4
|
+
optionals:
|
5
|
+
allow_nil:
|
6
|
+
positive: "allowing nil"
|
7
|
+
negative: "not allowing nil"
|
4
8
|
contain:
|
5
9
|
description: "contain the given values"
|
6
10
|
single_contain:
|
7
11
|
description: "contain {{value}}"
|
8
|
-
optionals:
|
12
|
+
optionals:
|
9
13
|
allow_nil:
|
10
14
|
positive: "allowing nil"
|
11
15
|
negative: "not allowing nil"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remarkable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Brando
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-04-
|
13
|
+
date: 2009-04-20 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|