backdrop 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
 - data/lib/backdrop/builders/builder.rb +1 -1
 - data/lib/backdrop/version.rb +1 -1
 - data/spec/backdrop/builders/builder_spec.rb +41 -16
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,15 +1,15 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            !binary "U0hBMQ==":
         
     | 
| 
       3 
3 
     | 
    
         
             
              metadata.gz: !binary |-
         
     | 
| 
       4 
     | 
    
         
            -
                 
     | 
| 
      
 4 
     | 
    
         
            +
                NGM0ZTA1MDE5N2E3ZGE1MmI2YmE3ZDJlNDY5MThlMjRiZjAwNTYzMA==
         
     | 
| 
       5 
5 
     | 
    
         
             
              data.tar.gz: !binary |-
         
     | 
| 
       6 
     | 
    
         
            -
                 
     | 
| 
      
 6 
     | 
    
         
            +
                ZWEwZjllNjk4N2MzM2YwZTJiOTgzN2E5YmVjZjA2NzEwYzkxZWUyZA==
         
     | 
| 
       7 
7 
     | 
    
         
             
            SHA512:
         
     | 
| 
       8 
8 
     | 
    
         
             
              metadata.gz: !binary |-
         
     | 
| 
       9 
     | 
    
         
            -
                 
     | 
| 
       10 
     | 
    
         
            -
                 
     | 
| 
       11 
     | 
    
         
            -
                 
     | 
| 
      
 9 
     | 
    
         
            +
                YmVjODEyOTE0OTMyOGUwOWQ1YjY4Nzk0NTAyZjZhOThmYTJjOGU2MWVkYjUx
         
     | 
| 
      
 10 
     | 
    
         
            +
                NTBjMzUxOGNjNmRlNDUwZDlhOThiNmVhODNhODlmODEzYzY2MTJhZTUyZWQ5
         
     | 
| 
      
 11 
     | 
    
         
            +
                MTA5MjgwMmY2MmQ1ODAzOGVmOTAwMmZiMmUzMWZkY2UwZDUxYzY=
         
     | 
| 
       12 
12 
     | 
    
         
             
              data.tar.gz: !binary |-
         
     | 
| 
       13 
     | 
    
         
            -
                 
     | 
| 
       14 
     | 
    
         
            -
                 
     | 
| 
       15 
     | 
    
         
            -
                 
     | 
| 
      
 13 
     | 
    
         
            +
                Zjk0MTRlNzgzNjhmMDQ5YzMxNWJiODA0ZDRlMDZjYWMzZDMyNDQ0MjI5Zjg2
         
     | 
| 
      
 14 
     | 
    
         
            +
                ZjhiYjZmYzFjMDk0OGQ1NTcxNzZmMDk5MjgwNGUzYThkYTFiMDU5ODg2MTAz
         
     | 
| 
      
 15 
     | 
    
         
            +
                YTE1OTdlNGQ5ODg4OTFhYjM3MjAxOWRjMDllM2IwZWE5Yjc1ZDA=
         
     | 
| 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Backdrop
         
     | 
| 
       2 
2 
     | 
    
         
             
              class Builder
         
     | 
| 
       3 
3 
     | 
    
         
             
                def build_response(output, project, data, response)
         
     | 
| 
       4 
     | 
    
         
            -
                  file = data['requests'].first['request_path']
         
     | 
| 
      
 4 
     | 
    
         
            +
                  file = data['requests'].first['request_path'].split('?')[0]
         
     | 
| 
       5 
5 
     | 
    
         
             
                  method = data['http_method'].downcase
         
     | 
| 
       6 
6 
     | 
    
         
             
                  path = File.dirname file
         
     | 
| 
       7 
7 
     | 
    
         
             
                  filename = File.basename file
         
     | 
    
        data/lib/backdrop/version.rb
    CHANGED
    
    
| 
         @@ -12,23 +12,48 @@ describe Backdrop::Builder do 
     | 
|
| 
       12 
12 
     | 
    
         
             
                  FileUtils.remove_entry_secure @output_dir
         
     | 
| 
       13 
13 
     | 
    
         
             
                end
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
                 
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
                    ' 
     | 
| 
       19 
     | 
    
         
            -
                      ' 
     | 
| 
       20 
     | 
    
         
            -
                      ' 
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 15 
     | 
    
         
            +
                context 'when the path has no query params' do
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                  let(:sample_data) do
         
     | 
| 
      
 18 
     | 
    
         
            +
                    { 'http_method' => 'GET',
         
     | 
| 
      
 19 
     | 
    
         
            +
                      'route' => '/project/:property',
         
     | 
| 
      
 20 
     | 
    
         
            +
                      'requests' => [{
         
     | 
| 
      
 21 
     | 
    
         
            +
                        'request_path' => '/resource/get_request',
         
     | 
| 
      
 22 
     | 
    
         
            +
                        'response_body' => '{"Hello":"World"}'
         
     | 
| 
      
 23 
     | 
    
         
            +
                      }] }
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
                  let(:project) { 'project' }
         
     | 
| 
      
 26 
     | 
    
         
            +
                  let(:response) { 'some response' }
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  it 'creates the response file with given input' do
         
     | 
| 
      
 29 
     | 
    
         
            +
                    subject.build_response(@output_dir, project, sample_data, response)
         
     | 
| 
      
 30 
     | 
    
         
            +
                    output = File.read(
         
     | 
| 
      
 31 
     | 
    
         
            +
                      "#{File.join(@output_dir, 'project', '/resource/get_request')}.get"
         
     | 
| 
      
 32 
     | 
    
         
            +
                    )
         
     | 
| 
      
 33 
     | 
    
         
            +
                    expect(output).to eq response
         
     | 
| 
      
 34 
     | 
    
         
            +
                  end
         
     | 
| 
       22 
35 
     | 
    
         
             
                end
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
                 
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                context 'when the path has query params' do
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                  let(:sample_data) do
         
     | 
| 
      
 40 
     | 
    
         
            +
                    { 'http_method' => 'GET',
         
     | 
| 
      
 41 
     | 
    
         
            +
                      'route' => '/project/:property',
         
     | 
| 
      
 42 
     | 
    
         
            +
                      'requests' => [{
         
     | 
| 
      
 43 
     | 
    
         
            +
                        'request_path' => '/resource/get_request?query=something',
         
     | 
| 
      
 44 
     | 
    
         
            +
                        'response_body' => '{"Hello":"World"}'
         
     | 
| 
      
 45 
     | 
    
         
            +
                      }] }
         
     | 
| 
      
 46 
     | 
    
         
            +
                  end
         
     | 
| 
      
 47 
     | 
    
         
            +
                  let(:project) { 'project' }
         
     | 
| 
      
 48 
     | 
    
         
            +
                  let(:response) { 'some response' }
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                  it 'creates the response file, stripping the query params' do
         
     | 
| 
      
 51 
     | 
    
         
            +
                    subject.build_response(@output_dir, project, sample_data, response)
         
     | 
| 
      
 52 
     | 
    
         
            +
                    output = File.read(
         
     | 
| 
      
 53 
     | 
    
         
            +
                      "#{File.join(@output_dir, 'project', '/resource/get_request')}.get"
         
     | 
| 
      
 54 
     | 
    
         
            +
                    )
         
     | 
| 
      
 55 
     | 
    
         
            +
                    expect(output).to eq response
         
     | 
| 
      
 56 
     | 
    
         
            +
                  end
         
     | 
| 
       32 
57 
     | 
    
         
             
                end
         
     | 
| 
       33 
58 
     | 
    
         
             
              end
         
     | 
| 
       34 
59 
     | 
    
         
             
            end
         
     |