diff options
| author | Stormwind <stormwind@stormwinds-page.de> | 2013-01-06 10:28:13 +0100 | 
|---|---|---|
| committer | Stormwind <stormwind@stormwinds-page.de> | 2013-01-06 10:28:13 +0100 | 
| commit | cd97198e2269e8651d5f8081ec20501c8ea39aa9 (patch) | |
| tree | 94f0f126bc8567e43dd694749ff1366040f04a65 | |
| parent | 3bb53d7343915e1a9f75f5ca4b53d61313b0ef29 (diff) | |
Kill all mutants in Zero::Request::Parameter
I've also changed "extract_query_params" because it does not matter, if the
query string it empty or not for the "parse_string" method.
| -rw-r--r-- | lib/zero/request/parameter.rb | 5 | ||||
| -rw-r--r-- | spec/unit/request/parameter/custom_spec.rb | 5 | ||||
| -rw-r--r-- | spec/unit/request/parameter/initialize_spec.rb | 3 | ||||
| -rw-r--r-- | spec/unit/request/parameter/payload_spec.rb | 10 | 
4 files changed, 20 insertions, 3 deletions
| diff --git a/lib/zero/request/parameter.rb b/lib/zero/request/parameter.rb index b1716bd..ac67401 100644 --- a/lib/zero/request/parameter.rb +++ b/lib/zero/request/parameter.rb @@ -79,14 +79,15 @@ module Zero        # extracts the key value pairs from the environment        # @return Hash all key value pairs from query string        def extract_query_params(environment) -        return {} if environment[ENV_KEY_QUERY].length == 0          parse_string(environment[ENV_KEY_QUERY])        end        # extracts the key value pairs from the body        # @return Hash all key value pairs from the payload        def extract_payload_params(environment) -        return {} unless PAYLOAD_CONTENT_TYPES.include?(environment[ENV_KEY_CONTENT_TYPE]) +        unless PAYLOAD_CONTENT_TYPES.include?(environment[ENV_KEY_CONTENT_TYPE]) +          return {} +        end          parse_string(environment[ENV_KEY_PAYLOAD].read)        end diff --git a/spec/unit/request/parameter/custom_spec.rb b/spec/unit/request/parameter/custom_spec.rb index 9c720d2..1abebc9 100644 --- a/spec/unit/request/parameter/custom_spec.rb +++ b/spec/unit/request/parameter/custom_spec.rb @@ -15,4 +15,9 @@ describe Zero::Request::Parameter, '#custom' do      expect(subject.custom['foo']).to eq('latest')    end + +  it 'is empty if no custom parameter is set' do +    expect(subject.custom).to eq({}) +    expect(env['zero.params.custom']).to eq({}) +  end  end diff --git a/spec/unit/request/parameter/initialize_spec.rb b/spec/unit/request/parameter/initialize_spec.rb index bc611b1..58432cb 100644 --- a/spec/unit/request/parameter/initialize_spec.rb +++ b/spec/unit/request/parameter/initialize_spec.rb @@ -3,7 +3,8 @@ require 'spec_helper'  describe Zero::Request::Parameter, '#initialize' do    subject { Zero::Request::Parameter.new(env) }    let(:env) { EnvGenerator.get('/get', { -    'zero.params.custom' => {'foo' => 'bar'} }) } +    'zero.params.custom' => {'foo' => 'bar'} +  }) }    it 'does not overwrite parameters' do      subject diff --git a/spec/unit/request/parameter/payload_spec.rb b/spec/unit/request/parameter/payload_spec.rb index af1d2ab..563b21d 100644 --- a/spec/unit/request/parameter/payload_spec.rb +++ b/spec/unit/request/parameter/payload_spec.rb @@ -30,4 +30,14 @@ describe Zero::Request::Parameter, '#payload' do      end      its(:payload) { should == {'bar' => 'foo bar'} }    end + +  # TODO behaves like this, but is this really good like this? +  context 'with a post body and content type application/json' do +    let(:env) do +      EnvGenerator.post('/foo', { +        :input => '"foobar"', 'CONTENT_TYPE' => 'application/json' +      }) +    end +    its(:payload) { should == {} } +  end  end | 
