riot-mongoid 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/lib/riot-mongoid.rb +19 -0
- data/test/riot-mongoid_test.rb +38 -0
- data/test/teststrap.rb +4 -0
- metadata +104 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 gabrielg
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= riot-mongoid
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 gabrielg. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "riot-mongoid"
|
8
|
+
gem.summary = %Q{Riot assertions for Mongoid}
|
9
|
+
gem.description = %Q{A collection of assertion macros for testing Mongoid with Riot}
|
10
|
+
gem.email = "gabriel.gironda@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/gabrielg/riot-mongoid"
|
12
|
+
gem.authors = ["gabrielg"]
|
13
|
+
gem.add_development_dependency "riot", ">= 0"
|
14
|
+
gem.add_development_dependency "yard", ">= 0"
|
15
|
+
gem.add_dependency "mongoid", ">=1.2.7"
|
16
|
+
gem.add_dependency "riot", ">=0.10.12"
|
17
|
+
end
|
18
|
+
Jeweler::GemcutterTasks.new
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'rake/testtask'
|
24
|
+
Rake::TestTask.new(:test) do |test|
|
25
|
+
test.libs << 'lib' << 'test'
|
26
|
+
test.pattern = 'test/**/*_test.rb'
|
27
|
+
test.verbose = true
|
28
|
+
end
|
29
|
+
|
30
|
+
begin
|
31
|
+
require 'rcov/rcovtask'
|
32
|
+
Rcov::RcovTask.new do |test|
|
33
|
+
test.libs << 'test'
|
34
|
+
test.pattern = 'test/**/*_test.rb'
|
35
|
+
test.verbose = true
|
36
|
+
end
|
37
|
+
rescue LoadError
|
38
|
+
task :rcov do
|
39
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
task :test => :check_dependencies
|
44
|
+
|
45
|
+
task :default => :test
|
46
|
+
|
47
|
+
begin
|
48
|
+
require 'yard'
|
49
|
+
YARD::Rake::YardocTask.new
|
50
|
+
rescue LoadError
|
51
|
+
task :yardoc do
|
52
|
+
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
53
|
+
end
|
54
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
data/lib/riot-mongoid.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module RiotMongoid
|
2
|
+
class HasFieldAssertion < Riot::AssertionMacro
|
3
|
+
register :has_field
|
4
|
+
|
5
|
+
def evaluate(model, *macro_info)
|
6
|
+
field_name, options = macro_info
|
7
|
+
field = model.fields[field_name.to_s]
|
8
|
+
if options.nil? || options.empty?
|
9
|
+
fail("field options must be specified with this assertion macro")
|
10
|
+
elsif field.nil?
|
11
|
+
fail("expected #{model} to have field #{field_name}")
|
12
|
+
else
|
13
|
+
options_valid = options.all? { |key,value| field.send(key) == value }
|
14
|
+
options_valid ? pass("#{model} has field '#{field_name}' with options #{options.inspect}") :
|
15
|
+
fail("expected model to have options #{options.inspect} on field #{field_name}")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end # HasFieldAssertion
|
19
|
+
end # RiotMongoid
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "riot-mongoid" do
|
4
|
+
|
5
|
+
setup do
|
6
|
+
test_class = Class.new
|
7
|
+
test_class.class_eval do
|
8
|
+
include Mongoid::Document
|
9
|
+
field :name, :type => String
|
10
|
+
field :rad, :type => Boolean, :default => false
|
11
|
+
end
|
12
|
+
test_class
|
13
|
+
end
|
14
|
+
|
15
|
+
asserts "the macro passes when the field options are specified" do
|
16
|
+
RiotMongoid::HasFieldAssertion.new.evaluate(topic, :name, :type => String).first
|
17
|
+
end.equals(:pass)
|
18
|
+
|
19
|
+
asserts "the macro pass message is useful" do
|
20
|
+
RiotMongoid::HasFieldAssertion.new.evaluate(topic, :name, :type => String).last
|
21
|
+
end.matches(/has field 'name' with options \{:type=>String\}/)
|
22
|
+
|
23
|
+
asserts "the macro fails when the field options are not specified" do
|
24
|
+
RiotMongoid::HasFieldAssertion.new.evaluate(topic, :name).first
|
25
|
+
end.equals(:fail)
|
26
|
+
|
27
|
+
asserts "the macro fails when invalid field options are specified" do
|
28
|
+
RiotMongoid::HasFieldAssertion.new.evaluate(topic, :name, :type => Date).first
|
29
|
+
end.equals(:fail)
|
30
|
+
|
31
|
+
asserts "the macro passes with a slightly more complex field setup" do
|
32
|
+
RiotMongoid::HasFieldAssertion.new.evaluate(topic, :rad, :type => Boolean, :default => false).first
|
33
|
+
end.equals(:pass)
|
34
|
+
|
35
|
+
asserts "the macro fails with a slightly more complex field setup and a bad assertion" do
|
36
|
+
RiotMongoid::HasFieldAssertion.new.evaluate(topic, :rad, :type => Boolean, :default => true).first
|
37
|
+
end.equals(:fail)
|
38
|
+
end
|
data/test/teststrap.rb
ADDED
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: riot-mongoid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- gabrielg
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-03-05 00:00:00 -06:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: riot
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: yard
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: mongoid
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.2.7
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: riot
|
47
|
+
type: :runtime
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.10.12
|
54
|
+
version:
|
55
|
+
description: A collection of assertion macros for testing Mongoid with Riot
|
56
|
+
email: gabriel.gironda@gmail.com
|
57
|
+
executables: []
|
58
|
+
|
59
|
+
extensions: []
|
60
|
+
|
61
|
+
extra_rdoc_files:
|
62
|
+
- LICENSE
|
63
|
+
- README.rdoc
|
64
|
+
files:
|
65
|
+
- .document
|
66
|
+
- .gitignore
|
67
|
+
- LICENSE
|
68
|
+
- README.rdoc
|
69
|
+
- Rakefile
|
70
|
+
- VERSION
|
71
|
+
- lib/riot-mongoid.rb
|
72
|
+
- test/riot-mongoid_test.rb
|
73
|
+
- test/teststrap.rb
|
74
|
+
has_rdoc: true
|
75
|
+
homepage: http://github.com/gabrielg/riot-mongoid
|
76
|
+
licenses: []
|
77
|
+
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options:
|
80
|
+
- --charset=UTF-8
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: "0"
|
88
|
+
version:
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: "0"
|
94
|
+
version:
|
95
|
+
requirements: []
|
96
|
+
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 1.3.5
|
99
|
+
signing_key:
|
100
|
+
specification_version: 3
|
101
|
+
summary: Riot assertions for Mongoid
|
102
|
+
test_files:
|
103
|
+
- test/riot-mongoid_test.rb
|
104
|
+
- test/teststrap.rb
|