freckle_io 0.1.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +7 -5
  3. data/freckle-io.gemspec +3 -3
  4. data/lib/freckle_io/client/entries.rb +1 -26
  5. data/lib/freckle_io/client/project_groups.rb +0 -2
  6. data/lib/freckle_io/client/projects.rb +1 -13
  7. data/lib/freckle_io/client/tags.rb +1 -6
  8. data/lib/freckle_io/client/users.rb +1 -6
  9. data/lib/freckle_io/configuration.rb +5 -5
  10. data/lib/freckle_io/connection.rb +1 -3
  11. data/lib/freckle_io/params.rb +5 -10
  12. data/lib/freckle_io/request/multiple_pages.rb +3 -3
  13. data/lib/freckle_io/request/single_page.rb +2 -2
  14. data/lib/freckle_io/validator/base_contract.rb +16 -0
  15. data/lib/freckle_io/validator/entry.rb +26 -50
  16. data/lib/freckle_io/validator/project.rb +13 -39
  17. data/lib/freckle_io/validator/project_group.rb +5 -24
  18. data/lib/freckle_io/validator/tag.rb +5 -24
  19. data/lib/freckle_io/validator/user.rb +13 -37
  20. data/lib/freckle_io/validator/validation.yml +8 -13
  21. data/lib/freckle_io.rb +1 -1
  22. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Entries/with_configuration/_all/result_must_be_a_Request_MultiplePages.yml +23 -18
  23. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Entries/with_configuration/_all/returns_a_entry_for_each_response.yml +23 -18
  24. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Entries/with_configuration/with_unknow_params/doesn_t_raise_a_invalid_params_error.yml +53 -0
  25. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Entries/with_configuration/with_valid_params/params_should_be_valid.yml +22 -17
  26. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Entries/with_configuration/with_validator/call_entry_s_validator.yml +24 -19
  27. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_ProjectGroups/with_configuration/_all/result_must_be_a_Request_MultiplePages.yml +261 -35
  28. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_ProjectGroups/with_configuration/_all/returns_a_project_group_for_each_response.yml +262 -36
  29. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_ProjectGroups/with_configuration/with_unknow_params/doesn_t_raises_a_invalid_params_error.yml +325 -0
  30. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_ProjectGroups/with_configuration/with_valid_params/params_should_be_valid.yml +22 -17
  31. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_ProjectGroups/with_configuration/with_validator/call_project_group_s_validator.yml +261 -35
  32. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Projects/with_configuration/_all/result_must_be_a_Request_MultiplePages.yml +501 -225
  33. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Projects/with_configuration/_all/returns_a_project_for_each_response.yml +501 -225
  34. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Projects/with_configuration/_show/get_a_spacific_project.yml +24 -19
  35. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Projects/with_configuration/_show/raw_links_should_be_a_empty_array.yml +24 -19
  36. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Projects/with_configuration/with_unknow_params/doesn_t_raises_a_invalid_params_error.yml +865 -0
  37. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Projects/with_configuration/with_valid_params/params_should_be_valid.yml +22 -17
  38. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Projects/with_configuration/with_validator/call_project_s_validator.yml +502 -226
  39. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Tags/with_configuration/_all/result_must_be_a_Request_MultiplePages.yml +23 -18
  40. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Tags/with_configuration/_all/returns_a_tag_for_each_response.yml +23 -18
  41. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Tags/with_configuration/with_unknow_params/doesn_t_raise_a_invalid_params_error.yml +53 -0
  42. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Tags/with_configuration/with_valid_params/params_should_be_valid.yml +22 -17
  43. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Tags/with_configuration/with_validator/call_tag_s_validator.yml +23 -18
  44. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Users/with_configuration/_all/result_must_be_a_Request_MultiplePages.yml +45 -35
  45. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Users/with_configuration/_all/returns_a_user_for_each_response.yml +45 -35
  46. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Users/with_configuration/with_unknow_params/doesn_t_raise_a_invalid_params_error.yml +109 -0
  47. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Users/with_configuration/with_valid_params/params_should_be_valid.yml +22 -17
  48. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Users/with_configuration/with_validator/call_user_s_validator.yml +45 -35
  49. data/spec/fixtures/vcr_cassettes/FreckleIO_Connection/with_default_configuration/with_a_valid_response/must_be_a_json_format.yml +23 -18
  50. data/spec/fixtures/vcr_cassettes/FreckleIO_Connection/with_default_configuration/with_freckle_token_authentication/set_X-FreckleToken.yml +23 -18
  51. data/spec/fixtures/vcr_cassettes/FreckleIO_Connection/with_default_configuration/with_header/set_user_agent.yml +23 -18
  52. data/spec/fixtures/vcr_cassettes/FreckleIO_Connection/with_default_configuration/with_invalid_url/raises_a_resource_not_found_error_for_invalid_resource.yml +13 -16
  53. data/spec/fixtures/vcr_cassettes/FreckleIO_Connection/with_default_configuration/with_page_param/response_must_be_success.yml +23 -18
  54. data/spec/fixtures/vcr_cassettes/FreckleIO_Connection/with_default_configuration/with_per_page_param/response_must_have_per_page_elements.yml +24 -19
  55. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_MultiplePages/with_configuration/_get/returns_an_array_of_faraday_response.yml +45 -35
  56. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_MultiplePages/with_configuration/_get/returns_freckle_default_per_page_elements.yml +45 -35
  57. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_MultiplePages/with_per_page/_get/return_per_page_number_elements.yml +74 -59
  58. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_first/next_page_should_be_a_SinglePage.yml +45 -35
  59. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_first/prev_page_should_be_nil.yml +23 -18
  60. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_first/when_get_last_page_from_the_first_page/next_should_be_nil.yml +45 -35
  61. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_get/returns_correct_raw_links_for_the_first_page.yml +23 -18
  62. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_last/next_page_should_be_nil.yml +45 -35
  63. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_last/returns_correct_raw_links_for_the_last_page.yml +45 -35
  64. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_last/when_get_prev_page_from_the_last_page/prev_should_be_nil.yml +67 -52
  65. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_next/previous_page_is_a_SinglePage.yml +67 -52
  66. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_next/previous_page_should_be_not_nil.yml +67 -52
  67. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_prev/next_page_is_a_SinglePage.yml +89 -69
  68. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_prev/when_get_prev_page_from_the_first_page/prev_should_be_nil.yml +67 -52
  69. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_total_page/with_first_page/returns_the_range_of_pages.yml +23 -18
  70. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_total_page/with_next_page/returns_an_empty_array.yml +45 -35
  71. data/spec/freckle_io/client/entries_spec.rb +23 -32
  72. data/spec/freckle_io/client/project_groups_spec.rb +11 -20
  73. data/spec/freckle_io/client/projects_spec.rb +15 -21
  74. data/spec/freckle_io/client/tags_spec.rb +10 -19
  75. data/spec/freckle_io/client/users_spec.rb +13 -21
  76. data/spec/freckle_io/configuration_spec.rb +7 -4
  77. data/spec/freckle_io/connection_spec.rb +1 -1
  78. data/spec/freckle_io/paginator_spec.rb +8 -8
  79. data/spec/freckle_io/params_spec.rb +1 -1
  80. data/spec/freckle_io/request/single_page_spec.rb +6 -6
  81. data/spec/spec_helper.rb +3 -3
  82. data/spec/support/anonymize/entries.rb +9 -8
  83. data/spec/support/anonymize/project_groups.rb +4 -3
  84. data/spec/support/anonymize/projects.rb +9 -8
  85. data/spec/support/anonymize/tags.rb +5 -4
  86. data/spec/support/anonymize/users.rb +13 -15
  87. data/spec/support/anonymize_interaction.rb +5 -5
  88. metadata +29 -24
  89. data/lib/freckle_io/validator/restricted_hash.rb +0 -11
@@ -73,25 +73,23 @@ describe FreckleIO::Client::Entries do
73
73
  {
74
74
  invalid_params: "oh! oh!",
75
75
  updated_from: "2018-01-15T00:00:00Z",
76
- updated_to: "2018-01-16T00:00:00Z"
76
+ updated_to: "2018-01-15T00:00:00Z"
77
77
  }
78
78
  end
79
79
 
80
80
  let(:results) { subject.all(params) }
81
81
 
82
- it "raises a invalid params error" do
83
- expect do
84
- results
85
- end.to raise_error(FreckleIO::Errors::Params::InvalidParams)
82
+ it "doesn't raise a invalid params error" do
83
+ expect { results }.not_to raise_error
86
84
  end
87
85
  end
88
86
 
89
87
  describe "with wrong user ids" do
90
88
  let(:params) do
91
89
  {
92
- user_id: 1234,
90
+ user_ids: 1234,
93
91
  updated_from: "2018-01-15T00:00:00Z",
94
- updated_to: "2018-01-16T00:00:00Z"
92
+ updated_to: "2018-01-15T00:00:00Z"
95
93
  }
96
94
  end
97
95
 
@@ -109,7 +107,7 @@ describe FreckleIO::Client::Entries do
109
107
  {
110
108
  description: 1234,
111
109
  updated_from: "2018-01-15T00:00:00Z",
112
- updated_to: "2018-01-16T00:00:00Z"
110
+ updated_to: "2018-01-15T00:00:00Z"
113
111
  }
114
112
  end
115
113
 
@@ -127,7 +125,7 @@ describe FreckleIO::Client::Entries do
127
125
  {
128
126
  project_ids: 123,
129
127
  updated_from: "2018-01-15T00:00:00Z",
130
- updated_to: "2018-01-16T00:00:00Z"
128
+ updated_to: "2018-01-15T00:00:00Z"
131
129
  }
132
130
  end
133
131
 
@@ -145,7 +143,7 @@ describe FreckleIO::Client::Entries do
145
143
  {
146
144
  tag_ids: 12,
147
145
  updated_from: "2018-01-15T00:00:00Z",
148
- updated_to: "2018-01-16T00:00:00Z"
146
+ updated_to: "2018-01-15T00:00:00Z"
149
147
  }
150
148
  end
151
149
 
@@ -163,7 +161,7 @@ describe FreckleIO::Client::Entries do
163
161
  {
164
162
  tag_filter_type: "or",
165
163
  updated_from: "2018-01-15T00:00:00Z",
166
- updated_to: "2018-01-16T00:00:00Z"
164
+ updated_to: "2018-01-15T00:00:00Z"
167
165
  }
168
166
  end
169
167
 
@@ -199,7 +197,7 @@ describe FreckleIO::Client::Entries do
199
197
  {
200
198
  to: 123,
201
199
  updated_from: "2018-01-15T00:00:00Z",
202
- updated_to: "2018-01-16T00:00:00Z"
200
+ updated_to: "2018-01-15T00:00:00Z"
203
201
  }
204
202
  end
205
203
 
@@ -247,9 +245,9 @@ describe FreckleIO::Client::Entries do
247
245
  describe "with wrong billable" do
248
246
  let(:params) do
249
247
  {
250
- tag_filter_type: 123,
248
+ billable: 123,
251
249
  updated_from: "2018-01-15T00:00:00Z",
252
- updated_to: "2018-01-16T00:00:00Z"
250
+ updated_to: "2018-01-15T00:00:00Z"
253
251
  }
254
252
  end
255
253
 
@@ -267,7 +265,7 @@ describe FreckleIO::Client::Entries do
267
265
  {
268
266
  approved_at_from: 123,
269
267
  updated_from: "2018-01-15T00:00:00Z",
270
- updated_to: "2018-01-16T00:00:00Z"
268
+ updated_to: "2018-01-15T00:00:00Z"
271
269
  }
272
270
  end
273
271
 
@@ -285,7 +283,7 @@ describe FreckleIO::Client::Entries do
285
283
  {
286
284
  approved_at_to: 123,
287
285
  updated_from: "2018-01-15T00:00:00Z",
288
- updated_to: "2018-01-16T00:00:00Z"
286
+ updated_to: "2018-01-15T00:00:00Z"
289
287
  }
290
288
  end
291
289
 
@@ -303,7 +301,7 @@ describe FreckleIO::Client::Entries do
303
301
  {
304
302
  approved_by_ids: 123,
305
303
  updated_from: "2018-01-15T00:00:00Z",
306
- updated_to: "2018-01-16T00:00:00Z"
304
+ updated_to: "2018-01-15T00:00:00Z"
307
305
  }
308
306
  end
309
307
 
@@ -318,17 +316,16 @@ describe FreckleIO::Client::Entries do
318
316
 
319
317
  describe "with validator" do
320
318
  let(:entry_validator) do
321
- class_double(
322
- FreckleIO::Validator::Entry,
323
- errors: {},
324
- output: params
325
- )
319
+ instance_double(FreckleIO::Validator::Entry)
320
+ end
321
+ let(:validation_result) do
322
+ instance_double(Dry::Validation::Result, errors: {}, to_h: params)
326
323
  end
327
324
 
328
325
  let(:params) do
329
326
  {
330
327
  updated_from: "2018-01-15T00:00:00Z",
331
- updated_to: "2018-01-16T00:00:00Z"
328
+ updated_to: "2018-01-15T00:00:00Z"
332
329
  }
333
330
  end
334
331
 
@@ -337,22 +334,16 @@ describe FreckleIO::Client::Entries do
337
334
  end
338
335
 
339
336
  before do
340
- allow(FreckleIO::Validator::Entry).to receive(
341
- :validation
342
- ).with(params, FreckleIO::Client::Entries::ALLOWED_KEYS) do
337
+ allow(FreckleIO::Validator::Entry).to receive(:new) do
343
338
  entry_validator
344
339
  end
345
-
346
- allow(FreckleIO::Validator::Entry).to receive(:errors)
347
- allow(FreckleIO::Validator::Entry).to receive(:output)
340
+ allow(entry_validator).to receive(:call) { validation_result }
348
341
 
349
342
  result
350
343
  end
351
344
 
352
345
  it "call entry's validator" do
353
- expect(FreckleIO::Validator::Entry).to have_received(
354
- :validation
355
- )
346
+ expect(entry_validator).to have_received(:call)
356
347
  end
357
348
  end
358
349
  end
@@ -57,10 +57,8 @@ describe FreckleIO::Client::ProjectGroups do
57
57
 
58
58
  let(:results) { subject.all(params) }
59
59
 
60
- it "raises a invalid params error" do
61
- expect do
62
- results
63
- end.to raise_error(FreckleIO::Errors::Params::InvalidParams)
60
+ it "doesn't raises a invalid params error" do
61
+ expect { results }.not_to raise_error
64
62
  end
65
63
  end
66
64
 
@@ -80,10 +78,10 @@ describe FreckleIO::Client::ProjectGroups do
80
78
  end
81
79
  end
82
80
 
83
- describe "with project ids" do
81
+ describe "with wrong project ids" do
84
82
  let(:params) do
85
83
  {
86
- state: 123
84
+ project_ids: 123
87
85
  }
88
86
  end
89
87
 
@@ -98,11 +96,10 @@ describe FreckleIO::Client::ProjectGroups do
98
96
 
99
97
  describe "with validator" do
100
98
  let(:project_group_validator) do
101
- class_double(
102
- FreckleIO::Validator::ProjectGroup,
103
- errors: {},
104
- output: {}
105
- )
99
+ instance_double(FreckleIO::Validator::ProjectGroup)
100
+ end
101
+ let(:validation_result) do
102
+ instance_double(Dry::Validation::Result, errors: {}, to_h: {})
106
103
  end
107
104
 
108
105
  let(:result) do
@@ -110,22 +107,16 @@ describe FreckleIO::Client::ProjectGroups do
110
107
  end
111
108
 
112
109
  before do
113
- allow(FreckleIO::Validator::ProjectGroup).to receive(
114
- :validation
115
- ).with({}, FreckleIO::Client::ProjectGroups::ALLOWED_KEYS) do
110
+ allow(FreckleIO::Validator::ProjectGroup).to receive(:new) do
116
111
  project_group_validator
117
112
  end
118
-
119
- allow(FreckleIO::Validator::ProjectGroup).to receive(:errors)
120
- allow(FreckleIO::Validator::ProjectGroup).to receive(:output)
113
+ allow(project_group_validator).to receive(:call) { validation_result }
121
114
 
122
115
  result
123
116
  end
124
117
 
125
118
  it "call project group's validator" do
126
- expect(FreckleIO::Validator::ProjectGroup).to have_received(
127
- :validation
128
- )
119
+ expect(project_group_validator).to have_received(:call)
129
120
  end
130
121
  end
131
122
  end
@@ -18,7 +18,10 @@ describe FreckleIO::Client::Projects do
18
18
  end
19
19
 
20
20
  describe "#show" do
21
- let(:result) { subject.show(ENV["REAL_FRECKLE_PROJECT_ID"]) }
21
+ let(:real_freckle_project_id) do
22
+ ENV.fetch("REAL_FRECKLE_PROJECT_ID", nil)
23
+ end
24
+ let(:result) { subject.show(real_freckle_project_id) }
22
25
  let(:response) { result.last_response }
23
26
 
24
27
  it "get a spacific project" do
@@ -60,17 +63,15 @@ describe FreckleIO::Client::Projects do
60
63
 
61
64
  let(:results) { subject.all(params) }
62
65
 
63
- it "raises a invalid params error" do
64
- expect do
65
- results
66
- end.to raise_error(FreckleIO::Errors::Params::InvalidParams)
66
+ it "doesn't raises a invalid params error" do
67
+ expect { results }.not_to raise_error
67
68
  end
68
69
  end
69
70
 
70
71
  describe "with wrong name" do
71
72
  let(:params) do
72
73
  {
73
- email: 1234
74
+ name: ""
74
75
  }
75
76
  end
76
77
 
@@ -102,7 +103,7 @@ describe FreckleIO::Client::Projects do
102
103
  describe "with wrong billing increment" do
103
104
  let(:params) do
104
105
  {
105
- billing_increment: "1,3,7"
106
+ billing_increment: "3"
106
107
  }
107
108
  end
108
109
 
@@ -149,11 +150,10 @@ describe FreckleIO::Client::Projects do
149
150
 
150
151
  describe "with validator" do
151
152
  let(:project_validator) do
152
- class_double(
153
- FreckleIO::Validator::Project,
154
- errors: {},
155
- output: {}
156
- )
153
+ instance_double(FreckleIO::Validator::Project)
154
+ end
155
+ let(:validation_result) do
156
+ instance_double(Dry::Validation::Result, errors: {}, to_h: {})
157
157
  end
158
158
 
159
159
  let(:result) do
@@ -161,22 +161,16 @@ describe FreckleIO::Client::Projects do
161
161
  end
162
162
 
163
163
  before do
164
- allow(FreckleIO::Validator::Project).to receive(
165
- :validation
166
- ).with({}, FreckleIO::Client::Projects::ALLOWED_KEYS) do
164
+ allow(FreckleIO::Validator::Project).to receive(:new) do
167
165
  project_validator
168
166
  end
169
-
170
- allow(FreckleIO::Validator::Project).to receive(:errors)
171
- allow(FreckleIO::Validator::Project).to receive(:output)
167
+ allow(project_validator).to receive(:call) { validation_result }
172
168
 
173
169
  result
174
170
  end
175
171
 
176
172
  it "call project's validator" do
177
- expect(FreckleIO::Validator::Project).to have_received(
178
- :validation
179
- )
173
+ expect(project_validator).to have_received(:call)
180
174
  end
181
175
  end
182
176
  end
@@ -57,10 +57,8 @@ describe FreckleIO::Client::Tags do
57
57
 
58
58
  let(:results) { subject.all(params) }
59
59
 
60
- it "raises a invalid params error" do
61
- expect do
62
- results
63
- end.to raise_error(FreckleIO::Errors::Params::InvalidParams)
60
+ it "doesn't raise a invalid params error" do
61
+ expect { results }.not_to raise_error
64
62
  end
65
63
  end
66
64
 
@@ -83,7 +81,7 @@ describe FreckleIO::Client::Tags do
83
81
  describe "with billable" do
84
82
  let(:params) do
85
83
  {
86
- state: 123
84
+ billable: 123
87
85
  }
88
86
  end
89
87
 
@@ -98,11 +96,10 @@ describe FreckleIO::Client::Tags do
98
96
 
99
97
  describe "with validator" do
100
98
  let(:tag_validator) do
101
- class_double(
102
- FreckleIO::Validator::Tag,
103
- errors: {},
104
- output: {}
105
- )
99
+ instance_double(FreckleIO::Validator::Tag)
100
+ end
101
+ let(:validation_result) do
102
+ instance_double(Dry::Validation::Result, errors: {}, to_h: {})
106
103
  end
107
104
 
108
105
  let(:result) do
@@ -110,22 +107,16 @@ describe FreckleIO::Client::Tags do
110
107
  end
111
108
 
112
109
  before do
113
- allow(FreckleIO::Validator::Tag).to receive(
114
- :validation
115
- ).with({}, FreckleIO::Client::Tags::ALLOWED_KEYS) do
110
+ allow(FreckleIO::Validator::Tag).to receive(:new) do
116
111
  tag_validator
117
112
  end
118
-
119
- allow(FreckleIO::Validator::Tag).to receive(:errors)
120
- allow(FreckleIO::Validator::Tag).to receive(:output)
113
+ allow(tag_validator).to receive(:call) { validation_result }
121
114
 
122
115
  result
123
116
  end
124
117
 
125
118
  it "call tag's validator" do
126
- expect(FreckleIO::Validator::Tag).to have_received(
127
- :validation
128
- )
119
+ expect(tag_validator).to have_received(:call)
129
120
  end
130
121
  end
131
122
  end
@@ -18,7 +18,10 @@ describe FreckleIO::Client::Users do
18
18
  end
19
19
 
20
20
  describe "#show" do
21
- let(:result) { subject.show(ENV["REAL_FRECKLE_USER_ID"]) }
21
+ let(:real_freckle_user_id) do
22
+ ENV.fetch("REAL_FRECKLE_USER_ID", nil)
23
+ end
24
+ let(:result) { subject.show(real_freckle_user_id) }
22
25
  let(:response) { result.last_response }
23
26
 
24
27
  it "get a spacific user" do
@@ -59,10 +62,8 @@ describe FreckleIO::Client::Users do
59
62
 
60
63
  let(:results) { subject.all(params) }
61
64
 
62
- it "raises a invalid params error" do
63
- expect do
64
- results
65
- end.to raise_error(FreckleIO::Errors::Params::InvalidParams)
65
+ it "doesn't raise a invalid params error" do
66
+ expect { results }.not_to raise_error
66
67
  end
67
68
  end
68
69
 
@@ -116,11 +117,10 @@ describe FreckleIO::Client::Users do
116
117
 
117
118
  describe "with validator" do
118
119
  let(:user_validator) do
119
- class_double(
120
- FreckleIO::Validator::User,
121
- errors: {},
122
- output: {}
123
- )
120
+ instance_double(FreckleIO::Validator::User)
121
+ end
122
+ let(:validation_result) do
123
+ instance_double(Dry::Validation::Result, errors: {}, to_h: {})
124
124
  end
125
125
 
126
126
  let(:result) do
@@ -128,22 +128,14 @@ describe FreckleIO::Client::Users do
128
128
  end
129
129
 
130
130
  before do
131
- allow(FreckleIO::Validator::User).to receive(
132
- :validation
133
- ).with({}, FreckleIO::Client::Users::ALLOWED_KEYS) do
134
- user_validator
135
- end
136
-
137
- allow(FreckleIO::Validator::User).to receive(:errors)
138
- allow(FreckleIO::Validator::User).to receive(:output)
131
+ allow(FreckleIO::Validator::User).to receive(:new) { user_validator }
132
+ allow(user_validator).to receive(:call) { validation_result }
139
133
 
140
134
  result
141
135
  end
142
136
 
143
137
  it "call user's validator" do
144
- expect(FreckleIO::Validator::User).to have_received(
145
- :validation
146
- )
138
+ expect(user_validator).to have_received(:call)
147
139
  end
148
140
  end
149
141
  end
@@ -1,25 +1,28 @@
1
1
  require_relative "../spec_helper"
2
2
 
3
3
  describe FreckleIO::Configuration do
4
+ let(:freckle_token) { ENV.fetch("FRECKLE_TOKEN", nil) }
5
+ let(:freckle_url) { ENV.fetch("FRECKLE_URL", nil) }
6
+
4
7
  context "with right configuration" do
5
8
  before do
6
9
  FreckleIO.reset
7
10
  FreckleIO.configure do |config|
8
- config.token = ENV["FRECKLE_TOKEN"]
9
- config.url = ENV["FRECKLE_URL"]
11
+ config.token = freckle_token
12
+ config.url = freckle_url
10
13
  end
11
14
  end
12
15
 
13
16
  it "return the correct token" do
14
17
  expect(
15
18
  FreckleIO.configuration.token
16
- ).to eq ENV["FRECKLE_TOKEN"]
19
+ ).to eq freckle_token
17
20
  end
18
21
 
19
22
  it "return the correct url" do
20
23
  expect(
21
24
  FreckleIO.configuration.url
22
- ).to eq ENV["FRECKLE_URL"]
25
+ ).to eq freckle_url
23
26
  end
24
27
  end
25
28
 
@@ -16,7 +16,7 @@ describe FreckleIO::Connection do
16
16
  let(:header_token) { result.env.request_headers["X-FreckleToken"] }
17
17
 
18
18
  it "set X-FreckleToken" do
19
- expect(header_token).not_to be nil
19
+ expect(header_token).not_to be_nil
20
20
  end
21
21
  end
22
22
 
@@ -52,25 +52,25 @@ describe FreckleIO::Paginator do
52
52
 
53
53
  describe "#next" do
54
54
  it "return nil" do
55
- expect(result.next).to eq(nil)
55
+ expect(result.next).to be_nil
56
56
  end
57
57
  end
58
58
 
59
59
  describe "#prev" do
60
60
  it "return nil" do
61
- expect(result.prev).to eq(nil)
61
+ expect(result.prev).to be_nil
62
62
  end
63
63
  end
64
64
 
65
65
  describe "#last" do
66
66
  it "return nil" do
67
- expect(result.last).to eq(nil)
67
+ expect(result.last).to be_nil
68
68
  end
69
69
  end
70
70
 
71
71
  describe "#first" do
72
72
  it "return nil" do
73
- expect(result.first).to eq(nil)
73
+ expect(result.first).to be_nil
74
74
  end
75
75
  end
76
76
  end
@@ -80,25 +80,25 @@ describe FreckleIO::Paginator do
80
80
 
81
81
  describe "#next" do
82
82
  it "return nil" do
83
- expect(result.next).to eq(nil)
83
+ expect(result.next).to be_nil
84
84
  end
85
85
  end
86
86
 
87
87
  describe "#prev" do
88
88
  it "return nil" do
89
- expect(result.prev).to eq(nil)
89
+ expect(result.prev).to be_nil
90
90
  end
91
91
  end
92
92
 
93
93
  describe "#last" do
94
94
  it "return nil" do
95
- expect(result.last).to eq(nil)
95
+ expect(result.last).to be_nil
96
96
  end
97
97
  end
98
98
 
99
99
  describe "#first" do
100
100
  it "return nil" do
101
- expect(result.first).to eq(nil)
101
+ expect(result.first).to be_nil
102
102
  end
103
103
  end
104
104
  end
@@ -3,7 +3,7 @@ require_relative "../spec_helper"
3
3
  describe FreckleIO::Params do
4
4
  context "when invalid module" do
5
5
  subject do
6
- described_class.new({}, nil, "invalid_module").call
6
+ described_class.new({}, "invalid_module").call
7
7
  end
8
8
 
9
9
  it "raises a invalid module error" do
@@ -17,7 +17,7 @@ describe FreckleIO::Request::SinglePage do
17
17
  let(:body_response) { next_users.last_response.body }
18
18
 
19
19
  it "previous page should be not nil" do
20
- expect(next_users.prev).to_not be nil
20
+ expect(next_users.prev).to_not be_nil
21
21
  end
22
22
 
23
23
  it "previous page is a SinglePage" do
@@ -39,7 +39,7 @@ describe FreckleIO::Request::SinglePage do
39
39
 
40
40
  context "when get prev page from the first page" do
41
41
  it "prev should be nil" do
42
- expect(prev_users.prev).to be nil
42
+ expect(prev_users.prev).to be_nil
43
43
  end
44
44
  end
45
45
  end
@@ -53,7 +53,7 @@ describe FreckleIO::Request::SinglePage do
53
53
  let(:body_response) { last_users.last_response.body }
54
54
 
55
55
  it "next page should be nil" do
56
- expect(last_users.next).to be nil
56
+ expect(last_users.next).to be_nil
57
57
  end
58
58
 
59
59
  it "returns correct raw links for the last page" do
@@ -62,7 +62,7 @@ describe FreckleIO::Request::SinglePage do
62
62
 
63
63
  context "when get prev page from the last page" do
64
64
  it "prev should be nil" do
65
- expect(last_users.first.prev).to be nil
65
+ expect(last_users.first.prev).to be_nil
66
66
  end
67
67
  end
68
68
  end
@@ -72,7 +72,7 @@ describe FreckleIO::Request::SinglePage do
72
72
  let(:body_response) { first_users.last_response.body }
73
73
 
74
74
  it "prev page should be nil" do
75
- expect(first_users.prev).to be nil
75
+ expect(first_users.prev).to be_nil
76
76
  end
77
77
 
78
78
  it "next page should be a SinglePage" do
@@ -81,7 +81,7 @@ describe FreckleIO::Request::SinglePage do
81
81
 
82
82
  context "when get last page from the first page" do
83
83
  it "next should be nil" do
84
- expect(first_users.last.next).to be nil
84
+ expect(first_users.last.next).to be_nil
85
85
  end
86
86
  end
87
87
  end
data/spec/spec_helper.rb CHANGED
@@ -29,16 +29,16 @@ require "dotenv"
29
29
  Dotenv.load(".env.test")
30
30
 
31
31
  RSpec.configure do |config|
32
- config.before(:each) do
32
+ config.before do
33
33
  FreckleIO.configure do |c|
34
- c.token = ENV["FRECKLE_TOKEN"]
34
+ c.token = ENV.fetch("FRECKLE_TOKEN", nil)
35
35
  c.auth_type = :freckle_token
36
36
  c.max_concurrency = 5
37
37
  c.url = "https://api.nokotime.com"
38
38
  end
39
39
  end
40
40
 
41
- config.after(:each) do
41
+ config.after do
42
42
  FreckleIO.reset
43
43
  end
44
44
 
@@ -1,15 +1,16 @@
1
1
  module Anonymize
2
2
  class Entries
3
3
  attr_accessor :interaction
4
+
4
5
  ENTRY_API_REPLACE_VALUES = {
5
- id: /\"id\":(.*?),/i,
6
- description: /\"description\":\"(.*?)\"/i,
7
- name: /\"name\":\"(.*?)\"/i,
8
- email: /\"email\":\"(.*?)\",/i,
9
- first_name: /\"first_name\":\"(.*?)\"/i,
10
- last_name: /\"last_name\":\"(.*?)\"/i,
11
- profile_image_url: /\"profile_image_url\":\"(.*?)\"/i,
12
- url: /\"url\":\"(.*?)\"/i
6
+ id: /"id":(.*?),/i,
7
+ description: /"description":"(.*?)"/i,
8
+ name: /"name":"(.*?)"/i,
9
+ email: /"email":"(.*?)",/i,
10
+ first_name: /"first_name":"(.*?)"/i,
11
+ last_name: /"last_name":"(.*?)"/i,
12
+ profile_image_url: /"profile_image_url":"(.*?)"/i,
13
+ url: /"url":"(.*?)"/i
13
14
  }.freeze
14
15
 
15
16
  def initialize(interaction:)
@@ -1,10 +1,11 @@
1
1
  module Anonymize
2
2
  class ProjectGroups
3
3
  attr_accessor :interaction
4
+
4
5
  PROJECT_GROUP_API_REPLACE_VALUES = {
5
- id: /\"id\":(.*?),/mi,
6
- name: /\"name\":\"(.*?)\"/mi,
7
- url: /\"url\":\"(.*?)\"/mi
6
+ id: /"id":(.*?),/mi,
7
+ name: /"name":"(.*?)"/mi,
8
+ url: /"url":"(.*?)"/mi
8
9
  }.freeze
9
10
 
10
11
  def initialize(interaction:)