sails 0.1.1 → 0.1.2
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/.gitignore +1 -0
- data/CHANGELOG.md +8 -1
- data/README.md +1 -1
- data/lib/sails/base.rb +23 -42
- data/lib/sails/cli.rb +1 -2
- data/lib/sails/daemon.rb +29 -16
- data/lib/sails/service/base.rb +17 -12
- data/lib/sails/service/callbacks.rb +28 -0
- data/lib/sails/service/interface.rb +18 -5
- data/lib/sails/service.rb +1 -0
- data/lib/sails/version.rb +1 -1
- data/spec/cli_spec.rb +1 -2
- data/spec/dummy/log/development.log +1402 -0
- data/spec/sails_spec.rb +1 -1
- data/spec/service/base_spec.rb +48 -0
- data/spec/service/callbacks_spec.rb +47 -0
- data/spec/spec_helper.rb +4 -1
- data/spec/support/service_support.rb +13 -0
- metadata +9 -4
- data/spec/service_spec.rb +0 -38
data/spec/sails_spec.rb
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Service' do
|
4
|
+
describe 'Base' do
|
5
|
+
class SimpleBaseTestService < Sails::Service::Base
|
6
|
+
def foo
|
7
|
+
end
|
8
|
+
|
9
|
+
def bar(a, b)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
def dar
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:simple) { SimpleBaseTestService.new }
|
18
|
+
|
19
|
+
describe '.raise_error' do
|
20
|
+
it { expect(simple).to respond_to(:raise_error) }
|
21
|
+
it {
|
22
|
+
expect { simple.raise_error(11,'foo') }.to raise_error do |error|
|
23
|
+
expect(error).to be_a(Sails::Service::Exception)
|
24
|
+
expect(error.code).to eq 11
|
25
|
+
expect(error.message).to eq 'foo'
|
26
|
+
end
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '.action_methods' do
|
31
|
+
it { expect(simple.action_methods).to include("foo", "bar") }
|
32
|
+
it { expect(simple.action_methods.size).to eq 2 }
|
33
|
+
it { expect(simple.action_methods).not_to include("dar") }
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '.logger' do
|
37
|
+
it { expect(simple.logger).to eq Sails.logger }
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '.params' do
|
41
|
+
it { expect(simple.params).to eq({}) }
|
42
|
+
it "should set val" do
|
43
|
+
simple.params[:foo] = 111
|
44
|
+
expect(simple.params).to eq({ foo: 111 })
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Service' do
|
4
|
+
describe 'Callbacks' do
|
5
|
+
context 'callback with method_name' do
|
6
|
+
class CallbackTest1Service < Sails::Service::Base
|
7
|
+
before_action :bar, :dar
|
8
|
+
def bar; end
|
9
|
+
def dar; end
|
10
|
+
def foo; end
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:simple) { CallbackTest1Service.new }
|
14
|
+
|
15
|
+
before do
|
16
|
+
insert_service(simple)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should work' do
|
20
|
+
expect(simple).to receive(:bar).once
|
21
|
+
expect(simple).to receive(:dar).once
|
22
|
+
service.foo
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'params' do
|
27
|
+
class CallbackTest3Service < Sails::Service::Base
|
28
|
+
def foo(a, b)
|
29
|
+
return params
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
let(:simple) { CallbackTest3Service.new }
|
34
|
+
|
35
|
+
before do
|
36
|
+
insert_service(simple)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should work" do
|
40
|
+
params = service.foo(1,2)
|
41
|
+
expect(params).to include(:a, :b)
|
42
|
+
expect(params[:a]).to eq 1
|
43
|
+
expect(params[:b]).to eq 2
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -14,8 +14,11 @@ module Sails
|
|
14
14
|
config.cache_store = [:dalli_store, '127.0.0.1']
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
Dir["./spec/support/**/*.rb"].each { |f| require f }
|
18
18
|
|
19
|
+
RSpec.configure do |config|
|
20
|
+
config.include ServiceSupport, file_path: /spec\/service/
|
21
|
+
|
19
22
|
config.before(:each) do
|
20
23
|
end
|
21
24
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Lee
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2014-12-
|
15
|
+
date: 2014-12-17 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: activesupport
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- lib/sails/rails.rb
|
86
86
|
- lib/sails/service.rb
|
87
87
|
- lib/sails/service/base.rb
|
88
|
+
- lib/sails/service/callbacks.rb
|
88
89
|
- lib/sails/service/exception.rb
|
89
90
|
- lib/sails/service/interface.rb
|
90
91
|
- lib/sails/templates/%app_name%.thrift.tt
|
@@ -110,8 +111,10 @@ files:
|
|
110
111
|
- spec/dummy/log/development.log
|
111
112
|
- spec/rails_spec.rb
|
112
113
|
- spec/sails_spec.rb
|
113
|
-
- spec/
|
114
|
+
- spec/service/base_spec.rb
|
115
|
+
- spec/service/callbacks_spec.rb
|
114
116
|
- spec/spec_helper.rb
|
117
|
+
- spec/support/service_support.rb
|
115
118
|
homepage: https://github.com/huacnlee/sails
|
116
119
|
licenses:
|
117
120
|
- MIT
|
@@ -141,6 +144,8 @@ test_files:
|
|
141
144
|
- spec/dummy/log/development.log
|
142
145
|
- spec/rails_spec.rb
|
143
146
|
- spec/sails_spec.rb
|
144
|
-
- spec/
|
147
|
+
- spec/service/base_spec.rb
|
148
|
+
- spec/service/callbacks_spec.rb
|
145
149
|
- spec/spec_helper.rb
|
150
|
+
- spec/support/service_support.rb
|
146
151
|
has_rdoc:
|
data/spec/service_spec.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe 'Service' do
|
4
|
-
class SimpleService < Sails::Service::Base
|
5
|
-
def foo
|
6
|
-
end
|
7
|
-
|
8
|
-
def bar
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
def dar
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
let(:simple) { SimpleService.new }
|
17
|
-
|
18
|
-
describe '.raise_error' do
|
19
|
-
it { expect(simple).to respond_to(:raise_error) }
|
20
|
-
it {
|
21
|
-
expect { simple.raise_error(11,'foo') }.to raise_error do |error|
|
22
|
-
expect(error).to be_a(Sails::Service::Exception)
|
23
|
-
expect(error.code).to eq 11
|
24
|
-
expect(error.message).to eq 'foo'
|
25
|
-
end
|
26
|
-
}
|
27
|
-
end
|
28
|
-
|
29
|
-
describe '.action_methods' do
|
30
|
-
it { expect(simple.action_methods).to include("foo", "bar") }
|
31
|
-
it { expect(simple.action_methods.size).to eq 2 }
|
32
|
-
it { expect(simple.action_methods).not_to include("dar") }
|
33
|
-
end
|
34
|
-
|
35
|
-
describe '.logger' do
|
36
|
-
it { expect(simple.logger).to eq Sails.logger }
|
37
|
-
end
|
38
|
-
end
|