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-1.1.0 spec/commands/generator/endpoint_spec.rb
pliny-1.0.0 spec/commands/generator/endpoint_spec.rb
pliny-0.32.0 spec/commands/generator/endpoint_spec.rb
pliny-0.31.0 spec/commands/generator/endpoint_spec.rb
pliny-0.30.1 spec/commands/generator/endpoint_spec.rb
pliny-0.30.0 spec/commands/generator/endpoint_spec.rb
pliny-0.29.0 spec/commands/generator/endpoint_spec.rb
pliny-0.28.0 spec/commands/generator/endpoint_spec.rb
pliny-0.27.1 spec/commands/generator/endpoint_spec.rb
pliny-0.27.0 spec/commands/generator/endpoint_spec.rb
pliny-0.26.2 spec/commands/generator/endpoint_spec.rb
pliny-0.26.1 spec/commands/generator/endpoint_spec.rb
pliny-0.26.0 spec/commands/generator/endpoint_spec.rb
pliny-0.25.1 spec/commands/generator/endpoint_spec.rb
pliny-0.25.0 spec/commands/generator/endpoint_spec.rb
pliny-0.24.0 spec/commands/generator/endpoint_spec.rb
pliny-0.23.0 spec/commands/generator/endpoint_spec.rb
pliny-0.22.0 spec/commands/generator/endpoint_spec.rb
pliny-0.21.0 spec/commands/generator/endpoint_spec.rb
pliny-0.20.2 spec/commands/generator/endpoint_spec.rb