inter 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/.rspec +1 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +4 -0
  7. data/Gemfile +3 -0
  8. data/Gemfile.lock +102 -0
  9. data/LICENSE +23 -0
  10. data/README.md +176 -0
  11. data/Rakefile +9 -0
  12. data/inter.gemspec +25 -0
  13. data/lib/generators/inter/install_generator.rb +15 -0
  14. data/lib/generators/templates/create_interactions.rb +13 -0
  15. data/lib/inter.rb +2 -0
  16. data/lib/inter/actable.rb +172 -0
  17. data/lib/inter/action.rb +26 -0
  18. data/lib/inter/version.rb +3 -0
  19. data/spec/class_spec.rb +38 -0
  20. data/spec/dummy/Rakefile +6 -0
  21. data/spec/dummy/app/assets/images/.keep +0 -0
  22. data/spec/dummy/app/assets/javascripts/application.js +16 -0
  23. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  24. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  25. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  26. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  27. data/spec/dummy/app/mailers/.keep +0 -0
  28. data/spec/dummy/app/models/.keep +0 -0
  29. data/spec/dummy/app/models/article.rb +3 -0
  30. data/spec/dummy/app/models/concerns/.keep +0 -0
  31. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  32. data/spec/dummy/bin/bundle +3 -0
  33. data/spec/dummy/bin/rails +4 -0
  34. data/spec/dummy/bin/rake +4 -0
  35. data/spec/dummy/config.ru +4 -0
  36. data/spec/dummy/config/application.rb +24 -0
  37. data/spec/dummy/config/boot.rb +4 -0
  38. data/spec/dummy/config/database.yml +25 -0
  39. data/spec/dummy/config/environment.rb +5 -0
  40. data/spec/dummy/config/environments/development.rb +29 -0
  41. data/spec/dummy/config/environments/production.rb +80 -0
  42. data/spec/dummy/config/environments/test.rb +36 -0
  43. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  44. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  45. data/spec/dummy/config/initializers/inflections.rb +16 -0
  46. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  47. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  48. data/spec/dummy/config/initializers/session_store.rb +3 -0
  49. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  50. data/spec/dummy/config/locales/en.yml +23 -0
  51. data/spec/dummy/config/routes.rb +56 -0
  52. data/spec/dummy/db/development.sqlite3 +0 -0
  53. data/spec/dummy/db/migrate/20131111155047_create_interactions.rb +13 -0
  54. data/spec/dummy/db/migrate/20131111233640_create_articles.rb +7 -0
  55. data/spec/dummy/db/schema.rb +30 -0
  56. data/spec/dummy/db/seeds.rb +7 -0
  57. data/spec/dummy/db/test.sqlite3 +0 -0
  58. data/spec/dummy/lib/assets/.keep +0 -0
  59. data/spec/dummy/lib/tasks/.keep +0 -0
  60. data/spec/dummy/log/.keep +0 -0
  61. data/spec/dummy/log/development.log +20 -0
  62. data/spec/dummy/log/test.log +41749 -0
  63. data/spec/dummy/public/404.html +58 -0
  64. data/spec/dummy/public/422.html +58 -0
  65. data/spec/dummy/public/500.html +57 -0
  66. data/spec/dummy/public/favicon.ico +0 -0
  67. data/spec/dummy/public/robots.txt +5 -0
  68. data/spec/dummy/test/controllers/.keep +0 -0
  69. data/spec/dummy/test/fixtures/.keep +0 -0
  70. data/spec/dummy/test/helpers/.keep +0 -0
  71. data/spec/dummy/test/integration/.keep +0 -0
  72. data/spec/dummy/test/mailers/.keep +0 -0
  73. data/spec/dummy/test/models/.keep +0 -0
  74. data/spec/dummy/test/test_helper.rb +15 -0
  75. data/spec/dummy/vendor/assets/javascripts/.keep +0 -0
  76. data/spec/dummy/vendor/assets/stylesheets/.keep +0 -0
  77. data/spec/instance_spec.rb +337 -0
  78. data/spec/related_spec.rb +43 -0
  79. data/spec/spec_helper.rb +15 -0
  80. metadata +240 -0
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/404.html -->
52
+ <div class="dialog">
53
+ <h1>The page you were looking for doesn't exist.</h1>
54
+ <p>You may have mistyped the address or the page may have moved.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/422.html -->
52
+ <div class="dialog">
53
+ <h1>The change you wanted was rejected.</h1>
54
+ <p>Maybe you tried to change something you didn't have access to.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/500.html -->
52
+ <div class="dialog">
53
+ <h1>We're sorry, but something went wrong.</h1>
54
+ </div>
55
+ <p>If you are the application owner check the logs for more information.</p>
56
+ </body>
57
+ </html>
File without changes
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-agent: *
5
+ # Disallow: /
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,15 @@
1
+ ENV["RAILS_ENV"] ||= "test"
2
+ require File.expand_path('../../config/environment', __FILE__)
3
+ require 'rails/test_help'
4
+
5
+ class ActiveSupport::TestCase
6
+ ActiveRecord::Migration.check_pending!
7
+
8
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
9
+ #
10
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
11
+ # -- they do not yet inherit this setting
12
+ fixtures :all
13
+
14
+ # Add more helper methods to be used by all tests here...
15
+ end
@@ -0,0 +1,337 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Inter::Actable Instance" do
4
+ before :each do
5
+ @article = Article.create!
6
+ end
7
+
8
+ describe "getting and setting" do
9
+ describe "booleans" do
10
+ it "#is_*!" do
11
+ @article.is_published!
12
+
13
+ expect(@article).to have(1).interaction
14
+ expect(@article.interactions.last.key).to be == "published"
15
+ expect(@article.interactions.last.value).to be_true
16
+ end
17
+
18
+ it "#isnt_*!" do
19
+ @article.isnt_published!
20
+
21
+ expect(@article).to have(1).interaction
22
+ expect(@article.interactions.last.key).to be == "published"
23
+ expect(@article.interactions.last.value).to be_false
24
+ end
25
+
26
+ it "#is_not_!" do
27
+ @article.is_not_published!
28
+
29
+ expect(@article).to have(1).interaction
30
+ expect(@article.interactions.last.key).to be == "published"
31
+ expect(@article.interactions.last.value).to be_false
32
+ end
33
+
34
+ it "#is_*?" do
35
+ expect(@article.is_published?).to be_false
36
+ @article.is_published!
37
+ expect(@article.is_published?).to be_true
38
+ @article.isnt_published!
39
+ expect(@article.is_published?).to be_false
40
+ end
41
+
42
+ it "#isnt_*?" do
43
+ expect(@article.isnt_published?).to be_true
44
+ @article.is_published!
45
+ expect(@article.isnt_published?).to be_false
46
+ @article.isnt_published!
47
+ expect(@article.isnt_published?).to be_true
48
+ end
49
+
50
+ it "#is_not_*?" do
51
+ @article.is_published!
52
+ expect(@article.is_not_published?).to be_false
53
+ @article.is_not_published!
54
+ expect(@article.isnt_published?).to be_true
55
+ end
56
+
57
+ it "#is_*_and_is_*?" do
58
+ @article.is_published!
59
+ @article.is_hidden!
60
+ expect(@article.is_hidden_and_published?).to be_true
61
+ @article.isnt_hidden!
62
+ expect(@article.is_hidden_and_published?).to be_false
63
+ end
64
+
65
+ it "#is_*_and_is_not_*?" do
66
+ @article.is_published!
67
+ @article.is_hidden!
68
+ expect(@article.is_hidden_and_is_not_published?).to be_false
69
+ @article.isnt_published!
70
+ expect(@article.is_hidden_and_is_not_published?).to be_true
71
+ end
72
+
73
+ it "#isnt_*_and_is_*?" do
74
+ @article.is_published!
75
+ @article.is_hidden!
76
+ expect(@article.isnt_hidden_and_is_published?).to be_false
77
+ @article.isnt_hidden!
78
+ expect(@article.isnt_hidden_and_is_published?).to be_true
79
+ end
80
+
81
+ it "#is_not_*_and_is_*?" do
82
+ @article.is_published!
83
+ @article.is_hidden!
84
+ expect(@article.is_not_hidden_and_is_published?).to be_false
85
+ @article.isnt_hidden!
86
+ expect(@article.is_not_hidden_and_is_published?).to be_true
87
+ end
88
+
89
+ it "#is_not_*_and_is_not_*?" do
90
+ @article.is_published!
91
+ @article.is_hidden!
92
+ expect(@article.is_not_hidden_and_is_not_published?).to be_false
93
+ @article.isnt_hidden!
94
+ @article.isnt_published!
95
+ expect(@article.is_not_hidden_and_is_not_published?).to be_true
96
+ end
97
+
98
+ it "#is_*_and_isnt_*?" do
99
+ @article.is_published!
100
+ @article.is_hidden!
101
+ expect(@article.is_hidden_and_isnt_published?).to be_false
102
+ @article.isnt_published!
103
+ expect(@article.is_hidden_and_isnt_published?).to be_true
104
+ end
105
+
106
+ it "#is_*_and_is_*_and_is_*?" do
107
+ @article.is_published!
108
+ @article.is_hidden!
109
+ expect(@article.is_hidden_and_is_published_and_is_amazing?).to be_false
110
+ @article.is_amazing!
111
+ expect(@article.is_hidden_and_is_published_and_is_amazing?).to be_true
112
+ end
113
+
114
+ it "#isnt_*_and_is_*_and_is_not_*?" do
115
+ @article.is_published!
116
+ @article.isnt_hidden!
117
+ @article.is_amazing!
118
+ expect(@article.isnt_hidden_and_is_published_and_is_not_amazing?).to be_false
119
+ @article.isnt_amazing!
120
+ expect(@article.isnt_hidden_and_is_published_and_is_not_amazing?).to be_true
121
+ end
122
+ end
123
+
124
+ describe "complex values" do
125
+ it "#set *symbol, *" do
126
+ @article.set :tags, [:foo, :bar]
127
+
128
+ expect(@article).to have(1).interaction
129
+ expect(@article.interactions.last.key).to be == "tags"
130
+ expect(@article.interactions.last.value).to be == ["foo", "bar"]
131
+ end
132
+
133
+ it "#set *string, *" do
134
+ @article.set "tags", [:foo, :bar]
135
+
136
+ expect(@article).to have(1).interaction
137
+ expect(@article.interactions.last.key).to be == "tags"
138
+ expect(@article.interactions.last.value).to be == ["foo", "bar"]
139
+ end
140
+
141
+ it "#get *symbol" do
142
+ @article.set "tags", [:foo, :bar]
143
+
144
+ expect(@article.get(:tags)).to be == ["foo", "bar"]
145
+ end
146
+
147
+ it "#get *string" do
148
+ @article.set :tags, [:foo, :bar]
149
+
150
+ expect(@article.get("tags")).to be == ["foo", "bar"]
151
+ end
152
+
153
+
154
+ it "#has? *" do
155
+ expect(@article.has? :tags).to be_false
156
+ @article.set "tags", [:foo, :bar]
157
+ expect(@article.has? :tags).to be_true
158
+ @article.set "tags", nil
159
+ expect(@article.has? :tags).to be_false
160
+ end
161
+ end
162
+ end
163
+
164
+ describe "direct access methods" do
165
+ describe "booleans" do
166
+ it "#is *string" do
167
+ @article.is "published"
168
+
169
+ expect(@article).to have(1).interaction
170
+ expect(@article.interactions.last.key).to be == "published"
171
+ expect(@article.interactions.last.value).to be_true
172
+ end
173
+
174
+ it "#is *symbol" do
175
+ @article.is :published
176
+
177
+ expect(@article).to have(1).interaction
178
+ expect(@article.interactions.last.key).to be == "published"
179
+ expect(@article.interactions.last.value).to be_true
180
+ end
181
+
182
+ it "#is *implicit_array" do
183
+ @article.is :hidden, :published
184
+
185
+ expect(@article).to have(2).interactions
186
+ expect(@article.interactions.last.key).to be == "published"
187
+ expect(@article.interactions.last.value).to be_true
188
+ end
189
+
190
+ it "#is *explicit_array" do
191
+ @article.is [:hidden, :published]
192
+
193
+ expect(@article).to have(2).interactions
194
+ expect(@article.interactions.last.key).to be == "published"
195
+ expect(@article.interactions.last.value).to be_true
196
+ end
197
+
198
+ it "#is *array with negatives" do
199
+ @article.is [:hidden, :not_published]
200
+
201
+ expect(@article).to have(2).interactions
202
+ expect(@article.interactions.last.key).to be == "published"
203
+ expect(@article.interactions.last.value).to be_false
204
+ end
205
+
206
+ it "#is? *" do
207
+ expect(@article.is?(:promoted, :published)).to be_false
208
+ @article.is [:promoted, :published]
209
+ expect(@article.is?(:promoted, :published)).to be_true
210
+ @article.is :not_published
211
+ expect(@article.is?(:promoted, :published)).to be_false
212
+ end
213
+
214
+ it "#is? []" do
215
+ expect(@article.is?([:promoted, :published])).to be_false
216
+ @article.is [:promoted, :published]
217
+ expect(@article.is?([:promoted, :published])).to be_true
218
+ @article.is :not_published
219
+ expect(@article.is?([:promoted, :published])).to be_false
220
+ end
221
+ end
222
+ end
223
+
224
+ describe "history" do
225
+ describe "booleans" do
226
+ it "#was_*?" do
227
+ expect(@article.was_published?).to be_false
228
+ @article.is_published!
229
+ @article.isnt_published!
230
+ expect(@article.was_published?).to be_true
231
+ end
232
+
233
+ it "#wasnt_?" do
234
+ expect(@article.wasnt_published?).to be_true
235
+ @article.is_published!
236
+ @article.isnt_published!
237
+ expect(@article.wasnt_published?).to be_false
238
+ end
239
+
240
+ it "#was_not_?" do
241
+ expect(@article.was_not_published?).to be_true
242
+ @article.is_published!
243
+ @article.isnt_published!
244
+ expect(@article.was_not_published?).to be_false
245
+ end
246
+
247
+ it "#was_*_and_*" do
248
+ expect(@article.was_published_and_hidden?).to be_false
249
+ @article.is_published_and_hidden!
250
+ @article.isnt_published_and_hidden!
251
+ expect(@article.was_published_and_hidden?).to be_true
252
+ end
253
+
254
+ it "#was_*_and_was_*?" do
255
+ expect(@article.was_published_and_was_hidden?).to be_false
256
+ @article.is_published_and_hidden!
257
+ @article.isnt_published_and_hidden!
258
+ expect(@article.was_published_and_was_hidden?).to be_true
259
+ end
260
+
261
+ it "#was_*_and_was_not_*?" do
262
+ expect(@article.was_published_and_was_not_hidden?).to be_false
263
+ @article.is_published!
264
+ @article.isnt_published!
265
+ expect(@article.was_published_and_was_not_hidden?).to be_true
266
+ end
267
+
268
+ it "#was_not_*_and_was_*?" do
269
+ expect(@article.was_not_published_and_was_hidden?).to be_false
270
+ @article.is_hidden!
271
+ @article.isnt_hidden!
272
+ expect(@article.was_not_published_and_was_hidden?).to be_true
273
+ end
274
+
275
+ it "#was_*_and_wasnt_*?" do
276
+ expect(@article.was_published_and_wasnt_hidden?).to be_false
277
+ @article.is_published!
278
+ @article.isnt_published!
279
+ expect(@article.was_published_and_wasnt_hidden?).to be_true
280
+ end
281
+
282
+ it "#wasnt_*_and_was_*?" do
283
+ expect(@article.wasnt_published_and_was_hidden?).to be_false
284
+ @article.is_hidden!
285
+ @article.isnt_hidden!
286
+ expect(@article.wasnt_published_and_was_hidden?).to be_true
287
+ end
288
+
289
+ it "#was_*_and_wasnt_*_and_was_*?" do
290
+ expect(@article.was_published_and_wasnt_hidden_and_was_promoted?).to be_false
291
+ @article.is_published!
292
+ @article.is_promoted!
293
+ @article.isnt_published!
294
+ expect(@article.was_published_and_wasnt_hidden_and_was_promoted?).to be_true
295
+ end
296
+
297
+ it "#history *string" do
298
+ @article.is_published!
299
+ @article.isnt_published_and_is_hidden!
300
+ history = @article.history "published"
301
+ expect(history).to have(2).interactions
302
+ history.each do |interaction|
303
+ expect(interaction).to be_a(Inter::Action)
304
+ expect(interaction.key).to be == "published"
305
+ end
306
+ end
307
+
308
+ it "#history *symbol" do
309
+ @article.is_published!
310
+ @article.isnt_published_and_is_hidden!
311
+ history = @article.history :published
312
+ expect(history).to have(2).interactions
313
+ history.each do |interaction|
314
+ expect(interaction).to be_a(Inter::Action)
315
+ expect(interaction.key).to be == "published"
316
+ end
317
+ end
318
+
319
+ it "#history *implicit array" do
320
+ @article.is_published!
321
+ @article.isnt_published_and_is_hidden!
322
+ history = @article.history :published, :hidden
323
+ expect(history).to have(3).interactions
324
+ end
325
+
326
+ it "#history *explicit array" do
327
+ @article.is_published!
328
+ @article.isnt_published_and_is_hidden!
329
+ history = @article.history ["published", "hidden"]
330
+ expect(history).to have(3).interactions
331
+ end
332
+
333
+ pending "#history *implicit hash"
334
+ pending "#history *explicit hash"
335
+ end
336
+ end
337
+ end