uat-matchers 0.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ Nzc3NWIwOTM4NjhhMGQwY2M1YzZkYzBmY2FkMzFjZGJlOGIzZWZlYQ==
5
+ data.tar.gz: !binary |-
6
+ OWZjOTZjOTI0MzQ2M2NjOTA2YWMwMDJkYzk0ZWVhZjBkZjQ3MTZhYQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YzFkMjkwMmEwMzQwZDBiMWFmOWU5YWQyYjYxNzIwMWE5Yjc5ZjcyNDcyY2Zm
10
+ NTJmMGE2ZTgzMjM4OWJlYzcwODM3MjE1NmRiZDkxYzE1YzkxNDdkMjEwMTQ4
11
+ ZjgyYjcwZTlhYmZiMWJkYjY4ODkwZTBkZDcxNjk0ZTc1MzBiMTM=
12
+ data.tar.gz: !binary |-
13
+ NzY4MTk2NTM5ZmI2ODMzMmE1OGE2Nzc2OGI3Mjc5MzA5MzRhNzE1ZWE3NDZj
14
+ YjViOTBmMTExMDI3Y2JlODkyNmUwZWI2NjdlNWMyMDlkNWI4ZTMzZDg3ZjA0
15
+ M2IxNGY0OWRhZTNlOWVmYzZlZjk3NTQ1N2Q5YzUwNzA3ZjNjNTc=
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper --format documentation --color true
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in uat-matchers.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # UAT::Matchers
2
+
3
+ A gem providing matchers to aid in testing
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'uat-matchers'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install uat-matchers
20
+
21
+ ## Usage
22
+
23
+ # uat
24
+
25
+ User Acceptance Test tooling
26
+
27
+ ```
28
+ UAT::Matchers::RPCHelper
29
+ UAT::Matchers::RPCHelper#setup!(url)
30
+ sets the url used by instances that include this module
31
+ #make_rpc(rpc_class, method, request, response_class, &optional_block)
32
+ when the request is successful
33
+ performs an rspec expectation that the class of the response matches "response_class"
34
+ behaves like an rpc call
35
+ creates an instance of rpc_class using the "client" class method, passing a hash with the url parts
36
+ calls the "method" on the resulting rpc_client, passing in the request
37
+ registers a callback for success
38
+ registers a callback for failure
39
+ and if the rspec expectation fails
40
+ raises an exception
41
+ and if the rspec expectation passes
42
+ and a block is passed
43
+ calls the block, passing in the response
44
+ when the request is a failure
45
+ raises an exception
46
+ which is the result of calling inspect on the parameter in the on_error handler block (PENDING: Temporarily skipped with xit)
47
+ behaves like an rpc call
48
+ creates an instance of rpc_class using the "client" class method, passing a hash with the url parts
49
+ calls the "method" on the resulting rpc_client, passing in the request
50
+ registers a callback for success
51
+ registers a callback for failure
52
+ ```
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require "rspec/core/rake_task"
2
+ RSpec::Core::RakeTask.new
3
+ task :default => [ :spec ]
@@ -0,0 +1 @@
1
+ Dir["#{File.dirname(__FILE__)}/matchers/**/*.rb"].each { |f| require(f) }
@@ -0,0 +1,15 @@
1
+ module UAT
2
+ module Matchers
3
+ class API
4
+ # @param configuration [UAT::Matchers::Configuration]
5
+ def initialize(configuration)
6
+ @configuration = configuration
7
+ end
8
+
9
+ # @return [UAT::Matchers::RPCHelper]
10
+ def rpc_helper
11
+ RPCHelper.new(@configuration.rpc_service_url, @configuration.rspec_example)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ module UAT
2
+ module Matchers
3
+ class Configuration
4
+ # @attr [String]
5
+ attr_accessor :rpc_service_url
6
+
7
+ # @attr [RSpec::Example] a reference to the current example to be used in the matcher
8
+ attr_accessor :rspec_example
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,32 @@
1
+ module UAT
2
+ module Matchers
3
+ # DRY up protobuf RPC call expectations with RPCHelper
4
+ class RPCHelper
5
+ # @param rpc_service_url [URI::Generic]
6
+ def initialize(rpc_service_url, rspec_example)
7
+ @rpc_service_url = rpc_service_url
8
+ @rspec_example = rspec_example
9
+ end
10
+
11
+ # @param rpc_class [#client] an rpc class with a client class method
12
+ # @param method [Symbol] a symbol containing the method name to call
13
+ # @param request [Protobuf::Message] the request object
14
+ # @param response_class [Class<Protobuf::Message>] the expected response class
15
+ # @yield block_that_receives_vetted_response an optional block which will be passed the response as long as it is an instance of the expected response_class
16
+ # @yieldparam response [Protobuf::Message]
17
+ # @yieldreturn is not used
18
+ def make_rpc(rpc_class, method, request, response_class, &block_that_receives_vetted_response)
19
+ opts = {:host => @rpc_service_url.host,
20
+ :port => @rpc_service_url.port,
21
+ :base => @rpc_service_url.path}
22
+ rpc_class.client(opts).send(method, request) do |rpc_response_handler|
23
+ rpc_response_handler.on_success do |response|
24
+ @rspec_example.expect(response.class).to @rspec_example.be response_class
25
+ block_that_receives_vetted_response.call(response) unless block_that_receives_vetted_response.nil?
26
+ end
27
+ rpc_response_handler.on_failure {|err| raise err.inspect }
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,5 @@
1
+ module UAT
2
+ module Matchers
3
+ VERSION = "0.0.1.pre"
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'uat/matchers/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "uat-matchers"
8
+ spec.version = UAT::Matchers::VERSION
9
+ spec.authors = ["Tommy Sullivan", "Blaine Schanfeldt"]
10
+ spec.email = ["thomas.sullivan@lookout.com", "blaine.schanfeldt@lookout.com"]
11
+
12
+ spec.summary = "A gem providing matchers that aid user acceptance testing"
13
+ spec.homepage = "https://github.com/lookout/uat"
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_development_dependency "rake", "~> 10.0"
20
+ spec.add_development_dependency "rspec", "~> 3.2.0"
21
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: uat-matchers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre
5
+ platform: ruby
6
+ authors:
7
+ - Tommy Sullivan
8
+ - Blaine Schanfeldt
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-04-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '10.0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: '10.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rspec
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 3.2.0
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: 3.2.0
42
+ description:
43
+ email:
44
+ - thomas.sullivan@lookout.com
45
+ - blaine.schanfeldt@lookout.com
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - .gitignore
51
+ - .rspec
52
+ - Gemfile
53
+ - README.md
54
+ - Rakefile
55
+ - lib/uat/matchers.rb
56
+ - lib/uat/matchers/api.rb
57
+ - lib/uat/matchers/configuration.rb
58
+ - lib/uat/matchers/rpc_helper.rb
59
+ - lib/uat/matchers/version.rb
60
+ - uat-matchers.gemspec
61
+ homepage: https://github.com/lookout/uat
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ! '>'
77
+ - !ruby/object:Gem::Version
78
+ version: 1.3.1
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 2.4.5
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: A gem providing matchers that aid user acceptance testing
85
+ test_files: []
86
+ has_rdoc: