rspec-rails-matchers 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/rspec-rails-matchers.rb
CHANGED
@@ -7,9 +7,11 @@ module RspecRailsMatchers
|
|
7
7
|
autoload :Message, 'rspec_rails_matchers/message'
|
8
8
|
autoload :Validations, 'rspec_rails_matchers/validations'
|
9
9
|
autoload :Associations, 'rspec_rails_matchers/associations'
|
10
|
+
autoload :Behavior, 'rspec_rails_matchers/behavior'
|
10
11
|
end
|
11
12
|
|
12
13
|
Rspec.configure do |c|
|
13
14
|
c.include RspecRailsMatchers::Validations
|
14
15
|
c.include RspecRailsMatchers::Associations
|
16
|
+
c.include RspecRailsMatchers::Behavior
|
15
17
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module RspecRailsMatchers
|
2
|
+
module Behavior
|
3
|
+
module Lint
|
4
|
+
share_as :AnActiveModel do
|
5
|
+
def be_a_boolean
|
6
|
+
Rspec::Matchers::Matcher.new :be_a_boolean do
|
7
|
+
match do |value|
|
8
|
+
[ true, false ].include?( value )
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it { should respond_to(:to_model) }
|
14
|
+
it { should respond_to(:to_key) }
|
15
|
+
it { should respond_to(:to_param) }
|
16
|
+
|
17
|
+
it { should respond_to(:valid?) }
|
18
|
+
its(:valid?) { should be_a_boolean }
|
19
|
+
|
20
|
+
it { should respond_to(:persisted?) }
|
21
|
+
its(:persisted?) { should be_a_boolean }
|
22
|
+
|
23
|
+
its(:class) { should respond_to(:model_name) }
|
24
|
+
|
25
|
+
context "the model name" do
|
26
|
+
def subject
|
27
|
+
super.class.model_name
|
28
|
+
end
|
29
|
+
|
30
|
+
it { should be_kind_of(String) }
|
31
|
+
its(:human) { should be_kind_of(String) }
|
32
|
+
its(:partial_path) { should be_kind_of(String) }
|
33
|
+
its(:singular) { should be_kind_of(String) }
|
34
|
+
its(:plural) { should be_kind_of(String) }
|
35
|
+
end
|
36
|
+
|
37
|
+
context "when its not persisted" do
|
38
|
+
def subject
|
39
|
+
obj = super.dup
|
40
|
+
obj.stub!(:persisted?).and_return(false)
|
41
|
+
obj
|
42
|
+
end
|
43
|
+
|
44
|
+
its(:to_key) { should be_nil }
|
45
|
+
its(:to_param) { should be_nil }
|
46
|
+
end
|
47
|
+
|
48
|
+
it { should respond_to(:errors) }
|
49
|
+
|
50
|
+
context "errors" do
|
51
|
+
def subject
|
52
|
+
super.errors
|
53
|
+
end
|
54
|
+
|
55
|
+
it { should respond_to(:[]) }
|
56
|
+
it { should respond_to(:full_messages) }
|
57
|
+
|
58
|
+
context "[:hello]" do
|
59
|
+
it { subject[:hello].should be_an_instance_of(Array) }
|
60
|
+
|
61
|
+
its(:full_messages) { should be_an_instance_of(Array) }
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rspec-rails-matchers}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Cyril David"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-03-04}
|
13
13
|
s.description = %q{Helps you write rspec with rails for fun}
|
14
14
|
s.email = %q{cyx@sinefunc.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -30,6 +30,8 @@ Gem::Specification.new do |s|
|
|
30
30
|
"lib/rspec_rails_matchers/associations/have_many.rb",
|
31
31
|
"lib/rspec_rails_matchers/associations/have_one.rb",
|
32
32
|
"lib/rspec_rails_matchers/associations/helpers.rb",
|
33
|
+
"lib/rspec_rails_matchers/behavior.rb",
|
34
|
+
"lib/rspec_rails_matchers/behavior/lint.rb",
|
33
35
|
"lib/rspec_rails_matchers/message.rb",
|
34
36
|
"lib/rspec_rails_matchers/validations.rb",
|
35
37
|
"lib/rspec_rails_matchers/validations/confirmation_of.rb",
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
- 1
|
8
7
|
- 2
|
9
|
-
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Cyril David
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-03-04 00:00:00 +08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -54,6 +54,8 @@ files:
|
|
54
54
|
- lib/rspec_rails_matchers/associations/have_many.rb
|
55
55
|
- lib/rspec_rails_matchers/associations/have_one.rb
|
56
56
|
- lib/rspec_rails_matchers/associations/helpers.rb
|
57
|
+
- lib/rspec_rails_matchers/behavior.rb
|
58
|
+
- lib/rspec_rails_matchers/behavior/lint.rb
|
57
59
|
- lib/rspec_rails_matchers/message.rb
|
58
60
|
- lib/rspec_rails_matchers/validations.rb
|
59
61
|
- lib/rspec_rails_matchers/validations/confirmation_of.rb
|