assertion 0.1.0 → 0.2.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 +17 -0
- data/Gemfile +0 -2
- data/Guardfile +6 -6
- data/README.md +8 -6
- data/assertion.gemspec +1 -1
- data/config/metrics/flay.yml +1 -1
- data/lib/assertion.rb +29 -80
- data/lib/assertion/base.rb +38 -64
- data/lib/assertion/base_dsl.rb +75 -0
- data/lib/assertion/dsl.rb +77 -0
- data/lib/assertion/guard.rb +1 -30
- data/lib/assertion/guard_dsl.rb +39 -0
- data/lib/assertion/{transprocs/inflector.rb → inflector.rb} +0 -0
- data/lib/assertion/inversion.rb +3 -3
- data/lib/assertion/inverter.rb +2 -2
- data/lib/assertion/translator.rb +95 -0
- data/lib/assertion/version.rb +1 -1
- data/spec/integration/guard_spec.rb +1 -1
- data/spec/shared/en.yml +4 -4
- data/spec/unit/assertion/base_spec.rb +124 -14
- data/spec/unit/assertion/guard_spec.rb +37 -13
- data/spec/unit/assertion/{transprocs/inflector → inflector}/to_path_spec.rb +0 -0
- data/spec/unit/assertion/{transprocs/inflector → inflector}/to_snake_path_spec.rb +0 -0
- data/spec/unit/assertion/{transprocs/inflector → inflector}/to_snake_spec.rb +0 -0
- data/spec/unit/assertion/{exceptions/invalid_error_spec.rb → invalid_error_spec.rb} +0 -0
- data/spec/unit/assertion/inversion_spec.rb +5 -5
- data/spec/unit/assertion/inverter_spec.rb +2 -2
- data/spec/unit/assertion/translator_spec.rb +57 -0
- metadata +23 -20
- data/lib/assertion/attributes.rb +0 -54
- data/lib/assertion/messages.rb +0 -65
- data/lib/assertion/transprocs/list.rb +0 -30
- data/spec/unit/assertion/attributes_spec.rb +0 -97
- data/spec/unit/assertion/messages_spec.rb +0 -41
- data/spec/unit/assertion/transprocs/list/symbolize_spec.rb +0 -19
@@ -1,41 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
describe Assertion::Messages, "#message" do
|
4
|
-
|
5
|
-
let(:test_klass) { Test = Class.new { include Assertion::Messages } }
|
6
|
-
let(:instance) { test_klass.new }
|
7
|
-
|
8
|
-
shared_examples "translating" do |state, as: nil|
|
9
|
-
|
10
|
-
subject(:message) { instance.message(state) }
|
11
|
-
|
12
|
-
it { is_expected.to eql "translation missing: en.assertion.test.#{as}" }
|
13
|
-
|
14
|
-
it "sends attributes to translation" do
|
15
|
-
expect(I18n).to receive(:translate) do |_, args|
|
16
|
-
expect(args.merge(instance.attributes)).to eql args
|
17
|
-
end
|
18
|
-
subject
|
19
|
-
end
|
20
|
-
|
21
|
-
end # shared examples
|
22
|
-
|
23
|
-
context "without attributes" do
|
24
|
-
|
25
|
-
it_behaves_like "translating", true, as: "right"
|
26
|
-
it_behaves_like "translating", false, as: "wrong"
|
27
|
-
|
28
|
-
end # context
|
29
|
-
|
30
|
-
context "with attributes" do
|
31
|
-
|
32
|
-
before { test_klass.send(:define_method, :attributes) { { foo: :FOO } } }
|
33
|
-
|
34
|
-
it_behaves_like "translating", true, as: "right"
|
35
|
-
it_behaves_like "translating", false, as: "wrong"
|
36
|
-
|
37
|
-
end # context
|
38
|
-
|
39
|
-
after { Object.send :remove_const, :Test }
|
40
|
-
|
41
|
-
end # describe Assertion::Messages
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
describe Assertion::List, "#symbolize" do
|
4
|
-
|
5
|
-
subject { fn[input] }
|
6
|
-
|
7
|
-
let(:fn) { described_class[:symbolize] }
|
8
|
-
let(:input) { [[:foo, "bar"], "foo"] }
|
9
|
-
let(:output) { [:foo, :bar] }
|
10
|
-
|
11
|
-
it "doesn't mutate the input" do
|
12
|
-
expect { subject }.not_to change { input }
|
13
|
-
end
|
14
|
-
|
15
|
-
it "returns the string converted to snake case" do
|
16
|
-
expect(subject).to eql output
|
17
|
-
end
|
18
|
-
|
19
|
-
end # describe Assertion::List#symbolize
|