versioncake 2.5.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +6 -14
  2. data/.rspec +2 -0
  3. data/.travis.yml +4 -0
  4. data/Appraisals +12 -0
  5. data/CHANGELOG.md +18 -1
  6. data/CONTRIBUTING.md +2 -2
  7. data/Gemfile.lock +96 -44
  8. data/README.md +79 -29
  9. data/RELEASE.md +1 -1
  10. data/Rakefile +3 -7
  11. data/gemfiles/rails3.2.gemfile +2 -1
  12. data/gemfiles/rails3.2.gemfile.lock +34 -10
  13. data/gemfiles/rails4.0.gemfile +2 -1
  14. data/gemfiles/rails4.0.gemfile.lock +31 -7
  15. data/gemfiles/rails4.1.gemfile +1 -1
  16. data/gemfiles/rails4.1.gemfile.lock +28 -8
  17. data/gemfiles/rails4.2.gemfile +9 -0
  18. data/gemfiles/rails4.2.gemfile.lock +133 -0
  19. data/lib/generators/templates/versioncake.rb +40 -0
  20. data/lib/generators/versioncake/install_generator.rb +12 -0
  21. data/lib/versioncake.rb +24 -3
  22. data/lib/versioncake/configuration.rb +19 -2
  23. data/lib/versioncake/controller_additions.rb +35 -23
  24. data/lib/versioncake/engine.rb +7 -0
  25. data/lib/versioncake/exceptions.rb +4 -0
  26. data/lib/versioncake/rack/middleware.rb +20 -0
  27. data/lib/versioncake/strategies/extraction_strategy.rb +8 -3
  28. data/lib/versioncake/strategies/http_accept_parameter_strategy.rb +2 -2
  29. data/lib/versioncake/strategies/http_header_strategy.rb +2 -2
  30. data/lib/versioncake/strategies/path_parameter_strategy.rb +6 -2
  31. data/lib/versioncake/strategies/query_parameter_strategy.rb +2 -2
  32. data/lib/versioncake/strategies/request_parameter_strategy.rb +2 -2
  33. data/lib/versioncake/test_helpers.rb +14 -0
  34. data/lib/versioncake/version.rb +1 -1
  35. data/lib/versioncake/version_checker.rb +28 -0
  36. data/lib/versioncake/version_context.rb +20 -0
  37. data/lib/versioncake/version_context_service.rb +47 -0
  38. data/lib/versioncake/versioned_request.rb +22 -33
  39. data/lib/versioncake/versioned_resource.rb +14 -0
  40. data/lib/versioncake/view_additions.rb +7 -7
  41. data/{test → spec}/fixtures/partials/_versioned.erb +0 -0
  42. data/{test → spec}/fixtures/partials/_versioned.v1.erb +0 -0
  43. data/{test → spec}/fixtures/partials/_versioned.v2.erb +0 -0
  44. data/{test → spec}/fixtures/partials/_versioned.v3.erb +0 -0
  45. data/{test → spec}/fixtures/partials/another_versioned_partial.erb +0 -0
  46. data/{test → spec}/fixtures/partials/another_versioned_partial.v1.erb +0 -0
  47. data/{test → spec}/fixtures/templates/unversioned.html.erb +0 -0
  48. data/{test → spec}/fixtures/templates/v1_extension_scheme.v3.html.erb +0 -0
  49. data/{test → spec}/fixtures/templates/v1_extension_scheme.v6.json +0 -0
  50. data/{test → spec}/fixtures/templates/versioned.html.erb +0 -0
  51. data/{test → spec}/fixtures/templates/versioned.html.v1.erb +0 -0
  52. data/{test → spec}/fixtures/templates/versioned.html.v2.erb +0 -0
  53. data/{test → spec}/fixtures/templates/versioned.html.v3.erb +0 -0
  54. data/spec/fixtures/test_cases.yml +45 -0
  55. data/spec/integration/controller/renders_controller_spec.rb +73 -0
  56. data/spec/integration/controller/unversioned_controller_spec.rb +12 -0
  57. data/spec/integration/rack/middleware_regression_spec.rb +41 -0
  58. data/spec/integration/view/render_spec.rb +33 -0
  59. data/spec/integration/view/view_additions_spec.rb +51 -0
  60. data/spec/rails_helper.rb +41 -0
  61. data/spec/spec_helper.rb +25 -0
  62. data/spec/test_app/Rakefile +7 -0
  63. data/{test → spec/test_app}/app/controllers/renders_controller.rb +0 -0
  64. data/spec/test_app/app/controllers/unversioned_controller.rb +6 -0
  65. data/spec/test_app/app/views/renders/index.html.erb +1 -0
  66. data/{test → spec/test_app}/app/views/renders/index.html.v1.erb +0 -0
  67. data/{test → spec/test_app}/app/views/renders/index.html.v2.erb +0 -0
  68. data/spec/test_app/app/views/unversioned/index.html.erb +1 -0
  69. data/spec/test_app/config.ru +4 -0
  70. data/{test → spec/test_app}/config/application.rb +4 -6
  71. data/spec/test_app/config/boot.rb +5 -0
  72. data/spec/test_app/config/environment.rb +5 -0
  73. data/spec/test_app/config/initializers/versioncake.rb +45 -0
  74. data/spec/test_app/config/routes.rb +4 -0
  75. data/spec/test_app/script/rails +4 -0
  76. data/spec/unit/cli_spec.rb +36 -0
  77. data/spec/unit/configuration_spec.rb +61 -0
  78. data/spec/unit/strategies/extraction_strategy_spec.rb +71 -0
  79. data/spec/unit/strategies/http_accept_parameter_strategy_spec.rb +20 -0
  80. data/spec/unit/strategies/http_header_strategy_spec.rb +19 -0
  81. data/spec/unit/strategies/path_parameter_strategy_spec.rb +18 -0
  82. data/spec/unit/strategies/query_parameter_strategy_spec.rb +24 -0
  83. data/spec/unit/strategies/request_parameter_strategy_spec.rb +19 -0
  84. data/spec/unit/version_checker_spec.rb +60 -0
  85. data/spec/unit/version_context_service_spec.rb +84 -0
  86. data/spec/unit/version_context_spec.rb +46 -0
  87. data/spec/unit/versioned_request_spec.rb +35 -0
  88. data/spec/unit/versioned_resource_spec.rb +12 -0
  89. data/versioncake.gemspec +5 -2
  90. metadata +91 -70
  91. data/lib/versioncake/railtie.rb +0 -7
  92. data/test/app/views/renders/index.html.erb +0 -1
  93. data/test/config.ru +0 -0
  94. data/test/config/routes.rb +0 -3
  95. data/test/fixtures/test_cases.yml +0 -70
  96. data/test/functional/custom_strategy_controller_test.rb +0 -16
  97. data/test/functional/multiple_strategy_controller_test.rb +0 -24
  98. data/test/functional/renders_controller_test.rb +0 -71
  99. data/test/functional/strategy_controller_test.rb +0 -38
  100. data/test/script/rails +0 -0
  101. data/test/template/render_test.rb +0 -34
  102. data/test/test_helper.rb +0 -21
  103. data/test/unit/cli_test.rb +0 -48
  104. data/test/unit/configuration_test.rb +0 -45
  105. data/test/unit/strategies/extraction_strategy_test.rb +0 -70
  106. data/test/unit/strategies/http_accept_parameter_strategy_test.rb +0 -17
  107. data/test/unit/strategies/http_header_strategy_test.rb +0 -17
  108. data/test/unit/strategies/path_parameter_strategy_test.rb +0 -17
  109. data/test/unit/strategies/query_parameter_strategy_test.rb +0 -22
  110. data/test/unit/strategies/request_parameter_strategy_test.rb +0 -17
  111. data/test/unit/versioned_request_test.rb +0 -44
  112. data/test/unit/view_additions_test.rb +0 -35
@@ -0,0 +1,5 @@
1
+ require 'rubygems'
2
+
3
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __FILE__)
4
+
5
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ RendersTest::Application.initialize!
@@ -0,0 +1,45 @@
1
+ VersionCake.setup do |config|
2
+ # Set the version key that clients will send example: `X-API-VERSION: 5`
3
+ # config.version_key = 'version'
4
+
5
+ # Enable Rails versioned filename mapping
6
+ # config.rails_view_versioning = true
7
+
8
+ # Extraction Strategies
9
+ # Define how you will accept version from the request.
10
+ #
11
+ # Defaults to all:
12
+ # [:http_accept_parameter, :http_header, :request_parameter, :path_parameter, :query_parameter]
13
+ #
14
+ # Custom strategy example:
15
+ # You can create your own extraction strategy by giving a proc or class that responds to execute:
16
+ # ```
17
+ # lambda {|request| request.headers["HTTP_X_MY_VERSION"] }
18
+ # ```
19
+ # or
20
+ # ```
21
+ # class ExtractorStrategy
22
+ # def execute(request)
23
+ # request.headers["HTTP_X_MY_VERSION"]
24
+ # end
25
+ # end
26
+ # ```
27
+ config.extraction_strategy = [:http_accept_parameter,
28
+ :http_header,
29
+ :request_parameter,
30
+ :path_parameter,
31
+ :query_parameter]
32
+
33
+ # Version when no version in present in the request. If none is
34
+ # specified then it will error?
35
+ config.missing_version = 3
36
+
37
+ # Versioned Resources
38
+ # Define what server resources are supported, deprecated or obsolete
39
+ # Resources listed are priority based upon creation. To version all
40
+ # resources you can define a catch all at the bottom of the block.
41
+ config.resources do |r|
42
+ # r.resource uri_regex, obsolete, deprecated, supported
43
+ r.resource %r{renders/*}, [2], [4], (1..5)
44
+ end
45
+ end
@@ -0,0 +1,4 @@
1
+ RendersTest::Application.routes.draw do
2
+ resources :renders, only: :index
3
+ resources :unversioned, only: :index
4
+ end
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe VersionCake::Cli do
4
+ quiet_stdout
5
+ before { allow(File).to receive :rename }
6
+
7
+ context '#migrate' do
8
+ subject(:migrated_files) { VersionCake::Cli.new.migrate(path) }
9
+
10
+ context 'when a path has migratable files' do
11
+ let(:path) { './spec/fixtures/templates' }
12
+
13
+ it {
14
+ renamed_files = [
15
+ ['./spec/fixtures/templates/v1_extension_scheme.v3.html.erb',
16
+ './spec/fixtures/templates/v1_extension_scheme.html.v3.erb'],
17
+ ['./spec/fixtures/templates/v1_extension_scheme.v6.json',
18
+ './spec/fixtures/templates/v1_extension_scheme.json.v6']
19
+ ]
20
+ expect(renamed_files).to match_array migrated_files
21
+ }
22
+ end
23
+
24
+ context 'when a path has no migratable files' do
25
+ let(:path) { './spec/test_app/app/views' }
26
+
27
+ it { expect(migrated_files).to be_empty }
28
+ end
29
+
30
+ context 'when the path is not found' do
31
+ let(:path) { './a/missing/path' }
32
+
33
+ it { expect { migrated_files }.to raise_error(ArgumentError) }
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ describe VersionCake::Configuration do
4
+ subject(:config) do
5
+ config = described_class.new
6
+ if supported_versions
7
+ config.supported_version_numbers = supported_versions
8
+ end
9
+ config
10
+ end
11
+
12
+ context '#supported_version_numbers' do
13
+ context 'by default' do
14
+ let(:supported_versions) { nil }
15
+
16
+ it 'is a logical set of version numbers' do
17
+ expect(config.supported_version_numbers).to eq (1..10).to_a.reverse
18
+ end
19
+ end
20
+
21
+ context 'when set with a range' do
22
+ let(:supported_versions) { (1..7) }
23
+
24
+ it { expect(config.supported_version_numbers).to eq [7,6,5,4,3,2,1] }
25
+ end
26
+
27
+ context 'when set with an unordered array' do
28
+ let(:supported_versions) { [2,4,1,5,3,6,7] }
29
+
30
+ it { expect(config.supported_version_numbers).to eq [7,6,5,4,3,2,1] }
31
+ end
32
+
33
+ context 'when set with a single value' do
34
+ let(:supported_versions) { 19 }
35
+
36
+ it { expect(config.supported_version_numbers).to eq [19] }
37
+ end
38
+ end
39
+
40
+ context '#supports_version?' do
41
+ let(:supported_versions) { (1..7) }
42
+
43
+ it 'is true for all supported versions' do
44
+ config.supported_version_numbers.each do |supported_version|
45
+ expect(config.supports_version?(supported_version)).to be_truthy
46
+ end
47
+ end
48
+
49
+ it 'is false for other versions' do
50
+ [-2,-1,0,8,9,10].each do |unsupported_version|
51
+ expect(config.supports_version?(unsupported_version)).to be_falsey
52
+ end
53
+ end
54
+ end
55
+
56
+ context '#latest_version' do
57
+ let(:supported_versions) { [4,1,3,9,2,54] }
58
+
59
+ it { expect(config.latest_version).to eq 54 }
60
+ end
61
+ end
@@ -0,0 +1,71 @@
1
+ require 'spec_helper'
2
+
3
+ # TODO: make better!!!
4
+ describe VersionCake::ExtractionStrategy do
5
+ it "execute is required for a strategy" do
6
+ expect do
7
+ VersionCake::ExtractionStrategy.new.execute("request")
8
+ end.to raise_error(Exception)
9
+ end
10
+
11
+ it "custom strategy result will be converted to integer" do
12
+ class TestStrategy < VersionCake::ExtractionStrategy
13
+ def execute(request); "123"; end
14
+ end
15
+
16
+ expect(TestStrategy.new.extract("request")).to eq 123
17
+ end
18
+
19
+ it "custom strategy result will be returned" do
20
+ class TestStrategy < VersionCake::ExtractionStrategy
21
+ def execute(request); 123; end
22
+ end
23
+ expect(TestStrategy.new.extract("request")).to eq 123
24
+ end
25
+
26
+ it "custom strategy will fail if it returns unexpected result" do
27
+ class TestStrategy < VersionCake::ExtractionStrategy
28
+ def execute(request); Object.new; end
29
+ end
30
+ expect { TestStrategy.new.extract("request") }.to raise_error(Exception)
31
+ end
32
+
33
+ context '#query_parameter' do
34
+ subject(:lookedup_strategy) { VersionCake::ExtractionStrategy.lookup(:query_parameter) }
35
+
36
+ it { expect(lookedup_strategy.class).to eq VersionCake::QueryParameterStrategy }
37
+ end
38
+
39
+ it "it creates a custom strategy for a proc" do
40
+ strategy = VersionCake::ExtractionStrategy.lookup(lambda{|req|})
41
+ expect(strategy.class).to eq VersionCake::CustomStrategy
42
+ end
43
+
44
+ it "it wraps a custom object" do
45
+ class FakeStrategy
46
+ def execute(request);end
47
+ end
48
+ strategy = VersionCake::ExtractionStrategy.lookup(FakeStrategy.new)
49
+ expect(strategy.class).to eq VersionCake::CustomStrategy
50
+ end
51
+
52
+ it "it calls a custom objects execute method" do
53
+ class FakeStrategy
54
+ def execute(request); 9999; end
55
+ end
56
+ strategy = VersionCake::ExtractionStrategy.lookup(FakeStrategy.new)
57
+ expect(strategy.execute(nil)).to eq 9999
58
+ end
59
+
60
+ it "it fails to create a custom strategy for a proc with no parameters" do
61
+ expect do
62
+ VersionCake::ExtractionStrategy.lookup(lambda{})
63
+ end.to raise_error(Exception)
64
+ end
65
+
66
+ it "it raises error when no strategy is found" do
67
+ expect do
68
+ VersionCake::ExtractionStrategy.lookup(:fake_extraction)
69
+ end.to raise_error(Exception)
70
+ end
71
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe VersionCake::HttpAcceptParameterStrategy do
4
+ let(:strategy) { VersionCake::HttpAcceptParameterStrategy.new }
5
+ subject { strategy.extract(request) }
6
+
7
+ context "a request with an HTTP_ACCEPT version retrieves the version" do
8
+ let(:request) { instance_double('Request', env: \
9
+ {'HTTP_ACCEPT' => 'application/xml; api_version=11'}) }
10
+
11
+ it { is_expected.to eq 11 }
12
+ end
13
+
14
+ context "a request without an HTTP_ACCEPT version returns nil" do
15
+ let(:request) { instance_double('Request', env: \
16
+ {'HTTP_ACCEPT' => 'text/x-dvi; q=.8; mxb=100000; mxt=5.0, text/x-c'}) }
17
+
18
+ it { is_expected.to be_nil }
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe VersionCake::HttpHeaderStrategy do
4
+ let(:strategy) { VersionCake::HttpHeaderStrategy.new }
5
+ subject { strategy.extract(request) }
6
+
7
+ context "a request with an HTTP_X_API_VERSION retrieves the version" do
8
+ let(:request) { instance_double('Request', env: {'HTTP_API_VERSION' => '11'}) }
9
+
10
+ it { is_expected.to eq 11 }
11
+ end
12
+
13
+ context "a request without an HTTP_X_API_VERSION returns nil" do
14
+ let(:request) { instance_double('Request', \
15
+ env: {'HTTP_ACCEPT' => 'text/x-dvi; q=.8; mxb=100000; mxt=5.0, text/x-c'}) }
16
+
17
+ it { is_expected.to be_nil }
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe VersionCake::PathParameterStrategy do
4
+ let(:strategy) { VersionCake::PathParameterStrategy.new }
5
+ subject { strategy.extract(request) }
6
+
7
+ context "a request with an api_version path parameter retrieves the version" do
8
+ let(:request) { instance_double('Request', path: 'api/v11/parameter') }
9
+
10
+ it { is_expected.to eq 11 }
11
+ end
12
+
13
+ context "a request without an api_version path parameter returns nil" do
14
+ let(:request) { instance_double('Request', path: 'parameter/parameter') }
15
+
16
+ it { is_expected.to be_nil }
17
+ end
18
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe VersionCake::QueryParameterStrategy do
4
+ let(:strategy) { VersionCake::QueryParameterStrategy.new }
5
+ subject { strategy.extract(request) }
6
+
7
+ context "a request with an api_version parameter retrieves the version" do
8
+ let(:request) { instance_double('Request', GET: {'api_version' => '11', 'other' => 'parameter'}) }
9
+
10
+ it { is_expected.to eq 11 }
11
+ end
12
+
13
+ context "a request with an Integer api_version parameter retrieves the version" do
14
+ let(:request) { instance_double('Request', GET: {'api_version' => 11, 'other' => 'parameter'}) }
15
+
16
+ it { is_expected.to eq 11 }
17
+ end
18
+
19
+ context "a request without an api_version parameter returns nil" do
20
+ let(:request) { instance_double('Request', GET: {'other' => 'parameter', 'another' => 'parameter'}) }
21
+
22
+ it { is_expected.to be_nil }
23
+ end
24
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe VersionCake::RequestParameterStrategy do
4
+ let(:strategy) { VersionCake::RequestParameterStrategy.new }
5
+ subject { strategy.extract(request) }
6
+
7
+ context "a request with an api_version request parameter retrieves the version" do
8
+ let(:request) { instance_double('Request', POST: {'api_version' => '11', 'other' => 'parameter'}) }
9
+
10
+ it { is_expected.to eq 11 }
11
+ end
12
+
13
+ context "a request without an api_version request parameter returns nil" do
14
+ let(:request) { instance_double('Request', POST: \
15
+ {'other' => 'parameter', 'another' => 'parameter'}) }
16
+
17
+ it { is_expected.to be_nil }
18
+ end
19
+ end
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+
3
+ describe VersionCake::VersionChecker do
4
+ let(:resource) do
5
+ double(
6
+ supported_versions: [5,6],
7
+ deprecated_versions: [4],
8
+ obsolete_versions: [2,3],
9
+ )
10
+ end
11
+ let(:version) { }
12
+ subject do
13
+ checker = VersionCake::VersionChecker.new(resource, version)
14
+ checker.execute
15
+ end
16
+
17
+ describe '#execute' do
18
+ context 'when no version is passed in' do
19
+ let(:version) { nil }
20
+
21
+ it { is_expected.to eq :no_version }
22
+ end
23
+
24
+ context 'when the version is a supported version' do
25
+ let(:version) { 5 }
26
+
27
+ it { is_expected.to eq :supported }
28
+ end
29
+
30
+ context 'when the version is an obsolete version' do
31
+ let(:version) { 3 }
32
+
33
+ it { is_expected.to eq :obsolete }
34
+ end
35
+
36
+ context 'when the version is a deprecated version' do
37
+ let(:version) { 4 }
38
+
39
+ it { is_expected.to eq :deprecated }
40
+ end
41
+
42
+ context 'when the version is greater than the supported versions' do
43
+ let(:version) { 7 }
44
+
45
+ it { is_expected.to eq :version_too_high }
46
+ end
47
+
48
+ context 'when the version is less than the supported versions' do
49
+ let(:version) { 1 }
50
+
51
+ it { is_expected.to eq :version_too_low }
52
+ end
53
+
54
+ context 'when the version is of a strange format' do
55
+ let(:version) { '1' }
56
+
57
+ it { is_expected.to eq :invalid_format }
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,84 @@
1
+ require 'spec_helper'
2
+
3
+ describe VersionCake::VersionContextService do
4
+
5
+ let(:resource_user) do
6
+ double('user_resource',
7
+ uri: %r{user},
8
+ supported_versions: [5,6,7],
9
+ deprecated_versions: [3,4],
10
+ obsolete_versions: [1,2]
11
+ )
12
+ end
13
+ let(:resource_all) do
14
+ double('default',
15
+ uri: %r{.*},
16
+ supported_versions: [6,7],
17
+ deprecated_versions: [3,4,5],
18
+ obsolete_versions: [1,2]
19
+ )
20
+ end
21
+ let(:config) do
22
+ double('config',
23
+ versioned_resources: [resource_user, resource_all],
24
+ missing_version: 9,
25
+ extraction_strategies: [
26
+ VersionCake::CustomStrategy.new(lambda{ |req| req.version })
27
+ ]
28
+ )
29
+ end
30
+ let(:service) { described_class.new(config) }
31
+
32
+ describe '#create_context_from_request' do
33
+ let(:request) { double(version: 5, path: 'users/123') }
34
+ subject(:context) { service.create_context_from_request(request) }
35
+
36
+ it { expect(context.version).to eq 5 }
37
+ it { expect(context.resource).to eq resource_user }
38
+ it { expect(context.result).to eq :supported }
39
+
40
+ context 'for a deprecated version' do
41
+ let(:request) { double(version: 5, path: 'posts/123') }
42
+
43
+ it { expect(context.version).to eq 5 }
44
+ it { expect(context.resource).to eq resource_all }
45
+ it { expect(context.result).to eq :deprecated }
46
+ end
47
+
48
+ context 'for an obsolete version' do
49
+ let(:request) { double(version: 2, path: 'users/123') }
50
+
51
+ it { expect(context.version).to eq 2 }
52
+ it { expect(context.resource).to eq resource_user }
53
+ it { expect(context.result).to eq :obsolete }
54
+ end
55
+ end
56
+
57
+ describe '#create_context' do
58
+ let(:uri) { 'users/21' }
59
+ let(:version) { 5 }
60
+ subject(:context) { service.create_context(uri, version) }
61
+
62
+ it { expect(context.version).to eq 5 }
63
+ it { expect(context.resource).to eq resource_user }
64
+ it { expect(context.result).to eq :supported }
65
+
66
+ context 'for a deprecated version' do
67
+ let(:uri) { 'posts/21' }
68
+ let(:version) { 5 }
69
+
70
+ it { expect(context.version).to eq 5 }
71
+ it { expect(context.resource).to eq resource_all }
72
+ it { expect(context.result).to eq :deprecated }
73
+ end
74
+
75
+ context 'for an obsolete version' do
76
+ let(:uri) { 'posts/21' }
77
+ let(:version) { 2 }
78
+
79
+ it { expect(context.version).to eq 2 }
80
+ it { expect(context.resource).to eq resource_all }
81
+ it { expect(context.result).to eq :obsolete }
82
+ end
83
+ end
84
+ end