Sha256: bab3c0768bdfc42530457912888d602282b0a8ae1fb1222d0d9822e9dbb4e9bc

Contents?: true

Size: 1.62 KB

Versions: 42

Compression:

Stored size: 1.62 KB

Contents

require 'pliny/commands/generator'
require 'pliny/commands/generator/endpoint'
require 'spec_helper'

describe Pliny::Commands::Generator::Endpoint do
  subject { Pliny::Commands::Generator::Endpoint.new(endpoint_name, {}, StringIO.new) }
  let(:endpoint_name) { 'resource_history' }

  describe '#url_path' do
    it 'builds a URL path' do
      assert_equal '/resource-histories', subject.url_path
    end
  end

  describe 'template' do
    before do
      # render the stub endpoint template to a string
      template = subject.render_template("endpoint.erb",
        plural_class_name: "Artists",
        url_path:          "/artists")

      # eval and assign it to rack_app so tests are pointing to it
      @rack_app = eval(template)
    end

    it "defines a stub GET /" do
      get "/artists"
      assert_equal 200, last_response.status
      assert_equal [], MultiJson.decode(last_response.body)
    end

    it "defines a stub POST /" do
      post "/artists"
      assert_equal 201, last_response.status
      assert_equal Hash.new, MultiJson.decode(last_response.body)
    end

    it "defines a stub GET /:id" do
      get "/artists/123"
      assert_equal 200, last_response.status
      assert_equal Hash.new, MultiJson.decode(last_response.body)
    end

    it "defines a stub PATCH /:id" do
      patch "/artists/123"
      assert_equal 200, last_response.status
      assert_equal Hash.new, MultiJson.decode(last_response.body)
    end

    it "defines a stub DELETE /:id" do
      delete "/artists/123"
      assert_equal 200, last_response.status
      assert_equal Hash.new, MultiJson.decode(last_response.body)
    end

  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
pliny-0.20.1 spec/commands/generator/endpoint_spec.rb
pliny-0.20.0 spec/commands/generator/endpoint_spec.rb
pliny-0.19.0 spec/commands/generator/endpoint_spec.rb
pliny-0.18.0 spec/commands/generator/endpoint_spec.rb
pliny-0.17.1 spec/commands/generator/endpoint_spec.rb
pliny-0.17.0 spec/commands/generator/endpoint_spec.rb
pliny-0.16.3 spec/commands/generator/endpoint_spec.rb
pliny-0.16.2 spec/commands/generator/endpoint_spec.rb
pliny-0.16.1 spec/commands/generator/endpoint_spec.rb
pliny-0.16.0 spec/commands/generator/endpoint_spec.rb
pliny-0.15.1 spec/commands/generator/endpoint_spec.rb
pliny-0.15.0 spec/commands/generator/endpoint_spec.rb
pliny-0.14.2 spec/commands/generator/endpoint_spec.rb
pliny-0.14.1 spec/commands/generator/endpoint_spec.rb
pliny-0.14.0 spec/commands/generator/endpoint_spec.rb
pliny-0.13.1 spec/commands/generator/endpoint_spec.rb
pliny-0.13.0 spec/commands/generator/endpoint_spec.rb
pliny-0.12.0 spec/commands/generator/endpoint_spec.rb
pliny-0.11.2 spec/commands/generator/endpoint_spec.rb
pliny-0.11.1 spec/commands/generator/endpoint_spec.rb