namely 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +22 -24
  3. data/lib/namely.rb +2 -101
  4. data/lib/namely/authenticator.rb +61 -14
  5. data/lib/namely/collection.rb +78 -0
  6. data/lib/namely/connection.rb +90 -0
  7. data/lib/namely/exceptions.rb +0 -3
  8. data/lib/namely/model.rb +78 -0
  9. data/lib/namely/resource_gateway.rb +7 -2
  10. data/lib/namely/version.rb +1 -1
  11. data/spec/fixtures/vcr_cassettes/{country_head.yml → countries_head.yml} +4 -4
  12. data/spec/fixtures/vcr_cassettes/{country_head_missing.yml → countries_head_missing.yml} +4 -4
  13. data/spec/fixtures/vcr_cassettes/{country_index.yml → countries_index.yml} +6 -6
  14. data/spec/fixtures/vcr_cassettes/{country_show.yml → countries_show.yml} +4 -4
  15. data/spec/fixtures/vcr_cassettes/{country_show_missing.yml → countries_show_missing.yml} +7 -7
  16. data/spec/fixtures/vcr_cassettes/{currencytype_index.yml → currency_types_index.yml} +5 -5
  17. data/spec/fixtures/vcr_cassettes/current_user.yml +57 -0
  18. data/spec/fixtures/vcr_cassettes/{event_head.yml → events_head.yml} +4 -4
  19. data/spec/fixtures/vcr_cassettes/{event_head_missing.yml → events_head_missing.yml} +5 -5
  20. data/spec/fixtures/vcr_cassettes/events_index.yml +89 -0
  21. data/spec/fixtures/vcr_cassettes/{event_show.yml → events_show.yml} +5 -5
  22. data/spec/fixtures/vcr_cassettes/{event_show_missing.yml → events_show_missing.yml} +6 -6
  23. data/spec/fixtures/vcr_cassettes/fields_index.yml +48 -0
  24. data/spec/fixtures/vcr_cassettes/{jobtier_index.yml → job_tiers_index.yml} +5 -5
  25. data/spec/fixtures/vcr_cassettes/{field_index.yml → profiles/fields_index.yml} +5 -5
  26. data/spec/fixtures/vcr_cassettes/profiles_create.yml +85 -0
  27. data/spec/fixtures/vcr_cassettes/{profile_create_failed.yml → profiles_create_failed.yml} +9 -10
  28. data/spec/fixtures/vcr_cassettes/{profile_head.yml → profiles_head.yml} +4 -4
  29. data/spec/fixtures/vcr_cassettes/{profile_head_missing.yml → profiles_head_missing.yml} +4 -4
  30. data/spec/fixtures/vcr_cassettes/profiles_index.yml +981 -0
  31. data/spec/fixtures/vcr_cassettes/{profile_show.yml → profiles_show.yml} +4 -4
  32. data/spec/fixtures/vcr_cassettes/{profile_show_missing.yml → profiles_show_missing.yml} +7 -7
  33. data/spec/fixtures/vcr_cassettes/profiles_show_updated.yml +91 -0
  34. data/spec/fixtures/vcr_cassettes/profiles_update.yml +95 -0
  35. data/spec/fixtures/vcr_cassettes/profiles_update_revert.yml +95 -0
  36. data/spec/fixtures/vcr_cassettes/{report_head.yml → reports_head.yml} +4 -4
  37. data/spec/fixtures/vcr_cassettes/{report_head_missing.yml → reports_head_missing.yml} +5 -5
  38. data/spec/fixtures/vcr_cassettes/reports_show.yml +186 -0
  39. data/spec/fixtures/vcr_cassettes/{report_show_missing.yml → reports_show_missing.yml} +7 -7
  40. data/spec/fixtures/vcr_cassettes/token.yml +6 -6
  41. data/spec/namely/authenticator_spec.rb +36 -0
  42. data/spec/namely/connection_spec.rb +15 -0
  43. data/spec/namely/integration_spec.rb +94 -0
  44. data/spec/namely/resource_gateway_spec.rb +18 -10
  45. data/spec/shared_examples/a_resource_with_a_create_action.rb +24 -0
  46. data/spec/shared_examples/a_resource_with_a_show_action.rb +38 -0
  47. data/spec/shared_examples/a_resource_with_an_index_action.rb +15 -0
  48. data/spec/shared_examples/{a_model_with_an_update_action.rb → a_resource_with_an_update_action.rb} +10 -9
  49. data/spec/spec_helper.rb +0 -17
  50. metadata +75 -88
  51. data/lib/namely/country.rb +0 -9
  52. data/lib/namely/currency_type.rb +0 -9
  53. data/lib/namely/event.rb +0 -9
  54. data/lib/namely/field.rb +0 -9
  55. data/lib/namely/job_tier.rb +0 -9
  56. data/lib/namely/profile.rb +0 -13
  57. data/lib/namely/report.rb +0 -9
  58. data/lib/namely/restful_model.rb +0 -150
  59. data/spec/fixtures/vcr_cassettes/event_index.yml +0 -88
  60. data/spec/fixtures/vcr_cassettes/profile_create.yml +0 -85
  61. data/spec/fixtures/vcr_cassettes/profile_index.yml +0 -979
  62. data/spec/fixtures/vcr_cassettes/profile_show_updated.yml +0 -91
  63. data/spec/fixtures/vcr_cassettes/profile_update.yml +0 -95
  64. data/spec/fixtures/vcr_cassettes/profile_update_revert.yml +0 -95
  65. data/spec/fixtures/vcr_cassettes/report_show.yml +0 -185
  66. data/spec/namely/configuration_spec.rb +0 -33
  67. data/spec/namely/country_spec.rb +0 -11
  68. data/spec/namely/currency_type_spec.rb +0 -5
  69. data/spec/namely/event_spec.rb +0 -11
  70. data/spec/namely/field_spec.rb +0 -5
  71. data/spec/namely/job_tier_spec.rb +0 -5
  72. data/spec/namely/profile_spec.rb +0 -25
  73. data/spec/namely/report_spec.rb +0 -8
  74. data/spec/shared_examples/a_model_with_a_create_action.rb +0 -24
  75. data/spec/shared_examples/a_model_with_a_show_action.rb +0 -38
  76. data/spec/shared_examples/a_model_with_an_index_action.rb +0 -17
@@ -1,33 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Namely::Configuration do
4
- before :each do
5
- unset_configuration!
6
- end
7
-
8
- after :each do
9
- set_configuration!
10
- end
11
-
12
- it "contains a subdomain and access_token when those have been set" do
13
- Namely.configure do |config|
14
- config.access_token = "my_token"
15
- config.subdomain = "my_subdomain"
16
- end
17
-
18
- expect(Namely.configuration.access_token).to eq "my_token"
19
- expect(Namely.configuration.subdomain).to eq "my_subdomain"
20
- end
21
-
22
- it "raises an error when the configuration block hasn't been run" do
23
- expect { Namely.configuration }.to raise_error Namely::ImproperlyConfiguredError
24
- end
25
-
26
- it "raises an error when variables haven't been set in the config" do
27
- Namely.configure do
28
- end
29
-
30
- expect { Namely.configuration.access_token }.to raise_error Namely::ImproperlyConfiguredError
31
- expect { Namely.configuration.subdomain }.to raise_error Namely::ImproperlyConfiguredError
32
- end
33
- end
@@ -1,11 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Namely::Country do
4
- it_behaves_like "a model with an index action", [:id, :name, :subdivision_type]
5
- it_behaves_like(
6
- "a model with a show action",
7
- id: "US",
8
- name: "United States",
9
- subdivision_type: "State"
10
- )
11
- end
@@ -1,5 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Namely::CurrencyType do
4
- it_behaves_like "a model with an index action"
5
- end
@@ -1,11 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Namely::Event do
4
- it_behaves_like "a model with an index action", [:type]
5
-
6
- it_behaves_like(
7
- "a model with a show action",
8
- id: "e5573698-3934-4abf-99cf-577b526d4789",
9
- type: "recent_arrival",
10
- )
11
- end
@@ -1,5 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Namely::Field do
4
- it_behaves_like "a model with an index action"
5
- end
@@ -1,5 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Namely::JobTier do
4
- it_behaves_like "a model with an index action", [:title]
5
- end
@@ -1,25 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Namely::Profile do
4
- it_behaves_like "a model with an index action", [:first_name, :last_name]
5
-
6
- it_behaves_like(
7
- "a model with a show action",
8
- id: "20332458-c1fe-412f-bcb8-01622f04a35d",
9
- first_name: "Leighton",
10
- last_name: "Meester"
11
- )
12
-
13
- it_behaves_like(
14
- "a model with a create action",
15
- first_name: "Beardsly",
16
- last_name: "McDog",
17
- email: "beardsly-#{Time.now.utc.to_f}@namely.com"
18
- )
19
-
20
- it_behaves_like(
21
- "a model with an update action",
22
- "20332458-c1fe-412f-bcb8-01622f04a35d",
23
- middle_name: "Beardsly"
24
- )
25
- end
@@ -1,8 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Namely::Report do
4
- it_behaves_like(
5
- "a model with a show action",
6
- id: "bbf089f6-90c5-473c-8928-058014a462c9"
7
- )
8
- end
@@ -1,24 +0,0 @@
1
- shared_examples_for "a model with a create action" do |model_attributes|
2
- def invalid_attributes
3
- {}
4
- end
5
-
6
- describe ".create" do
7
- it "creates a model based on a hash of attributes" do
8
- model = nil
9
-
10
- VCR.use_cassette("#{classname}_create") do
11
- model = described_class.create!(model_attributes)
12
- end
13
-
14
- expect(model).to respond_to :id
15
- expect(model.id).not_to be_empty
16
- end
17
-
18
- it "raises a FailedRequestError when the create action fails" do
19
- VCR.use_cassette("#{classname}_create_failed") do
20
- expect { described_class.create!(invalid_attributes) }.to raise_error Namely::FailedRequestError
21
- end
22
- end
23
- end
24
- end
@@ -1,38 +0,0 @@
1
- shared_examples_for "a model with a show action" do |model_attributes|
2
- def invalid_id
3
- "this-is-almost-certainly-not-the-id-of-any-model"
4
- end
5
-
6
- describe ".find" do
7
- it "finds a model by its unique id" do
8
- VCR.use_cassette("#{classname}_show") do
9
- object = described_class.find(model_attributes[:id])
10
-
11
- expect(object).to be_a described_class
12
- model_attributes.each do |method, value|
13
- expect(object.public_send(method)).to eq value
14
- end
15
- end
16
- end
17
-
18
- it "raises an error if that model can't be found" do
19
- VCR.use_cassette("#{classname}_show_missing") do
20
- expect { described_class.find(invalid_id) }.to raise_error Namely::NoSuchModelError
21
- end
22
- end
23
- end
24
-
25
- describe ".exists?" do
26
- it "returns true if a model exists" do
27
- VCR.use_cassette("#{classname}_head") do
28
- expect(described_class.exists?(model_attributes[:id])).to eq true
29
- end
30
- end
31
-
32
- it "returns false if a model doesn't exist" do
33
- VCR.use_cassette("#{classname}_head_missing") do
34
- expect(described_class.exists?(invalid_id)).to eq false
35
- end
36
- end
37
- end
38
- end
@@ -1,17 +0,0 @@
1
- shared_examples_for "a model with an index action" do |instance_methods = []|
2
- describe ".all" do
3
- it "returns every model" do
4
- VCR.use_cassette("#{classname}_index") do
5
- objects = described_class.all
6
-
7
- expect(objects).not_to be_empty
8
- objects.each do |object|
9
- expect(object).to be_a described_class
10
- instance_methods.each do |instance_method|
11
- expect(object).to respond_to instance_method
12
- end
13
- end
14
- end
15
- end
16
- end
17
- end