assertion 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -0
  3. data/Gemfile +0 -2
  4. data/Guardfile +6 -6
  5. data/README.md +8 -6
  6. data/assertion.gemspec +1 -1
  7. data/config/metrics/flay.yml +1 -1
  8. data/lib/assertion.rb +29 -80
  9. data/lib/assertion/base.rb +38 -64
  10. data/lib/assertion/base_dsl.rb +75 -0
  11. data/lib/assertion/dsl.rb +77 -0
  12. data/lib/assertion/guard.rb +1 -30
  13. data/lib/assertion/guard_dsl.rb +39 -0
  14. data/lib/assertion/{transprocs/inflector.rb → inflector.rb} +0 -0
  15. data/lib/assertion/inversion.rb +3 -3
  16. data/lib/assertion/inverter.rb +2 -2
  17. data/lib/assertion/translator.rb +95 -0
  18. data/lib/assertion/version.rb +1 -1
  19. data/spec/integration/guard_spec.rb +1 -1
  20. data/spec/shared/en.yml +4 -4
  21. data/spec/unit/assertion/base_spec.rb +124 -14
  22. data/spec/unit/assertion/guard_spec.rb +37 -13
  23. data/spec/unit/assertion/{transprocs/inflector → inflector}/to_path_spec.rb +0 -0
  24. data/spec/unit/assertion/{transprocs/inflector → inflector}/to_snake_path_spec.rb +0 -0
  25. data/spec/unit/assertion/{transprocs/inflector → inflector}/to_snake_spec.rb +0 -0
  26. data/spec/unit/assertion/{exceptions/invalid_error_spec.rb → invalid_error_spec.rb} +0 -0
  27. data/spec/unit/assertion/inversion_spec.rb +5 -5
  28. data/spec/unit/assertion/inverter_spec.rb +2 -2
  29. data/spec/unit/assertion/translator_spec.rb +57 -0
  30. metadata +23 -20
  31. data/lib/assertion/attributes.rb +0 -54
  32. data/lib/assertion/messages.rb +0 -65
  33. data/lib/assertion/transprocs/list.rb +0 -30
  34. data/spec/unit/assertion/attributes_spec.rb +0 -97
  35. data/spec/unit/assertion/messages_spec.rb +0 -41
  36. 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