Sha256: 1d97c8247993690c216275c1c316a0ed5950936165a288aa3b7c99900f07a853

Contents?: true

Size: 998 Bytes

Versions: 8

Compression:

Stored size: 998 Bytes

Contents

require 'test_helper'

describe "API Versioning" do

  before do
    Post.destroy_all
    @posts = create_list(:post, 10)
    @api = Api::PostsApi.new
  end

  after do
    Post.destroy_all
  end

  describe "when creating an API" do

    it "must create a v1 API if v1 given" do
      api = Api::PostsApi.new('v1')
      api.wont_be_nil
      api.api_version.must_equal :v1
    end

    it "must create a v1.1 API if v1.1 given" do
      api = Api::PostsApi.new('v1_1')
      api.wont_be_nil
      api.api_version.must_equal :v1_1
    end

    it "must create a v1.1 API if no version given" do
      api = Api::PostsApi.new('')
      api.wont_be_nil
      api.api_version.must_equal :v1_1
    end

    it "must create a v1.1 API if a bad version given" do
      api = Api::PostsApi.new('dlk090@!')
      api.wont_be_nil
      api.api_version.must_equal :v1_1
    end

  end

  describe "when rendering json" do
    it "must render json" do
      @api.render(@posts).wont_be_nil
    end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
api_versioning-0.0.8 test/unit/api_versioning_test.rb
api_versioning-0.0.7 test/unit/api_versioning_test.rb
api_versioning-0.0.6 test/unit/api_versioning_test.rb
api_versioning-0.0.5 test/unit/api_versioning_test.rb
api_versioning-0.0.4 test/unit/api_versioning_test.rb
api_versioning-0.0.3 test/unit/api_versioning_test.rb
api_versioning-0.0.2 test/unit/api_versioning_test.rb
api_versioning-0.0.1 test/unit/api_versioning_test.rb