heisenberg 0.0.2 → 0.0.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.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heisenberg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-31 00:00:00.000000000 Z
12
+ date: 2013-04-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack-test
@@ -34,19 +34,7 @@ email:
34
34
  executables: []
35
35
  extensions: []
36
36
  extra_rdoc_files: []
37
- files:
38
- - .gitignore
39
- - Gemfile
40
- - Gemfile.lock
41
- - LICENSE
42
- - README.md
43
- - Rakefile
44
- - heisenberg.gemspec
45
- - lib/heisenberg.rb
46
- - lib/heisenberg/api_integration_spec.rb
47
- - lib/heisenberg/hashext.rb
48
- - lib/heisenberg/matchers.rb
49
- - lib/heisenberg/version.rb
37
+ files: []
50
38
  homepage: https://github.com/marcelloma/heisenberg
51
39
  licenses: []
52
40
  post_install_message:
data/.gitignore DELETED
@@ -1,18 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- coverage
6
- InstalledFiles
7
- lib/bundler/man
8
- pkg
9
- rdoc
10
- spec/reports
11
- test/tmp
12
- test/version_tmp
13
- tmp
14
-
15
- # YARD artifacts
16
- .yardoc
17
- _yardoc
18
- doc/
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source :rubygems
2
-
3
- gemspec
data/Gemfile.lock DELETED
@@ -1,18 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- heisenberg (0.0.2)
5
- rack-test (>= 0.6.2)
6
-
7
- GEM
8
- remote: http://rubygems.org/
9
- specs:
10
- rack (1.4.1)
11
- rack-test (0.6.2)
12
- rack (>= 1.0)
13
-
14
- PLATFORMS
15
- ruby
16
-
17
- DEPENDENCIES
18
- heisenberg!
data/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2012 Marcello Milhomem Albuquerque
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md DELETED
@@ -1,75 +0,0 @@
1
- Heisenberg
2
- =======
3
-
4
- Acceptance test for REST apis.
5
-
6
- Installation
7
- ---------
8
-
9
- Simply add the gem to your project's Gemfile:
10
-
11
- gem 'heisenberg', group: :test
12
-
13
- and then run the bundle command:
14
-
15
- $ bundle
16
-
17
- Usage
18
- -----
19
-
20
- First of all, we must set our spec to use Heisenberg by setting the spec type to rest_api.
21
-
22
- ```ruby
23
- require "spec_helper"
24
-
25
- describe "My awesome REST API", type: :rest_api
26
- it "should do something awesome"
27
- end
28
- ```
29
-
30
- By default, all specs under the rest_apis directory will use Heisenberg, allowing you to ommit the type declaration.
31
-
32
- To send messages to your api you can call any of these methods:
33
-
34
- ```ruby
35
- get "/people"
36
- post "/people", person: { name: "Chuck Norris" }
37
- delete "/people/1"
38
- put "/people/1", person: { name: "Jet Li" }
39
- ```
40
-
41
- To get the response body from the last request can call the response_body method, which will return the response body parsed to a HashWithIndifferentAccess. For example:
42
-
43
- ```ruby
44
- get "/people/1"
45
- expect(response_body).to be_eql {person: {name: "Jet Li" }}
46
- ```
47
-
48
- You can get the response status code from the last request and do expectations using Heisenberg's status code matchers, as follows:
49
-
50
- ```ruby
51
- get "/people/1"
52
- expect(response_status).to be_successful
53
- ```
54
-
55
- Other status code matchers available are:
56
-
57
- ```ruby
58
- expect(response_status).to be_successful
59
- expect(response_status).to be_forbidden
60
- expect(response_status).to be_bad_request
61
- expect(response_status).to be_created
62
- expect(response_status).to be_unauthorized
63
- expect(response_status).to be_server_error
64
- expect(response_status).to be_not_found
65
- expect(response_status).to be_no_content
66
- ```
67
-
68
- Contributing
69
- ------------
70
-
71
- 1. Fork it
72
- 2. Create your feature branch (git checkout -b my-new-feature)
73
- 3. Commit your changes (git commit -am 'Added some feature')
74
- 4. Push to the branch (git push origin my-new-feature)
75
- 5. Create new Pull Request
data/Rakefile DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
data/heisenberg.gemspec DELETED
@@ -1,16 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/heisenberg/version', __FILE__)
3
-
4
- Gem::Specification.new do |gem|
5
- gem.authors = ["Marcello Milhomem Albuquerque"]
6
- gem.email = ["marcello.m.albuquerque@gmail.com"]
7
- gem.description = "Heisenberg is an REST API integration testing tool for rack based REST APIs"
8
- gem.summary = "Heisenberg's goal is to make API integration tests more concise by allowing to spec APIs through a dead simple API"
9
- gem.homepage = "https://github.com/marcelloma/heisenberg"
10
- gem.files = `git ls-files`.split($\)
11
- gem.name = "heisenberg"
12
- gem.require_paths = ["lib"]
13
- gem.version = Heisenberg::VERSION
14
-
15
- gem.add_dependency "rack-test", ">= 0.6.2"
16
- end
@@ -1,39 +0,0 @@
1
- module Heisenberg
2
- module ApiIntegrationSpec
3
- extend ActiveSupport::Concern
4
-
5
- included do
6
- include Rack::Test::Methods
7
- include Rails.application.routes.url_helpers
8
-
9
- metadata[:type] = :rest_api
10
-
11
- Rails.application.routes.default_url_options[:host] = Rack::Test::DEFAULT_HOST
12
-
13
- def app
14
- Rails.application
15
- end
16
-
17
- def last_response_json
18
- parsed_json = JSON.parse(last_response.body)
19
- parsed_json = parsed_json.recursive_symbolize_keys if parsed_json.is_a? Hash
20
- parsed_json = parsed_json.map(&:recursive_symbolize_keys) if parsed_json.is_a? Array
21
- parsed_json
22
- end
23
-
24
- def serialize resource, options = {}
25
- if resource.is_a? Array
26
- array_serializer = options.fetch(:serializer) { ActiveModel::ArraySerializer }
27
- array_serializer.new(resource, options).as_json
28
- else
29
- serializer = options.fetch(:serializer) { resource.active_model_serializer }
30
- serializer.new(resource).as_json
31
- end
32
- end
33
-
34
- before :each do
35
- header 'Accept', "application/json"
36
- end
37
- end
38
- end
39
- end
@@ -1,14 +0,0 @@
1
- class Hash
2
- def recursive_symbolize_keys
3
- new_hash = self.dup
4
- new_hash.symbolize_keys!
5
- new_hash.values.select{ |v| v.is_a?(Hash) }.each &:recursive_symbolize_keys!
6
- new_hash.values.select{ |v| v.is_a?(Array) }.each { |h| h.each &:recursive_symbolize_keys! }
7
- new_hash
8
- end
9
-
10
- def recursive_symbolize_keys!
11
- symbolize_keys!
12
- values.select{ |v| v.is_a?(Hash) }.each { |h| h.recursive_symbolize_keys! }
13
- end
14
- end
@@ -1,26 +0,0 @@
1
- http_statuses = {
2
- successful: 200,
3
- created: 201,
4
- no_content: 204,
5
- bad_request: 400,
6
- unauthorized: 401,
7
- forbidden: 403,
8
- not_found: 404,
9
- server_error: 500,
10
- }
11
-
12
- for status, code in http_statuses
13
- eval <<-EOS
14
- RSpec::Matchers.define "be_#{status}" do
15
-
16
- match do |actual|
17
- actual.to_s == "#{code}"
18
- end
19
-
20
- failure_message_for_should do |actual|
21
- "Expected " + http_statuses.key(actual).to_s + " to be #{status.to_s}"
22
- end
23
-
24
- end
25
- EOS
26
- end
@@ -1,3 +0,0 @@
1
- module Heisenberg
2
- VERSION = "0.0.2"
3
- end
data/lib/heisenberg.rb DELETED
@@ -1,16 +0,0 @@
1
- require "rack/test"
2
- require "heisenberg/hashext"
3
- require "heisenberg/version"
4
- require "heisenberg/api_integration_spec"
5
-
6
- module Heisenberg
7
- if defined? RSpec
8
- RSpec.configure do |config|
9
- config.include ApiIntegrationSpec,
10
- example_group: { file_path: /spec\/rest_apis/ },
11
- type: :rest_api
12
- end
13
-
14
- require "heisenberg/matchers"
15
- end
16
- end