hexx 7.1.0 → 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +2 -0
- data/.gitignore +9 -0
- data/.metrics +5 -0
- data/.rspec +2 -0
- data/.rubocop.yml +2 -63
- data/.travis.yml +5 -0
- data/.yardopts +2 -0
- data/Gemfile +3 -0
- data/Guardfile +16 -0
- data/{LICENSE.rdoc → LICENSE} +2 -2
- data/README.md +138 -0
- data/Rakefile +8 -14
- data/config/initializer.rb +5 -0
- data/config/initializers/capture.rb +19 -0
- data/config/initializers/sandbox.rb +16 -0
- data/config/initializers/sandbox/helpers.rb +38 -0
- data/config/initializers/sandbox/matchers.rb +19 -0
- data/config/metrics/STYLEGUIDE +230 -0
- data/config/metrics/cane.yml +5 -0
- data/config/metrics/churn.yml +6 -0
- data/config/metrics/flay.yml +2 -0
- data/config/metrics/metric_fu.yml +15 -0
- data/config/metrics/pippi.yml +3 -0
- data/config/metrics/reek.yml +1 -0
- data/config/metrics/roodi.yml +24 -0
- data/config/metrics/rubocop.yml +79 -0
- data/config/metrics/saikuro.yml +3 -0
- data/config/metrics/simplecov.yml +6 -0
- data/config/metrics/yardstick.yml +37 -0
- data/hexx.gemspec +24 -0
- data/lib/hexx.rb +8 -15
- data/lib/hexx/generator.rb +71 -0
- data/lib/hexx/generator/file.rb +83 -0
- data/lib/hexx/generator/folder.rb +68 -0
- data/lib/hexx/name.rb +122 -46
- data/lib/hexx/version.rb +6 -5
- data/spec/fixtures/root/_.beta +1 -0
- data/spec/fixtures/root/__omega +0 -0
- data/spec/fixtures/root/delta.erb.erb +0 -0
- data/spec/fixtures/root/gamma.rb.erb +1 -0
- data/spec/fixtures/root/subfolder/alfa.yml +0 -0
- data/spec/spec_helper.rb +5 -10
- data/spec/tests/lib/generator_spec.rb +126 -0
- data/spec/tests/lib/name_spec.rb +113 -0
- metadata +54 -168
- data/README.rdoc +0 -371
- data/lib/hexx/coercible.rb +0 -43
- data/lib/hexx/configurable.rb +0 -101
- data/lib/hexx/creators/base.rb +0 -103
- data/lib/hexx/creators/coercion.rb +0 -82
- data/lib/hexx/creators/dependency.rb +0 -87
- data/lib/hexx/creators/module_dependency.rb +0 -57
- data/lib/hexx/creators/parameter.rb +0 -40
- data/lib/hexx/dependable.rb +0 -51
- data/lib/hexx/helpers/exceptions.rb +0 -53
- data/lib/hexx/helpers/messages.rb +0 -26
- data/lib/hexx/helpers/parameters.rb +0 -47
- data/lib/hexx/helpers/validations.rb +0 -21
- data/lib/hexx/message.rb +0 -79
- data/lib/hexx/null.rb +0 -218
- data/lib/hexx/service.rb +0 -388
- data/lib/hexx/service/with_callbacks.rb +0 -104
- data/lib/hexx/service_invalid.rb +0 -73
- data/spec/hexx/coercible_spec.rb +0 -72
- data/spec/hexx/configurable_spec.rb +0 -93
- data/spec/hexx/dependable_spec.rb +0 -125
- data/spec/hexx/helpers/exceptions_spec.rb +0 -96
- data/spec/hexx/helpers/messages_spec.rb +0 -48
- data/spec/hexx/helpers/parameters_spec.rb +0 -96
- data/spec/hexx/helpers/validations_spec.rb +0 -32
- data/spec/hexx/message_spec.rb +0 -83
- data/spec/hexx/name_spec.rb +0 -80
- data/spec/hexx/null_spec.rb +0 -152
- data/spec/hexx/service_invalid_spec.rb +0 -46
- data/spec/hexx/service_spec.rb +0 -89
- data/spec/support/initializers/focus.rb +0 -5
- data/spec/support/initializers/garbage_collection.rb +0 -11
- data/spec/support/initializers/i18n.rb +0 -3
- data/spec/support/initializers/random_order.rb +0 -4
- data/spec/support/initializers/rspec.rb +0 -5
- data/spec/support/matchers/methods.rb +0 -11
@@ -1,46 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
module Hexx
|
4
|
-
describe ServiceInvalid do
|
5
|
-
|
6
|
-
let(:service) { Service.new }
|
7
|
-
let(:error) { Hexx::Message.new(type: "error", text: "some error") }
|
8
|
-
|
9
|
-
describe ".new" do
|
10
|
-
|
11
|
-
subject { Invalid }
|
12
|
-
|
13
|
-
it "fails if no arguments given" do
|
14
|
-
expect { described_class.new }.to raise_error ArgumentError
|
15
|
-
end
|
16
|
-
|
17
|
-
it "initializes the #service" do
|
18
|
-
expect { described_class.new Service.new }.not_to raise_error
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "#messages" do
|
23
|
-
|
24
|
-
subject { described_class.new(service).messages }
|
25
|
-
let(:message) { subject.first }
|
26
|
-
|
27
|
-
it "returns an array" do
|
28
|
-
expect(subject).to be_kind_of Array
|
29
|
-
end
|
30
|
-
|
31
|
-
it "returns error messages" do
|
32
|
-
service.errors.send :add, :base, error.text
|
33
|
-
expect(message).to eq error
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe "#message" do
|
38
|
-
|
39
|
-
subject { described_class.new(service).message }
|
40
|
-
|
41
|
-
it "returns a proper message" do
|
42
|
-
expect(subject).to eq "Service invalid: #{ service.inspect }"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
data/spec/hexx/service_spec.rb
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
module Hexx
|
4
|
-
describe Service do
|
5
|
-
|
6
|
-
around :each do |example|
|
7
|
-
class Test < Service
|
8
|
-
attr_reader :on_something, :something
|
9
|
-
private :on_something, :something
|
10
|
-
end
|
11
|
-
example.run
|
12
|
-
Hexx.send :remove_const, :Test
|
13
|
-
end
|
14
|
-
|
15
|
-
let!(:described_class) { Test }
|
16
|
-
|
17
|
-
it "includes Whisper::Publisher" do
|
18
|
-
expect(subject).to be_kind_of Wisper::Publisher
|
19
|
-
end
|
20
|
-
|
21
|
-
it "includes helpers from Parameters" do
|
22
|
-
expect(described_class).to include Hexx::Helpers::Parameters
|
23
|
-
expect(described_class).to have_private_method :allow_params
|
24
|
-
expect(subject).to have_private_method :params
|
25
|
-
end
|
26
|
-
|
27
|
-
it "includes helpers from Messages" do
|
28
|
-
expect(described_class).to include Hexx::Helpers::Messages
|
29
|
-
expect(subject).to have_public_method :messages
|
30
|
-
expect(subject).to have_private_method :add_message
|
31
|
-
expect(subject).to have_private_method :t
|
32
|
-
end
|
33
|
-
|
34
|
-
it "includes helpers from Validations" do
|
35
|
-
expect(described_class).to include Hexx::Helpers::Validations
|
36
|
-
expect(subject).to have_private_method :validate!
|
37
|
-
end
|
38
|
-
|
39
|
-
it "includes helpers from Exceptions" do
|
40
|
-
expect(described_class).to include Hexx::Helpers::Exceptions
|
41
|
-
expect(described_class).to have_private_method :raises
|
42
|
-
expect(subject).to have_private_method :on_error
|
43
|
-
expect(subject).to have_private_method :escape
|
44
|
-
end
|
45
|
-
|
46
|
-
it "doesn't extend Hexx::Dependable by default" do
|
47
|
-
expect(described_class).not_to be_kind_of Hexx::Dependable
|
48
|
-
end
|
49
|
-
|
50
|
-
describe ".new" do
|
51
|
-
|
52
|
-
before { described_class.send :allow_params, :name }
|
53
|
-
subject { described_class.new(name: "name", code: "code") }
|
54
|
-
|
55
|
-
it "assigns params properly" do
|
56
|
-
expect(subject.send :params).to eq("name" => "name")
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "#run" do
|
61
|
-
|
62
|
-
it "is defined" do
|
63
|
-
expect(subject).to respond_to :run
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe "##run_service" do
|
68
|
-
|
69
|
-
def service_spy(result)
|
70
|
-
object = described_class.new
|
71
|
-
allow(object).to receive(:run) { object.send :publish, result }
|
72
|
-
class_spy described_class.name, new: object
|
73
|
-
end
|
74
|
-
|
75
|
-
let(:other_service_class) { service_spy :result }
|
76
|
-
before { allow(subject).to receive(:on_service_result) }
|
77
|
-
|
78
|
-
it "if wrong class given it fails with TypeError" do
|
79
|
-
expect { subject.send :run_service, String, :on_string }
|
80
|
-
.to raise_error { TypeError }
|
81
|
-
end
|
82
|
-
|
83
|
-
it "receives notifications from a service object" do
|
84
|
-
subject.send :run_service, other_service_class, :on_service
|
85
|
-
expect(subject).to have_received(:on_service_result)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
RSpec::Matchers.define :have_private_method do |name|
|
2
|
-
match do |object|
|
3
|
-
expect(object.private_methods).to include(name)
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
RSpec::Matchers.define :have_public_method do |name|
|
8
|
-
match do |object|
|
9
|
-
expect(object.public_methods).to include(name)
|
10
|
-
end
|
11
|
-
end
|