satchel 0.0.1.placeholder → 0.0.1
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/Gemfile +6 -0
- data/Guardfile +10 -0
- data/Rakefile +2 -29
- data/TODO.md +24 -0
- data/app/assets/images/satchel/.gitkeep +0 -0
- data/app/assets/javascripts/satchel/application.js +15 -0
- data/app/assets/stylesheets/satchel/application.css +13 -0
- data/app/controllers/satchel/application_controller.rb +4 -0
- data/app/helpers/satchel/application_helper.rb +4 -0
- data/app/models/satchel/activity.rb +28 -0
- data/app/views/layouts/satchel/application.html.erb +14 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20130722162331_create_satchel_activities.rb +13 -0
- data/lib/satchel/activity_builder.rb +45 -0
- data/lib/satchel/activity_data_structure.rb +10 -0
- data/lib/satchel/context_builder.rb +40 -0
- data/lib/satchel/engine.rb +17 -0
- data/lib/satchel/exceptions.rb +7 -0
- data/lib/satchel/version.rb +1 -1
- data/lib/satchel.rb +12 -0
- data/satchel.gemspec +2 -0
- data/script/rails +8 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config/application.rb +59 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/schema.rb +27 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/lib/satchel/activity_builder_spec.rb +54 -0
- data/spec/lib/satchel/activity_data_structure_spec.rb +10 -0
- data/spec/lib/satchel/context_builder_spec.rb +83 -0
- data/spec/lib/satchel_spec.rb +42 -0
- data/spec/models/satchel/activity_spec.rb +42 -0
- data/spec/spec_helper.rb +9 -0
- data/spec/spec_patch.rb +43 -0
- data/spec/support/persistence_layer.rb +14 -0
- metadata +117 -5
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'satchel'
|
3
|
+
|
4
|
+
describe Satchel do
|
5
|
+
class Cat < PersistenceLayer
|
6
|
+
def initialize(name)
|
7
|
+
super()
|
8
|
+
@name = name
|
9
|
+
end
|
10
|
+
attr_reader :name
|
11
|
+
def eat(food); food; end
|
12
|
+
end
|
13
|
+
Food = Struct.new(:name)
|
14
|
+
|
15
|
+
describe '.register' do
|
16
|
+
let(:cat) { Cat.new('Beautiful Steve') }
|
17
|
+
let(:food) { Food.new('catsup') }
|
18
|
+
let(:receiver) { Satchel::Activity }
|
19
|
+
|
20
|
+
it 'reports when the method is called' do
|
21
|
+
Satchel.register(Cat, :eat, receiver) do |config, context|
|
22
|
+
config.subject = context
|
23
|
+
config.activity_type = 'Cat#eat'
|
24
|
+
end
|
25
|
+
cat.eat(food)
|
26
|
+
expect(receiver.last.subject).to eq(cat)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'entry creation' do
|
31
|
+
it 'creates an entry for a persisted object'
|
32
|
+
it 'requires an object to be persisted'
|
33
|
+
it 'extracts the requesting user from the context'
|
34
|
+
it 'extracts the entry type from the context'
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'entry finder scopes' do
|
38
|
+
it 'has a scope for finding based on the persisted object'
|
39
|
+
it 'has a scope for finding based on a user'
|
40
|
+
it 'has a scope for finding based on an entry type'
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Satchel
|
4
|
+
describe Activity do
|
5
|
+
subject { Satchel::Activity.new }
|
6
|
+
let(:object) { PersistenceLayer.new }
|
7
|
+
|
8
|
+
describe 'with persisted object' do
|
9
|
+
it 'should marshal the subject' do
|
10
|
+
subject.subject = object
|
11
|
+
expect(subject.subject).to eq(object)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should capture the subject id' do
|
15
|
+
subject.subject = object
|
16
|
+
expect(subject.subject_id).to eq(object.to_param)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should capture the subject type' do
|
20
|
+
subject.subject = object
|
21
|
+
expect(subject.subject_type).to eq(object.class.to_s)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'with a non persisted object' do
|
26
|
+
|
27
|
+
it 'raise exception if the object is not persisted' do
|
28
|
+
def object.persisted?; false; end
|
29
|
+
expect {
|
30
|
+
subject.subject = object
|
31
|
+
}.to raise_error(Satchel::UnpersistedSubjectError)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'raise exception if the object does not respond to persisted' do
|
35
|
+
expect {
|
36
|
+
subject.subject = 2
|
37
|
+
}.to raise_error(NoMethodError)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
ENV["RAILS_ENV"] ||= 'test'
|
2
|
+
|
3
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
4
|
+
require File.expand_path('../spec_patch', __FILE__)
|
5
|
+
require "rails/test_help"
|
6
|
+
require 'rspec/rails'
|
7
|
+
|
8
|
+
Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each {|f| require f}
|
9
|
+
|
1
10
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
11
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
12
|
# Require this file using `require "spec_helper"` to ensure that it is only
|
data/spec/spec_patch.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Why: http://groups.google.com/group/cukes/browse_thread/thread/5682d41436e235d7
|
2
|
+
begin
|
3
|
+
require 'minitest/unit'
|
4
|
+
# Don't attempt to monkeypatch if the require succeeded but didn't
|
5
|
+
# define the actual module.
|
6
|
+
#
|
7
|
+
# https://github.com/cucumber/cucumber/pull/93
|
8
|
+
# http://youtrack.jetbrains.net/issue/TW-17414
|
9
|
+
if defined?(MiniTest::Unit)
|
10
|
+
class MiniTest::Unit
|
11
|
+
class << self
|
12
|
+
@@installed_at_exit = true
|
13
|
+
end
|
14
|
+
|
15
|
+
def run(*)
|
16
|
+
0
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
rescue LoadError => ignore
|
21
|
+
end
|
22
|
+
|
23
|
+
# Do the same for Test::Unit
|
24
|
+
begin
|
25
|
+
require 'test/unit'
|
26
|
+
# Don't attempt to monkeypatch if the require succeeded but didn't
|
27
|
+
# define the actual module.
|
28
|
+
#
|
29
|
+
# https://github.com/cucumber/cucumber/pull/93
|
30
|
+
# http://youtrack.jetbrains.net/issue/TW-17414
|
31
|
+
if defined?(Test::Unit)
|
32
|
+
module Test::Unit
|
33
|
+
def self.run?
|
34
|
+
true
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# if defined?(Test::Unit::AutoRunner)
|
40
|
+
# Test::Unit::AutoRunner.need_auto_run = false
|
41
|
+
# end
|
42
|
+
rescue LoadError => ignore
|
43
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class PersistenceLayer
|
2
|
+
def self.registry
|
3
|
+
@registry ||= []
|
4
|
+
end
|
5
|
+
def initialize
|
6
|
+
self.class.registry << self
|
7
|
+
end
|
8
|
+
def self.find(id)
|
9
|
+
@registry.find {|obj| obj.to_param == Integer(id)}
|
10
|
+
end
|
11
|
+
|
12
|
+
def persisted?; true; end
|
13
|
+
def to_param; object_id; end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: satchel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Friesen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: Satchel - a mountable Rails engine for activity streams
|
42
56
|
email:
|
43
57
|
- jeremy.n.friesen@gmail.com
|
@@ -48,16 +62,74 @@ files:
|
|
48
62
|
- .gitignore
|
49
63
|
- .rspec
|
50
64
|
- Gemfile
|
65
|
+
- Guardfile
|
51
66
|
- LICENSE.txt
|
52
67
|
- README.md
|
53
68
|
- Rakefile
|
69
|
+
- TODO.md
|
70
|
+
- app/assets/images/satchel/.gitkeep
|
71
|
+
- app/assets/javascripts/satchel/application.js
|
72
|
+
- app/assets/stylesheets/satchel/application.css
|
73
|
+
- app/controllers/satchel/application_controller.rb
|
74
|
+
- app/helpers/satchel/application_helper.rb
|
75
|
+
- app/models/satchel/activity.rb
|
76
|
+
- app/views/layouts/satchel/application.html.erb
|
77
|
+
- config/routes.rb
|
78
|
+
- db/migrate/20130722162331_create_satchel_activities.rb
|
54
79
|
- lib/satchel.rb
|
80
|
+
- lib/satchel/activity_builder.rb
|
81
|
+
- lib/satchel/activity_data_structure.rb
|
82
|
+
- lib/satchel/context_builder.rb
|
83
|
+
- lib/satchel/engine.rb
|
84
|
+
- lib/satchel/exceptions.rb
|
55
85
|
- lib/satchel/version.rb
|
56
86
|
- lib/tasks/satchel_tasks.rake
|
57
87
|
- satchel.gemspec
|
88
|
+
- script/rails
|
89
|
+
- spec/dummy/README.rdoc
|
90
|
+
- spec/dummy/Rakefile
|
91
|
+
- spec/dummy/app/assets/javascripts/application.js
|
92
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
93
|
+
- spec/dummy/app/controllers/application_controller.rb
|
94
|
+
- spec/dummy/app/helpers/application_helper.rb
|
95
|
+
- spec/dummy/app/mailers/.gitkeep
|
96
|
+
- spec/dummy/app/models/.gitkeep
|
97
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
98
|
+
- spec/dummy/config.ru
|
99
|
+
- spec/dummy/config/application.rb
|
100
|
+
- spec/dummy/config/boot.rb
|
101
|
+
- spec/dummy/config/database.yml
|
102
|
+
- spec/dummy/config/environment.rb
|
103
|
+
- spec/dummy/config/environments/development.rb
|
104
|
+
- spec/dummy/config/environments/production.rb
|
105
|
+
- spec/dummy/config/environments/test.rb
|
106
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
107
|
+
- spec/dummy/config/initializers/inflections.rb
|
108
|
+
- spec/dummy/config/initializers/mime_types.rb
|
109
|
+
- spec/dummy/config/initializers/secret_token.rb
|
110
|
+
- spec/dummy/config/initializers/session_store.rb
|
111
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
112
|
+
- spec/dummy/config/locales/en.yml
|
113
|
+
- spec/dummy/config/routes.rb
|
114
|
+
- spec/dummy/db/schema.rb
|
115
|
+
- spec/dummy/lib/assets/.gitkeep
|
116
|
+
- spec/dummy/log/.gitkeep
|
117
|
+
- spec/dummy/public/404.html
|
118
|
+
- spec/dummy/public/422.html
|
119
|
+
- spec/dummy/public/500.html
|
120
|
+
- spec/dummy/public/favicon.ico
|
121
|
+
- spec/dummy/script/rails
|
122
|
+
- spec/lib/satchel/activity_builder_spec.rb
|
123
|
+
- spec/lib/satchel/activity_data_structure_spec.rb
|
124
|
+
- spec/lib/satchel/context_builder_spec.rb
|
125
|
+
- spec/lib/satchel_spec.rb
|
126
|
+
- spec/models/satchel/activity_spec.rb
|
58
127
|
- spec/spec_helper.rb
|
128
|
+
- spec/spec_patch.rb
|
129
|
+
- spec/support/persistence_layer.rb
|
59
130
|
homepage: http://github.com/ndlib/satchel
|
60
|
-
licenses:
|
131
|
+
licenses:
|
132
|
+
- APACHE2
|
61
133
|
metadata: {}
|
62
134
|
post_install_message:
|
63
135
|
rdoc_options: []
|
@@ -70,9 +142,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
70
142
|
version: '0'
|
71
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
144
|
requirements:
|
73
|
-
- - '
|
145
|
+
- - '>='
|
74
146
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
147
|
+
version: '0'
|
76
148
|
requirements: []
|
77
149
|
rubyforge_project:
|
78
150
|
rubygems_version: 2.0.3
|
@@ -80,4 +152,44 @@ signing_key:
|
|
80
152
|
specification_version: 4
|
81
153
|
summary: Satchel - a mountable Rails engine for activity streams
|
82
154
|
test_files:
|
155
|
+
- spec/dummy/README.rdoc
|
156
|
+
- spec/dummy/Rakefile
|
157
|
+
- spec/dummy/app/assets/javascripts/application.js
|
158
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
159
|
+
- spec/dummy/app/controllers/application_controller.rb
|
160
|
+
- spec/dummy/app/helpers/application_helper.rb
|
161
|
+
- spec/dummy/app/mailers/.gitkeep
|
162
|
+
- spec/dummy/app/models/.gitkeep
|
163
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
164
|
+
- spec/dummy/config.ru
|
165
|
+
- spec/dummy/config/application.rb
|
166
|
+
- spec/dummy/config/boot.rb
|
167
|
+
- spec/dummy/config/database.yml
|
168
|
+
- spec/dummy/config/environment.rb
|
169
|
+
- spec/dummy/config/environments/development.rb
|
170
|
+
- spec/dummy/config/environments/production.rb
|
171
|
+
- spec/dummy/config/environments/test.rb
|
172
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
173
|
+
- spec/dummy/config/initializers/inflections.rb
|
174
|
+
- spec/dummy/config/initializers/mime_types.rb
|
175
|
+
- spec/dummy/config/initializers/secret_token.rb
|
176
|
+
- spec/dummy/config/initializers/session_store.rb
|
177
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
178
|
+
- spec/dummy/config/locales/en.yml
|
179
|
+
- spec/dummy/config/routes.rb
|
180
|
+
- spec/dummy/db/schema.rb
|
181
|
+
- spec/dummy/lib/assets/.gitkeep
|
182
|
+
- spec/dummy/log/.gitkeep
|
183
|
+
- spec/dummy/public/404.html
|
184
|
+
- spec/dummy/public/422.html
|
185
|
+
- spec/dummy/public/500.html
|
186
|
+
- spec/dummy/public/favicon.ico
|
187
|
+
- spec/dummy/script/rails
|
188
|
+
- spec/lib/satchel/activity_builder_spec.rb
|
189
|
+
- spec/lib/satchel/activity_data_structure_spec.rb
|
190
|
+
- spec/lib/satchel/context_builder_spec.rb
|
191
|
+
- spec/lib/satchel_spec.rb
|
192
|
+
- spec/models/satchel/activity_spec.rb
|
83
193
|
- spec/spec_helper.rb
|
194
|
+
- spec/spec_patch.rb
|
195
|
+
- spec/support/persistence_layer.rb
|