Sha256: e78c971ff0fa424774e22bed4209c22b42fd7abd5a0ee37de038f65bdc86bf38

Contents?: true

Size: 1.61 KB

Versions: 14

Compression:

Stored size: 1.61 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(model_name, {}, StringIO.new) }
  let(:model_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

14 entries across 14 versions & 1 rubygems

Version Path
pliny-0.9.2 spec/commands/generator/endpoint_spec.rb
pliny-0.9.1 spec/commands/generator/endpoint_spec.rb
pliny-0.9.0 spec/commands/generator/endpoint_spec.rb
pliny-0.8.2 spec/commands/generator/endpoint_spec.rb
pliny-0.8.1 spec/commands/generator/endpoint_spec.rb
pliny-0.8.0 spec/commands/generator/endpoint_spec.rb
pliny-0.7.3 spec/commands/generator/endpoint_spec.rb
pliny-0.7.2 spec/commands/generator/endpoint_spec.rb
pliny-0.7.1 spec/commands/generator/endpoint_spec.rb
pliny-0.7.0 spec/commands/generator/endpoint_spec.rb
pliny-0.6.3 spec/commands/generator/endpoint_spec.rb
pliny-0.6.2 spec/commands/generator/endpoint_spec.rb
pliny-0.6.1 spec/commands/generator/endpoint_spec.rb
pliny-0.6.0 spec/commands/generator/endpoint_spec.rb