Sha256: ef806561cd4bd396a6991412e6feaf184577c0873d5fc49f899a136e11a8056a

Contents?: true

Size: 874 Bytes

Versions: 10

Compression:

Stored size: 874 Bytes

Contents

require 'main/entities/user'

RSpec.describe '/users', type: :request do
  describe 'GET /users' do
    it 'renders hello template' do
      get '/users'

      expect(last_response).to be_ok

      expect(last_response.body).to eql(
        '<!DOCTYPE html><html><head><title>Woohaa</title></head><body><h1>Users</h1><div class="users"><ul><li>Jane</li><li>Joe</li></ul></div></body></html>'
      )
    end
  end

  describe 'POST /users' do
    it 'creates a user' do
      user = { id: '1', name: 'Jane' }

      post '/users', user: user

      expect(last_response).to be_created

      expect(container['main.persistence.repositories.users'].all).to eql([Main::Entities::User.new('1', 'Jane')])
    end

    it 'redirects when name is missing' do
      user = { id: '1' }

      post '/users', user: user

      expect(last_response).to be_redirect
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
dry-web-roda-0.5.1 spec/request/users_spec.rb
dry-web-roda-0.5.0 spec/request/users_spec.rb
dry-web-roda-0.4.0 spec/request/users_spec.rb
dry-web-roda-0.3.0 spec/request/users_spec.rb
dry-web-roda-0.2.3 spec/request/users_spec.rb
dry-web-roda-0.2.2 spec/request/users_spec.rb
dry-web-roda-0.2.1 spec/request/users_spec.rb
dry-web-roda-0.2.0 spec/request/users_spec.rb
dry-web-roda-0.1.0 spec/request/users_spec.rb
dry-web-0.1.0 spec/request/users_spec.rb