actionfacade 0.2.2 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64d3cea1d22a692b72218f19db02d5d39de09d53a3a5fc98da0803d9bbd217bb
4
- data.tar.gz: 94ce319ac7540e225e535e89aef50e636359a00c02d1c8bc9ad21cb799767bd2
3
+ metadata.gz: 254de0962aa168621e443a7a14c7e4453f5f2c2274f04648bb6026f45699f108
4
+ data.tar.gz: 88829fc832f6ea5d6056395e0e4ce1bb28da6933b27521e39d0ed00996086863
5
5
  SHA512:
6
- metadata.gz: 6ad6c5032c237f64311a7efd20e8fa26e3ae612a7ccc9e1e258aa8d325c8aa20825de3b1e42dc346ecd10b1c9b3d39ed89a6785e18e031806d9b12d051b37701
7
- data.tar.gz: d141b6a9fccad09c49dc57eb6d20835be189c3064edfc016f75e1a851a37890ac13f90c14297933d685454b6ce1200d788383573ba888f879ff1ca8aa7c32366
6
+ metadata.gz: f0c6b513755215cdea05f2086c9dddf6e2ee66ee97b4f460dd1eee85dd26e080d105da6ae1144f11d8e992f154398e68f9df7ed5b442b530517db4ce06d5800d
7
+ data.tar.gz: f8ede72602f4e8eb948a95450c8af11b498f19a56f12e360b1ecfa23a24833c25e26adad21f99d837809c9b74045859592cd2507b0e7c58b4938e2bad4b78424
@@ -1,5 +1,4 @@
1
- require "test/unit"
2
- require_relative "../lib/actionfacade"
1
+ require_relative "./test_helper"
3
2
 
4
3
  class BaseTest < Test::Unit::TestCase
5
4
  test ".new does not raise error" do
@@ -1,5 +1,4 @@
1
- require "test/unit"
2
- require_relative "../lib/actionfacade"
1
+ require_relative "./test_helper"
3
2
 
4
3
  class UserFacade < ActionFacade::Base
5
4
  USER_DATA = [{ id: 1, name: "john" }, { id: 2, name: "taro" }]
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../test_helper"
4
+ require_relative "./test_app"
5
+
6
+ module RailsApp
7
+ USER_DATA = [{ id: 1, name: "john" }, { id: 2, name: "bob" }]
8
+ end
9
+
10
+ module Home; end
11
+
12
+ class Home::IndexFacade < ActionFacade::Base
13
+ def all_users
14
+ RailsApp::USER_DATA
15
+ end
16
+ end
17
+
18
+ class HomeController < ActionController::Base
19
+ include Rails.application.routes.url_helpers
20
+ include ActionFacade::Retrieval
21
+
22
+ def index
23
+ retrieve_from({}, :all_users)
24
+ render plain: @all_users
25
+ end
26
+ end
27
+
28
+ require "rack/test"
29
+
30
+ module RailsApp; end
31
+
32
+ class RailsApp::RetrievalTest < Test::Unit::TestCase
33
+ include Rack::Test::Methods
34
+
35
+ test "@all_users is set after retrieve_from({}, :all_users)" do
36
+ get "/"
37
+ assert_equal(last_response.body, USER_DATA.to_s)
38
+ end
39
+
40
+ private
41
+
42
+ def app
43
+ Rails.application
44
+ end
45
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "action_controller/railtie"
4
+
5
+ class TestApp < Rails::Application
6
+ config.root = __dir__
7
+ config.hosts << "example.org"
8
+ secrets.secret_key_base = "secret_key_base"
9
+
10
+ config.logger = Logger.new($stdout)
11
+ Rails.logger = config.logger
12
+
13
+ routes.draw do
14
+ get "/" => "home#index"
15
+ end
16
+ end
@@ -1,6 +1,4 @@
1
- require "test/unit"
2
- require_relative "../lib/action_facade/base.rb"
3
- require_relative "../lib/action_facade/retrieval.rb"
1
+ require_relative "./test_helper"
4
2
 
5
3
  USER_DATA = [{ id: 1, name: "john" }, { id: 2, name: "bob" }]
6
4
 
@@ -35,23 +33,6 @@ class UsersController
35
33
  end
36
34
  end
37
35
 
38
- class AdminController
39
- include ActionFacade::Retrieval
40
-
41
- attr_reader :bob
42
-
43
- def show
44
- payload = {}
45
- retrieve_from(payload, :bob)
46
- end
47
-
48
- private
49
-
50
- def params
51
- { action: 'show' }
52
- end
53
- end
54
-
55
36
  class RetrievalTest < Test::Unit::TestCase
56
37
  test ".show does not raise error" do
57
38
  assert_nothing_raised { UsersController.new.show }
@@ -70,11 +51,4 @@ class RetrievalTest < Test::Unit::TestCase
70
51
  controller.show_from
71
52
  assert_equal(controller.john, { id: 1, name: "john" })
72
53
  end
73
-
74
- test "@bob is set after retrieve_from(payload, :bob)" do
75
- controller = AdminController.new
76
- assert_nil(controller.bob)
77
- controller.show
78
- assert_equal(controller.bob, { id: 2, name: "bob" })
79
- end
80
54
  end
@@ -0,0 +1,2 @@
1
+ require "test/unit"
2
+ require_relative "../lib/actionfacade"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionfacade
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Hashimoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-08 00:00:00.000000000 Z
11
+ date: 2020-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,7 +80,10 @@ files:
80
80
  - lib/actionfacade.rb
81
81
  - test/base_test.rb
82
82
  - test/inheritance_test.rb
83
+ - test/rails_app/retrieval_test.rb
84
+ - test/rails_app/test_app.rb
83
85
  - test/retrieval_test.rb
86
+ - test/test_helper.rb
84
87
  homepage: https://github.com/ryohashimoto/lightrails
85
88
  licenses:
86
89
  - MIT
@@ -108,4 +111,7 @@ summary: Action Facade provides a simple interface for data required by view / c
108
111
  test_files:
109
112
  - test/base_test.rb
110
113
  - test/inheritance_test.rb
114
+ - test/rails_app/retrieval_test.rb
115
+ - test/rails_app/test_app.rb
111
116
  - test/retrieval_test.rb
117
+ - test/test_helper.rb