cf 1.1.3.rc1 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cf/cli.rb +2 -7
- data/lib/cf/cli/organization/delete.rb +4 -6
- data/lib/cf/cli/service/create.rb +23 -17
- data/lib/cf/cli/space/create.rb +43 -41
- data/lib/cf/cli/space/space.rb +49 -46
- data/lib/cf/version.rb +1 -1
- data/lib/console/console.rb +1 -1
- data/spec/cf/cli/app/delete_spec.rb +16 -28
- data/spec/cf/cli/app/instances_spec.rb +4 -5
- data/spec/cf/cli/app/push/create_spec.rb +362 -373
- data/spec/cf/cli/app/push_spec.rb +216 -215
- data/spec/cf/cli/app/rename_spec.rb +28 -31
- data/spec/cf/cli/app/scale_spec.rb +44 -41
- data/spec/cf/cli/app/start_spec.rb +194 -193
- data/spec/cf/cli/app/stats_spec.rb +55 -56
- data/spec/cf/cli/domain/map_spec.rb +105 -102
- data/spec/cf/cli/domain/unmap_spec.rb +60 -56
- data/spec/cf/cli/organization/delete_spec.rb +85 -84
- data/spec/cf/cli/organization/orgs_spec.rb +80 -83
- data/spec/cf/cli/organization/rename_spec.rb +90 -89
- data/spec/cf/cli/populators/organization_spec.rb +117 -119
- data/spec/cf/cli/populators/space_spec.rb +107 -108
- data/spec/cf/cli/populators/target_spec.rb +17 -12
- data/spec/cf/cli/route/delete_spec.rb +4 -4
- data/spec/cf/cli/route/map_spec.rb +106 -102
- data/spec/cf/cli/route/unmap_spec.rb +5 -5
- data/spec/cf/cli/service/create_spec.rb +74 -46
- data/spec/cf/cli/service/rename_spec.rb +29 -33
- data/spec/cf/cli/service/services_spec.rb +48 -48
- data/spec/cf/cli/space/base_spec.rb +39 -32
- data/spec/cf/cli/space/create_spec.rb +52 -53
- data/spec/cf/cli/space/delete_spec.rb +84 -85
- data/spec/cf/cli/space/rename_spec.rb +93 -94
- data/spec/cf/cli/space/space_spec.rb +60 -60
- data/spec/cf/cli/space/spaces_spec.rb +75 -80
- data/spec/cf/cli/space/switch_space_spec.rb +45 -48
- data/spec/cf/cli/start/info_spec.rb +4 -6
- data/spec/cf/cli/start/login_spec.rb +18 -20
- data/spec/cf/cli/start/logout_spec.rb +36 -37
- data/spec/cf/cli/start/target_spec.rb +86 -89
- data/spec/cf/cli/user/create_spec.rb +83 -84
- data/spec/cf/cli/user/passwd_spec.rb +87 -86
- data/spec/cf/cli/user/register_spec.rb +109 -108
- data/spec/cf/cli_spec.rb +305 -310
- data/spec/console/console_spec.rb +58 -58
- data/spec/factories/cfoundry/v2/domain_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/route_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/user_factory.rb +7 -0
- data/spec/features/org_spec.rb +11 -11
- data/spec/manifests/manifests_spec.rb +21 -21
- data/spec/manifests/plugin_spec.rb +34 -34
- data/spec/spec_helper.rb +1 -2
- data/spec/support/cli_helper.rb +5 -14
- data/spec/support/factory_girl.rb +6 -0
- data/spec/support/interact_helper.rb +5 -15
- data/spec/support/shared_examples/errors.rb +1 -1
- data/spec/tunnel/plugin_spec.rb +2 -2
- data/spec/tunnel/tunnel_spec.rb +5 -5
- metadata +36 -28
@@ -1,121 +1,118 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
require "webmock/rspec"
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
let(:app) { fake :app }
|
3
|
+
module CF
|
4
|
+
module Start
|
5
|
+
describe Target do
|
6
|
+
before do
|
7
|
+
stub_client_and_precondition
|
8
|
+
end
|
11
9
|
|
12
|
-
|
13
|
-
|
10
|
+
let(:client) { fake_client :apps => [app] }
|
11
|
+
let(:app) { fake :app }
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
its(:description) { should eq "Set or display the target cloud, organization, and space" }
|
18
|
-
specify { expect(Mothership::Help.group(:start)).to include(subject) }
|
19
|
-
end
|
13
|
+
describe "metadata" do
|
14
|
+
let(:command) { Mothership.commands[:target] }
|
20
15
|
|
21
|
-
|
16
|
+
describe "command" do
|
17
|
+
subject { command }
|
18
|
+
its(:description) { should eq "Set or display the target cloud, organization, and space" }
|
19
|
+
specify { expect(Mothership::Help.group(:start)).to include(subject) }
|
20
|
+
end
|
22
21
|
|
23
|
-
|
24
|
-
subject { command.flags }
|
22
|
+
include_examples "inputs must have descriptions"
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
its(["-s"]) { should eq :space }
|
29
|
-
end
|
24
|
+
describe "flags" do
|
25
|
+
subject { command.flags }
|
30
26
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "running the command" do
|
40
|
-
stub_home_dir_with { "#{SPEC_ROOT}/fixtures/fake_home_dirs/new" }
|
41
|
-
|
42
|
-
context "when the user is authenticated and has an organization" do
|
43
|
-
let(:user) { stub! }
|
44
|
-
let(:organization) { fake(:organization, :name => "My Org", :guid => "organization-id-1", :users => [user], :spaces => [space]) }
|
45
|
-
let(:space) { fake(:space, :name => "Staging", :guid => "space-id-2", :developers => [user]) }
|
46
|
-
let(:client) { fake_client :organizations => [organization], :token => CFoundry::AuthToken.new("bearer some-access-token") }
|
27
|
+
its(["-o"]) { should eq :organization }
|
28
|
+
its(["--org"]) { should eq :organization }
|
29
|
+
its(["-s"]) { should eq :space }
|
30
|
+
end
|
47
31
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
stub(instance).client { client }
|
32
|
+
describe "arguments" do
|
33
|
+
subject(:arguments) { command.arguments }
|
34
|
+
it "have the correct commands" do
|
35
|
+
expect(arguments).to eq [{:type => :optional, :value => nil, :name => :url}]
|
36
|
+
end
|
54
37
|
end
|
55
38
|
end
|
56
39
|
|
57
|
-
describe "
|
58
|
-
|
59
|
-
subject { cf ["target", target] }
|
40
|
+
describe "running the command" do
|
41
|
+
stub_home_dir_with { "#{SPEC_ROOT}/fixtures/fake_home_dirs/new" }
|
60
42
|
|
61
|
-
context "when the
|
62
|
-
|
43
|
+
context "when the user is authenticated and has an organization" do
|
44
|
+
let(:user) { fake(:user) }
|
45
|
+
let(:organization) { fake(:organization, :name => "My Org", :guid => "organization-id-1", :users => [user], :spaces => [space]) }
|
46
|
+
let(:space) { fake(:space, :name => "Staging", :guid => "space-id-2", :developers => [user]) }
|
47
|
+
let(:client) { fake_client :organizations => [organization], :token => CFoundry::AuthToken.new("bearer some-access-token") }
|
63
48
|
|
64
|
-
|
65
|
-
|
49
|
+
before do
|
50
|
+
client.stub(:current_user) { user }
|
51
|
+
client.stub(:organization) { organization }
|
52
|
+
client.stub(:current_organization) { organization }
|
53
|
+
described_class.any_instance.stub(:client) { client }
|
66
54
|
end
|
67
|
-
end
|
68
55
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
56
|
+
describe "switching the target" do
|
57
|
+
let(:target) { "some-valid-target.com" }
|
58
|
+
subject { cf ["target", target] }
|
59
|
+
|
60
|
+
context "when the target is not valid" do
|
61
|
+
before { WebMock.stub_request(:get, "http://#{target}/info").to_return(:body => "{}") }
|
62
|
+
|
63
|
+
it "should still be able to switch to a valid target after that" do
|
64
|
+
subject
|
65
|
+
end
|
73
66
|
end
|
74
67
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
end
|
68
|
+
context "when the target is valid but the connection is refused" do
|
69
|
+
it "shows a pretty error message" do
|
70
|
+
CFoundry::V2::Client.any_instance.stub(:info) { raise CFoundry::TargetRefused, "foo" }
|
79
71
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
stub(cli).info { raise CFoundry::InvalidTarget.new(target) }
|
72
|
+
subject
|
73
|
+
expect(error_output).to say("Target refused connection.")
|
74
|
+
end
|
84
75
|
end
|
85
76
|
|
86
|
-
|
87
|
-
|
77
|
+
context "when the uri is malformed" do
|
78
|
+
it "shows a pretty error message" do
|
79
|
+
CFoundry::V2::Client.any_instance.stub(:info) { raise CFoundry::InvalidTarget.new(target) }
|
80
|
+
|
81
|
+
subject
|
82
|
+
expect(error_output).to say("Invalid target URI.")
|
83
|
+
end
|
84
|
+
end
|
88
85
|
end
|
89
|
-
end
|
90
|
-
end
|
91
86
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
87
|
+
describe "switching the space" do
|
88
|
+
def run_command
|
89
|
+
cf %W[target -s #{space.name}]
|
90
|
+
end
|
96
91
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
92
|
+
it "calls use a PopulateTarget to ensure that an organization and space is set" do
|
93
|
+
CF::Populators::Target.should_receive(:new) { double(:target, :populate_and_save! => true) }
|
94
|
+
run_command
|
95
|
+
end
|
101
96
|
|
102
|
-
|
103
|
-
|
104
|
-
|
97
|
+
it "prints out the space from the updated client" do
|
98
|
+
CF::Populators::Target.any_instance.stub(:populate_and_save!) { true }
|
99
|
+
client.stub(:current_space) { space }
|
105
100
|
|
106
|
-
|
107
|
-
|
101
|
+
run_command
|
102
|
+
expect(output).to say("space: #{space.name}")
|
103
|
+
end
|
104
|
+
end
|
108
105
|
end
|
109
|
-
end
|
110
|
-
end
|
111
106
|
|
112
|
-
|
113
|
-
|
114
|
-
|
107
|
+
context "when client is nil" do
|
108
|
+
let(:client) { nil }
|
109
|
+
subject { cf ["target"] }
|
115
110
|
|
116
|
-
|
117
|
-
|
118
|
-
|
111
|
+
it 'prints an error' do
|
112
|
+
subject
|
113
|
+
expect(error_output).to say("No target has been specified.")
|
114
|
+
end
|
115
|
+
end
|
119
116
|
end
|
120
117
|
end
|
121
118
|
end
|
@@ -1,99 +1,98 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
describe 'arguments' do
|
16
|
-
subject { command.arguments }
|
17
|
-
it 'has the correct argument order' do
|
18
|
-
should eq([
|
19
|
-
{ :type => :optional, :value => nil, :name => :email }
|
20
|
-
])
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "running the command" do
|
26
|
-
let(:client) { fake_client }
|
27
|
-
let(:org) { fake(:organization) }
|
28
|
-
let(:user) { fake(:user) }
|
29
|
-
|
30
|
-
before do
|
31
|
-
any_instance_of(described_class) { |cli| stub(cli).client { client } }
|
32
|
-
stub(client).register
|
33
|
-
end
|
34
|
-
|
35
|
-
subject { cf %W[create-user --#{bool_flag(:force)}] }
|
36
|
-
|
37
|
-
context "when the user is not logged in" do
|
38
|
-
let(:force) { true }
|
39
|
-
|
40
|
-
before do
|
41
|
-
stub(client).logged_in? { false }
|
42
|
-
end
|
43
|
-
|
44
|
-
it "tells the user to log in" do
|
45
|
-
subject
|
46
|
-
expect(stderr.string).to include("Please log in")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context "when the user is logged in" do
|
51
|
-
let(:force) { false }
|
52
|
-
let(:confirmation) { "password1" }
|
53
|
-
|
54
|
-
before do
|
55
|
-
stub(client).logged_in? { true }
|
56
|
-
stub_ask("Email") { "some-angry-dude@example.com" }
|
57
|
-
stub_ask("Password", anything) { "password1" }
|
58
|
-
stub_ask("Verify Password", anything) { confirmation }
|
59
|
-
stub(CF::Populators::Organization).new(instance_of(Mothership::Inputs)) { stub!.populate_and_save! { org } }
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module CF
|
4
|
+
module User
|
5
|
+
describe Create do
|
6
|
+
describe "metadata" do
|
7
|
+
let(:command) { Mothership.commands[:create_user] }
|
8
|
+
|
9
|
+
describe "command" do
|
10
|
+
subject { command }
|
11
|
+
its(:description) { should eq "Create a user" }
|
12
|
+
it { expect(Mothership::Help.group(:admin, :user)).to include(subject) }
|
13
|
+
end
|
60
14
|
|
61
|
-
|
62
|
-
stub(user).update!
|
63
|
-
end
|
15
|
+
include_examples "inputs must have descriptions"
|
64
16
|
|
65
|
-
|
66
|
-
|
67
|
-
|
17
|
+
describe "arguments" do
|
18
|
+
subject { command.arguments }
|
19
|
+
it "has the correct argument order" do
|
20
|
+
should eq([
|
21
|
+
{:type => :optional, :value => nil, :name => :email}
|
22
|
+
])
|
23
|
+
end
|
24
|
+
end
|
68
25
|
end
|
69
26
|
|
70
|
-
|
71
|
-
let(:
|
27
|
+
describe "running the command" do
|
28
|
+
let(:client) { fake_client }
|
29
|
+
let(:org) { fake(:organization) }
|
30
|
+
let(:user) { fake(:user) }
|
72
31
|
|
73
|
-
|
74
|
-
|
75
|
-
|
32
|
+
before do
|
33
|
+
stub_client
|
34
|
+
client.stub(:register)
|
76
35
|
end
|
77
|
-
end
|
78
36
|
|
79
|
-
|
80
|
-
it "creates a user" do
|
81
|
-
mock(client).register("some-angry-dude@example.com", "password1") { user }
|
82
|
-
stub(user).update!
|
83
|
-
subject
|
84
|
-
end
|
37
|
+
subject { cf %W[create-user --#{bool_flag(:force)}] }
|
85
38
|
|
86
|
-
|
87
|
-
|
88
|
-
mock(user).update!
|
39
|
+
context "when the user is not logged in" do
|
40
|
+
let(:force) { true }
|
89
41
|
|
90
|
-
|
42
|
+
before do
|
43
|
+
client.stub(:logged_in?) { false }
|
44
|
+
end
|
91
45
|
|
92
|
-
user
|
93
|
-
|
94
|
-
|
46
|
+
it "tells the user to log in" do
|
47
|
+
subject
|
48
|
+
expect(stderr.string).to include("Please log in")
|
49
|
+
end
|
95
50
|
end
|
96
51
|
|
52
|
+
context "when the user is logged in" do
|
53
|
+
let(:force) { false }
|
54
|
+
let(:confirmation) { "password1" }
|
55
|
+
|
56
|
+
before do
|
57
|
+
client.stub(:logged_in?) { true }
|
58
|
+
stub_ask("Email") { "some-angry-dude@example.com" }
|
59
|
+
stub_ask("Password", anything) { "password1" }
|
60
|
+
stub_ask("Verify Password", anything) { confirmation }
|
61
|
+
|
62
|
+
CF::Populators::Organization.stub(:new) { stub(:organization, :populate_and_save! => org) }
|
63
|
+
client.stub(:register).with("some-angry-dude@example.com", "password1") { user }
|
64
|
+
user.stub(:update!)
|
65
|
+
end
|
66
|
+
|
67
|
+
context "when the password does not match its confirmation" do
|
68
|
+
let(:confirmation) { "wrong" }
|
69
|
+
|
70
|
+
it "displays an error message" do
|
71
|
+
subject
|
72
|
+
expect(stderr.string).to include("Passwords don't match")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context "when the password matches its confirmation" do
|
77
|
+
it "creates a user" do
|
78
|
+
client.should_receive(:register).with("some-angry-dude@example.com", "password1") { user }
|
79
|
+
user.stub(:update!)
|
80
|
+
subject
|
81
|
+
end
|
82
|
+
|
83
|
+
it "adds the user to the current org" do
|
84
|
+
client.stub(:register).and_return(user)
|
85
|
+
user.should_receive(:update!)
|
86
|
+
|
87
|
+
subject
|
88
|
+
|
89
|
+
user.organizations.should == [org]
|
90
|
+
user.managed_organizations.should == [org]
|
91
|
+
user.audited_organizations.should == [org]
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
97
96
|
end
|
98
97
|
end
|
99
98
|
end
|
@@ -1,94 +1,95 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module CF
|
4
|
+
module User
|
5
|
+
describe Passwd do
|
6
|
+
describe "metadata" do
|
7
|
+
let(:command) { Mothership.commands[:passwd] }
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
include_examples 'inputs must have descriptions'
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#passwd' do
|
17
|
-
let(:client) { fake_client }
|
18
|
-
let(:old_password) { "old" }
|
19
|
-
let(:new_password) { "password" }
|
20
|
-
let(:verify_password) { new_password }
|
21
|
-
let(:score) { :strong }
|
22
|
-
let(:guid) { random_string("my-object-guid") }
|
23
|
-
let(:user_model) { fake_model { attribute :password, :object } }
|
24
|
-
let(:user_object) { user_model.new(guid, client) }
|
25
|
-
let(:user) { user_object.fake(:password => 'foo') }
|
26
|
-
|
27
|
-
before do
|
28
|
-
any_instance_of described_class do |cli|
|
29
|
-
stub(cli).client { client }
|
30
|
-
stub(cli).precondition { nil }
|
31
|
-
end
|
32
|
-
stub(client).logged_in? { true }
|
33
|
-
stub(client).current_user { user }
|
34
|
-
stub(client).register
|
35
|
-
stub(client).base.stub!.password_score(new_password) { score }
|
36
|
-
end
|
37
|
-
|
38
|
-
subject { cf %W[passwd --password #{old_password} --new-password #{new_password} --verify #{verify_password} --no-force --debug] }
|
39
|
-
|
40
|
-
context 'when the passwords dont match' do
|
41
|
-
let(:verify_password) { "other_password" }
|
42
|
-
|
43
|
-
it { should eq 1 }
|
44
|
-
|
45
|
-
it 'fails' do
|
46
|
-
subject
|
47
|
-
expect(stderr.string).to include "Passwords do not match."
|
48
|
-
end
|
49
|
-
|
50
|
-
it "doesn't print out the score" do
|
51
|
-
subject
|
52
|
-
expect(stdout.string).not_to include "strength"
|
53
|
-
end
|
54
|
-
|
55
|
-
it "doesn't log in or register" do
|
56
|
-
dont_allow(user).change_password!
|
57
|
-
subject
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'when the password is good or strong' do
|
62
|
-
before do
|
63
|
-
stub(user).change_password!
|
64
|
-
end
|
65
|
-
|
66
|
-
it { should eq 0 }
|
67
|
-
|
68
|
-
it 'prints out the password score' do
|
69
|
-
subject
|
70
|
-
expect(stdout.string).to include "Your password strength is: strong"
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'changes the password' do
|
74
|
-
mock(user).change_password!(new_password, old_password)
|
75
|
-
subject
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
context 'when the password is weak' do
|
80
|
-
let(:score) { :weak }
|
81
|
-
|
82
|
-
it { should eq 1 }
|
9
|
+
describe "command" do
|
10
|
+
subject { command }
|
11
|
+
its(:description) { should eq "Update the current user's password" }
|
12
|
+
it { expect(Mothership::Help.group(:admin, :user)).to include(subject) }
|
13
|
+
end
|
83
14
|
|
84
|
-
|
85
|
-
subject
|
86
|
-
expect(stderr.string).to include "Your password strength is: weak"
|
15
|
+
include_examples "inputs must have descriptions"
|
87
16
|
end
|
88
17
|
|
89
|
-
|
90
|
-
|
91
|
-
|
18
|
+
describe "#passwd" do
|
19
|
+
let(:client) { fake_client }
|
20
|
+
let(:old_password) { "old" }
|
21
|
+
let(:new_password) { "password" }
|
22
|
+
let(:verify_password) { new_password }
|
23
|
+
let(:score) { :strong }
|
24
|
+
let(:guid) { random_string("my-object-guid") }
|
25
|
+
let(:user_model) { fake_model { attribute :password, :object } }
|
26
|
+
let(:user_object) { user_model.new(guid, client) }
|
27
|
+
let(:user) { user_object.fake(:password => "foo") }
|
28
|
+
|
29
|
+
before do
|
30
|
+
stub_client_and_precondition
|
31
|
+
client.stub(:logged_in?) { true }
|
32
|
+
client.stub(:current_user) { user }
|
33
|
+
client.stub(:register)
|
34
|
+
client.base.stub(:password_score).with(new_password).and_return(score)
|
35
|
+
end
|
36
|
+
|
37
|
+
subject { cf %W[passwd --password #{old_password} --new-password #{new_password} --verify #{verify_password} --no-force --debug] }
|
38
|
+
|
39
|
+
context "when the passwords dont match" do
|
40
|
+
let(:verify_password) { "other_password" }
|
41
|
+
|
42
|
+
it { should eq 1 }
|
43
|
+
|
44
|
+
it "fails" do
|
45
|
+
subject
|
46
|
+
expect(stderr.string).to include "Passwords do not match."
|
47
|
+
end
|
48
|
+
|
49
|
+
it "doesn't print out the score" do
|
50
|
+
subject
|
51
|
+
expect(stdout.string).not_to include "strength"
|
52
|
+
end
|
53
|
+
|
54
|
+
it "doesn't log in or register" do
|
55
|
+
user.should_not_receive(:change_password!)
|
56
|
+
subject
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "when the password is good or strong" do
|
61
|
+
before do
|
62
|
+
user.stub(:change_password!)
|
63
|
+
end
|
64
|
+
|
65
|
+
it { should eq 0 }
|
66
|
+
|
67
|
+
it "prints out the password score" do
|
68
|
+
subject
|
69
|
+
expect(stdout.string).to include "Your password strength is: strong"
|
70
|
+
end
|
71
|
+
|
72
|
+
it "changes the password" do
|
73
|
+
user.should_receive(:change_password!).with(new_password, old_password)
|
74
|
+
subject
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context "when the password is weak" do
|
79
|
+
let(:score) { :weak }
|
80
|
+
|
81
|
+
it { should eq 1 }
|
82
|
+
|
83
|
+
it "prints out the password score" do
|
84
|
+
subject
|
85
|
+
expect(stderr.string).to include "Your password strength is: weak"
|
86
|
+
end
|
87
|
+
|
88
|
+
it "doesn't change the password" do
|
89
|
+
user.should_not_receive(:change_password!)
|
90
|
+
subject
|
91
|
+
end
|
92
|
+
end
|
92
93
|
end
|
93
94
|
end
|
94
95
|
end
|