rspec_api_test 0.0.1
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.
- data/.document +5 -0
- data/.rspec +3 -0
- data/.rvmrc +1 -0
- data/.travis.yml +6 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +78 -0
- data/Guardfile +30 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +104 -0
- data/Rakefile +39 -0
- data/VERSION +1 -0
- data/lib/rspec_api_test/http_helpers.rb +60 -0
- data/lib/rspec_api_test.rb +6 -0
- data/rspec_api_test.gemspec +93 -0
- data/spec/fixtures/400.yml +110 -0
- data/spec/fixtures/404.yml +106 -0
- data/spec/fixtures/json_array.yml +1039 -0
- data/spec/fixtures/json_hash.yml +54 -0
- data/spec/lib/rspec_api_test/http_helpers_spec.rb +90 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/vcr_setup.rb +17 -0
- metadata +263 -0
    
        data/.document
    ADDED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/.rvmrc
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            rvm --create use ruby-1.9.3@rspec_api_test
         | 
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    | @@ -0,0 +1,17 @@ | |
| 1 | 
            +
            source "http://rubygems.org"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            gem 'bundler'
         | 
| 4 | 
            +
            gem 'rspec', '>= 2.0.0'
         | 
| 5 | 
            +
            gem 'rest-client'
         | 
| 6 | 
            +
            gem 'activesupport'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            group :development do
         | 
| 9 | 
            +
              gem 'jeweler'
         | 
| 10 | 
            +
              gem 'webmock'
         | 
| 11 | 
            +
              gem 'vcr'
         | 
| 12 | 
            +
              gem 'guard'
         | 
| 13 | 
            +
              gem 'guard-rspec'
         | 
| 14 | 
            +
              gem 'guard-bundler'
         | 
| 15 | 
            +
              gem 'terminal-notifier'
         | 
| 16 | 
            +
              gem 'rb-fsevent'
         | 
| 17 | 
            +
            end
         | 
    
        data/Gemfile.lock
    ADDED
    
    | @@ -0,0 +1,78 @@ | |
| 1 | 
            +
            GEM
         | 
| 2 | 
            +
              remote: http://rubygems.org/
         | 
| 3 | 
            +
              specs:
         | 
| 4 | 
            +
                activesupport (3.2.12)
         | 
| 5 | 
            +
                  i18n (~> 0.6)
         | 
| 6 | 
            +
                  multi_json (~> 1.0)
         | 
| 7 | 
            +
                addressable (2.3.2)
         | 
| 8 | 
            +
                coderay (1.0.8)
         | 
| 9 | 
            +
                crack (0.3.2)
         | 
| 10 | 
            +
                diff-lcs (1.1.3)
         | 
| 11 | 
            +
                git (1.2.5)
         | 
| 12 | 
            +
                guard (1.6.2)
         | 
| 13 | 
            +
                  listen (>= 0.6.0)
         | 
| 14 | 
            +
                  lumberjack (>= 1.0.2)
         | 
| 15 | 
            +
                  pry (>= 0.9.10)
         | 
| 16 | 
            +
                  terminal-table (>= 1.4.3)
         | 
| 17 | 
            +
                  thor (>= 0.14.6)
         | 
| 18 | 
            +
                guard-bundler (1.0.0)
         | 
| 19 | 
            +
                  bundler (~> 1.0)
         | 
| 20 | 
            +
                  guard (~> 1.1)
         | 
| 21 | 
            +
                guard-rspec (2.4.0)
         | 
| 22 | 
            +
                  guard (>= 1.1)
         | 
| 23 | 
            +
                  rspec (~> 2.11)
         | 
| 24 | 
            +
                i18n (0.6.1)
         | 
| 25 | 
            +
                jeweler (1.8.4)
         | 
| 26 | 
            +
                  bundler (~> 1.0)
         | 
| 27 | 
            +
                  git (>= 1.2.5)
         | 
| 28 | 
            +
                  rake
         | 
| 29 | 
            +
                  rdoc
         | 
| 30 | 
            +
                json (1.7.7)
         | 
| 31 | 
            +
                listen (0.7.2)
         | 
| 32 | 
            +
                lumberjack (1.0.2)
         | 
| 33 | 
            +
                method_source (0.8.1)
         | 
| 34 | 
            +
                mime-types (1.21)
         | 
| 35 | 
            +
                multi_json (1.6.1)
         | 
| 36 | 
            +
                pry (0.9.12)
         | 
| 37 | 
            +
                  coderay (~> 1.0.5)
         | 
| 38 | 
            +
                  method_source (~> 0.8)
         | 
| 39 | 
            +
                  slop (~> 3.4)
         | 
| 40 | 
            +
                rake (10.0.3)
         | 
| 41 | 
            +
                rb-fsevent (0.9.3)
         | 
| 42 | 
            +
                rdoc (3.12.1)
         | 
| 43 | 
            +
                  json (~> 1.4)
         | 
| 44 | 
            +
                rest-client (1.6.7)
         | 
| 45 | 
            +
                  mime-types (>= 1.16)
         | 
| 46 | 
            +
                rspec (2.12.0)
         | 
| 47 | 
            +
                  rspec-core (~> 2.12.0)
         | 
| 48 | 
            +
                  rspec-expectations (~> 2.12.0)
         | 
| 49 | 
            +
                  rspec-mocks (~> 2.12.0)
         | 
| 50 | 
            +
                rspec-core (2.12.2)
         | 
| 51 | 
            +
                rspec-expectations (2.12.1)
         | 
| 52 | 
            +
                  diff-lcs (~> 1.1.3)
         | 
| 53 | 
            +
                rspec-mocks (2.12.2)
         | 
| 54 | 
            +
                slop (3.4.3)
         | 
| 55 | 
            +
                terminal-notifier (1.4.2)
         | 
| 56 | 
            +
                terminal-table (1.4.5)
         | 
| 57 | 
            +
                thor (0.17.0)
         | 
| 58 | 
            +
                vcr (2.4.0)
         | 
| 59 | 
            +
                webmock (1.9.2)
         | 
| 60 | 
            +
                  addressable (>= 2.2.7)
         | 
| 61 | 
            +
                  crack (>= 0.3.2)
         | 
| 62 | 
            +
             | 
| 63 | 
            +
            PLATFORMS
         | 
| 64 | 
            +
              ruby
         | 
| 65 | 
            +
             | 
| 66 | 
            +
            DEPENDENCIES
         | 
| 67 | 
            +
              activesupport
         | 
| 68 | 
            +
              bundler
         | 
| 69 | 
            +
              guard
         | 
| 70 | 
            +
              guard-bundler
         | 
| 71 | 
            +
              guard-rspec
         | 
| 72 | 
            +
              jeweler
         | 
| 73 | 
            +
              rb-fsevent
         | 
| 74 | 
            +
              rest-client
         | 
| 75 | 
            +
              rspec (>= 2.0.0)
         | 
| 76 | 
            +
              terminal-notifier
         | 
| 77 | 
            +
              vcr
         | 
| 78 | 
            +
              webmock
         | 
    
        data/Guardfile
    ADDED
    
    | @@ -0,0 +1,30 @@ | |
| 1 | 
            +
            # A sample Guardfile
         | 
| 2 | 
            +
            # More info at https://github.com/guard/guard#readme
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            guard 'rspec' do
         | 
| 5 | 
            +
              watch(%r{^spec/.+_spec\.rb$})
         | 
| 6 | 
            +
              watch(%r{^lib/(.+)\.rb$})     { |m| "spec/lib/#{m[1]}_spec.rb" }
         | 
| 7 | 
            +
              watch('spec/spec_helper.rb')  { "spec" }
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              # Rails example
         | 
| 10 | 
            +
              watch(%r{^app/(.+)\.rb$})                           { |m| "spec/#{m[1]}_spec.rb" }
         | 
| 11 | 
            +
              watch(%r{^app/(.*)(\.erb|\.haml)$})                 { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
         | 
| 12 | 
            +
              watch(%r{^app/controllers/(.+)_(controller)\.rb$})  { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
         | 
| 13 | 
            +
              watch(%r{^spec/support/(.+)\.rb$})                  { "spec" }
         | 
| 14 | 
            +
              watch('config/routes.rb')                           { "spec/routing" }
         | 
| 15 | 
            +
              watch('app/controllers/application_controller.rb')  { "spec/controllers" }
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              # Capybara features specs
         | 
| 18 | 
            +
              watch(%r{^app/views/(.+)/.*\.(erb|haml)$})          { |m| "spec/features/#{m[1]}_spec.rb" }
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              # Turnip features and steps
         | 
| 21 | 
            +
              watch(%r{^spec/acceptance/(.+)\.feature$})
         | 
| 22 | 
            +
              watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$})   { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
         | 
| 23 | 
            +
            end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
             | 
| 26 | 
            +
            guard 'bundler' do
         | 
| 27 | 
            +
              watch('Gemfile')
         | 
| 28 | 
            +
              # Uncomment next line if Gemfile contain `gemspec' command
         | 
| 29 | 
            +
              # watch(/^.+\.gemspec/)
         | 
| 30 | 
            +
            end
         | 
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            Copyright (c) 2013 Jannis Hermanns
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 4 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 5 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 6 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 7 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 8 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 9 | 
            +
            the following conditions:
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 12 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 15 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 16 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 17 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 18 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 19 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 20 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.markdown
    ADDED
    
    | @@ -0,0 +1,104 @@ | |
| 1 | 
            +
            [](https://travis-ci.org/jayniz/rspec-api-test)
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            Easy JSON API testing with RSpec
         | 
| 5 | 
            +
            ================================
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            If you want to test a real API to make sure it behaves as
         | 
| 8 | 
            +
            expected via HTTP, or if you want to do some more complex
         | 
| 9 | 
            +
            monitoring of your live API (e.g. write something, read it,
         | 
| 10 | 
            +
            delete it, etc.), this gem helps you make your test code easier
         | 
| 11 | 
            +
            on the eyes.
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            Here's what it does:
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            1. HTTP verbs as helper methods in your specs
         | 
| 16 | 
            +
            2. Applies default options to all your requests (headers, etc.)
         | 
| 17 | 
            +
            3. Assumes the response is JSON and parses it
         | 
| 18 | 
            +
            4. Gives you the JSON response object (Array or Hash) with a
         | 
| 19 | 
            +
               little extra: the `code` method (so you don't have to 
         | 
| 20 | 
            +
               catch an exception to test for a 404).
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            Usage
         | 
| 23 | 
            +
            -----
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            This gem adds helper methods for all HTTP verbs to your RSpec
         | 
| 26 | 
            +
            tests, so you can just say something like:
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            ```ruby
         | 
| 29 | 
            +
            it "returns the correct user" do
         | 
| 30 | 
            +
              get("/users/123")[:name].should == "Jens Mander"
         | 
| 31 | 
            +
            end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            it "returns a 404" do 
         | 
| 34 | 
            +
              get("/users/0").code.should == 404
         | 
| 35 | 
            +
            end
         | 
| 36 | 
            +
            ```
         | 
| 37 | 
            +
             | 
| 38 | 
            +
            So far so good, but your current monitoring tool can also do that.
         | 
| 39 | 
            +
            Here's an example where we create something, read an id, check
         | 
| 40 | 
            +
            for the correct value and delete our test data:
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            ```ruby
         | 
| 43 | 
            +
            describe "CRUD" do
         | 
| 44 | 
            +
              let(:response){ post("/users", test_data.to_json) }
         | 
| 45 | 
            +
             | 
| 46 | 
            +
              it "creates a new user" do
         | 
| 47 | 
            +
                response.code.should == 201
         | 
| 48 | 
            +
              end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
              it "returned the correct id" do
         | 
| 51 | 
            +
                u = get("/users/#{response[:id]}")
         | 
| 52 | 
            +
                u[:name].should == test_data[:name]
         | 
| 53 | 
            +
              end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
              it "deletes the user correctl" do
         | 
| 56 | 
            +
                delete("/users/#{response[:id]}")
         | 
| 57 | 
            +
                get("/users/#{response[:id]}").code.should == 404
         | 
| 58 | 
            +
              end
         | 
| 59 | 
            +
            end
         | 
| 60 | 
            +
            ```
         | 
| 61 | 
            +
             | 
| 62 | 
            +
            Defaults and configuration
         | 
| 63 | 
            +
            --------------------------
         | 
| 64 | 
            +
             | 
| 65 | 
            +
            Yes, you are right, there was no protocol or hostname in any
         | 
| 66 | 
            +
            of the examples. Here's how you can configure things, for example
         | 
| 67 | 
            +
            in `spec_helper.rb`:
         | 
| 68 | 
            +
             | 
| 69 | 
            +
            ```ruby
         | 
| 70 | 
            +
            RSpecAPITest.config = {
         | 
| 71 | 
            +
              base_url: 'http://my-live-instance.com',
         | 
| 72 | 
            +
              defaults: {
         | 
| 73 | 
            +
                content_type: :json,
         | 
| 74 | 
            +
                accept: :json
         | 
| 75 | 
            +
              }
         | 
| 76 | 
            +
            }
         | 
| 77 | 
            +
            ```
         | 
| 78 | 
            +
             | 
| 79 | 
            +
            The `defaults` hash is passed on to RestClient and is used as
         | 
| 80 | 
            +
            documented [here](https://github.com/archiloque/rest-client).
         | 
| 81 | 
            +
            The parameters of our `get, put, post, delete` helpers are 
         | 
| 82 | 
            +
            the same as `RestClient.get, RestClient.put, RestClient.post,
         | 
| 83 | 
            +
            RestClient.delete`.
         | 
| 84 | 
            +
             | 
| 85 | 
            +
            If the response couldn't be parsed as JSON, you'll just get
         | 
| 86 | 
            +
            back the RestClient object so you can do whatever you want with
         | 
| 87 | 
            +
            it.
         | 
| 88 | 
            +
             | 
| 89 | 
            +
            Installation
         | 
| 90 | 
            +
            ------------
         | 
| 91 | 
            +
            Just add
         | 
| 92 | 
            +
             | 
| 93 | 
            +
                gem 'rspec_api_test'
         | 
| 94 | 
            +
             | 
| 95 | 
            +
            to your `Gemfile` and in `spec_helper.rb` do a 
         | 
| 96 | 
            +
             | 
| 97 | 
            +
                require 'rspec_api_test'
         | 
| 98 | 
            +
             | 
| 99 | 
            +
            after you required rspec or did a `Bundler.require`.
         | 
| 100 | 
            +
             | 
| 101 | 
            +
             | 
| 102 | 
            +
            Test
         | 
| 103 | 
            +
            ----
         | 
| 104 | 
            +
            Git clone this repo and run `rake`.
         | 
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            # encoding: utf-8
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'rubygems'
         | 
| 4 | 
            +
            require 'bundler'
         | 
| 5 | 
            +
            begin
         | 
| 6 | 
            +
              Bundler.setup(:default, :development)
         | 
| 7 | 
            +
            rescue Bundler::BundlerError => e
         | 
| 8 | 
            +
              $stderr.puts e.message
         | 
| 9 | 
            +
              $stderr.puts "Run `bundle install` to install missing gems"
         | 
| 10 | 
            +
              exit e.status_code
         | 
| 11 | 
            +
            end
         | 
| 12 | 
            +
            require 'rake'
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            require 'jeweler'
         | 
| 15 | 
            +
            Jeweler::Tasks.new do |gem|
         | 
| 16 | 
            +
              # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
         | 
| 17 | 
            +
              gem.name = "rspec_api_test"
         | 
| 18 | 
            +
              gem.homepage = "http://github.com/jayniz/rspec-api-test"
         | 
| 19 | 
            +
              gem.license = "MIT"
         | 
| 20 | 
            +
              gem.summary = %Q{Makes JSON-API integration testing easier with rspec}
         | 
| 21 | 
            +
              gem.description = %Q{Test a JSON-API using rspec and simple get/put/post/delete helpers}
         | 
| 22 | 
            +
              gem.email = "jannis@moviepilot.com"
         | 
| 23 | 
            +
              gem.authors = ["Jannis Hermanns"]
         | 
| 24 | 
            +
              # dependencies defined in Gemfile
         | 
| 25 | 
            +
            end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            Jeweler::RubygemsDotOrgTasks.new
         | 
| 28 | 
            +
            require 'rspec/core'
         | 
| 29 | 
            +
            require 'rspec/core/rake_task'
         | 
| 30 | 
            +
            RSpec::Core::RakeTask.new(:spec) do |spec|
         | 
| 31 | 
            +
              spec.pattern = FileList['spec/**/*_spec.rb']
         | 
| 32 | 
            +
            end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            RSpec::Core::RakeTask.new(:rcov) do |spec|
         | 
| 35 | 
            +
              spec.pattern = 'spec/**/*_spec.rb'
         | 
| 36 | 
            +
              spec.rcov = true
         | 
| 37 | 
            +
            end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            task :default => :spec
         | 
    
        data/VERSION
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            0.0.1
         | 
| @@ -0,0 +1,60 @@ | |
| 1 | 
            +
            require 'json'
         | 
| 2 | 
            +
            require 'active_support/core_ext/hash'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            class RSpecAPITest
         | 
| 5 | 
            +
              def self.config=(config)
         | 
| 6 | 
            +
                @config = config
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              def self.config
         | 
| 10 | 
            +
                @config ||= {}
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              module HTTPHelpers
         | 
| 14 | 
            +
                class JSONHashResponse < DelegateClass(Hash)
         | 
| 15 | 
            +
                  attr_reader :code, :headers
         | 
| 16 | 
            +
                  def initialize(hash, code, headers)
         | 
| 17 | 
            +
                    @code = code
         | 
| 18 | 
            +
                    @headers = headers
         | 
| 19 | 
            +
                    super(hash.with_indifferent_access)
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                class JSONArrayResponse < DelegateClass(Array)
         | 
| 24 | 
            +
                  attr_reader :code, :headers
         | 
| 25 | 
            +
                  def initialize(array, code, headers)
         | 
| 26 | 
            +
                    @code = code
         | 
| 27 | 
            +
                    @headers = headers
         | 
| 28 | 
            +
                    super(array)
         | 
| 29 | 
            +
                  end
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                def request(*args)
         | 
| 33 | 
            +
                  defaults = RSpecAPITest.config[:defaults] || {}
         | 
| 34 | 
            +
                  opts_i = args[2].is_a?(String) ? 3 : 2
         | 
| 35 | 
            +
                  args[opts_i] ||= {} if defaults
         | 
| 36 | 
            +
                  args[opts_i].reverse_merge!(defaults) 
         | 
| 37 | 
            +
                  RestClient.send(*args)
         | 
| 38 | 
            +
                rescue RestClient::Exception => e
         | 
| 39 | 
            +
                  e.response
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                classes = {
         | 
| 43 | 
            +
                  Hash => JSONHashResponse,
         | 
| 44 | 
            +
                  Array => JSONArrayResponse
         | 
| 45 | 
            +
                }
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                [:get, :put, :post, :delete, :head].each do |verb|
         | 
| 48 | 
            +
                  self.send(:define_method, verb) do |*args|
         | 
| 49 | 
            +
                    out = [verb, "#{RSpecAPITest.config[:base_url]}#{args[0]}"] +  args[1..-1]
         | 
| 50 | 
            +
                    response = request(*out)
         | 
| 51 | 
            +
                    begin 
         | 
| 52 | 
            +
                      json = JSON.parse(response)
         | 
| 53 | 
            +
                      classes[json.class].new(json, response.code, response.headers)
         | 
| 54 | 
            +
                    rescue JSON::ParserError
         | 
| 55 | 
            +
                      response
         | 
| 56 | 
            +
                    end
         | 
| 57 | 
            +
                  end
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
              end
         | 
| 60 | 
            +
            end
         | 
| @@ -0,0 +1,93 @@ | |
| 1 | 
            +
            # Generated by jeweler
         | 
| 2 | 
            +
            # DO NOT EDIT THIS FILE DIRECTLY
         | 
| 3 | 
            +
            # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
         | 
| 4 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |s|
         | 
| 7 | 
            +
              s.name = "rspec_api_test"
         | 
| 8 | 
            +
              s.version = "0.0.1"
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 11 | 
            +
              s.authors = ["Jannis Hermanns"]
         | 
| 12 | 
            +
              s.date = "2013-02-18"
         | 
| 13 | 
            +
              s.description = "Test a JSON-API using rspec and simple get/put/post/delete helpers"
         | 
| 14 | 
            +
              s.email = "jannis@moviepilot.com"
         | 
| 15 | 
            +
              s.extra_rdoc_files = [
         | 
| 16 | 
            +
                "LICENSE.txt",
         | 
| 17 | 
            +
                "README.markdown"
         | 
| 18 | 
            +
              ]
         | 
| 19 | 
            +
              s.files = [
         | 
| 20 | 
            +
                ".document",
         | 
| 21 | 
            +
                ".rspec",
         | 
| 22 | 
            +
                ".rvmrc",
         | 
| 23 | 
            +
                ".travis.yml",
         | 
| 24 | 
            +
                "Gemfile",
         | 
| 25 | 
            +
                "Gemfile.lock",
         | 
| 26 | 
            +
                "Guardfile",
         | 
| 27 | 
            +
                "LICENSE.txt",
         | 
| 28 | 
            +
                "README.markdown",
         | 
| 29 | 
            +
                "Rakefile",
         | 
| 30 | 
            +
                "VERSION",
         | 
| 31 | 
            +
                "lib/rspec_api_test.rb",
         | 
| 32 | 
            +
                "lib/rspec_api_test/http_helpers.rb",
         | 
| 33 | 
            +
                "rspec_api_test.gemspec",
         | 
| 34 | 
            +
                "spec/fixtures/400.yml",
         | 
| 35 | 
            +
                "spec/fixtures/404.yml",
         | 
| 36 | 
            +
                "spec/fixtures/json_array.yml",
         | 
| 37 | 
            +
                "spec/fixtures/json_hash.yml",
         | 
| 38 | 
            +
                "spec/lib/rspec_api_test/http_helpers_spec.rb",
         | 
| 39 | 
            +
                "spec/spec_helper.rb",
         | 
| 40 | 
            +
                "spec/vcr_setup.rb"
         | 
| 41 | 
            +
              ]
         | 
| 42 | 
            +
              s.homepage = "http://github.com/jayniz/rspec-api-test"
         | 
| 43 | 
            +
              s.licenses = ["MIT"]
         | 
| 44 | 
            +
              s.require_paths = ["lib"]
         | 
| 45 | 
            +
              s.rubygems_version = "1.8.24"
         | 
| 46 | 
            +
              s.summary = "Makes JSON-API integration testing easier with rspec"
         | 
| 47 | 
            +
             | 
| 48 | 
            +
              if s.respond_to? :specification_version then
         | 
| 49 | 
            +
                s.specification_version = 3
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
         | 
| 52 | 
            +
                  s.add_runtime_dependency(%q<bundler>, [">= 0"])
         | 
| 53 | 
            +
                  s.add_runtime_dependency(%q<rspec>, [">= 2.0.0"])
         | 
| 54 | 
            +
                  s.add_runtime_dependency(%q<rest-client>, [">= 0"])
         | 
| 55 | 
            +
                  s.add_runtime_dependency(%q<activesupport>, [">= 0"])
         | 
| 56 | 
            +
                  s.add_development_dependency(%q<jeweler>, [">= 0"])
         | 
| 57 | 
            +
                  s.add_development_dependency(%q<webmock>, [">= 0"])
         | 
| 58 | 
            +
                  s.add_development_dependency(%q<vcr>, [">= 0"])
         | 
| 59 | 
            +
                  s.add_development_dependency(%q<guard>, [">= 0"])
         | 
| 60 | 
            +
                  s.add_development_dependency(%q<guard-rspec>, [">= 0"])
         | 
| 61 | 
            +
                  s.add_development_dependency(%q<guard-bundler>, [">= 0"])
         | 
| 62 | 
            +
                  s.add_development_dependency(%q<terminal-notifier>, [">= 0"])
         | 
| 63 | 
            +
                  s.add_development_dependency(%q<rb-fsevent>, [">= 0"])
         | 
| 64 | 
            +
                else
         | 
| 65 | 
            +
                  s.add_dependency(%q<bundler>, [">= 0"])
         | 
| 66 | 
            +
                  s.add_dependency(%q<rspec>, [">= 2.0.0"])
         | 
| 67 | 
            +
                  s.add_dependency(%q<rest-client>, [">= 0"])
         | 
| 68 | 
            +
                  s.add_dependency(%q<activesupport>, [">= 0"])
         | 
| 69 | 
            +
                  s.add_dependency(%q<jeweler>, [">= 0"])
         | 
| 70 | 
            +
                  s.add_dependency(%q<webmock>, [">= 0"])
         | 
| 71 | 
            +
                  s.add_dependency(%q<vcr>, [">= 0"])
         | 
| 72 | 
            +
                  s.add_dependency(%q<guard>, [">= 0"])
         | 
| 73 | 
            +
                  s.add_dependency(%q<guard-rspec>, [">= 0"])
         | 
| 74 | 
            +
                  s.add_dependency(%q<guard-bundler>, [">= 0"])
         | 
| 75 | 
            +
                  s.add_dependency(%q<terminal-notifier>, [">= 0"])
         | 
| 76 | 
            +
                  s.add_dependency(%q<rb-fsevent>, [">= 0"])
         | 
| 77 | 
            +
                end
         | 
| 78 | 
            +
              else
         | 
| 79 | 
            +
                s.add_dependency(%q<bundler>, [">= 0"])
         | 
| 80 | 
            +
                s.add_dependency(%q<rspec>, [">= 2.0.0"])
         | 
| 81 | 
            +
                s.add_dependency(%q<rest-client>, [">= 0"])
         | 
| 82 | 
            +
                s.add_dependency(%q<activesupport>, [">= 0"])
         | 
| 83 | 
            +
                s.add_dependency(%q<jeweler>, [">= 0"])
         | 
| 84 | 
            +
                s.add_dependency(%q<webmock>, [">= 0"])
         | 
| 85 | 
            +
                s.add_dependency(%q<vcr>, [">= 0"])
         | 
| 86 | 
            +
                s.add_dependency(%q<guard>, [">= 0"])
         | 
| 87 | 
            +
                s.add_dependency(%q<guard-rspec>, [">= 0"])
         | 
| 88 | 
            +
                s.add_dependency(%q<guard-bundler>, [">= 0"])
         | 
| 89 | 
            +
                s.add_dependency(%q<terminal-notifier>, [">= 0"])
         | 
| 90 | 
            +
                s.add_dependency(%q<rb-fsevent>, [">= 0"])
         | 
| 91 | 
            +
              end
         | 
| 92 | 
            +
            end
         | 
| 93 | 
            +
             | 
| @@ -0,0 +1,110 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            http_interactions:
         | 
| 3 | 
            +
            - request:
         | 
| 4 | 
            +
                method: get
         | 
| 5 | 
            +
                uri: http://localhost:9292/nodes/0
         | 
| 6 | 
            +
                body:
         | 
| 7 | 
            +
                  encoding: US-ASCII
         | 
| 8 | 
            +
                  string: ''
         | 
| 9 | 
            +
                headers:
         | 
| 10 | 
            +
                  Accept:
         | 
| 11 | 
            +
                  - ! '*/*; q=0.5, application/xml'
         | 
| 12 | 
            +
                  Accept-Encoding:
         | 
| 13 | 
            +
                  - gzip, deflate
         | 
| 14 | 
            +
                  Content-Type:
         | 
| 15 | 
            +
                  - application/json
         | 
| 16 | 
            +
                  User-Agent:
         | 
| 17 | 
            +
                  - Ruby
         | 
| 18 | 
            +
              response:
         | 
| 19 | 
            +
                status:
         | 
| 20 | 
            +
                  code: 400
         | 
| 21 | 
            +
                  message: ! 'Bad Request '
         | 
| 22 | 
            +
                headers:
         | 
| 23 | 
            +
                  X-Frame-Options:
         | 
| 24 | 
            +
                  - sameorigin
         | 
| 25 | 
            +
                  X-Xss-Protection:
         | 
| 26 | 
            +
                  - 1; mode=block
         | 
| 27 | 
            +
                  Content-Type:
         | 
| 28 | 
            +
                  - application/json;charset=utf-8
         | 
| 29 | 
            +
                  Content-Length:
         | 
| 30 | 
            +
                  - '6413'
         | 
| 31 | 
            +
                  Cache-Control:
         | 
| 32 | 
            +
                  - no-cache
         | 
| 33 | 
            +
                  Access-Control-Allow-Origin:
         | 
| 34 | 
            +
                  - ! '*'
         | 
| 35 | 
            +
                  Access-Control-Allow-Methods:
         | 
| 36 | 
            +
                  - GET, POST, OPTIONS, PUT
         | 
| 37 | 
            +
                  Access-Control-Allow-Headers:
         | 
| 38 | 
            +
                  - Content-Type
         | 
| 39 | 
            +
                  Access-Control-Max-Age:
         | 
| 40 | 
            +
                  - '86400'
         | 
| 41 | 
            +
                  Server:
         | 
| 42 | 
            +
                  - WEBrick/1.3.1 (Ruby/1.9.2/2012-02-22)
         | 
| 43 | 
            +
                  Date:
         | 
| 44 | 
            +
                  - Mon, 18 Feb 2013 16:16:19 GMT
         | 
| 45 | 
            +
                  Connection:
         | 
| 46 | 
            +
                  - Keep-Alive
         | 
| 47 | 
            +
                body:
         | 
| 48 | 
            +
                  encoding: US-ASCII
         | 
| 49 | 
            +
                  string: ! '{"success":false,"reason":"ArgumentError","backtrace":"/Users/jannis/Dev/core/sheldon-moviepilot/lib/sheldon/modules/ix.rb:315:in
         | 
| 50 | 
            +
                    `check_ext_id''\n/Users/jannis/Dev/core/sheldon-moviepilot/lib/sheldon/modules/ix.rb:112:in
         | 
| 51 | 
            +
                    `nodes_by_ext_id''\n/Users/jannis/Dev/core/sheldon-moviepilot/lib/sheldon/app/node.rb:319:in
         | 
| 52 | 
            +
                    `by_ext_id''\n/Users/jannis/Dev/core/sheldon-moviepilot/lib/sheldon/app/node.rb:20:in
         | 
| 53 | 
            +
                    `load''\n/Users/jannis/Dev/core/sheldon-moviepilot/lib/sheldon/app/node.rb:25:in
         | 
| 54 | 
            +
                    `find!''\n/Users/jannis/Dev/core/sheldon-moviepilot/lib/sinatra/app/nodes.rb:11:in
         | 
| 55 | 
            +
                    `HEAD /nodes/:id''\norg/jruby/RubyMethod.java:121:in `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/sinatra-1.3.3/lib/sinatra/base.rb:1264:in
         | 
| 56 | 
            +
                    `compile!''\norg/jruby/RubyProc.java:258:in `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in
         | 
| 57 | 
            +
                    `route!''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/sinatra-1.3.3/lib/sinatra/base.rb:851:in
         | 
| 58 | 
            +
                    `route_eval''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/sinatra-1.3.3/lib/sinatra/base.rb:835:in
         | 
| 59 | 
            +
                    `route!''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/sinatra-1.3.3/lib/sinatra/base.rb:872:in
         | 
| 60 | 
            +
                    `process_route''\norg/jruby/RubyKernel.java:1197:in `catch''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/sinatra-1.3.3/lib/sinatra/base.rb:870:in
         | 
| 61 | 
            +
                    `process_route''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/sinatra-1.3.3/lib/sinatra/base.rb:834:in
         | 
| 62 | 
            +
                    `route!''\norg/jruby/RubyArray.java:1615:in `each''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/sinatra-1.3.3/lib/sinatra/base.rb:833:in
         | 
| 63 | 
            +
                    `route!''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/sinatra-1.3.3/lib/sinatra/base.rb:936:in
         | 
| 64 | 
            +
                    `dispatch!''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/newrelic_rpm-3.5.5.38/lib/new_relic/agent/instrumentation/sinatra.rb:48:in
         | 
| 65 | 
            +
                    `dispatch_with_newrelic''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/newrelic_rpm-3.5.5.38/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:268:in
         | 
| 66 | 
            +
                    `perform_action_with_newrelic_trace''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/newrelic_rpm-3.5.5.38/lib/new_relic/agent/method_tracer.rb:240:in
         | 
| 67 | 
            +
                    `trace_execution_scoped''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/newrelic_rpm-3.5.5.38/lib/new_relic/agent/method_tracer.rb:239:in
         | 
| 68 | 
            +
                    `trace_execution_scoped''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/newrelic_rpm-3.5.5.38/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:263:in
         | 
| 69 | 
            +
                    `perform_action_with_newrelic_trace''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/newrelic_rpm-3.5.5.38/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:262:in
         | 
| 70 | 
            +
                    `perform_action_with_newrelic_trace''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/newrelic_rpm-3.5.5.38/lib/new_relic/agent/instrumentation/sinatra.rb:45:in
         | 
| 71 | 
            +
                    `dispatch_with_newrelic''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/sinatra-1.3.3/lib/sinatra/base.rb:769:in
         | 
| 72 | 
            +
                    `call!''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:in
         | 
| 73 | 
            +
                    `invoke''\norg/jruby/RubyKernel.java:1197:in `catch''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/sinatra-1.3.3/lib/sinatra/base.rb:921:in
         | 
| 74 | 
            +
                    `invoke''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/sinatra-1.3.3/lib/sinatra/base.rb:769:in
         | 
| 75 | 
            +
                    `call!''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/sinatra-1.3.3/lib/sinatra/base.rb:755:in
         | 
| 76 | 
            +
                    `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/rack-1.4.1/lib/rack/commonlogger.rb:20:in
         | 
| 77 | 
            +
                    `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/sinatra-1.3.3/lib/sinatra/base.rb:136:in
         | 
| 78 | 
            +
                    `call''\n/Users/jannis/Dev/core/sheldon-moviepilot/lib/rack/jsonp.rb:13:in
         | 
| 79 | 
            +
                    `call''\n/Users/jannis/Dev/core/sheldon-moviepilot/lib/rack/header_control.rb:10:in
         | 
| 80 | 
            +
                    `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb:22:in
         | 
| 81 | 
            +
                    `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/rack-protection-1.2.0/lib/rack/protection/path_traversal.rb:16:in
         | 
| 82 | 
            +
                    `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/rack-protection-1.2.0/lib/rack/protection/json_csrf.rb:17:in
         | 
| 83 | 
            +
                    `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/rack-protection-1.2.0/lib/rack/protection/base.rb:47:in
         | 
| 84 | 
            +
                    `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb:22:in
         | 
| 85 | 
            +
                    `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/rack-1.4.1/lib/rack/logger.rb:15:in
         | 
| 86 | 
            +
                    `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/sinatra-1.3.3/lib/sinatra/base.rb:129:in
         | 
| 87 | 
            +
                    `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/rack-1.4.1/lib/rack/head.rb:9:in
         | 
| 88 | 
            +
                    `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in
         | 
| 89 | 
            +
                    `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/sinatra-1.3.3/lib/sinatra/base.rb:99:in
         | 
| 90 | 
            +
                    `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/sinatra-1.3.3/lib/sinatra/base.rb:1389:in
         | 
| 91 | 
            +
                    `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/sinatra-1.3.3/lib/sinatra/base.rb:1471:in
         | 
| 92 | 
            +
                    `synchronize''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/sinatra-1.3.3/lib/sinatra/base.rb:1389:in
         | 
| 93 | 
            +
                    `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/newrelic_rpm-3.5.5.38/lib/new_relic/rack/developer_mode.rb:24:in
         | 
| 94 | 
            +
                    `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/rack-1.4.1/lib/rack/lint.rb:48:in
         | 
| 95 | 
            +
                    `_call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/rack-1.4.1/lib/rack/lint.rb:36:in
         | 
| 96 | 
            +
                    `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/rack-1.4.1/lib/rack/showexceptions.rb:24:in
         | 
| 97 | 
            +
                    `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/rack-1.4.1/lib/rack/commonlogger.rb:20:in
         | 
| 98 | 
            +
                    `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/sinatra-1.3.3/lib/sinatra/base.rb:136:in
         | 
| 99 | 
            +
                    `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/rack-1.4.1/lib/rack/chunked.rb:43:in
         | 
| 100 | 
            +
                    `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/rack-1.4.1/lib/rack/content_length.rb:14:in
         | 
| 101 | 
            +
                    `call''\n/Users/jannis/.rvm/gems/jruby-1.6.7@sheldon/gems/rack-1.4.1/lib/rack/handler/webrick.rb:59:in
         | 
| 102 | 
            +
                    `service''\n/Users/jannis/.rvm/rubies/jruby-1.6.7/lib/ruby/1.9/webrick/httpserver.rb:111:in
         | 
| 103 | 
            +
                    `service''\n/Users/jannis/.rvm/rubies/jruby-1.6.7/lib/ruby/1.9/webrick/httpserver.rb:70:in
         | 
| 104 | 
            +
                    `run''\n/Users/jannis/.rvm/rubies/jruby-1.6.7/lib/ruby/1.9/webrick/httpserver.rb:48:in
         | 
| 105 | 
            +
                    `run''\n/Users/jannis/.rvm/rubies/jruby-1.6.7/lib/ruby/1.9/webrick/server.rb:183:in
         | 
| 106 | 
            +
                    `start_thread''\n/Users/jannis/.rvm/rubies/jruby-1.6.7/lib/ruby/1.9/webrick/server.rb:173:in
         | 
| 107 | 
            +
                    `start_thread''"}'
         | 
| 108 | 
            +
                http_version: 
         | 
| 109 | 
            +
              recorded_at: Mon, 18 Feb 2013 16:16:19 GMT
         | 
| 110 | 
            +
            recorded_with: VCR 2.4.0
         |