Sha256: 1edaadd4b1e4c2cbd4c26f796869e76e03acfcc0b5a4fa8866771830225c7026

Contents?: true

Size: 1010 Bytes

Versions: 1

Compression:

Stored size: 1010 Bytes

Contents

require 'test_helper'

describe "API Versioning" do

  before do
    Post.destroy_all
    @posts = FactoryGirl.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

1 entries across 1 versions & 1 rubygems

Version Path
api_versioning-0.0.9 test/unit/api_versioning_test.rb