sequenceDiagram
participant Element
participant Composition as Composition Module<br/>(method_missing)
participant OwnersChain as Owners Chain<br/>(Enumerator)
participant Subform
participant Form
participant Handler as Handler/HostObject
Note over Element,Handler: Phase 1: Ownership EstablishmentsequenceDiagram
participant Controller
participant Handler
participant URLParams as URL Params<br/>(SteelWheel::Params)
participant FormParams as Form Params<br/>(EasyParams)
participant Form as ActionForm
participant BusinessLogic
Note over Controller,BusinessLogic: Initialization Phase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Configurable | |
| def config(*attrs) | |
| @configuration ||= Struct.new(*attrs).new | |
| end | |
| def configure | |
| yield(@configuration) if block_given? | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| body\code | 200 | 201 | 403 | 404 | 422 | |
|---|---|---|---|---|---|---|
| raw | text/plain | string | text/plain | string | text/plain | string | text/plain | string | text/plain | string | |
| object | x-json | ostruct | x-json | ostruct | x-json | ostruct | x-json | ostruct | x-json | ostruct | |
| collection | x-json | hash | x-json | hash | x-json | hash | x-json | hash | x-json | hash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RSpec.describe '', type: :request do | |
| include_context 'api session' | |
| <% @path_params.each do |param| %> | |
| <%= "let(#{param}) { #{rand(99..500)} }" %> | |
| <% end %> | |
| let(:path) { "<%= @path %>" } | |
| let(:valid_params) { {} } | |
| let(:valid_response) { {} } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Rspec | |
| class EndpointGenerator < Rails::Generators::NamedBase | |
| desc 'Generate a spec/requests file for specified action of controller' | |
| argument :controller, type: :string, required: true, banner: 'CONTOLLER' | |
| source_root File.expand_path('../templates', __FILE__) | |
| # https://www.rubytapas.com/2012/11/28/episode-029-redirecting-output/ | |
| def capture_output |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| include_context 'api session' | |
| let(:path) { "/api/v1/#{order_id}/line" } | |
| let(:order_id) { 456 } | |
| context 'when do some complex things' do | |
| let(:order) { FactoryBot.create(:order) } | |
| let(:order_id) { order.id } | |
| let(:item) { LineItem.last } | |
| let(:valid_params) do | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| factory :search_results_resps, class: 'OpenStruct' do | |
| variant_id { variant.id } | |
| product_name { variant.product.name } | |
| product_brand_name { variant.product.brand_name.to_s } | |
| flavor { variant.flavor.to_s } | |
| warehouse_category { variant.product.warehouse_category.to_s } | |
| skip_container { variant.skip_container } | |
| transient do | |
| variant nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Helpers | |
| def assert_body | |
| expect(response.body).to eq message # raw body | |
| end | |
| def assert_response_object | |
| expect(response_object).to have_attributes(resp_attrs) # object | |
| end | |
| def assert_response_body |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it 'renders correct response' do | |
| get path, valid_params, valid_headers # do request | |
| expect(response).to have_http_status(:ok) # | |
| expect(response.content_type).to eq 'application/json' # Assert status, mime type and response body | |
| expect(response_object).to have_attributes(valid_response) # | |
| item.reload | |
| expect(item.qc_by).to eq nil # | |
| expect(item.qc_signed_by).to eq nil # Check database state |
NewerOlder