assertion 0.0.1 → 0.1.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/README.md +54 -43
- data/lib/assertion.rb +37 -6
- data/lib/assertion/attributes.rb +54 -0
- data/lib/assertion/base.rb +7 -65
- data/lib/assertion/guard.rb +99 -0
- data/lib/assertion/{exceptions/invalid_error.rb → invalid_error.rb} +5 -1
- data/lib/assertion/inversion.rb +1 -1
- data/lib/assertion/messages.rb +65 -0
- data/lib/assertion/state.rb +1 -1
- data/lib/assertion/transprocs/inflector.rb +2 -0
- data/lib/assertion/version.rb +1 -1
- data/spec/integration/assertion_spec.rb +3 -12
- data/spec/integration/guard_spec.rb +29 -0
- data/spec/{integration → shared}/en.yml +1 -1
- data/spec/shared/i18n.rb +21 -0
- data/spec/unit/assertion/attributes_spec.rb +97 -0
- data/spec/unit/assertion/base_spec.rb +6 -103
- data/spec/unit/assertion/exceptions/invalid_error_spec.rb +11 -10
- data/spec/unit/assertion/guard_spec.rb +82 -0
- data/spec/unit/assertion/messages_spec.rb +41 -0
- data/spec/unit/assertion_spec.rb +69 -12
- metadata +18 -15
- data/lib/assertion/exceptions/name_error.rb +0 -29
- data/lib/assertion/exceptions/not_implemented_error.rb +0 -29
- data/lib/assertion/transprocs/i18n.rb +0 -55
- data/spec/unit/assertion/exceptions/name_error_spec.rb +0 -26
- data/spec/unit/assertion/exceptions/not_implemented_error_spec.rb +0 -26
- data/spec/unit/assertion/transprocs/i18n/to_scope_spec.rb +0 -19
- data/spec/unit/assertion/transprocs/i18n/translate_spec.rb +0 -28
@@ -1,26 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
describe Assertion::NameError do
|
4
|
-
|
5
|
-
subject(:error) { described_class.new :foo, :bar }
|
6
|
-
|
7
|
-
describe ".new" do
|
8
|
-
|
9
|
-
it { is_expected.to be_kind_of ::NameError }
|
10
|
-
|
11
|
-
it { is_expected.to be_frozen }
|
12
|
-
|
13
|
-
end # describe .new
|
14
|
-
|
15
|
-
describe "#message" do
|
16
|
-
|
17
|
-
subject(:message) { error.message }
|
18
|
-
|
19
|
-
it "returns a proper message" do
|
20
|
-
expect(subject)
|
21
|
-
.to include "Wrong name(s) for attribute(s): foo, bar"
|
22
|
-
end
|
23
|
-
|
24
|
-
end # describe #message
|
25
|
-
|
26
|
-
end # describe Assertion::NameError
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
describe Assertion::NotImplementedError do
|
4
|
-
|
5
|
-
subject(:error) { described_class.new klass, :foo }
|
6
|
-
let(:klass) { double name: :Test }
|
7
|
-
|
8
|
-
describe ".new" do
|
9
|
-
|
10
|
-
it { is_expected.to be_kind_of ::NotImplementedError }
|
11
|
-
|
12
|
-
it { is_expected.to be_frozen }
|
13
|
-
|
14
|
-
end # describe .new
|
15
|
-
|
16
|
-
describe "#message" do
|
17
|
-
|
18
|
-
subject(:message) { error.message }
|
19
|
-
|
20
|
-
it "returns a proper message" do
|
21
|
-
expect(subject).to include "Test#foo method not implemented"
|
22
|
-
end
|
23
|
-
|
24
|
-
end # describe #message
|
25
|
-
|
26
|
-
end # describe Assertion::NotImplementedError
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
describe Assertion::I18n, "#scope" do
|
4
|
-
|
5
|
-
subject { fn[input] }
|
6
|
-
|
7
|
-
let(:fn) { described_class[:scope] }
|
8
|
-
let(:input) { "Foo::BarBaz" }
|
9
|
-
let(:output) { [:assertion, :"foo/bar_baz"] }
|
10
|
-
|
11
|
-
it "doesn't mutate the input" do
|
12
|
-
expect { subject }.not_to change { input }
|
13
|
-
end
|
14
|
-
|
15
|
-
it "returns the class scope" do
|
16
|
-
expect(subject).to eql output
|
17
|
-
end
|
18
|
-
|
19
|
-
end # describe Assertion::I18n#scope
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
describe Assertion::I18n, "#translate" do
|
4
|
-
|
5
|
-
subject { fn[input] }
|
6
|
-
|
7
|
-
let(:fn) { described_class[:translate, scope, args] }
|
8
|
-
let(:args) { { foo: :FOO } }
|
9
|
-
let(:scope) { double }
|
10
|
-
let(:input) { double }
|
11
|
-
let(:output) { double }
|
12
|
-
|
13
|
-
before do
|
14
|
-
allow(::I18n)
|
15
|
-
.to receive(:t)
|
16
|
-
.with(input, foo: :FOO, scope: scope)
|
17
|
-
.and_return output
|
18
|
-
end
|
19
|
-
|
20
|
-
it "doesn't mutate the input" do
|
21
|
-
expect { subject }.not_to change { input }
|
22
|
-
end
|
23
|
-
|
24
|
-
it "returns the string converted to snake case" do
|
25
|
-
expect(subject).to eql output
|
26
|
-
end
|
27
|
-
|
28
|
-
end # describe Assertion::I18n#translate
|