monban 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +15 -0
- data/lib/monban/configuration.rb +7 -1
- data/lib/monban/version.rb +1 -1
- data/spec/monban/services/sign_up_spec.rb +15 -25
- data/spec/spec_helper.rb +15 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88fcb289b4f7cb94c7e1db2b0f73839834199e44
|
4
|
+
data.tar.gz: a702fa411b1291d301504036c074ecffb9966250
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 648921ba94be7351c4d8926bf853713a4bfa78c5971a04ec98465ce164f47b0e55419db47c3bd04a228aa7b68a21d5ddc302dd4aaf9f4a6bab42da24fce15367
|
7
|
+
data.tar.gz: 034a4de27934f0f068a7f02be53576ec178f84dbf1492379446d4b7bea202527df3021f7d88f9451b65c3a9056630dc530bbff30a2d7569167dd1cecc448e0c6
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -117,6 +117,21 @@ feature "A feature spec" do
|
|
117
117
|
end
|
118
118
|
```
|
119
119
|
|
120
|
+
### Monban Backdoor
|
121
|
+
|
122
|
+
Similar to clearance's backdoor you can visit a path and sign in quickly via
|
123
|
+
|
124
|
+
```ruby
|
125
|
+
user = create(:user)
|
126
|
+
visit dashboard_path(as: user)
|
127
|
+
```
|
128
|
+
|
129
|
+
To enable this functionality you'll want to add the following to `config/environments/test.rb`:
|
130
|
+
|
131
|
+
```ruby
|
132
|
+
config.middleware.insert_after Warden::Manager, Monban::BackDoor
|
133
|
+
```
|
134
|
+
|
120
135
|
### Controller Specs
|
121
136
|
|
122
137
|
If you are going to write controller tests, helpers are provided for those as well:
|
data/lib/monban/configuration.rb
CHANGED
data/lib/monban/version.rb
CHANGED
@@ -3,47 +3,37 @@ require 'monban/services/sign_up'
|
|
3
3
|
|
4
4
|
describe Monban::SignUp, '#perform' do
|
5
5
|
it 'creates a user with the right parameters' do
|
6
|
-
create
|
7
|
-
stub_const('User', create)
|
6
|
+
allow(User).to receive(:create)
|
8
7
|
user_params = { email: 'email@example.com', password: 'password' }
|
9
8
|
|
10
|
-
create.should_receive(:create) do |args|
|
11
|
-
args[:email].should eq(user_params[:email])
|
12
|
-
Monban.compare_token(args[:password_digest], 'password').should be_true
|
13
|
-
end
|
14
|
-
|
15
9
|
Monban::SignUp.new(user_params).perform
|
10
|
+
expect(User).to have_received(:create) do |args|
|
11
|
+
expect(args[:email]).to eq(user_params[:email])
|
12
|
+
expect(Monban.compare_token(args[:password_digest], 'password')).to be_true
|
13
|
+
end
|
16
14
|
end
|
17
15
|
|
18
16
|
it 'creates a user from the configured user creation method' do
|
19
|
-
user_create_double =
|
20
|
-
user_create_double.should_receive(:call) do |args|
|
21
|
-
Monban.compare_token(args[:password_digest], 'password').should be_true
|
22
|
-
end
|
17
|
+
user_create_double = double(Proc, call: true)
|
23
18
|
|
24
19
|
user_params = { email: 'email@example.com', password: 'password' }
|
25
|
-
|
20
|
+
|
21
|
+
with_monban_config(creation_method: user_create_double) do
|
26
22
|
Monban::SignUp.new(user_params).perform
|
27
23
|
end
|
28
|
-
end
|
29
24
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
yield
|
34
|
-
ensure
|
35
|
-
Monban.config.creation_method = old_creation_method
|
25
|
+
expect(user_create_double).to have_received(:call) do |args|
|
26
|
+
expect(Monban.compare_token(args[:password_digest], 'password')).to be_true
|
27
|
+
end
|
36
28
|
end
|
37
29
|
|
38
30
|
it 'does not create a user with an empty password' do
|
39
|
-
create
|
40
|
-
stub_const('User', create)
|
31
|
+
allow(User).to receive(:create)
|
41
32
|
user_params = { email: 'email@example.com', password: '' }
|
42
33
|
|
43
|
-
create.should_receive(:create) do |args|
|
44
|
-
args[:password_digest].should be_nil
|
45
|
-
end
|
46
|
-
|
47
34
|
Monban::SignUp.new(user_params).perform
|
35
|
+
expect(User).to have_received(:create) do |args|
|
36
|
+
expect(args[:password_digest]).to be_nil
|
37
|
+
end
|
48
38
|
end
|
49
39
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -8,4 +8,19 @@ require 'capybara'
|
|
8
8
|
|
9
9
|
RSpec.configure do |config|
|
10
10
|
config.include Warden::Test::Helpers
|
11
|
+
config.order = "random"
|
12
|
+
end
|
13
|
+
|
14
|
+
def with_monban_config(hash, &block)
|
15
|
+
old_config = {}
|
16
|
+
hash.each do |key, value|
|
17
|
+
old_config[key] = Monban.config.send(key)
|
18
|
+
Monban.config.send(:"#{key}=", value)
|
19
|
+
end
|
20
|
+
|
21
|
+
yield
|
22
|
+
|
23
|
+
old_config.each do |key, value|
|
24
|
+
Monban.config.send(:"#{key}=", old_config[key])
|
25
|
+
end
|
11
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monban
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- halogenandtoast
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-05-
|
12
|
+
date: 2014-05-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|