riot-mongo_mapper 0.0.2 → 0.0.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.
- data/README.md +4 -1
- data/lib/riot-mongo_mapper/has_plugin.rb +14 -0
- data/riot-mongo_mapper.gemspec +1 -1
- data/test/fixtures/test.rb +6 -0
- data/test/has_plugin_test.rb +23 -0
- metadata +7 -4
data/README.md
CHANGED
@@ -7,7 +7,7 @@ Riot assertions for MongoMapper
|
|
7
7
|
context "Photo Model" do
|
8
8
|
|
9
9
|
context 'definition' do
|
10
|
-
setup { Photo
|
10
|
+
setup { Photo }
|
11
11
|
|
12
12
|
# field associations
|
13
13
|
asserts_topic.has_key :title, String
|
@@ -20,6 +20,9 @@ Riot assertions for MongoMapper
|
|
20
20
|
|
21
21
|
# validation assertions
|
22
22
|
asserts_topic.has_validation :validates_presence_of, :caption
|
23
|
+
|
24
|
+
# plugin assertions
|
25
|
+
asserts_topic.has_plugin Plugins::SomePlugin
|
23
26
|
end
|
24
27
|
end
|
25
28
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module RiotMongoMapper
|
2
|
+
class HasPluginAssertion < Riot::AssertionMacro
|
3
|
+
register :has_plugin
|
4
|
+
|
5
|
+
def evaluate(model, plugin)
|
6
|
+
assert = model.respond_to?(:plugins) ? model.plugins.include?(plugin) : model.class.plugins.include?(plugin)
|
7
|
+
if assert
|
8
|
+
pass("#{model} has plugin #{plugin.inspect}")
|
9
|
+
else
|
10
|
+
fail("expected #{model} to have plugin #{plugin.inspect}")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/riot-mongo_mapper.gemspec
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'teststrap')
|
2
|
+
require File.join(File.dirname(__FILE__), 'fixtures', 'test')
|
3
|
+
|
4
|
+
context "has_plugin macro" do
|
5
|
+
setup{ @assertion = RiotMongoMapper::HasPluginAssertion.new }
|
6
|
+
setup do
|
7
|
+
mock_model do
|
8
|
+
plugin Plugins::Test
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
asserts "passes when has plugin" do
|
13
|
+
@assertion.evaluate(topic, Plugins::Test).first
|
14
|
+
end.equals(:pass)
|
15
|
+
|
16
|
+
asserts "fails when it doesn't have plugin" do
|
17
|
+
@assertion.evaluate(topic, Plugins::Faux).first
|
18
|
+
end.equals(:fail)
|
19
|
+
|
20
|
+
asserts "returns a message" do
|
21
|
+
@assertion.evaluate(topic, Plugins::Test).last
|
22
|
+
end.matches %r{has plugin Plugins::Test}
|
23
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riot-mongo_mapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Arthur Chiu
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-07-
|
18
|
+
date: 2010-07-23 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -93,10 +93,13 @@ files:
|
|
93
93
|
- riot-mongo_mapper.gemspec
|
94
94
|
- lib/riot-mongo_mapper/has_association.rb
|
95
95
|
- lib/riot-mongo_mapper/has_key.rb
|
96
|
+
- lib/riot-mongo_mapper/has_plugin.rb
|
96
97
|
- lib/riot-mongo_mapper/has_validation.rb
|
97
98
|
- lib/riot-mongo_mapper.rb
|
99
|
+
- test/fixtures/test.rb
|
98
100
|
- test/has_association_test.rb
|
99
101
|
- test/has_key_test.rb
|
102
|
+
- test/has_plugin_test.rb
|
100
103
|
- test/has_validation_test.rb
|
101
104
|
- test/teststrap.rb
|
102
105
|
has_rdoc: true
|