remarkable 3.1.8 → 3.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +58 -58
- data/LICENSE +20 -20
- data/README +197 -197
- data/lib/remarkable.rb +18 -18
- data/lib/remarkable/base.rb +55 -56
- data/lib/remarkable/core_ext/array.rb +19 -19
- data/lib/remarkable/dsl.rb +35 -35
- data/lib/remarkable/dsl/assertions.rb +384 -384
- data/lib/remarkable/dsl/callbacks.rb +52 -52
- data/lib/remarkable/dsl/optionals.rb +122 -122
- data/lib/remarkable/i18n.rb +53 -53
- data/lib/remarkable/macros.rb +48 -48
- data/lib/remarkable/matchers.rb +17 -17
- data/lib/remarkable/messages.rb +103 -103
- data/lib/remarkable/pending.rb +66 -66
- data/lib/remarkable/rspec.rb +24 -24
- data/lib/remarkable/version.rb +3 -3
- data/locale/en.yml +14 -14
- data/spec/base_spec.rb +41 -41
- data/spec/dsl/assertions_spec.rb +54 -54
- data/spec/dsl/optionals_spec.rb +237 -237
- data/spec/i18n_spec.rb +41 -41
- data/spec/locale/en.yml +20 -20
- data/spec/locale/pt-BR.yml +21 -21
- data/spec/macros_spec.rb +26 -26
- data/spec/matchers/be_a_person_matcher.rb +25 -25
- data/spec/matchers/collection_contain_matcher.rb +32 -32
- data/spec/matchers/contain_matcher.rb +31 -31
- data/spec/matchers/single_contain_matcher.rb +49 -49
- data/spec/matchers_spec.rb +5 -5
- data/spec/messages_spec.rb +66 -66
- data/spec/pending_spec.rb +7 -7
- data/spec/spec.opts +4 -4
- data/spec/spec_helper.rb +15 -15
- metadata +3 -3
data/spec/i18n_spec.rb
CHANGED
@@ -1,41 +1,41 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe Remarkable::I18n do
|
4
|
-
subject { [1, 2, 3] }
|
5
|
-
|
6
|
-
before(:all) do
|
7
|
-
Remarkable.locale = :"pt-BR"
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'should have a locale apart from I18n' do
|
11
|
-
I18n.locale.should_not == Remarkable.locale
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'should delegate translate to I18n API overwriting the default locale' do
|
15
|
-
::I18n.should_receive(:translate).with('remarkable.core.not', :locale => :"pt-BR").and_return('translated')
|
16
|
-
Remarkable.t('remarkable.core.not').should == 'translated'
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'should delegate localize to I18n API overwriting the default locale' do
|
20
|
-
::I18n.should_receive(:localize).with('remarkable.core.not', :locale => :"pt-BR").and_return('localized')
|
21
|
-
Remarkable.l('remarkable.core.not').should == 'localized'
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should delegate add_locale to I18n backend' do
|
25
|
-
backend = mock(::I18n::Backend)
|
26
|
-
::I18n.should_receive(:backend).and_return(backend)
|
27
|
-
backend.should_receive(:load_translations).with('a', 'b', 'c')
|
28
|
-
|
29
|
-
Remarkable.add_locale('a', 'b', 'c')
|
30
|
-
end
|
31
|
-
|
32
|
-
after(:all) do
|
33
|
-
Remarkable.locale = :en
|
34
|
-
end
|
35
|
-
|
36
|
-
Remarkable.locale = :"pt-BR"
|
37
|
-
should_collection_contain(1)
|
38
|
-
should_not_collection_contain(4)
|
39
|
-
xshould_not_collection_contain(5)
|
40
|
-
Remarkable.locale = :en
|
41
|
-
end
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe Remarkable::I18n do
|
4
|
+
subject { [1, 2, 3] }
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
Remarkable.locale = :"pt-BR"
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should have a locale apart from I18n' do
|
11
|
+
I18n.locale.should_not == Remarkable.locale
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should delegate translate to I18n API overwriting the default locale' do
|
15
|
+
::I18n.should_receive(:translate).with('remarkable.core.not', :locale => :"pt-BR").and_return('translated')
|
16
|
+
Remarkable.t('remarkable.core.not').should == 'translated'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should delegate localize to I18n API overwriting the default locale' do
|
20
|
+
::I18n.should_receive(:localize).with('remarkable.core.not', :locale => :"pt-BR").and_return('localized')
|
21
|
+
Remarkable.l('remarkable.core.not').should == 'localized'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should delegate add_locale to I18n backend' do
|
25
|
+
backend = mock(::I18n::Backend)
|
26
|
+
::I18n.should_receive(:backend).and_return(backend)
|
27
|
+
backend.should_receive(:load_translations).with('a', 'b', 'c')
|
28
|
+
|
29
|
+
Remarkable.add_locale('a', 'b', 'c')
|
30
|
+
end
|
31
|
+
|
32
|
+
after(:all) do
|
33
|
+
Remarkable.locale = :en
|
34
|
+
end
|
35
|
+
|
36
|
+
Remarkable.locale = :"pt-BR"
|
37
|
+
should_collection_contain(1)
|
38
|
+
should_not_collection_contain(4)
|
39
|
+
xshould_not_collection_contain(5)
|
40
|
+
Remarkable.locale = :en
|
41
|
+
end
|
data/spec/locale/en.yml
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
en:
|
2
|
-
remarkable:
|
1
|
+
en:
|
2
|
+
remarkable:
|
3
3
|
specs:
|
4
4
|
optionals:
|
5
|
-
allow_nil:
|
6
|
-
positive: "allowing nil"
|
7
|
-
negative: "not allowing nil"
|
8
|
-
contain:
|
9
|
-
description: "contain the given values"
|
10
|
-
single_contain:
|
11
|
-
description: "contain {{value}}"
|
5
|
+
allow_nil:
|
6
|
+
positive: "allowing nil"
|
7
|
+
negative: "not allowing nil"
|
8
|
+
contain:
|
9
|
+
description: "contain the given values"
|
10
|
+
single_contain:
|
11
|
+
description: "contain {{value}}"
|
12
12
|
optionals:
|
13
|
-
allow_nil:
|
14
|
-
positive: "allowing nil"
|
15
|
-
negative: "not allowing nil"
|
16
|
-
allow_blank:
|
17
|
-
positive: "with blank equal {{inspect}}"
|
13
|
+
allow_nil:
|
14
|
+
positive: "allowing nil"
|
15
|
+
negative: "not allowing nil"
|
16
|
+
allow_blank:
|
17
|
+
positive: "with blank equal {{inspect}}"
|
18
18
|
not_given: "not checking for blank"
|
19
19
|
values:
|
20
|
-
positive: "values equal to {{sentence}}"
|
21
|
-
collection_contain:
|
22
|
-
description: "contain {{values}}"
|
23
|
-
expectations:
|
24
|
-
included: "{{more}}{{value}} is included in {{subject_inspect}}"
|
25
|
-
is_array?: "subject is a array, but got {{subject_name}}"
|
20
|
+
positive: "values equal to {{sentence}}"
|
21
|
+
collection_contain:
|
22
|
+
description: "contain {{values}}"
|
23
|
+
expectations:
|
24
|
+
included: "{{more}}{{value}} is included in {{subject_inspect}}"
|
25
|
+
is_array?: "subject is a array, but got {{subject_name}}"
|
data/spec/locale/pt-BR.yml
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
pt-BR:
|
2
|
-
remarkable:
|
3
|
-
core:
|
4
|
-
not: não
|
5
|
-
should: deve
|
6
|
-
should_not: não deve
|
7
|
-
example_disabled: Exemplo desativado
|
8
|
-
failure_message_for_should: Esperava que {{expectation}}
|
9
|
-
failure_message_for_should_not: Não esperava que {{expectation}}
|
10
|
-
|
11
|
-
helpers:
|
12
|
-
words_connector: ', '
|
13
|
-
two_words_connector: ' e '
|
14
|
-
last_word_connector: ' e '
|
15
|
-
|
16
|
-
specs:
|
17
|
-
collection_contain:
|
18
|
-
description: "conter os valores fornecidos"
|
19
|
-
expectations:
|
20
|
-
included: "{{value}} estivesse incluso em {{subject_inspect}}"
|
21
|
-
is_array?: "valor dado é um array, mas é {{subject_name}}"
|
1
|
+
pt-BR:
|
2
|
+
remarkable:
|
3
|
+
core:
|
4
|
+
not: não
|
5
|
+
should: deve
|
6
|
+
should_not: não deve
|
7
|
+
example_disabled: Exemplo desativado
|
8
|
+
failure_message_for_should: Esperava que {{expectation}}
|
9
|
+
failure_message_for_should_not: Não esperava que {{expectation}}
|
10
|
+
|
11
|
+
helpers:
|
12
|
+
words_connector: ', '
|
13
|
+
two_words_connector: ' e '
|
14
|
+
last_word_connector: ' e '
|
15
|
+
|
16
|
+
specs:
|
17
|
+
collection_contain:
|
18
|
+
description: "conter os valores fornecidos"
|
19
|
+
expectations:
|
20
|
+
included: "{{value}} estivesse incluso em {{subject_inspect}}"
|
21
|
+
is_array?: "valor dado é um array, mas é {{subject_name}}"
|
data/spec/macros_spec.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe Remarkable::Macros do
|
4
|
-
subject { [1, 2, 3] }
|
5
|
-
|
6
|
-
should_contain(1)
|
7
|
-
should_contain(1, 2)
|
8
|
-
should_contain(1, 2, 3)
|
9
|
-
|
10
|
-
should_not_contain(4)
|
11
|
-
should_not_contain(1, 4)
|
12
|
-
|
13
|
-
describe "with disabled examples" do
|
14
|
-
# Example disabled without parameters to ensure rescue works properly
|
15
|
-
xshould_not_single_contain
|
16
|
-
xshould_contain(5)
|
17
|
-
xshould_not_contain(1)
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "with blocks" do
|
21
|
-
subject { [1, 2, 3] }
|
22
|
-
|
23
|
-
should_not_single_contain(4)
|
24
|
-
should_single_contain(4){ self << 4 }
|
25
|
-
end
|
26
|
-
end
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe Remarkable::Macros do
|
4
|
+
subject { [1, 2, 3] }
|
5
|
+
|
6
|
+
should_contain(1)
|
7
|
+
should_contain(1, 2)
|
8
|
+
should_contain(1, 2, 3)
|
9
|
+
|
10
|
+
should_not_contain(4)
|
11
|
+
should_not_contain(1, 4)
|
12
|
+
|
13
|
+
describe "with disabled examples" do
|
14
|
+
# Example disabled without parameters to ensure rescue works properly
|
15
|
+
xshould_not_single_contain
|
16
|
+
xshould_contain(5)
|
17
|
+
xshould_not_contain(1)
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "with blocks" do
|
21
|
+
subject { [1, 2, 3] }
|
22
|
+
|
23
|
+
should_not_single_contain(4)
|
24
|
+
should_single_contain(4){ self << 4 }
|
25
|
+
end
|
26
|
+
end
|
@@ -1,29 +1,29 @@
|
|
1
|
-
module Remarkable
|
2
|
-
module Specs
|
3
|
-
module Matchers
|
4
|
-
class BeAPersonMatcher < Remarkable::Base
|
5
|
-
arguments
|
6
|
-
|
7
|
-
optional :first_name
|
8
|
-
optional :age, :default => 18
|
1
|
+
module Remarkable
|
2
|
+
module Specs
|
3
|
+
module Matchers
|
4
|
+
class BeAPersonMatcher < Remarkable::Base
|
5
|
+
arguments
|
6
|
+
|
7
|
+
optional :first_name
|
8
|
+
optional :age, :default => 18
|
9
9
|
optional :last_name, :alias => :family_name
|
10
10
|
optional :bands, :splat => true
|
11
11
|
optional :builder, :block => true
|
12
12
|
|
13
|
-
attr_reader :options
|
14
|
-
|
15
|
-
def description
|
16
|
-
"be a person"
|
17
|
-
end
|
18
|
-
|
19
|
-
def expectation
|
20
|
-
"is not a person"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def be_a_person(*args, &block)
|
25
|
-
BeAPersonMatcher.new(*args, &block).spec(self)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
13
|
+
attr_reader :options
|
14
|
+
|
15
|
+
def description
|
16
|
+
"be a person"
|
17
|
+
end
|
18
|
+
|
19
|
+
def expectation
|
20
|
+
"is not a person"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def be_a_person(*args, &block)
|
25
|
+
BeAPersonMatcher.new(*args, &block).spec(self)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,32 +1,32 @@
|
|
1
|
-
module Remarkable
|
2
|
-
module Specs
|
3
|
-
module Matchers
|
4
|
-
class CollectionContainMatcher < Remarkable::Base
|
5
|
-
arguments :collection => :values, :as => :value
|
6
|
-
|
7
|
-
optional :working, :allow_nil
|
8
|
-
default_options :working => true
|
9
|
-
|
10
|
-
assertion :is_array? do
|
11
|
-
@subject.is_a?(Array)
|
12
|
-
end
|
13
|
-
|
14
|
-
collection_assertion :included? do
|
15
|
-
return @subject.include?(@value), :more => 'that '
|
16
|
-
end
|
17
|
-
|
18
|
-
after_initialize do
|
19
|
-
@after_initialize = true
|
20
|
-
end
|
21
|
-
|
22
|
-
before_assert do
|
23
|
-
@before_assert = true
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def collection_contain(*args, &block)
|
28
|
-
CollectionContainMatcher.new(*args, &block).spec(self)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
1
|
+
module Remarkable
|
2
|
+
module Specs
|
3
|
+
module Matchers
|
4
|
+
class CollectionContainMatcher < Remarkable::Base
|
5
|
+
arguments :collection => :values, :as => :value
|
6
|
+
|
7
|
+
optional :working, :allow_nil
|
8
|
+
default_options :working => true
|
9
|
+
|
10
|
+
assertion :is_array? do
|
11
|
+
@subject.is_a?(Array)
|
12
|
+
end
|
13
|
+
|
14
|
+
collection_assertion :included? do
|
15
|
+
return @subject.include?(@value), :more => 'that '
|
16
|
+
end
|
17
|
+
|
18
|
+
after_initialize do
|
19
|
+
@after_initialize = true
|
20
|
+
end
|
21
|
+
|
22
|
+
before_assert do
|
23
|
+
@before_assert = true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def collection_contain(*args, &block)
|
28
|
+
CollectionContainMatcher.new(*args, &block).spec(self)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,31 +1,31 @@
|
|
1
|
-
module Remarkable
|
2
|
-
module Specs
|
3
|
-
module Matchers
|
4
|
-
class ContainMatcher < Remarkable::Base
|
5
|
-
def initialize(*values)
|
6
|
-
@values = values
|
7
|
-
end
|
8
|
-
|
9
|
-
def matches?(subject)
|
10
|
-
@subject = subject
|
11
|
-
|
12
|
-
assert_collection(nil, @values) do |value|
|
13
|
-
@value = value
|
14
|
-
included?
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def included?
|
19
|
-
return true if @subject.include?(@value)
|
20
|
-
|
21
|
-
@expectation = "#{@value} is included in #{@subject.inspect}"
|
22
|
-
false
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def contain(*args, &block)
|
27
|
-
ContainMatcher.new(*args, &block).spec(self)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
1
|
+
module Remarkable
|
2
|
+
module Specs
|
3
|
+
module Matchers
|
4
|
+
class ContainMatcher < Remarkable::Base
|
5
|
+
def initialize(*values)
|
6
|
+
@values = values
|
7
|
+
end
|
8
|
+
|
9
|
+
def matches?(subject)
|
10
|
+
@subject = subject
|
11
|
+
|
12
|
+
assert_collection(nil, @values) do |value|
|
13
|
+
@value = value
|
14
|
+
included?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def included?
|
19
|
+
return true if @subject.include?(@value)
|
20
|
+
|
21
|
+
@expectation = "#{@value} is included in #{@subject.inspect}"
|
22
|
+
false
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def contain(*args, &block)
|
27
|
+
ContainMatcher.new(*args, &block).spec(self)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,51 +1,51 @@
|
|
1
|
-
module Remarkable
|
2
|
-
module Specs
|
3
|
-
module Matchers
|
4
|
-
class SingleContainMatcher < Remarkable::Base
|
5
|
-
arguments :value, :block => :iterator
|
6
|
-
|
7
|
-
assertions :is_array?, :included?
|
8
|
-
|
9
|
-
optional :allow_nil
|
1
|
+
module Remarkable
|
2
|
+
module Specs
|
3
|
+
module Matchers
|
4
|
+
class SingleContainMatcher < Remarkable::Base
|
5
|
+
arguments :value, :block => :iterator
|
6
|
+
|
7
|
+
assertions :is_array?, :included?
|
8
|
+
|
9
|
+
optional :allow_nil
|
10
10
|
optional :allow_blank
|
11
|
-
optional :values, :splat => true
|
12
|
-
|
13
|
-
after_initialize :set_after_initialize
|
14
|
-
|
15
|
-
before_assert do
|
11
|
+
optional :values, :splat => true
|
12
|
+
|
13
|
+
after_initialize :set_after_initialize
|
14
|
+
|
15
|
+
before_assert do
|
16
16
|
@before_assert = true
|
17
|
-
@subject.instance_eval(&@iterator) if @iterator
|
18
|
-
end
|
19
|
-
|
20
|
-
protected
|
21
|
-
|
22
|
-
def included?
|
23
|
-
return true if @subject.include?(@value)
|
24
|
-
|
25
|
-
@expectation = "#{@value} is not included in #{@subject.inspect}"
|
26
|
-
false
|
27
|
-
end
|
28
|
-
|
29
|
-
def is_array?
|
30
|
-
return true if @subject.is_a?(Array)
|
31
|
-
|
32
|
-
@expectation = "subject is a #{subject_name}"
|
33
|
-
false
|
34
|
-
end
|
35
|
-
|
36
|
-
def default_options
|
37
|
-
{ :working => true }
|
38
|
-
end
|
39
|
-
|
40
|
-
def set_after_initialize
|
41
|
-
@after_initialize = true
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
def single_contain(*args, &block)
|
47
|
-
SingleContainMatcher.new(*args, &block).spec(self)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
17
|
+
@subject.instance_eval(&@iterator) if @iterator
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
def included?
|
23
|
+
return true if @subject.include?(@value)
|
24
|
+
|
25
|
+
@expectation = "#{@value} is not included in #{@subject.inspect}"
|
26
|
+
false
|
27
|
+
end
|
28
|
+
|
29
|
+
def is_array?
|
30
|
+
return true if @subject.is_a?(Array)
|
31
|
+
|
32
|
+
@expectation = "subject is a #{subject_name}"
|
33
|
+
false
|
34
|
+
end
|
35
|
+
|
36
|
+
def default_options
|
37
|
+
{ :working => true }
|
38
|
+
end
|
39
|
+
|
40
|
+
def set_after_initialize
|
41
|
+
@after_initialize = true
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
def single_contain(*args, &block)
|
47
|
+
SingleContainMatcher.new(*args, &block).spec(self)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|