minitest-rails-shoulda 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/CHANGELOG.txt +3 -0
- data/Gemfile +4 -0
- data/License.txt +22 -0
- data/README.rdoc +66 -0
- data/Rakefile +1 -0
- data/lib/minitest-rails-shoulda.rb +12 -0
- data/lib/minitest-rails-shoulda/integrations.rb +36 -0
- data/lib/minitest-rails-shoulda/version.rb +7 -0
- data/minitest-rails-shoulda.gemspec +24 -0
- metadata +105 -0
data/.gitignore
ADDED
data/CHANGELOG.txt
ADDED
data/Gemfile
ADDED
data/License.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2012 Robert Bousquet, Rafal Wrzochol
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
= minitest-rails-shoulda
|
2
|
+
|
3
|
+
Make shoulda-matchers available for minitest-rails.
|
4
|
+
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
In Rails 3 and Bundler, add the following to your Gemfile:
|
8
|
+
|
9
|
+
group :test do
|
10
|
+
gem "minitest-rails-shoulda"
|
11
|
+
end
|
12
|
+
|
13
|
+
== Usage
|
14
|
+
|
15
|
+
=== ActiveRecord Matchers
|
16
|
+
|
17
|
+
Matchers to test associations:
|
18
|
+
|
19
|
+
describe Post do
|
20
|
+
subject { Post.new }
|
21
|
+
it { must belong_to(:user) }
|
22
|
+
it { must have_many(:tags).through(:taggings) }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe User do
|
26
|
+
subject { User.new }
|
27
|
+
it { must have_many(:posts) }
|
28
|
+
end
|
29
|
+
|
30
|
+
=== ActiveModel Matchers
|
31
|
+
|
32
|
+
Matchers to test validations and mass assignments:
|
33
|
+
|
34
|
+
describe Post do
|
35
|
+
subject { Post.new }
|
36
|
+
it { must validate_uniqueness_of(:title) }
|
37
|
+
it { must validate_presence_of(:body).with_message(/wtf/) }
|
38
|
+
it { must validate_presence_of(:title) }
|
39
|
+
it { must validate_numericality_of(:user_id) }
|
40
|
+
end
|
41
|
+
|
42
|
+
describe User do
|
43
|
+
subject { User.new }
|
44
|
+
it { wont allow_value("blah").for(:email) }
|
45
|
+
it { must allow_value("a@b.com").for(:email) }
|
46
|
+
it { must ensure_inclusion_of(:age).in_range(1..100) }
|
47
|
+
it { wont allow_mass_assignment_of(:password) }
|
48
|
+
end
|
49
|
+
|
50
|
+
=== ActionController Matchers
|
51
|
+
|
52
|
+
Matchers to test common patterns:
|
53
|
+
|
54
|
+
describe PostsController, "#show" do
|
55
|
+
context "for a fictional user" do
|
56
|
+
before do
|
57
|
+
get :show, :id => 1
|
58
|
+
end
|
59
|
+
|
60
|
+
it { must assign_to(:user) }
|
61
|
+
it { must respond_with(:success) }
|
62
|
+
it { must render_template(:show) }
|
63
|
+
it { wont set_the_flash }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,36 @@
|
|
1
|
+
if defined? ActionController
|
2
|
+
require "shoulda/matchers/action_controller"
|
3
|
+
|
4
|
+
class MiniTest::Rails::ActionController::TestCase
|
5
|
+
include Shoulda::Matchers::ActionController
|
6
|
+
extend Shoulda::Matchers::ActionController
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
if defined? ActionMailer
|
11
|
+
require "shoulda/matchers/action_mailer"
|
12
|
+
|
13
|
+
class MiniTest::Rails::ActionMailer::TestCase
|
14
|
+
include Shoulda::Matchers::ActionMailer
|
15
|
+
extend Shoulda::Matchers::ActionMailer
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
if defined? ActiveRecord
|
20
|
+
require "shoulda/matchers/active_record"
|
21
|
+
require "shoulda/matchers/active_model"
|
22
|
+
|
23
|
+
class MiniTest::Rails::ActiveSupport::TestCase
|
24
|
+
include Shoulda::Matchers::ActiveRecord
|
25
|
+
extend Shoulda::Matchers::ActiveRecord
|
26
|
+
include Shoulda::Matchers::ActiveModel
|
27
|
+
extend Shoulda::Matchers::ActiveModel
|
28
|
+
end
|
29
|
+
elsif defined? ActiveModel
|
30
|
+
require "shoulda/matchers/active_model"
|
31
|
+
|
32
|
+
class MiniTest::Rails::ActiveSupport::TestCase
|
33
|
+
include Shoulda::Matchers::ActiveModel
|
34
|
+
extend Shoulda::Matchers::ActiveModel
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "minitest-rails-shoulda/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "minitest-rails-shoulda"
|
7
|
+
s.version = MiniTest::Rails::Shoulda::VERSION
|
8
|
+
s.authors = ["Robert Bousquet", "Rafal Wrzochol"]
|
9
|
+
s.email = ["robert@robertbousquet.com", "rafal@wrzochol.net"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Making shoulda-matchers available for minitest-rails}
|
12
|
+
s.description = %q{Making shoulda-matchers available for minitest-rails}
|
13
|
+
|
14
|
+
s.rubyforge_project = "minitest-rails-shoulda"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
# s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_runtime_dependency "minitest-rails", "~> 0.1.0"
|
22
|
+
s.add_runtime_dependency "minitest-matchers", "~> 1.1.3"
|
23
|
+
s.add_runtime_dependency "shoulda-matchers", "~> 1.2.0"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: minitest-rails-shoulda
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Robert Bousquet
|
9
|
+
- Rafal Wrzochol
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-08-06 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: minitest-rails
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.1.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 0.1.0
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: minitest-matchers
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ~>
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 1.1.3
|
39
|
+
type: :runtime
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.1.3
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: shoulda-matchers
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.2.0
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.2.0
|
63
|
+
description: Making shoulda-matchers available for minitest-rails
|
64
|
+
email:
|
65
|
+
- robert@robertbousquet.com
|
66
|
+
- rafal@wrzochol.net
|
67
|
+
executables: []
|
68
|
+
extensions: []
|
69
|
+
extra_rdoc_files: []
|
70
|
+
files:
|
71
|
+
- .gitignore
|
72
|
+
- CHANGELOG.txt
|
73
|
+
- Gemfile
|
74
|
+
- License.txt
|
75
|
+
- README.rdoc
|
76
|
+
- Rakefile
|
77
|
+
- lib/minitest-rails-shoulda.rb
|
78
|
+
- lib/minitest-rails-shoulda/integrations.rb
|
79
|
+
- lib/minitest-rails-shoulda/version.rb
|
80
|
+
- minitest-rails-shoulda.gemspec
|
81
|
+
homepage: ''
|
82
|
+
licenses: []
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project: minitest-rails-shoulda
|
101
|
+
rubygems_version: 1.8.24
|
102
|
+
signing_key:
|
103
|
+
specification_version: 3
|
104
|
+
summary: Making shoulda-matchers available for minitest-rails
|
105
|
+
test_files: []
|