passaporteweb-client 0.1.0 → 0.2.0

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/.travis.yml CHANGED
@@ -1,5 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.1.1
3
+ - 2.1.6
4
+ - 2.2.2
data/Gemfile.lock CHANGED
@@ -1,54 +1,76 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- passaporteweb-client (0.0.19)
4
+ passaporteweb-client (0.2.0)
5
5
  multi_json (~> 1.9.0)
6
- rest-client (~> 1.6.7)
6
+ rest-client (~> 1.8.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  addressable (2.3.3)
12
- awesome_print (1.1.0)
13
- coderay (1.0.9)
14
- colorize (0.5.8)
15
- coveralls (0.6.3)
16
- colorize
17
- multi_json (~> 1.3)
18
- rest-client
19
- simplecov (>= 0.7)
20
- thor
12
+ awesome_print (1.6.1)
13
+ byebug (4.0.5)
14
+ columnize (= 0.9.0)
15
+ coderay (1.1.0)
16
+ columnize (0.9.0)
17
+ coveralls (0.8.1)
18
+ json (~> 1.8)
19
+ rest-client (>= 1.6.8, < 2)
20
+ simplecov (~> 0.10.0)
21
+ term-ansicolor (~> 1.3)
22
+ thor (~> 0.19.1)
21
23
  crack (0.3.2)
22
- diff-lcs (1.2.1)
23
- json (1.7.7)
24
- method_source (0.8.1)
25
- mime-types (1.21)
24
+ diff-lcs (1.2.5)
25
+ docile (1.1.5)
26
+ domain_name (0.5.24)
27
+ unf (>= 0.0.5, < 1.0.0)
28
+ http-cookie (1.0.2)
29
+ domain_name (~> 0.5)
30
+ json (1.8.3)
31
+ method_source (0.8.2)
32
+ mime-types (2.6.1)
26
33
  multi_json (1.9.2)
27
- pry (0.9.12)
28
- coderay (~> 1.0.5)
29
- method_source (~> 0.8)
34
+ netrc (0.10.3)
35
+ pry (0.10.1)
36
+ coderay (~> 1.1.0)
37
+ method_source (~> 0.8.1)
30
38
  slop (~> 3.4)
31
- pry-nav (0.2.3)
32
- pry (~> 0.9.10)
33
- rake (10.0.4)
34
- rdoc (4.0.1)
35
- json (~> 1.4)
36
- rest-client (1.6.7)
37
- mime-types (>= 1.16)
38
- rspec (2.13.0)
39
- rspec-core (~> 2.13.0)
40
- rspec-expectations (~> 2.13.0)
41
- rspec-mocks (~> 2.13.0)
42
- rspec-core (2.13.1)
43
- rspec-expectations (2.13.0)
44
- diff-lcs (>= 1.1.3, < 2.0)
45
- rspec-mocks (2.13.0)
46
- simplecov (0.7.1)
47
- multi_json (~> 1.0)
48
- simplecov-html (~> 0.7.1)
49
- simplecov-html (0.7.1)
50
- slop (3.4.4)
51
- thor (0.18.0)
39
+ pry-byebug (3.1.0)
40
+ byebug (~> 4.0)
41
+ pry (~> 0.10)
42
+ rake (10.4.2)
43
+ rdoc (4.2.0)
44
+ rest-client (1.8.0)
45
+ http-cookie (>= 1.0.2, < 2.0)
46
+ mime-types (>= 1.16, < 3.0)
47
+ netrc (~> 0.7)
48
+ rspec (3.3.0)
49
+ rspec-core (~> 3.3.0)
50
+ rspec-expectations (~> 3.3.0)
51
+ rspec-mocks (~> 3.3.0)
52
+ rspec-core (3.3.0)
53
+ rspec-support (~> 3.3.0)
54
+ rspec-expectations (3.3.0)
55
+ diff-lcs (>= 1.2.0, < 2.0)
56
+ rspec-support (~> 3.3.0)
57
+ rspec-mocks (3.3.0)
58
+ diff-lcs (>= 1.2.0, < 2.0)
59
+ rspec-support (~> 3.3.0)
60
+ rspec-support (3.3.0)
61
+ simplecov (0.10.0)
62
+ docile (~> 1.1.0)
63
+ json (~> 1.8)
64
+ simplecov-html (~> 0.10.0)
65
+ simplecov-html (0.10.0)
66
+ slop (3.6.0)
67
+ term-ansicolor (1.3.0)
68
+ tins (~> 1.0)
69
+ thor (0.19.1)
70
+ tins (1.5.2)
71
+ unf (0.1.4)
72
+ unf_ext
73
+ unf_ext (0.0.7.1)
52
74
  vcr (2.4.0)
53
75
  webmock (1.9.3)
54
76
  addressable (>= 2.2.7)
@@ -58,15 +80,15 @@ PLATFORMS
58
80
  ruby
59
81
 
60
82
  DEPENDENCIES
61
- awesome_print (~> 1.1)
62
- bundler (~> 1.5.3)
63
- coveralls (~> 0.6)
83
+ awesome_print (~> 1.6)
84
+ bundler (~> 1.9)
85
+ coveralls (~> 0.8)
86
+ json (= 1.8.3)
64
87
  passaporteweb-client!
65
- pry (~> 0.9)
66
- pry-nav (~> 0.2)
67
- rake (~> 10.0)
68
- rdoc (~> 4.0)
69
- rspec (~> 2.13)
70
- simplecov (~> 0.7)
88
+ pry-byebug (~> 3.1)
89
+ rake (~> 10.4)
90
+ rdoc (~> 4.2)
91
+ rspec (~> 3.3.0)
92
+ simplecov (~> 0.10)
71
93
  vcr (~> 2.4)
72
94
  webmock (~> 1.9.3)
data/README.rdoc CHANGED
@@ -6,6 +6,7 @@ A Ruby client for the PassaporteWeb REST API
6
6
  {<img src="https://travis-ci.org/myfreecomm/passaporteweb-client-ruby.png?branch=master" alt="Build Status" />}[https://travis-ci.org/myfreecomm/passaporteweb-client-ruby]
7
7
  {<img src="https://coveralls.io/repos/myfreecomm/passaporteweb-client-ruby/badge.png?branch=master" alt="Coverage Status" />}[https://coveralls.io/r/myfreecomm/passaporteweb-client-ruby]
8
8
  {<img src="https://codeclimate.com/github/myfreecomm/passaporteweb-client-ruby.png" alt="Code Climate Status" />}[https://codeclimate.com/github/myfreecomm/passaporteweb-client-ruby]
9
+ {<img src="http://inch-ci.org/github/myfreecomm/passaporteweb-client-ruby.svg" alt="Inline docs" />}[http://inch-ci.org/github/myfreecomm/passaporteweb-client-ruby]
9
10
 
10
11
  PassaporteWeb API docs: https://app.passaporteweb.com.br/static/docs/
11
12
 
@@ -29,6 +30,10 @@ Or install it yourself as:
29
30
 
30
31
  $ gem install passaporteweb-client
31
32
 
33
+ == Support
34
+
35
+ This gem supports Ruby 2.1 and Ruby 2.2.
36
+
32
37
  == Usage
33
38
 
34
39
  === Mapping of API endpoints to this client
@@ -97,6 +97,22 @@ module PassaporteWeb
97
97
  @persisted == true
98
98
  end
99
99
 
100
+ # Activates an existing ServiceAccount. Returns true if successfull or false if not. In case of failure,
101
+ # it will fill the <tt>errors</tt> attribute with the reason for the failure to save the object.
102
+ #
103
+ # API method: <tt>PUT /organizations/api/activate/</tt>
104
+ #
105
+ # API documentation: http://myfreecomm.github.io/passaporte-web/pweb/api/account_manager.html#put-organizations-api-activate
106
+ def activate(identity)
107
+ response = Http.put("/organizations/api/activate/", {slug: self.plan_slug, identity: identity, global_account: self.uuid})
108
+ raise "unexpected response: #{response.code} - #{response.body}" unless response.code == 200
109
+ @errors = {}
110
+ true
111
+ rescue *[RestClient::Conflict, RestClient::BadRequest] => e
112
+ @errors = MultiJson.decode(e.response.body)
113
+ false
114
+ end
115
+
100
116
  private
101
117
 
102
118
  def update
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module PassaporteWeb
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
@@ -8,8 +8,8 @@ require File.join([File.dirname(__FILE__),'lib','passaporte_web','version.rb'])
8
8
  Gem::Specification.new do |spec|
9
9
  spec.name = "passaporteweb-client"
10
10
  spec.version = PassaporteWeb::VERSION
11
- spec.authors = ["Rodrigo Tassinari de Oliveira", "Rodrigo Martins"]
12
- spec.email = ["rodrigo@pittlandia.net", "rodrigo.tassinari@myfreecomm.com.br", "rodrigo@rrmartins.com", "rodrigo.martins@myfreecomm.com.br"]
11
+ spec.authors = ["Rodrigo Tassinari de Oliveira", "Eduardo Hertz", "Rafael B. Tauil"]
12
+ spec.email = ["rodrigo@pittlandia.net", "rodrigo.tassinari@myfreecomm.com.br", "eduardo.hertz@myfreecomm.com.br", "rafael@tauil.com.br"]
13
13
  spec.description = %q{A Ruby client for the PassaporteWeb REST API}
14
14
  spec.summary = %q{A Ruby client for the PassaporteWeb REST API: https://app.passaporteweb.com.br/static/docs/}
15
15
  spec.homepage = "https://github.com/myfreecomm/passaporteweb-client-ruby"
@@ -23,18 +23,18 @@ Gem::Specification.new do |spec|
23
23
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
24
24
  spec.require_paths = ["lib"]
25
25
 
26
- spec.add_dependency "rest-client", "~> 1.6.7"
26
+ spec.add_dependency "rest-client", "~> 1.8.0"
27
27
  spec.add_dependency "multi_json", "~> 1.9.0"
28
28
 
29
- spec.add_development_dependency "bundler", "~> 1.5.3"
30
- spec.add_development_dependency "rake", "~> 10.0"
31
- spec.add_development_dependency 'rdoc', '~> 4.0'
32
- spec.add_development_dependency "rspec", "~> 2.13"
29
+ spec.add_development_dependency "bundler", "~> 1.9"
30
+ spec.add_development_dependency "rake", "~> 10.4"
31
+ spec.add_development_dependency 'rdoc', '~> 4.2'
32
+ spec.add_development_dependency "rspec", "~> 3.3.0"
33
33
  spec.add_development_dependency "vcr", "~> 2.4"
34
34
  spec.add_development_dependency "webmock", "~> 1.9.3"
35
- spec.add_development_dependency "pry", "~> 0.9"
36
- spec.add_development_dependency "pry-nav", "~> 0.2"
37
- spec.add_development_dependency "awesome_print", "~> 1.1"
38
- spec.add_development_dependency "simplecov", "~> 0.7"
39
- spec.add_development_dependency "coveralls", "~> 0.6"
35
+ spec.add_development_dependency "pry-byebug", "~> 3.1"
36
+ spec.add_development_dependency "awesome_print", "~> 1.6"
37
+ spec.add_development_dependency "simplecov", "~> 0.10"
38
+ spec.add_development_dependency "coveralls", "~> 0.8"
39
+ spec.add_development_dependency "json", "1.8.3"
40
40
  end
@@ -13,7 +13,7 @@ describe PassaporteWeb::Http do
13
13
  end
14
14
  end
15
15
 
16
- let(:mock_response) { mock('restclient http response') }
16
+ let(:mock_response) { 'restclient http response' }
17
17
 
18
18
  describe ".get" do
19
19
  it "should use RestClient.get with the supplied params and common options" do
@@ -87,7 +87,7 @@ describe PassaporteWeb::IdentityServiceAccount do
87
87
  name: 'Conta Nova em Folha'
88
88
  }
89
89
  account = described_class.new(identity, attributes)
90
- account.save.should be_true
90
+ expect(account.save).to be_truthy
91
91
  account.should be_persisted
92
92
 
93
93
  account.plan_slug.should == 'basic'
@@ -135,7 +135,7 @@ describe PassaporteWeb::IdentityServiceAccount do
135
135
  name: 'Conta Nova em Folha 2: A missão'
136
136
  }
137
137
  account = described_class.new(identity, attributes)
138
- account.save.should be_false
138
+ expect(account.save).to be_falsy
139
139
  account.should_not be_persisted
140
140
  account.errors.should == {"field_errors"=>{"expiration"=>["Cannot set the expiration to the past."]}}
141
141
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
 
4
4
  describe PassaporteWeb::IdentityService do
5
5
  let(:identity) { PassaporteWeb::Identity.find('5e32f927-c4ab-404e-a91c-b2abc05afb56') }
6
- let(:mock_identity) { mock('Identity', uuid: 'identity-uuid') }
6
+ let(:mock_identity) { double('Identity', uuid: 'identity-uuid') }
7
7
  let(:identity_service_data_hash) { {:foo => 'bar', 'spam' => :eggs, 'integer' => 2, :float => 3.456, :array => [1, 2.0, 'three', :four], :hash => {oba: 'eba'}} }
8
8
  let(:identity_service_data_hash_as_strings) { {"foo"=>"bar", "hash"=>{"oba"=>"eba"}, "spam"=>"eggs", "integer"=>2, "array"=>[1, 2.0, "three", "four"], "float"=>3.456} }
9
9
 
@@ -14,7 +14,7 @@ describe PassaporteWeb::IdentityService do
14
14
  identity_service.identity.should == mock_identity
15
15
  identity_service.slug.should be_nil
16
16
  identity_service.is_active.should be_nil
17
- identity_service.is_active?.should be_false
17
+ expect(identity_service.is_active?).to be_falsy
18
18
  identity_service.service_data.should be_nil
19
19
  identity_service.errors.should be_empty
20
20
  identity_service.should_not be_persisted
@@ -31,7 +31,7 @@ describe PassaporteWeb::IdentityService do
31
31
  identity_service.identity.should == mock_identity
32
32
  identity_service.slug.should == 'identity_client'
33
33
  identity_service.is_active.should == true
34
- identity_service.is_active?.should be_true
34
+ expect(identity_service.is_active?).to be_truthy
35
35
  identity_service.service_data.should == identity_service_data_hash
36
36
  identity_service.errors.should be_empty
37
37
  identity_service.should_not be_persisted
@@ -44,8 +44,8 @@ describe PassaporteWeb::IdentityService do
44
44
  identity_service.should be_instance_of(described_class)
45
45
  identity_service.identity.should == identity
46
46
  identity_service.slug.should == 'identity_client'
47
- identity_service.is_active.should == true
48
- identity_service.is_active?.should be_true
47
+ expect(identity_service.is_active).to be_truthy
48
+ expect(identity_service.is_active?).to be_truthy
49
49
  identity_service.service_data.should be_nil
50
50
  identity_service.errors.should be_empty
51
51
  identity_service.should be_persisted
@@ -65,7 +65,7 @@ describe PassaporteWeb::IdentityService do
65
65
  'service_data' => identity_service_data_hash
66
66
  }
67
67
  identity_service = described_class.new(other_identity, attributes)
68
- identity_service.save.should be_true
68
+ expect(identity_service.save).to be_truthy
69
69
  identity_service.service_data.should == identity_service_data_hash_as_strings
70
70
 
71
71
  identity_service = described_class.find(other_identity, 'identity_client')
@@ -75,7 +75,7 @@ describe PassaporteWeb::IdentityService do
75
75
  identity_service = described_class.find(identity, 'identity_client')
76
76
  identity_service.service_data.should be_empty
77
77
  identity_service.service_data = identity_service_data_hash
78
- identity_service.save.should be_true
78
+ expect(identity_service.save).to be_truthy
79
79
  identity_service.service_data.should == identity_service_data_hash_as_strings
80
80
 
81
81
  identity_service = described_class.find(identity, 'identity_client')
@@ -128,7 +128,7 @@ describe PassaporteWeb::Identity do
128
128
  # REGRSSION
129
129
  it "should return the is_active and id_token fields" do
130
130
  identity = described_class.find('13b972ab-0946-4a5b-8217-60255a9cbee7', true, true)
131
- identity.is_active.should be_true
131
+ expect(identity.is_active).to be_truthy
132
132
  identity.id_token.should be_nil # não mostra token pois não foi autenticado com a senha do usuário
133
133
  end
134
134
  it "should raise an error if no profiles exist with that uuid" do
@@ -175,7 +175,7 @@ describe PassaporteWeb::Identity do
175
175
  # REGRSSION
176
176
  it "should return the is_active and id_token fields" do
177
177
  identity = described_class.find_by_email('mobileteste269@mailinator.com', true, true)
178
- identity.is_active.should be_true
178
+ expect(identity.is_active).to be_truthy
179
179
  identity.id_token.should be_nil # não mostra token pois não foi autenticado com a senha do usuário
180
180
  end
181
181
  it "should raise an error if no profiles exist with that email" do
@@ -205,12 +205,12 @@ describe PassaporteWeb::Identity do
205
205
  identity.email_list.count.should == 2
206
206
  # Primary e-mail
207
207
  identity.email_list[0]['address'].should == 'jaime.lannister@mailinator.com'
208
- identity.email_list[0]['is_primary'].should be_true
209
- identity.email_list[0]['is_active'].should be_true
208
+ expect(identity.email_list[0]['is_primary']).to be_truthy
209
+ expect(identity.email_list[0]['is_active']).to be_truthy
210
210
  # Secondary email
211
211
  identity.email_list[1]['address'].should == 'kingslayer@mailinator.com'
212
- identity.email_list[1]['is_primary'].should be_false
213
- identity.email_list[1]['is_active'].should be_true
212
+ expect(identity.email_list[1]['is_primary']).to be_falsy
213
+ expect(identity.email_list[1]['is_active']).to be_truthy
214
214
  end
215
215
  it "should raise an error if no profiles exist with that email" do
216
216
  expect {
@@ -231,11 +231,11 @@ describe PassaporteWeb::Identity do
231
231
  # REGRSSION
232
232
  it "should return the is_active and id_token fields" do
233
233
  identity = described_class.authenticate('mobileteste269@mailinator.com', 'vivalasvegas')
234
- identity.is_active.should be_true
234
+ expect(identity.is_active).to be_truthy
235
235
  identity.id_token.should == '9864ec27fb4fd866f6fad5bc041d0363d0bc0fd2945858a1'
236
236
  end
237
237
  it "should return false if the password is wrong for the given email" do
238
- described_class.authenticate('teste@teste.com', 'wrong password').should be_false
238
+ expect(described_class.authenticate('teste@teste.com', 'wrong password')).to be_falsy
239
239
  end
240
240
  it "should return false if no Identity exists on PassaporteWeb with that email" do
241
241
  described_class.authenticate('non_existing_email@teste.com', 'some password')
@@ -245,10 +245,10 @@ describe PassaporteWeb::Identity do
245
245
  describe "#authenticate", vcr: true do
246
246
  let(:identity) { described_class.find("5e32f927-c4ab-404e-a91c-b2abc05afb56") }
247
247
  it "should return true if the password is correct" do
248
- identity.authenticate('123456').should be_true
248
+ expect(identity.authenticate('123456')).to be_truthy
249
249
  end
250
250
  it "should return false if the password is wrong" do
251
- identity.authenticate('wrong password').should be_false
251
+ expect(identity.authenticate('wrong password')).to be_falsy
252
252
  end
253
253
  it "should raise an error if the email is not set" do
254
254
  identity.instance_variable_set(:@email, nil)
@@ -266,7 +266,7 @@ describe PassaporteWeb::Identity do
266
266
  identity.first_name.should == 'Testador'
267
267
  identity.should be_persisted
268
268
  identity.first_name = 'Testador 2'
269
- identity.save.should be_true
269
+ expect(identity.save).to be_truthy
270
270
  identity.should be_persisted
271
271
  identity.first_name.should == 'Testador 2'
272
272
 
@@ -278,7 +278,7 @@ describe PassaporteWeb::Identity do
278
278
  it "should return false and set the errors hash" do
279
279
  identity.cpf = 42
280
280
  identity.should be_persisted
281
- identity.save.should be_false
281
+ expect(identity.save).to be_falsy
282
282
  identity.should be_persisted
283
283
  identity.errors.should == {"cpf" => ["Certifique-se de que o valor tenha no mínimo 11 caracteres (ele possui 2)."]}
284
284
  end
@@ -298,7 +298,7 @@ describe PassaporteWeb::Identity do
298
298
  }
299
299
  identity = described_class.new(attributes)
300
300
  identity.should_not be_persisted
301
- identity.save.should be_true
301
+ expect(identity.save).to be_truthy
302
302
  identity.should be_persisted
303
303
  end
304
304
  it "should save with all params" do
@@ -317,7 +317,7 @@ describe PassaporteWeb::Identity do
317
317
  }
318
318
  identity = described_class.new(attributes)
319
319
  identity.should_not be_persisted
320
- identity.save.should be_true
320
+ expect(identity.save).to be_truthy
321
321
  identity.should be_persisted
322
322
  end
323
323
  # REGRESSION
@@ -332,9 +332,9 @@ describe PassaporteWeb::Identity do
332
332
  send_myfreecomm_news: true
333
333
  }
334
334
  identity = described_class.new(attributes)
335
- mock_response = mock('response', code: 201, body: MultiJson.encode(attributes))
335
+ mock_response = double('response', code: 201, body: MultiJson.encode(attributes))
336
336
  PassaporteWeb::Http.should_receive(:post).with("/accounts/api/create/", attributes).and_return(mock_response)
337
- identity.save.should be_true
337
+ expect(identity.save).to be_truthy
338
338
  end
339
339
  end
340
340
  context "on failure" do
@@ -347,7 +347,7 @@ describe PassaporteWeb::Identity do
347
347
  }
348
348
  identity = described_class.new(attributes)
349
349
  identity.should_not be_persisted
350
- identity.save.should_not be_true
350
+ expect(identity.save).to_not be_truthy
351
351
  identity.should_not be_persisted
352
352
  identity.errors.should == {"password2"=>["Este campo é obrigatório."], "password"=>["Este campo é obrigatório."]}
353
353
  end
@@ -55,7 +55,7 @@ describe PassaporteWeb::Notification do
55
55
 
56
56
  notifications = data.notifications
57
57
  notifications.size.should == 2
58
- notifications.map { |n| n.instance_of?(described_class) }.uniq.should be_true
58
+ expect(notifications.map { |n| n.instance_of?(described_class) }.uniq).to be_truthy
59
59
  n1, n2 = notifications
60
60
  n1.body.should == '"oioioi"' # TODO why? was it created like this?
61
61
  n2.body.should == '"oioioisss"'
@@ -74,7 +74,7 @@ describe PassaporteWeb::Notification do
74
74
 
75
75
  notifications = data.notifications
76
76
  notifications.size.should == 1
77
- notifications.map { |n| n.instance_of?(described_class) }.uniq.should be_true
77
+ expect(notifications.map { |n| n.instance_of?(described_class) }.uniq). to be_truthy
78
78
  n1 = notifications.first
79
79
  n1.body.should == '"oioioi"' # TODO why? was it created like this?
80
80
  n1.uuid.should == "2ca046be-0178-418d-80ac-3a334c264009"
@@ -125,7 +125,7 @@ describe PassaporteWeb::Notification do
125
125
  it "should create the Notification on PassaporteWeb, authenticated as the user" do
126
126
  PassaporteWeb.configuration.user_token = "f01d30c0a2e878fecc838735560253f9e9395932f5337f40"
127
127
  notification.should_not be_persisted
128
- notification.save.should be_true # by default authenticates as the user
128
+ expect(notification.save).to be_truthy # by default authenticates as the user
129
129
  notification.should be_persisted
130
130
  notification.uuid.should_not be_nil
131
131
  notification.absolute_url.should_not be_nil
@@ -139,7 +139,7 @@ describe PassaporteWeb::Notification do
139
139
  end
140
140
  it "should create the Notification on PassaporteWeb, authenticated as the application" do
141
141
  notification.should_not be_persisted
142
- notification.save('application').should be_true
142
+ expect(notification.save('application')).to be_truthy
143
143
  notification.should be_persisted
144
144
  notification.uuid.should_not be_nil
145
145
  notification.absolute_url.should_not be_nil
@@ -156,13 +156,13 @@ describe PassaporteWeb::Notification do
156
156
  it "should return false an do nothing if the Notification is already persisted" do
157
157
  PassaporteWeb.configuration.user_token = "f01d30c0a2e878fecc838735560253f9e9395932f5337f40"
158
158
  notification = described_class.find_all(1,20,nil,true).notifications.last
159
- notification.save.should be_false
159
+ expect(notification.save).to be_falsy
160
160
  end
161
161
  it "should return false and set the errors with the reason for the failure, authenticated as the user" do
162
162
  PassaporteWeb.configuration.user_token = "f01d30c0a2e878fecc838735560253f9e9395932f5337f40"
163
163
  notification.target_url = 'lalalala'
164
164
  notification.should_not be_persisted
165
- notification.save('user').should be_false
165
+ expect(notification.save('user')).to be_falsy
166
166
  notification.should_not be_persisted
167
167
  notification.uuid.should be_nil
168
168
  notification.errors.should == {"field_errors"=>{"target_url"=>["Informe uma URL válida."]}}
@@ -170,7 +170,7 @@ describe PassaporteWeb::Notification do
170
170
  it "should return false and set the errors with the reason for the failure, authenticated as the application" do
171
171
  notification.destination = nil # required field
172
172
  notification.should_not be_persisted
173
- notification.save('application').should be_false
173
+ expect(notification.save('application')).to be_falsy
174
174
  notification.should_not be_persisted
175
175
  notification.uuid.should be_nil
176
176
  notification.errors.should == {"field_errors"=>{"destination"=>["Este campo é obrigatório."]}}
@@ -187,7 +187,7 @@ describe PassaporteWeb::Notification do
187
187
  context "on success" do
188
188
  it "should mark the Notification as read" do
189
189
  notification.read_at.should be_nil
190
- notification.read!.should be_true
190
+ expect(notification.read!).to be_truthy
191
191
  notification.read_at.should_not be_nil
192
192
  end
193
193
  end
@@ -195,7 +195,7 @@ describe PassaporteWeb::Notification do
195
195
  it "should return false if the notification is already read" do
196
196
  read_notification = described_class.find_all(1,20,nil,true).notifications.detect { |n| !n.read_at.nil? }
197
197
  read_notification.read_at.should_not be_nil
198
- read_notification.read!.should be_false
198
+ expect(read_notification.read!).to be_falsy
199
199
  read_notification.errors.should == {message: 'notification already read'}
200
200
  end
201
201
  end
@@ -204,19 +204,19 @@ describe PassaporteWeb::Notification do
204
204
  describe "#destroy" do
205
205
  let(:notification) { described_class.new(body: 'novinha', destination: 'a5868d14-6529-477a-9c6b-a09dd42a7cd2', scheduled_to: '2013-04-06') } # 2.days.from_now
206
206
  it "should return false if the record is not persisted" do
207
- notification.destroy.should be_false
207
+ expect(notification.destroy).to be_falsy
208
208
  notification.errors.should == {message: 'notification not persisted yet'}
209
209
  end
210
210
  it "should destroy the notification on PassaporteWeb if the notification has not been read and is scheduled", vcr: true do
211
- notification.save('application').should be_true
211
+ expect(notification.save('application')).to be_truthy
212
212
  notification.read_at.should be_nil
213
213
  notification.scheduled_to.should == "2013-04-06 00:00:00"
214
- notification.destroy.should be_true
214
+ expect(notification.destroy).to be_truthy
215
215
  end
216
216
  it "should not exclude non-scheduled notification", vcr: true do
217
217
  notification.scheduled_to = nil
218
- notification.save('application').should be_true
219
- notification.destroy.should be_false
218
+ expect(notification.save('application')).to be_truthy
219
+ expect(notification.destroy).to be_falsy
220
220
  notification.errors.should == "Only scheduled notifications can be deleted via API"
221
221
  end
222
222
  end