heks 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/lib/generators/heks/templates/use_case.rb.erb +4 -6
  3. data/lib/heks/version.rb +1 -1
  4. data/test/dummy/app/controllers/cats_controller.rb +39 -0
  5. data/test/dummy/app/hexagon/cat.rb +13 -0
  6. data/test/dummy/app/hexagon/repository/adapters/ar/cat.rb +36 -0
  7. data/test/dummy/app/hexagon/repository/adapters/ar/data/cat.rb +4 -0
  8. data/test/dummy/app/hexagon/repository/database/cat.rb +54 -0
  9. data/test/dummy/app/hexagon/repository/memory/cat.rb +40 -0
  10. data/test/dummy/app/hexagon/use_case/blog_post.rb +20 -0
  11. data/test/dummy/app/hexagon/use_case/blog_posts.rb +20 -0
  12. data/test/dummy/app/hexagon/use_case/create_blog_post.rb +3 -5
  13. data/test/dummy/app/hexagon/use_case/create_cat.rb +20 -0
  14. data/test/dummy/app/hexagon/use_case/delete_blog_post.rb +3 -5
  15. data/test/dummy/app/hexagon/use_case/delete_cat.rb +20 -0
  16. data/test/dummy/app/hexagon/use_case/list_blog_posts.rb +3 -5
  17. data/test/dummy/app/hexagon/use_case/list_cats.rb +20 -0
  18. data/test/dummy/app/hexagon/use_case/read_blog_post.rb +3 -5
  19. data/test/dummy/app/hexagon/use_case/read_cat.rb +20 -0
  20. data/test/dummy/app/hexagon/use_case/update_blog_post.rb +3 -5
  21. data/test/dummy/app/hexagon/use_case/update_cat.rb +20 -0
  22. data/test/dummy/db/migrate/20150914164840_create_cats.rb +8 -0
  23. data/test/dummy/spec/hexagon/cat_spec.rb +6 -0
  24. data/test/dummy/spec/hexagon/repository/adapters/ar/cat_spec.rb +0 -0
  25. data/test/dummy/spec/hexagon/repository/adapters/ar/data/cat_spec.rb +0 -0
  26. data/test/dummy/spec/hexagon/repository/database/cat_spec.rb +54 -0
  27. data/test/dummy/spec/hexagon/repository/memory/cat_spec.rb +40 -0
  28. data/test/dummy/spec/hexagon/use_case/blog_post_spec.rb +20 -0
  29. data/test/dummy/spec/hexagon/use_case/blog_posts_spec.rb +20 -0
  30. data/test/dummy/spec/hexagon/use_case/create_cat_spec.rb +20 -0
  31. data/test/dummy/spec/hexagon/use_case/delete_cat_spec.rb +20 -0
  32. data/test/dummy/spec/hexagon/use_case/list_cats_spec.rb +20 -0
  33. data/test/dummy/spec/hexagon/use_case/read_cat_spec.rb +20 -0
  34. data/test/dummy/spec/hexagon/use_case/update_cat_spec.rb +20 -0
  35. metadata +53 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48c97ea7d9421eb5fe570b5caf23df3d5864a0b0
4
- data.tar.gz: 02fd4803d8f68dbee4dd3eaa906e79b3eeea49ef
3
+ metadata.gz: 600e1de43b99da484bd51c5bbc97756df3c0775d
4
+ data.tar.gz: 41e3390aa17cc38fcca6c1ca0a5de7b093c0ff9a
5
5
  SHA512:
6
- metadata.gz: 564d2d0e8b66b198343ecf463cc55b6319f8d650d8d6bba2c416163e9da76b70e5ebf7ac4d69aa859018acc325fdeb0998daef6a7b78bc2d1ccff2e74562d723
7
- data.tar.gz: afdc402dc7c30d00d64d9957c483014e31486343172a510275dd8bf1d4a1b85142f9e1d4bc658c54d8b307b6ab23b147ce11153ab7864fbcc6590392ca37d79b
6
+ metadata.gz: 584c6ecbda526f8e3ab550589bb6249c21a1022abc58e6935c971b539103a85d6627cccc2569f9a188cde77e772cd00133f58ab4136bc1c2f5b1119d02d2d3b5
7
+ data.tar.gz: b5bea9688def002d79f042ed840e7d99f7c52359fc846f122edd76e51293a4bf4ea612ba36b6766933dc641011771c99e8455d838aafe788ad910e4d5b7e8251
@@ -1,18 +1,16 @@
1
1
  module UseCase
2
2
  class <%= file_name.camelize %>
3
- attr_accessor :repository_name
4
-
5
3
  def initialize(listener, repository=nil)
6
4
  @listener = listener
7
- @repository = (repository || Repository::Memory::<%= file_name.camelize %>).new(self)
5
+ @repository = (repository || Repository::Memory::<%= repository_name.camelize %>).new(self)
8
6
  end
9
7
 
10
- def <%= file_name.split('_').first %> <%= parameters.join(", ") %>
8
+ def <%= repository_action %> <%= parameters.join(", ") %>
11
9
  @repository.<%= repository_action %> <%= parameters.join(", ") %>
12
10
  end
13
11
 
14
- def <%= repository_name %>_repository_<%= repository_action %>_success(<%= file_name %>)
15
- @listener.<%= file_name %>_success(<%= file_name %>)
12
+ def <%= repository_name %>_repository_<%= repository_action %>_success(<%= repository_name %>)
13
+ @listener.<%= file_name %>_success(<%= repository_name %>)
16
14
  end
17
15
 
18
16
  def <%= repository_name %>_repository_<%= repository_action %>_failure
@@ -1,3 +1,3 @@
1
1
  module Heks
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -0,0 +1,39 @@
1
+ class CatsController < ApplicationController
2
+ before_filter -> { @command_driver = Heks::Driver.new(self) }
3
+
4
+ def index
5
+ @command_driver[:list_cats].list
6
+ end
7
+
8
+ def new
9
+ @cat = Cat.new
10
+ end
11
+
12
+ def create
13
+ @command_driver[:create_cat].create(cat_attributes)
14
+ end
15
+
16
+ def edit
17
+ @command_driver[:read_cat].read(params[:id])
18
+ end
19
+
20
+ def update
21
+ @command_driver[:update_cat].update(params[:id], cat_attributes)
22
+ end
23
+
24
+ def destroy
25
+ @command_driver[:delete_cat].update(params[:id], cat_attributes)
26
+ end
27
+
28
+ private
29
+
30
+ listen_for(:list_cats_success) { |cats| @cats = cats }
31
+ listen_for(:create_cat_success) { |cat| redirect_to cats_path }
32
+ listen_for(:update_cat_success) { |cat| redirect_to cats_path }
33
+ listen_for(:read_cat_success) { |cat| @cat = cat }
34
+ listen_for(:destroy_cat_success){ |cat| redirect_to cats_path }
35
+
36
+ def cat_attributes
37
+ params.require(:cat).permit(:name, :age)
38
+ end
39
+ end
@@ -0,0 +1,13 @@
1
+ class Cat
2
+ include ActiveModel::Model
3
+ attr_accessor :attributes, :id, :name, :age
4
+
5
+ def initialize(attributes={})
6
+ @attributes = attributes
7
+ super(attributes)
8
+ end
9
+
10
+ def persisted?
11
+ id.present?
12
+ end
13
+ end
@@ -0,0 +1,36 @@
1
+ module Repository::Adapters::AR
2
+ class Cat
3
+ def initialize(listener)
4
+ @listener = listener
5
+ @data = Repository::Adapters::AR::Data::Cat
6
+ end
7
+
8
+ def read id
9
+ @listener.cat_adapter_read_success(
10
+ ::Cat.new(@data.find(id).attributes))
11
+ end
12
+
13
+ def create(attributes)
14
+ @listener.cat_adapter_create_success(
15
+ ::Cat.new(@data.create(attributes).attributes))
16
+ end
17
+
18
+ def update(id, attributes)
19
+ record = @data.find(id)
20
+ record.update_attributes(attributes)
21
+
22
+ @listener.cat_adapter_update_success(
23
+ ::Cat.new(record.attributes)
24
+ )
25
+ end
26
+
27
+ def list
28
+ @listener.cat_adapter_list_success(@data.all)
29
+ end
30
+
31
+ def all
32
+ @listener.cat_adapter_all_success(
33
+ @data.all.map {|cat| ::Cat.new(cat.attributes)})
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,4 @@
1
+ module Repository::Adapters::AR::Data
2
+ class Cat < ActiveRecord::Base
3
+ end
4
+ end
@@ -0,0 +1,54 @@
1
+ module Repository
2
+ module Database
3
+ class Cat
4
+ def initialize(listener = nil)
5
+ @listener = listener
6
+ @adapter = Repository::Adapters::AR::Cat.new(self)
7
+ @model = ::Cat
8
+ end
9
+
10
+ def create(attributes)
11
+ @model.new(attributes).tap do |cat|
12
+ return unless cat.valid?
13
+ @adapter.create(cat.attributes)
14
+ end
15
+ end
16
+
17
+ def cat_adapter_create_success(sequence)
18
+ @listener.cat_repository_create_success(sequence)
19
+ end
20
+
21
+ def list
22
+ @listener.cat_repository_list_success(@adapter.list)
23
+ end
24
+
25
+ def count
26
+ @model.count
27
+ end
28
+
29
+ def update(id, attributes)
30
+ @adapter.update(id, attributes)
31
+ end
32
+
33
+ def cat_adapter_update_success(cat)
34
+ @listener.cat_repository_update_success(cat)
35
+ end
36
+
37
+ def first
38
+ @adapter.first
39
+ end
40
+
41
+ def cat_adapter_list_success(sequences)
42
+ @listener.cat_repository_list_success(sequences)
43
+ end
44
+
45
+ def read(id)
46
+ @adapter.read(id)
47
+ end
48
+
49
+ def cat_adapter_read_success(cat)
50
+ @listener.cat_repository_read_success(cat)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,40 @@
1
+ module Repository
2
+ module Memory
3
+ class Cat
4
+ attr_accessor :listener
5
+
6
+ def initialize
7
+ @list = []
8
+ end
9
+
10
+ def find(cat)
11
+ @list.first do |listed_cat|
12
+ cat == listed_cat
13
+ end
14
+ end
15
+
16
+ def all
17
+ @listener.cat_repository_all_success(@list)
18
+ end
19
+
20
+ def create(attributes)
21
+ ::Cat.new(attributes).tap do |cat|
22
+ if cat.valid?
23
+ @list << cat
24
+ @listener.cat_repository_create_success(cat) if @listener
25
+ else
26
+ @listener.cat_repository_create_failure if @listener
27
+ end
28
+ end
29
+ end
30
+
31
+ def count
32
+ @list.count
33
+ end
34
+
35
+ def first
36
+ @list.first
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,20 @@
1
+ module UseCase
2
+ class BlogPostBlogPost
3
+ def initialize(listener, repository=nil)
4
+ @listener = listener
5
+ @repository = (repository || Repository::Memory::BlogPost).new(self)
6
+ end
7
+
8
+ def blog id
9
+ @repository.delete id
10
+ end
11
+
12
+ def blog_post_repository_delete_success(blog_post)
13
+ @listener.blog_post_success(blog_post)
14
+ end
15
+
16
+ def blog_post_repository_delete_failure
17
+ @listener.blog_post_failure
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module UseCase
2
+ class BlogPostsBlogPost
3
+ def initialize(listener, repository=nil)
4
+ @listener = listener
5
+ @repository = (repository || Repository::Memory::BlogPosts).new(self)
6
+ end
7
+
8
+ def blog
9
+ @repository.list
10
+ end
11
+
12
+ def blog_post_repository_list_success(blog_posts)
13
+ @listener.blog_posts_success(blog_posts)
14
+ end
15
+
16
+ def blog_post_repository_list_failure
17
+ @listener.blog_posts_failure
18
+ end
19
+ end
20
+ end
@@ -1,18 +1,16 @@
1
1
  module UseCase
2
2
  class CreateBlogPost
3
- attr_accessor :repository_name
4
-
5
3
  def initialize(listener, repository=nil)
6
4
  @listener = listener
7
- @repository = (repository || Repository::Memory::CreateBlogPost).new(self)
5
+ @repository = (repository || Repository::Memory::BlogPost).new(self)
8
6
  end
9
7
 
10
8
  def create attributes
11
9
  @repository.create attributes
12
10
  end
13
11
 
14
- def blog_post_repository_create_success(create_blog_post)
15
- @listener.create_blog_post_success(create_blog_post)
12
+ def blog_post_repository_create_success(blog_post)
13
+ @listener.create_blog_post_success(blog_post)
16
14
  end
17
15
 
18
16
  def blog_post_repository_create_failure
@@ -0,0 +1,20 @@
1
+ module UseCase
2
+ class CreateCat
3
+ def initialize(listener, repository=nil)
4
+ @listener = listener
5
+ @repository = (repository || Repository::Memory::Cat).new(self)
6
+ end
7
+
8
+ def create attributes
9
+ @repository.create attributes
10
+ end
11
+
12
+ def cat_repository_create_success(cat)
13
+ @listener.create_cat_success(cat)
14
+ end
15
+
16
+ def cat_repository_create_failure
17
+ @listener.create_cat_failure
18
+ end
19
+ end
20
+ end
@@ -1,18 +1,16 @@
1
1
  module UseCase
2
2
  class DeleteBlogPost
3
- attr_accessor :repository_name
4
-
5
3
  def initialize(listener, repository=nil)
6
4
  @listener = listener
7
- @repository = (repository || Repository::Memory::DeleteBlogPost).new(self)
5
+ @repository = (repository || Repository::Memory::BlogPost).new(self)
8
6
  end
9
7
 
10
8
  def delete id
11
9
  @repository.delete id
12
10
  end
13
11
 
14
- def blog_post_repository_delete_success(delete_blog_post)
15
- @listener.delete_blog_post_success(delete_blog_post)
12
+ def blog_post_repository_delete_success(blog_post)
13
+ @listener.delete_blog_post_success(blog_post)
16
14
  end
17
15
 
18
16
  def blog_post_repository_delete_failure
@@ -0,0 +1,20 @@
1
+ module UseCase
2
+ class DeleteCat
3
+ def initialize(listener, repository=nil)
4
+ @listener = listener
5
+ @repository = (repository || Repository::Memory::Cat).new(self)
6
+ end
7
+
8
+ def delete id
9
+ @repository.delete id
10
+ end
11
+
12
+ def cat_repository_delete_success(cat)
13
+ @listener.delete_cat_success(cat)
14
+ end
15
+
16
+ def cat_repository_delete_failure
17
+ @listener.delete_cat_failure
18
+ end
19
+ end
20
+ end
@@ -1,18 +1,16 @@
1
1
  module UseCase
2
2
  class ListBlogPosts
3
- attr_accessor :repository_name
4
-
5
3
  def initialize(listener, repository=nil)
6
4
  @listener = listener
7
- @repository = (repository || Repository::Memory::ListBlogPosts).new(self)
5
+ @repository = (repository || Repository::Memory::BlogPost).new(self)
8
6
  end
9
7
 
10
8
  def list
11
9
  @repository.list
12
10
  end
13
11
 
14
- def blog_post_repository_list_success(list_blog_posts)
15
- @listener.list_blog_posts_success(list_blog_posts)
12
+ def blog_post_repository_list_success(blog_post)
13
+ @listener.list_blog_posts_success(blog_post)
16
14
  end
17
15
 
18
16
  def blog_post_repository_list_failure
@@ -0,0 +1,20 @@
1
+ module UseCase
2
+ class ListCats
3
+ def initialize(listener, repository=nil)
4
+ @listener = listener
5
+ @repository = (repository || Repository::Memory::Cat).new(self)
6
+ end
7
+
8
+ def list
9
+ @repository.list
10
+ end
11
+
12
+ def cat_repository_list_success(cat)
13
+ @listener.list_cats_success(cat)
14
+ end
15
+
16
+ def cat_repository_list_failure
17
+ @listener.list_cats_failure
18
+ end
19
+ end
20
+ end
@@ -1,18 +1,16 @@
1
1
  module UseCase
2
2
  class ReadBlogPost
3
- attr_accessor :repository_name
4
-
5
3
  def initialize(listener, repository=nil)
6
4
  @listener = listener
7
- @repository = (repository || Repository::Memory::ReadBlogPost).new(self)
5
+ @repository = (repository || Repository::Memory::BlogPost).new(self)
8
6
  end
9
7
 
10
8
  def read id
11
9
  @repository.read id
12
10
  end
13
11
 
14
- def blog_post_repository_read_success(read_blog_post)
15
- @listener.read_blog_post_success(read_blog_post)
12
+ def blog_post_repository_read_success(blog_post)
13
+ @listener.read_blog_post_success(blog_post)
16
14
  end
17
15
 
18
16
  def blog_post_repository_read_failure
@@ -0,0 +1,20 @@
1
+ module UseCase
2
+ class ReadCat
3
+ def initialize(listener, repository=nil)
4
+ @listener = listener
5
+ @repository = (repository || Repository::Memory::Cat).new(self)
6
+ end
7
+
8
+ def read id
9
+ @repository.read id
10
+ end
11
+
12
+ def cat_repository_read_success(cat)
13
+ @listener.read_cat_success(cat)
14
+ end
15
+
16
+ def cat_repository_read_failure
17
+ @listener.read_cat_failure
18
+ end
19
+ end
20
+ end
@@ -1,18 +1,16 @@
1
1
  module UseCase
2
2
  class UpdateBlogPost
3
- attr_accessor :repository_name
4
-
5
3
  def initialize(listener, repository=nil)
6
4
  @listener = listener
7
- @repository = (repository || Repository::Memory::UpdateBlogPost).new(self)
5
+ @repository = (repository || Repository::Memory::BlogPost).new(self)
8
6
  end
9
7
 
10
8
  def update id, attributes
11
9
  @repository.update id, attributes
12
10
  end
13
11
 
14
- def blog_post_repository_update_success(update_blog_post)
15
- @listener.update_blog_post_success(update_blog_post)
12
+ def blog_post_repository_update_success(blog_post)
13
+ @listener.update_blog_post_success(blog_post)
16
14
  end
17
15
 
18
16
  def blog_post_repository_update_failure
@@ -0,0 +1,20 @@
1
+ module UseCase
2
+ class UpdateCat
3
+ def initialize(listener, repository=nil)
4
+ @listener = listener
5
+ @repository = (repository || Repository::Memory::Cat).new(self)
6
+ end
7
+
8
+ def update id, attributes
9
+ @repository.update id, attributes
10
+ end
11
+
12
+ def cat_repository_update_success(cat)
13
+ @listener.update_cat_success(cat)
14
+ end
15
+
16
+ def cat_repository_update_failure
17
+ @listener.update_cat_failure
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,8 @@
1
+ class CreateCats < ActiveRecord::Migration
2
+ def change
3
+ create_table :cats do |t|
4
+ t.string :name
5
+ t.integer :age
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ require 'rails_helper'
2
+
3
+ describe Cat do
4
+ let(:attributes) {{}}
5
+ subject { Cat.new(attributes) }
6
+ end
@@ -0,0 +1,54 @@
1
+ module Repository
2
+ module Database
3
+ class Cat
4
+ def initialize(listener = nil)
5
+ @listener = listener
6
+ @adapter = Repository::Adapters::AR::Cat.new(self)
7
+ @model = ::Cat
8
+ end
9
+
10
+ def create(attributes)
11
+ @model.new(attributes).tap do |cat|
12
+ return unless cat.valid?
13
+ @adapter.create(cat.attributes)
14
+ end
15
+ end
16
+
17
+ def cat_adapter_create_success(sequence)
18
+ @listener.cat_repository_create_success(sequence)
19
+ end
20
+
21
+ def list
22
+ @listener.cat_repository_list_success(@adapter.list)
23
+ end
24
+
25
+ def count
26
+ @model.count
27
+ end
28
+
29
+ def update(id, attributes)
30
+ @adapter.update(id, attributes)
31
+ end
32
+
33
+ def cat_adapter_update_success(cat)
34
+ @listener.cat_repository_update_success(cat)
35
+ end
36
+
37
+ def first
38
+ @adapter.first
39
+ end
40
+
41
+ def cat_adapter_list_success(sequences)
42
+ @listener.cat_repository_list_success(sequences)
43
+ end
44
+
45
+ def read(id)
46
+ @adapter.read(id)
47
+ end
48
+
49
+ def cat_adapter_read_success(cat)
50
+ @listener.cat_repository_read_success(cat)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,40 @@
1
+ module Repository
2
+ module Memory
3
+ class Cat
4
+ attr_accessor :listener
5
+
6
+ def initialize
7
+ @list = []
8
+ end
9
+
10
+ def find(cat)
11
+ @list.first do |listed_cat|
12
+ cat == listed_cat
13
+ end
14
+ end
15
+
16
+ def all
17
+ @listener.cat_repository_all_success(@list)
18
+ end
19
+
20
+ def create(attributes)
21
+ ::Cat.new(attributes).tap do |cat|
22
+ if cat.valid?
23
+ @list << cat
24
+ @listener.cat_repository_create_success(cat) if @listener
25
+ else
26
+ @listener.cat_repository_create_failure if @listener
27
+ end
28
+ end
29
+ end
30
+
31
+ def count
32
+ @list.count
33
+ end
34
+
35
+ def first
36
+ @list.first
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,20 @@
1
+ require 'rails_helper'
2
+
3
+ describe UseCase::BlogPost do
4
+ describe 'blog' do
5
+ subject { described_class.new(listener, Repository::Memory::Blog Post.new) }
6
+ let (:listener) { double("blog_post listener", blog_post_success: nil, blog_post_failure: nil) }
7
+ let (:repository) { subject.repository }
8
+
9
+ context "With Valid Properties" do
10
+ it 'notifies listener of success' do
11
+ expect(listener).to receive(:blog_post_success)
12
+ subject.blog()
13
+ end
14
+ end
15
+
16
+ context "With Invalid Properties" do
17
+ it 'notifies the listener of failure'
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require 'rails_helper'
2
+
3
+ describe UseCase::BlogPosts do
4
+ describe 'blog' do
5
+ subject { described_class.new(listener, Repository::Memory::Blog Posts.new) }
6
+ let (:listener) { double("blog_posts listener", blog_posts_success: nil, blog_posts_failure: nil) }
7
+ let (:repository) { subject.repository }
8
+
9
+ context "With Valid Properties" do
10
+ it 'notifies listener of success' do
11
+ expect(listener).to receive(:blog_posts_success)
12
+ subject.blog()
13
+ end
14
+ end
15
+
16
+ context "With Invalid Properties" do
17
+ it 'notifies the listener of failure'
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require 'rails_helper'
2
+
3
+ describe UseCase::CreateCat do
4
+ describe 'create' do
5
+ subject { described_class.new(listener, Repository::Memory::Create Cat.new) }
6
+ let (:listener) { double("create_cat listener", create_cat_success: nil, create_cat_failure: nil) }
7
+ let (:repository) { subject.repository }
8
+
9
+ context "With Valid Properties" do
10
+ it 'notifies listener of success' do
11
+ expect(listener).to receive(:create_cat_success)
12
+ subject.create()
13
+ end
14
+ end
15
+
16
+ context "With Invalid Properties" do
17
+ it 'notifies the listener of failure'
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require 'rails_helper'
2
+
3
+ describe UseCase::DeleteCat do
4
+ describe 'delete' do
5
+ subject { described_class.new(listener, Repository::Memory::Delete Cat.new) }
6
+ let (:listener) { double("delete_cat listener", delete_cat_success: nil, delete_cat_failure: nil) }
7
+ let (:repository) { subject.repository }
8
+
9
+ context "With Valid Properties" do
10
+ it 'notifies listener of success' do
11
+ expect(listener).to receive(:delete_cat_success)
12
+ subject.delete()
13
+ end
14
+ end
15
+
16
+ context "With Invalid Properties" do
17
+ it 'notifies the listener of failure'
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require 'rails_helper'
2
+
3
+ describe UseCase::ListCats do
4
+ describe 'list' do
5
+ subject { described_class.new(listener, Repository::Memory::List Cats.new) }
6
+ let (:listener) { double("list_cats listener", list_cats_success: nil, list_cats_failure: nil) }
7
+ let (:repository) { subject.repository }
8
+
9
+ context "With Valid Properties" do
10
+ it 'notifies listener of success' do
11
+ expect(listener).to receive(:list_cats_success)
12
+ subject.list()
13
+ end
14
+ end
15
+
16
+ context "With Invalid Properties" do
17
+ it 'notifies the listener of failure'
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require 'rails_helper'
2
+
3
+ describe UseCase::ReadCat do
4
+ describe 'read' do
5
+ subject { described_class.new(listener, Repository::Memory::Read Cat.new) }
6
+ let (:listener) { double("read_cat listener", read_cat_success: nil, read_cat_failure: nil) }
7
+ let (:repository) { subject.repository }
8
+
9
+ context "With Valid Properties" do
10
+ it 'notifies listener of success' do
11
+ expect(listener).to receive(:read_cat_success)
12
+ subject.read()
13
+ end
14
+ end
15
+
16
+ context "With Invalid Properties" do
17
+ it 'notifies the listener of failure'
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require 'rails_helper'
2
+
3
+ describe UseCase::UpdateCat do
4
+ describe 'update' do
5
+ subject { described_class.new(listener, Repository::Memory::Update Cat.new) }
6
+ let (:listener) { double("update_cat listener", update_cat_success: nil, update_cat_failure: nil) }
7
+ let (:repository) { subject.repository }
8
+
9
+ context "With Valid Properties" do
10
+ it 'notifies listener of success' do
11
+ expect(listener).to receive(:update_cat_success)
12
+ subject.update()
13
+ end
14
+ end
15
+
16
+ context "With Invalid Properties" do
17
+ it 'notifies the listener of failure'
18
+ end
19
+ end
20
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Young
@@ -104,17 +104,30 @@ files:
104
104
  - test/dummy/app/controllers/application_controller.rb
105
105
  - test/dummy/app/controllers/blog_post_controller.rb
106
106
  - test/dummy/app/controllers/blog_posts_controller.rb
107
+ - test/dummy/app/controllers/cats_controller.rb
107
108
  - test/dummy/app/helpers/application_helper.rb
108
109
  - test/dummy/app/hexagon/blog_post.rb
110
+ - test/dummy/app/hexagon/cat.rb
109
111
  - test/dummy/app/hexagon/repository/adapters/ar/blog_post.rb
112
+ - test/dummy/app/hexagon/repository/adapters/ar/cat.rb
110
113
  - test/dummy/app/hexagon/repository/adapters/ar/data/blog_post.rb
114
+ - test/dummy/app/hexagon/repository/adapters/ar/data/cat.rb
111
115
  - test/dummy/app/hexagon/repository/database/blog_post.rb
116
+ - test/dummy/app/hexagon/repository/database/cat.rb
112
117
  - test/dummy/app/hexagon/repository/memory/blog_post.rb
118
+ - test/dummy/app/hexagon/repository/memory/cat.rb
119
+ - test/dummy/app/hexagon/use_case/blog_post.rb
120
+ - test/dummy/app/hexagon/use_case/blog_posts.rb
113
121
  - test/dummy/app/hexagon/use_case/create_blog_post.rb
122
+ - test/dummy/app/hexagon/use_case/create_cat.rb
114
123
  - test/dummy/app/hexagon/use_case/delete_blog_post.rb
124
+ - test/dummy/app/hexagon/use_case/delete_cat.rb
115
125
  - test/dummy/app/hexagon/use_case/list_blog_posts.rb
126
+ - test/dummy/app/hexagon/use_case/list_cats.rb
116
127
  - test/dummy/app/hexagon/use_case/read_blog_post.rb
128
+ - test/dummy/app/hexagon/use_case/read_cat.rb
117
129
  - test/dummy/app/hexagon/use_case/update_blog_post.rb
130
+ - test/dummy/app/hexagon/use_case/update_cat.rb
118
131
  - test/dummy/app/views/blog_posts/_form.html.erb
119
132
  - test/dummy/app/views/blog_posts/edit.html.erb
120
133
  - test/dummy/app/views/blog_posts/index.html.erb
@@ -145,6 +158,7 @@ files:
145
158
  - test/dummy/config/secrets.yml
146
159
  - test/dummy/db/development.sqlite3
147
160
  - test/dummy/db/migrate/20150914062943_create_blog_posts.rb
161
+ - test/dummy/db/migrate/20150914164840_create_cats.rb
148
162
  - test/dummy/db/schema.rb
149
163
  - test/dummy/log/development.log
150
164
  - test/dummy/public/404.html
@@ -157,15 +171,27 @@ files:
157
171
  - test/dummy/spec/heks/use_case/read_blog_post_spec.rb
158
172
  - test/dummy/spec/heks/use_case/update_blog_post_spec.rb
159
173
  - test/dummy/spec/hexagon/blog_post_spec.rb
174
+ - test/dummy/spec/hexagon/cat_spec.rb
160
175
  - test/dummy/spec/hexagon/repository/adapters/ar/blog_post_spec.rb
176
+ - test/dummy/spec/hexagon/repository/adapters/ar/cat_spec.rb
161
177
  - test/dummy/spec/hexagon/repository/adapters/ar/data/blog_post_spec.rb
178
+ - test/dummy/spec/hexagon/repository/adapters/ar/data/cat_spec.rb
162
179
  - test/dummy/spec/hexagon/repository/database/blog_post_spec.rb
180
+ - test/dummy/spec/hexagon/repository/database/cat_spec.rb
163
181
  - test/dummy/spec/hexagon/repository/memory/blog_post_spec.rb
182
+ - test/dummy/spec/hexagon/repository/memory/cat_spec.rb
183
+ - test/dummy/spec/hexagon/use_case/blog_post_spec.rb
184
+ - test/dummy/spec/hexagon/use_case/blog_posts_spec.rb
164
185
  - test/dummy/spec/hexagon/use_case/create_blog_post_spec.rb
186
+ - test/dummy/spec/hexagon/use_case/create_cat_spec.rb
165
187
  - test/dummy/spec/hexagon/use_case/delete_blog_post_spec.rb
188
+ - test/dummy/spec/hexagon/use_case/delete_cat_spec.rb
166
189
  - test/dummy/spec/hexagon/use_case/list_blog_posts_spec.rb
190
+ - test/dummy/spec/hexagon/use_case/list_cats_spec.rb
167
191
  - test/dummy/spec/hexagon/use_case/read_blog_post_spec.rb
192
+ - test/dummy/spec/hexagon/use_case/read_cat_spec.rb
168
193
  - test/dummy/spec/hexagon/use_case/update_blog_post_spec.rb
194
+ - test/dummy/spec/hexagon/use_case/update_cat_spec.rb
169
195
  - test/dummy/spec/models/blog_post_spec.rb
170
196
  - test/dummy/tmp/cache/assets/development/sprockets/v3.0/-vafv4A0l3iJF0-IyX9Uk_oQ-RIKXhPFXitPc3k4mk8.cache
171
197
  - test/dummy/tmp/cache/assets/development/sprockets/v3.0/0ieeKnMtadPClPcf7n4_-7f9dFAa5EKPn-nhh8g4E_I.cache
@@ -215,17 +241,30 @@ test_files:
215
241
  - test/dummy/app/controllers/application_controller.rb
216
242
  - test/dummy/app/controllers/blog_post_controller.rb
217
243
  - test/dummy/app/controllers/blog_posts_controller.rb
244
+ - test/dummy/app/controllers/cats_controller.rb
218
245
  - test/dummy/app/helpers/application_helper.rb
219
246
  - test/dummy/app/hexagon/blog_post.rb
247
+ - test/dummy/app/hexagon/cat.rb
220
248
  - test/dummy/app/hexagon/repository/adapters/ar/blog_post.rb
249
+ - test/dummy/app/hexagon/repository/adapters/ar/cat.rb
221
250
  - test/dummy/app/hexagon/repository/adapters/ar/data/blog_post.rb
251
+ - test/dummy/app/hexagon/repository/adapters/ar/data/cat.rb
222
252
  - test/dummy/app/hexagon/repository/database/blog_post.rb
253
+ - test/dummy/app/hexagon/repository/database/cat.rb
223
254
  - test/dummy/app/hexagon/repository/memory/blog_post.rb
255
+ - test/dummy/app/hexagon/repository/memory/cat.rb
256
+ - test/dummy/app/hexagon/use_case/blog_post.rb
257
+ - test/dummy/app/hexagon/use_case/blog_posts.rb
224
258
  - test/dummy/app/hexagon/use_case/create_blog_post.rb
259
+ - test/dummy/app/hexagon/use_case/create_cat.rb
225
260
  - test/dummy/app/hexagon/use_case/delete_blog_post.rb
261
+ - test/dummy/app/hexagon/use_case/delete_cat.rb
226
262
  - test/dummy/app/hexagon/use_case/list_blog_posts.rb
263
+ - test/dummy/app/hexagon/use_case/list_cats.rb
227
264
  - test/dummy/app/hexagon/use_case/read_blog_post.rb
265
+ - test/dummy/app/hexagon/use_case/read_cat.rb
228
266
  - test/dummy/app/hexagon/use_case/update_blog_post.rb
267
+ - test/dummy/app/hexagon/use_case/update_cat.rb
229
268
  - test/dummy/app/views/blog_posts/_form.html.erb
230
269
  - test/dummy/app/views/blog_posts/edit.html.erb
231
270
  - test/dummy/app/views/blog_posts/index.html.erb
@@ -256,6 +295,7 @@ test_files:
256
295
  - test/dummy/config.ru
257
296
  - test/dummy/db/development.sqlite3
258
297
  - test/dummy/db/migrate/20150914062943_create_blog_posts.rb
298
+ - test/dummy/db/migrate/20150914164840_create_cats.rb
259
299
  - test/dummy/db/schema.rb
260
300
  - test/dummy/log/development.log
261
301
  - test/dummy/public/404.html
@@ -270,15 +310,27 @@ test_files:
270
310
  - test/dummy/spec/heks/use_case/read_blog_post_spec.rb
271
311
  - test/dummy/spec/heks/use_case/update_blog_post_spec.rb
272
312
  - test/dummy/spec/hexagon/blog_post_spec.rb
313
+ - test/dummy/spec/hexagon/cat_spec.rb
273
314
  - test/dummy/spec/hexagon/repository/adapters/ar/blog_post_spec.rb
315
+ - test/dummy/spec/hexagon/repository/adapters/ar/cat_spec.rb
274
316
  - test/dummy/spec/hexagon/repository/adapters/ar/data/blog_post_spec.rb
317
+ - test/dummy/spec/hexagon/repository/adapters/ar/data/cat_spec.rb
275
318
  - test/dummy/spec/hexagon/repository/database/blog_post_spec.rb
319
+ - test/dummy/spec/hexagon/repository/database/cat_spec.rb
276
320
  - test/dummy/spec/hexagon/repository/memory/blog_post_spec.rb
321
+ - test/dummy/spec/hexagon/repository/memory/cat_spec.rb
322
+ - test/dummy/spec/hexagon/use_case/blog_post_spec.rb
323
+ - test/dummy/spec/hexagon/use_case/blog_posts_spec.rb
277
324
  - test/dummy/spec/hexagon/use_case/create_blog_post_spec.rb
325
+ - test/dummy/spec/hexagon/use_case/create_cat_spec.rb
278
326
  - test/dummy/spec/hexagon/use_case/delete_blog_post_spec.rb
327
+ - test/dummy/spec/hexagon/use_case/delete_cat_spec.rb
279
328
  - test/dummy/spec/hexagon/use_case/list_blog_posts_spec.rb
329
+ - test/dummy/spec/hexagon/use_case/list_cats_spec.rb
280
330
  - test/dummy/spec/hexagon/use_case/read_blog_post_spec.rb
331
+ - test/dummy/spec/hexagon/use_case/read_cat_spec.rb
281
332
  - test/dummy/spec/hexagon/use_case/update_blog_post_spec.rb
333
+ - test/dummy/spec/hexagon/use_case/update_cat_spec.rb
282
334
  - test/dummy/spec/models/blog_post_spec.rb
283
335
  - test/dummy/tmp/cache/assets/development/sprockets/v3.0/-vafv4A0l3iJF0-IyX9Uk_oQ-RIKXhPFXitPc3k4mk8.cache
284
336
  - test/dummy/tmp/cache/assets/development/sprockets/v3.0/0ieeKnMtadPClPcf7n4_-7f9dFAa5EKPn-nhh8g4E_I.cache