remarkable_devise 1.0.0.alpha2 → 1.0.0.alpha3

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -19,10 +19,12 @@ Add the require after the remarkable/active_record line in your spec_heplers.rb:
19
19
  # spec/models/user_spec.rb
20
20
  describe User do
21
21
  should_be_a_database_authenticatable
22
+ should_be_a_token_authenticatable
22
23
  should_be_a_confirmable
23
24
  should_be_a_recoverable
24
25
  should_be_a_rememberable
25
26
  should_be_a_trackable
27
+ should_be_a_validatable
26
28
  end
27
29
 
28
30
  ## See alse
@@ -0,0 +1,19 @@
1
+ module Remarkable
2
+ module Devise
3
+ module Matchers
4
+ class BeATokenAuthenticatableMatcher < Base
5
+ assertions :included?, :has_authentication_token_column?
6
+
7
+ protected
8
+
9
+ def included?
10
+ subject_class.ancestors.include?(::Devise::Models::TokenAuthenticatable)
11
+ end
12
+ end
13
+
14
+ def be_a_token_authenticatable
15
+ BeATokenAuthenticatableMatcher.new
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module Remarkable
2
+ module Devise
3
+ module Matchers
4
+ class BeAValidatableMatcher < Base
5
+ assertion :included?
6
+
7
+ protected
8
+
9
+ def included?
10
+ subject_class.ancestors.include?(::Devise::Models::Validatable)
11
+ end
12
+ end
13
+
14
+ def be_a_validatable
15
+ BeAValidatableMatcher.new
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,7 +1,7 @@
1
1
  module Remarkable
2
2
  module Devise
3
3
  module Version
4
- STRING = '1.0.0.alpha2'
4
+ STRING = '1.0.0.alpha3'
5
5
  end
6
6
  end
7
7
  end
data/locale/en.yml CHANGED
@@ -39,3 +39,14 @@ en:
39
39
  has_last_sign_in_at_column: "%{subject_name} to have last_sign_in_at column"
40
40
  has_current_sign_in_ip_column: "%{subject_name} to have current_sign_in_ip column"
41
41
  has_last_sign_in_ip_column: "%{subject_name} to have last_sign_in_ip column"
42
+
43
+ be_a_validatable:
44
+ description: "be a validatable"
45
+ expectations:
46
+ included: "%{subject_name} to include Devise :validatable model"
47
+
48
+ be_a_token_authenticatable:
49
+ description: "be a token authenticatable"
50
+ expectations:
51
+ included: "%{subject_name} to include Devise :token_authenticatable model"
52
+ has_authentication_token_column: "%{subject_name} to have authentication_token column"
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
8
8
  s.authors = ["Vasily Reys"]
9
9
  s.email = "reys.vasily@gmail.com"
10
10
  s.homepage = "http://github.com/vreys/remarkable_devise"
11
- s.summary = "remarkable_devise_#{Remarkable::Devise::Version}"
12
- s.description = "Devise remarkable rspec matchers"
11
+ s.summary = "Devise remarkable rspec matchers"
12
+ s.description = "remarkable_devise is a collection of RSpec matchers for Devise"
13
13
 
14
14
  s.rubygems_version = "1.3.7"
15
15
  s.rubyforge_project = "remarkbl-devise"
@@ -1,5 +1,6 @@
1
1
  class User < ActiveRecord::Base
2
- devise :database_authenticatable, :confirmable, :recoverable, :rememberable, :trackable
2
+ devise :database_authenticatable, :confirmable, :recoverable,
3
+ :rememberable, :trackable, :validatable, :token_authenticatable
3
4
  end
4
5
 
5
6
  class FooUser < ActiveRecord::Base
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+
3
+ describe Remarkable::Devise::Matchers::BeATokenAuthenticatableMatcher do
4
+ before do
5
+ @valid_columns = ['authentication_token']
6
+
7
+ User.stubs(:column_names).returns(@valid_columns)
8
+ end
9
+
10
+ context "validate inclusion of Devise::Models::TokenAuthenticatable" do
11
+ it "should validate that model has Devise::Models::TokenAuthenticatable module included" do
12
+ subject.matches?(User).should be_true
13
+ end
14
+
15
+ it "should validate that model has not Devise::Models::TokenAuthenticatable module included" do
16
+ subject.matches?(FooUser).should be_false
17
+ end
18
+ end
19
+
20
+ context "columns validation" do
21
+ before do
22
+ subject.stubs(:included?).returns(true)
23
+ end
24
+
25
+ context "authentication_token column" do
26
+ it "should validate that model has authentication_column column" do
27
+ subject.matches?(User).should be_true
28
+ end
29
+
30
+ it "should validate that model has no authentication_column column" do
31
+ User.stubs(:column_names).returns(@valid_columns - ['authentication_token'])
32
+
33
+ subject.matches?(User).should be_false
34
+ end
35
+ end
36
+ end
37
+
38
+ describe "description" do
39
+ specify { subject.description.should eql('be a token authenticatable') }
40
+ end
41
+
42
+ describe "expectation message" do
43
+ context "when Devise::Models::TokenAuthenticatable is not included" do
44
+ before do
45
+ subject.matches?(FooUser)
46
+ end
47
+
48
+ specify { subject.failure_message_for_should.should match("to include Devise :token_authenticatable model") }
49
+ end
50
+
51
+ context "when model has no authentication_token column" do
52
+ before do
53
+ subject.stubs(:has_authentication_token_column?).returns(false)
54
+ subject.matches?(User)
55
+ end
56
+
57
+ specify { subject.failure_message_for_should.should match("to have authentication_token column") }
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe Remarkable::Devise::Matchers::BeAValidatableMatcher do
4
+ context "validate inclusion of Devise::Models::Validatable" do
5
+ it "should validate that model has Devise::Models::Validatable module included" do
6
+ subject.matches?(User).should be_true
7
+ end
8
+
9
+ it "should validate that model has no Devise::Models::Validatable module included" do
10
+ subject.matches?(FooUser).should be_false
11
+ end
12
+ end
13
+
14
+ context "description" do
15
+ specify { subject.description.should eql('be a validatable') }
16
+ end
17
+
18
+ context "expectation message" do
19
+ before do
20
+ subject.matches?(FooUser)
21
+ end
22
+
23
+ specify { subject.failure_message_for_should.should match('to include Devise :validatable model')}
24
+ end
25
+ end
@@ -30,4 +30,16 @@ describe Remarkable::Devise::Matchers do
30
30
  be_a_trackable.should be_an_instance_of(Remarkable::Devise::Matchers::BeATrackableMatcher)
31
31
  end
32
32
  end
33
+
34
+ describe "#be_a_validatable" do
35
+ it "should return Remarkable::Devise::Matchers::BeAValidatableMatcher" do
36
+ be_a_validatable.should be_an_instance_of(Remarkable::Devise::Matchers::BeAValidatableMatcher)
37
+ end
38
+ end
39
+
40
+ describe "#be_a_token_authenticatable" do
41
+ it "should return Remarkable::Devise::Matchers::BeATokenAuthenticatableMatcher" do
42
+ be_a_token_authenticatable.should be_an_instance_of(Remarkable::Devise::Matchers::BeATokenAuthenticatableMatcher)
43
+ end
44
+ end
33
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remarkable_devise
3
3
  version: !ruby/object:Gem::Version
4
- hash: -1710980576
4
+ hash: -1710980575
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
9
  - 0
10
- - alpha2
11
- version: 1.0.0.alpha2
10
+ - alpha3
11
+ version: 1.0.0.alpha3
12
12
  platform: ruby
13
13
  authors:
14
14
  - Vasily Reys
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-12-05 00:00:00 +06:00
19
+ date: 2010-12-06 00:00:00 +06:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -114,7 +114,7 @@ dependencies:
114
114
  version: "0"
115
115
  type: :development
116
116
  version_requirements: *id006
117
- description: Devise remarkable rspec matchers
117
+ description: remarkable_devise is a collection of RSpec matchers for Devise
118
118
  email: reys.vasily@gmail.com
119
119
  executables: []
120
120
 
@@ -135,7 +135,9 @@ files:
135
135
  - lib/remarkable/devise/matchers/be_a_database_authenticatable_matcher.rb
136
136
  - lib/remarkable/devise/matchers/be_a_recoverable_matcher.rb
137
137
  - lib/remarkable/devise/matchers/be_a_rememberable_matcher.rb
138
+ - lib/remarkable/devise/matchers/be_a_token_authenticatable_matcher.rb
138
139
  - lib/remarkable/devise/matchers/be_a_trackable_matcher.rb
140
+ - lib/remarkable/devise/matchers/be_a_validatable_matcher.rb
139
141
  - lib/remarkable/devise/version.rb
140
142
  - locale/en.yml
141
143
  - remarkable_devise.gemspec
@@ -144,7 +146,9 @@ files:
144
146
  - spec/matchers/be_a_database_authenticatable_spec.rb
145
147
  - spec/matchers/be_a_recoverable_spec.rb
146
148
  - spec/matchers/be_a_rememberable_spec.rb
149
+ - spec/matchers/be_a_token_authenticatable_spec.rb
147
150
  - spec/matchers/be_a_trackable_spec.rb
151
+ - spec/matchers/be_a_validatable_spec.rb
148
152
  - spec/matchers_spec.rb
149
153
  - spec/spec_helper.rb
150
154
  has_rdoc: true
@@ -182,13 +186,15 @@ rubyforge_project: remarkbl-devise
182
186
  rubygems_version: 1.3.7
183
187
  signing_key:
184
188
  specification_version: 3
185
- summary: remarkable_devise_Remarkable::Devise::Version
189
+ summary: Devise remarkable rspec matchers
186
190
  test_files:
187
191
  - spec/example_models.rb
188
192
  - spec/matchers/be_a_confirmable_spec.rb
189
193
  - spec/matchers/be_a_database_authenticatable_spec.rb
190
194
  - spec/matchers/be_a_recoverable_spec.rb
191
195
  - spec/matchers/be_a_rememberable_spec.rb
196
+ - spec/matchers/be_a_token_authenticatable_spec.rb
192
197
  - spec/matchers/be_a_trackable_spec.rb
198
+ - spec/matchers/be_a_validatable_spec.rb
193
199
  - spec/matchers_spec.rb
194
200
  - spec/spec_helper.rb