webtrap 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e32a4e898ff867cc637d3d172aac40ded927bc32
4
- data.tar.gz: 32235a98f61b4479aa6e3d1d96bfa481e1ecfe8e
3
+ metadata.gz: 6588474ffa8dde283728eb5f92c5eff22fe4dcba
4
+ data.tar.gz: 6bbd81d456fb3a44a72c95a570c2b24dfb5df1a1
5
5
  SHA512:
6
- metadata.gz: 741d50fb982ea969bc9630abae14ba8ddc7269b300ca82c4fdae8e1c7d1f9ea86e0622e0fde45617e7c6a7f56415d49b6687cc9cae1286567697c27363aee99a
7
- data.tar.gz: 42b5e1a259c7904857dbf27b35f268f7cd962dc882f7bdb0852b98d875110a6f35dfb670084b09f7cc2d9fa533fba0bc7902811c52e4e5af6d7674f794a6d5af
6
+ metadata.gz: de34495dfafe249c736524599a365bd9ad3e5dce325fa1421dadd04d65e5f248a8b20ec0f5e664d7d25b74ce73fc5f55165742ee8fe18accecd11d2b7dd2032a
7
+ data.tar.gz: 98a88a5212a5769ce493862ae11db94f4a54f7b273c0f2880dc081a6cb84dc300b092f52a6d5ecd63970b845dd11437905da019b964b770578fb8a67795ee81a
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ *.gem
2
+ .yardoc/
3
+ doc/
data/.rubocop.yml ADDED
@@ -0,0 +1,60 @@
1
+ AllCops:
2
+ Include:
3
+ - "**/Rakefile"
4
+ - "**/config.ru"
5
+ Exclude:
6
+ - "db/**/*"
7
+ - "config/**/*"
8
+ - "script/**/*"
9
+ - "bin/**/*"
10
+ - "vendor/**/*"
11
+ - "node_modules/**/*"
12
+ - "spec/factories.rb"
13
+ TargetRubyVersion: 2.3
14
+
15
+ Metrics/LineLength:
16
+ Enabled: false
17
+
18
+ Style/AlignParameters:
19
+ EnforcedStyle: with_fixed_indentation
20
+
21
+ Style/ClassAndModuleChildren:
22
+ Enabled: false
23
+
24
+ Style/Documentation:
25
+ Enabled: false
26
+
27
+ Style/DotPosition:
28
+ EnforcedStyle: trailing
29
+
30
+ Style/IfUnlessModifier:
31
+ Enabled: false
32
+
33
+ Style/PredicateName:
34
+ NamePrefixBlacklist:
35
+ - is_
36
+ - have_
37
+
38
+ Style/StringLiterals:
39
+ EnforcedStyle: double_quotes
40
+
41
+ Style/NumericLiterals:
42
+ Enabled: false
43
+
44
+ Style/SingleLineBlockParams:
45
+ Enabled: false
46
+
47
+ Style/MultilineOperationIndentation:
48
+ EnforcedStyle: indented
49
+
50
+ Style/MultilineMethodCallIndentation:
51
+ EnforcedStyle: indented
52
+
53
+ Style/TrailingCommaInArguments:
54
+ EnforcedStyleForMultiline: comma
55
+
56
+ Style/TrailingCommaInLiteral:
57
+ EnforcedStyleForMultiline: comma
58
+
59
+ Style/FrozenStringLiteralComment:
60
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+ sudo: false
3
+ cache:
4
+ directories:
5
+ - ../bundle
6
+ bundler_args: "--standalone --path ../bundle"
7
+ rvm:
8
+ - 2.0.0
9
+ - 2.1
10
+ - 2.2.5
11
+ - 2.3.3
12
+ - 2.4.0
13
+ - ruby-head
14
+ before_install: gem install bundler -v 1.13.6
15
+ script:
16
+ - bundle exec cucumber
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,45 @@
1
+ Contributing
2
+ ============
3
+
4
+ We welcome all kinds of contributions whether it is a bug, a new feature,
5
+ documentation, etc.
6
+
7
+ Please follow these guidelines when contributing to this project.
8
+
9
+
10
+ ## Bug Reporting
11
+
12
+ If anything feels like a bug, it is probably a bug. But if it isn't, we're happy
13
+ to let you know why :smile:. When submitting your issue, follow these tips:
14
+
15
+ * Include an thorough environment description:
16
+ - Operating System;
17
+ - Ruby version;
18
+ - Gem versions (include your `Gemfile.lock` when not sure);
19
+ * Describe the bug as well as possible so that we can reproduce it;
20
+ * If possible, provide a code sample that showcases the issue.
21
+
22
+
23
+ ## Pull Requests
24
+
25
+ Pull requests are **always** welcome. After that we'll review it and get back to
26
+ you on it. To increase the chance of your PR being accepted, follow these tips:
27
+
28
+ * Your changes **must** pass in the [CI][ci];
29
+ * If your changes include code, it **must** be tested (if not sure how, we're
30
+ here to help);
31
+ * **Avoid** breaking the conventions set by existing code unless you have a very
32
+ good reason for it (just because there isn't a linter to catch it, doesn't
33
+ mean it's ok);
34
+ * After your changes get approved, you **must** squash all your commits to the
35
+ minimal logical set (which is _one_, unless instructed otherwise);
36
+ * **It's ok to ask for help**: if you're struggling to finish implementing your
37
+ idea, reach out to us and we'll try to point you in the right direction.
38
+
39
+
40
+ ## Thank you
41
+
42
+ Thank you for even considering helping out. You're awesome! :heart:
43
+
44
+
45
+ [ci]: https://travis-ci.org/pfac/webtrap
data/Gemfile CHANGED
@@ -1,3 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "http://rubygems.org"
2
4
 
3
5
  gemspec
6
+
7
+ group :documentation do
8
+ gem "yard", "~> 0.9.8"
9
+ end
data/Gemfile.lock CHANGED
@@ -12,6 +12,7 @@ GEM
12
12
  specs:
13
13
  addressable (2.5.0)
14
14
  public_suffix (~> 2.0, >= 2.0.2)
15
+ ast (2.3.0)
15
16
  builder (3.2.3)
16
17
  crack (0.4.3)
17
18
  safe_yaml (~> 1.0.0)
@@ -36,10 +37,14 @@ GEM
36
37
  multi_test (0.1.2)
37
38
  nokogiri (1.6.8.1)
38
39
  mini_portile2 (~> 2.1.0)
40
+ parser (2.4.0.0)
41
+ ast (~> 2.2)
42
+ powerpack (0.1.1)
39
43
  public_suffix (2.0.5)
40
44
  rack (1.6.5)
41
45
  rack-protection (1.5.3)
42
46
  rack
47
+ rainbow (2.2.1)
43
48
  rake (10.4.2)
44
49
  rspec (3.5.0)
45
50
  rspec-core (~> 3.5.0)
@@ -54,16 +59,25 @@ GEM
54
59
  diff-lcs (>= 1.2.0, < 2.0)
55
60
  rspec-support (~> 3.5.0)
56
61
  rspec-support (3.5.0)
62
+ rubocop (0.47.1)
63
+ parser (>= 2.3.3.1, < 3.0)
64
+ powerpack (~> 0.1)
65
+ rainbow (>= 1.99.1, < 3.0)
66
+ ruby-progressbar (~> 1.7)
67
+ unicode-display_width (~> 1.0, >= 1.0.1)
68
+ ruby-progressbar (1.8.1)
57
69
  safe_yaml (1.0.4)
58
70
  sinatra (1.4.8)
59
71
  rack (~> 1.5)
60
72
  rack-protection (~> 1.4)
61
73
  tilt (>= 1.3, < 3)
62
74
  tilt (2.0.6)
75
+ unicode-display_width (1.1.3)
63
76
  webmock (2.3.2)
64
77
  addressable (>= 2.3.6)
65
78
  crack (>= 0.3.2)
66
79
  hashdiff
80
+ yard (0.9.8)
67
81
 
68
82
  PLATFORMS
69
83
  ruby
@@ -72,7 +86,9 @@ DEPENDENCIES
72
86
  bundler (~> 1.13)
73
87
  cucumber (~> 2.0)
74
88
  rake (~> 10.0)
89
+ rubocop (~> 0.47.1)
75
90
  webtrap!
91
+ yard (~> 0.9.8)
76
92
 
77
93
  BUNDLED WITH
78
94
  1.13.6
data/README.md CHANGED
@@ -1,4 +1,194 @@
1
- Send Request
2
- ============
1
+ WebTrap
2
+ =======
3
3
 
4
- Not the best name for this.
4
+ [![Gem Version](https://badge.fury.io/rb/webtrap.svg)](https://badge.fury.io/rb/webtrap)
5
+ [![Build Status](https://travis-ci.org/pfac/webtrap.svg?branch=master)](https://travis-ci.org/pfac/webtrap)
6
+ [![Dependency Status](https://gemnasium.com/badges/github.com/pfac/webtrap.svg)](https://gemnasium.com/github.com/pfac/webtrap)
7
+ [![Code Climate](https://codeclimate.com/github/pfac/webtrap/badges/gpa.svg)](https://codeclimate.com/github/pfac/webtrap)
8
+ [![Inch CI](https://inch-ci.org/github/pfac/webtrap.svg?branch=master)](https://inch-ci.org/github/pfac/webtrap)
9
+
10
+ WebTrap allows you to write tests that assert on outgoing requests. This allows
11
+ you to verify that such requests match the documentation of external services
12
+ without actually having to hit them.
13
+
14
+ ## Install
15
+
16
+ To install this library, just run the following command on your shell:
17
+
18
+ ```sh
19
+ #!/bin/sh
20
+ gem install webtrap
21
+ ```
22
+
23
+ Or, if you're using [Bundler][bundler], add the following to your project's
24
+ `Gemfile`:
25
+
26
+ ```ruby
27
+ # Gemfile
28
+ gem "webtrap", group: :test
29
+ ```
30
+
31
+
32
+ ## Usage
33
+
34
+ WebTrap consists on a set of matchers that given a block where an HTTP request
35
+ is sent provide the ability to assert over on the outgoing request.
36
+
37
+
38
+ ### Configuration
39
+
40
+ In order to use WebTrap matchers, make sure you require the correct file into
41
+ your configuration:
42
+
43
+
44
+ #### RSpec
45
+
46
+ ```ruby
47
+ require "webtrap/rspec"
48
+ ```
49
+
50
+ Include this line in the specs where you wish to use these matchers. If you
51
+ prefer to make WebTrap matchers available to all specs add this line to
52
+ `specs/spec_helper.rb`, or, if you are using `rspec-rails`, add it to
53
+ `specs/support/webtrap.rb`.
54
+
55
+
56
+ ### Examples
57
+
58
+ * Verify that a request is sent anywhere:
59
+ ```ruby
60
+ expect do
61
+ # ...
62
+ end.to send_request
63
+ ```
64
+
65
+ * Verify that a request is send with a specific XML body (or [equivalent][equivalent-xml]):
66
+ ```ruby
67
+ expect do
68
+ # ...
69
+ end.to send_request.with_xml(xml)
70
+ ```
71
+
72
+
73
+ ## Contributing
74
+
75
+ If you find a problem, have an idea or a suggestion, but don't know how to
76
+ implement it, or if you simply have a question regarding this project,
77
+ [please create an issue on GitHub][github-issue]. Your issue will be reviewed by
78
+ one of the main contributors and taken into consideration in the development of
79
+ the project.
80
+
81
+ On the other hand, if you are able to take action on the issue
82
+ [please submit a pull request][github-pull-request] instead. Development will go
83
+ a lot faster with contributions from the community, be it in code, documentation
84
+ or any other form.
85
+
86
+ Any contribution is more than welcome.
87
+
88
+ ### Setup
89
+
90
+ Start by cloning the project into your system and running the bootstrapping
91
+ script included to set up your development environment:
92
+
93
+ ```sh
94
+ #!/bin/sh
95
+ git clone https://github.com/pfac/webtrap.git
96
+ cd webtrap
97
+ ./bin/setup
98
+ ```
99
+
100
+ Here's what the script does:
101
+
102
+ 1. Checks the existence of a compatible Ruby environment (MRI 2.0+);
103
+ 2. Checks the presence of [Bundler][bundler], and installs it if missing;
104
+ 3. Installs all dependencies.
105
+
106
+ Feel free to check the script before running it. To check if everything is
107
+ correctly set up run:
108
+
109
+ ```sh
110
+ #!/bin/sh
111
+ bundle exec rake
112
+ ```
113
+
114
+ That will run the linters and acceptance tests. If the tests fail please check
115
+ the [build status][travis-ci] for the branch you checked out. Unless the build
116
+ status is already failing, please investigate the issue on your environment. If
117
+ you found a defect in the bootstraping script, please file an issue to let us
118
+ know (be as detailed as possible).
119
+
120
+
121
+ ### Development
122
+
123
+ In this project we use BDD with Cucumber. Ideally you should start with a
124
+ successful build, which you can check by running:
125
+
126
+ ```sh
127
+ #!/bin/sh
128
+ bundle exec rake
129
+ ```
130
+
131
+ It may happen that the branch where you started (usually `master`) is already
132
+ broken on [the CI][travis-ci]. If that is the case try to focus only on the scenarios you
133
+ are working on, by running instead:
134
+
135
+ ```sh
136
+ #!/bin/sh
137
+ cucumber features/<path-to-file>
138
+ ```
139
+
140
+ Start by describing your idea in either a new scenario or a whole new feature
141
+ file. If you are not sure which one to go for, create a new feature file and
142
+ someone will point you in the right direction during code revision. Make sure
143
+ your scenario fails before proceeding.
144
+
145
+ After that, implement the necessary code required to make your scenario pass. If
146
+ you find yourself in trouble feel free to [create an issue][github-issue]
147
+ pointing to your changes and someone will try to help you.
148
+
149
+ Once your scenario passes, refactor as required. Make sure your code gets
150
+ properly checked by the linters. When you feel your changes are ready,
151
+ [submit a pull request][github-pull-request]. We'll review it in the nicest way
152
+ possible. :smile:
153
+
154
+ For a short-list to follow before submitting your pull request, see
155
+ [CONTRIBUTING](./CONTRIBUTING.md).
156
+
157
+
158
+ ### Deployment
159
+
160
+ Any main contributor can deploy a new version. To do so, update the version
161
+ number as appropriate according to [Semantic Versioning][semver] and run the
162
+ deployment script:
163
+
164
+ ```sh
165
+ #!/bin/sh
166
+ ./bin/deploy
167
+ ```
168
+
169
+ On the other hand, if you are not a main contributor with deployment
170
+ permissions your idea will have to wait for a new version release to become
171
+ available in [RubyGems][rubygems] once it gets accepted.
172
+
173
+ At the moment there is no need for a release schedule, so new versions will be
174
+ released at the discretion of the main contributors team. Should you require
175
+ a pending feature to be released, feel free to mention it in your pull request
176
+ once it gets merged, or to open a new issue. We'll try to honor such requests
177
+ as much as possible when reasonable.
178
+
179
+
180
+ ## About
181
+
182
+ WebTrap was originally designed by and is currently maintained by
183
+ [Pedro Costa][pfac]. All artifacts in this project are released under the
184
+ [MIT license](./LICENSE.txt).
185
+
186
+
187
+ [bundler]: http://bundler.io/
188
+ [equivalent-xml]: https://github.com/mbklein/equivalent-xml
189
+ [github-issue]: https://github.com/pfac/webtrap/issues/new
190
+ [github-pull-request]: https://github.com/pfac/webtrap/pull/new
191
+ [pfac]: https://github.com/pfac
192
+ [rubygems]: https://rubygems.org/gems/webtrap
193
+ [semver]: http://semver.org/
194
+ [travis-ci]: https://travis-ci.org/pfac/webtrap
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :lint do
4
+ require "rubocop/rake_task"
5
+ RuboCop::RakeTask.new(:ruby)
6
+ end
7
+ task lint: %i(lint:ruby)
8
+
9
+ namespace :test do
10
+ require "cucumber/rake/task"
11
+ Cucumber::Rake::Task.new(:acceptance)
12
+ end
13
+ task test: %i(test:acceptance)
14
+
15
+ task default: %i(lint test)
data/bin/deploy ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ _webtrap_has_gem () {
6
+ type gem > /dev/null 2>&1
7
+ }
8
+
9
+ _webtrap_deploy () {
10
+ if ! _webtrap_has_gem; then
11
+ echo '* Compatible Ruby environment not found' >&2
12
+ echo 'WebTrap Setup error: this project requires a compatible Ruby environment.' >&2
13
+ exit 1
14
+ fi
15
+
16
+ gem push "$(gem build webtrap.gemspec | grep "File:" | cut -d\ -f4)"
17
+ }
18
+
19
+ _webtrap_deploy "$@"
data/bin/setup ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env sh
2
+
3
+ _webtrap_has_compatible_ruby () {
4
+ if ! type ruby > /dev/null 2>&1; then
5
+ return 1
6
+ fi
7
+
8
+ local major_version=`ruby --version | cut -d\ -f2 | cut -dp -f1 | cut -d. -f1`
9
+
10
+ [ "$major_version" -ge "2" ]
11
+ }
12
+
13
+ _webtrap_has_gem () {
14
+ type gem > /dev/null 2>&1
15
+ }
16
+
17
+ _webtrap_has_bundler () {
18
+ type bundler > /dev/null 2>&1
19
+ }
20
+
21
+ _webtrap_setup () {
22
+ if ! _webtrap_has_compatible_ruby || ! _webtrap_has_gem; then
23
+ echo '* Compatible Ruby environment not found' >&2
24
+ echo 'WebTrap Setup error: this project requires MRI 2.0+ to be available.' >&2
25
+ exit 1
26
+ fi
27
+
28
+ if ! _webtrap_has_bundler; then
29
+ echo '* Bundler not found.'
30
+ echo 'WebTrap Setup error: this project requires Bundler to be available.' >&2
31
+ exit 2
32
+ fi
33
+
34
+ echo '* Checking dependencies'
35
+ (bundle check || bundle install) > /dev/null
36
+
37
+ echo '* All done'
38
+ }
39
+
40
+ _webtrap_setup "$@"
data/cucumber.yml ADDED
@@ -0,0 +1 @@
1
+ default: --format progress
@@ -1,26 +1,56 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "webmock/rspec"
2
4
 
3
5
  module WebTrap
4
6
  module RSpec
5
7
  module Matchers
8
+ # @api private
9
+ # Provides the implementation for `send_request`.
10
+ # Not intended to be instantiated directly.
6
11
  class SendRequest
12
+ # @api public
13
+ # Specifies the XML payload of the request.
14
+ #
15
+ # The expectation will pass only if a request is sent with a payload
16
+ # that is considered equivalent to the reference. For further details
17
+ # see the {https://github.com/mbklein/equivalent-xml equivalent-xml}
18
+ # gem.
19
+ #
20
+ # @param xml [] The reference XML payload.
21
+ # @return [SendRequestWithXml]
22
+ # The matcher to verify that a request is with a payload equivalent
23
+ # to the reference.
24
+ def with_xml(xml)
25
+ SendRequestWithXml.new(xml)
26
+ end
27
+
28
+ # @api private
29
+ # Checks if the provided Proc sends an HTTP request.
30
+ # @param transmission_proc [Proc]
31
+ # The proc that should send an HTTP request.
32
+ # @return
33
+ # Whether an HTTP request was sent.
34
+ # @see {RSpec::Matchers::MatcherProtocol#matches?}
7
35
  def matches?(transmission_proc)
8
36
  perform_transmission(transmission_proc)
9
37
  request_sent?
10
38
  end
11
39
 
40
+ # @api private
41
+ # Message to be shown if the expectation fails to pass.
42
+ # @return [String]
12
43
  def failure_message
13
44
  "expected block to send an HTTP request, but nothing was sent out"
14
45
  end
15
46
 
47
+ # @api private
48
+ # Allows the matcher to be used with block expectations.
49
+ # @return [TrueClass]
16
50
  def supports_block_expectations?
17
51
  true
18
52
  end
19
53
 
20
- def with_xml(xml)
21
- SendRequestWithXml.new(xml)
22
- end
23
-
24
54
  private
25
55
 
26
56
  def perform_transmission(transmission_proc)
@@ -1,27 +1,51 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "equivalent-xml"
2
4
  require "webmock/rspec"
3
5
 
4
6
  module WebTrap
5
7
  module RSpec
6
8
  module Matchers
9
+ # @api private
10
+ # Used to specify the XML payload of the request.
7
11
  class SendRequestWithXml < SendRequest
12
+ # Reference to be compared with the payload of outgoing XML requests.
8
13
  attr_reader :expected_payload
9
14
 
15
+ # Allows the parameterization of the matcher with the reference payload.
16
+ # @param expected_payload []
17
+ # Reference to be compared with the payload of outgoing XML requests.
10
18
  def initialize(expected_payload)
11
19
  @expected_payload = expected_payload
12
20
  end
13
21
 
22
+ # @api private
23
+ # Checks if the provided Proc sends a request with an XML payload
24
+ # equivalent to the expected reference.
25
+ # @param transmission_proc [Proc]
26
+ # The proc that should send a valid request.
27
+ # @return
28
+ # Whether a request was sent with an equivalent XML payload.
29
+ # @see {RSpec::Matchers::MatcherProtocol#matches?}
14
30
  def matches?(transmission_proc)
15
31
  perform_transmission(transmission_proc)
16
32
  request_sent? && valid_payload?
17
33
  end
18
34
 
35
+ # @api private
36
+ # Message to be shown if the expectation fails to pass.
37
+ # @return [String]
38
+ # @see {RSpec::Matchers::MatcherProtocol#failure_message}
19
39
  def failure_message
20
40
  return super unless request_sent?
21
41
 
22
42
  "expected block to send an HTTP request with XML body, but payload was not equivalent"
23
43
  end
24
44
 
45
+ # @api private
46
+ # Allows the matcher to be used with block expectations.
47
+ # @return [TrueClass]
48
+ # @see {RSpec::Matchers::MatcherProtocol#supports_block_expectations?}
25
49
  def supports_block_expectations?
26
50
  true
27
51
  end
@@ -1,9 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "webtrap/rspec/matchers/send_request"
2
4
  require "webtrap/rspec/matchers/send_request_with_xml"
3
5
 
4
6
  module WebTrap
5
7
  module RSpec
8
+ # WebTrap::RSpec::Matchers provides the set of matchers available to define
9
+ # expections about outgoing requests.
6
10
  module Matchers
11
+ # Passes if the block sends any HTTP request.
12
+ #
13
+ # @return [SendRequest]
14
+ # The matcher to verify that the request is sent.
7
15
  def send_request
8
16
  SendRequest.new
9
17
  end
data/lib/webtrap/rspec.rb CHANGED
@@ -1,3 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "webtrap/server"
2
4
 
3
5
  require "webtrap/rspec/matchers"
6
+
7
+ module WebTrap
8
+ # Implementation of the WebTrap features for the RSpec testing tool.
9
+ #
10
+ # @example
11
+ # require "webtrap/rspec"
12
+ module RSpec
13
+ end
14
+ end
@@ -1,24 +1,39 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "sinatra"
2
4
 
3
5
  module WebTrap
6
+ # Base class for creating fake web application to capture outgoing web
7
+ # requests and assert on them.
8
+ #
9
+ # Descendants of this class are in charge of setting the required rules to
10
+ # correctly intercept the target requests.
11
+ #
12
+ # Currently it is only used by SendRequestWithXml.
4
13
  class Server < Sinatra::Base
5
14
  @payload_was_valid = false
6
15
  @request_received = false
7
16
 
8
- def self.payload_was_valid?
9
- @payload_was_valid
17
+ class << self
18
+ # Set whether the payload met the matcher constraints.
19
+ # @param value [Boolean]
20
+ attr_writer :payload_was_valid
21
+
22
+ # Set whether a request was received at all.
23
+ # @param value [Boolean]
24
+ attr_writer :request_received
10
25
  end
11
26
 
12
- def self.payload_was_valid=(payload_was_valid)
13
- @payload_was_valid = payload_was_valid
27
+ # Whether the payload met the matcher constraints.
28
+ # @return [Boolean] `false` by default.
29
+ def self.payload_was_valid?
30
+ @payload_was_valid
14
31
  end
15
32
 
33
+ # Whether a request was received at all.
34
+ # @return [Boolean] `false` by default.
16
35
  def self.request_received?
17
36
  @request_received
18
37
  end
19
-
20
- def self.request_received=(request_received)
21
- @request_received = request_received
22
- end
23
38
  end
24
39
  end
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WebTrap
2
- VERSION = "0.0.0"
4
+ # Current version of the WebTrap gem.
5
+ VERSION = "0.0.1"
3
6
  end
data/lib/webtrap.rb ADDED
@@ -0,0 +1,6 @@
1
+ # WebTrap's top level namespace.
2
+ #
3
+ # This module should not be required directly. Instead, require the specific
4
+ # submodule for the testing tool being used.
5
+ module WebTrap
6
+ end
data/webtrap.gemspec CHANGED
@@ -41,7 +41,7 @@ Gem::Specification.new do |spec|
41
41
  spec.add_dependency "webmock", "~> 2.0"
42
42
 
43
43
  spec.add_development_dependency "bundler", "~> 1.13"
44
- spec.add_development_dependency "rake", "~> 10.0"
45
44
  spec.add_development_dependency "cucumber", "~> 2.0"
45
+ spec.add_development_dependency "rake", "~> 10.0"
46
+ spec.add_development_dependency "rubocop", "~> 0.47.1"
46
47
  end
47
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webtrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Costa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-05 00:00:00.000000000 Z
11
+ date: 2017-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.13'
83
+ - !ruby/object:Gem::Dependency
84
+ name: cucumber
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rake
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -95,19 +109,19 @@ dependencies:
95
109
  - !ruby/object:Gem::Version
96
110
  version: '10.0'
97
111
  - !ruby/object:Gem::Dependency
98
- name: cucumber
112
+ name: rubocop
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: '2.0'
117
+ version: 0.47.1
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: '2.0'
124
+ version: 0.47.1
111
125
  description: |2
112
126
  WebTrap allows you to write tests that assert on outgoing requests. This
113
127
  allows you to verify that such requests match the documentation of external
@@ -118,11 +132,20 @@ executables: []
118
132
  extensions: []
119
133
  extra_rdoc_files: []
120
134
  files:
135
+ - ".gitignore"
136
+ - ".rubocop.yml"
121
137
  - ".ruby-version"
138
+ - ".travis.yml"
139
+ - CONTRIBUTING.md
122
140
  - Gemfile
123
141
  - Gemfile.lock
124
142
  - LICENSE.txt
125
143
  - README.md
144
+ - Rakefile
145
+ - bin/deploy
146
+ - bin/setup
147
+ - cucumber.yml
148
+ - lib/webtrap.rb
126
149
  - lib/webtrap/rspec.rb
127
150
  - lib/webtrap/rspec/matchers.rb
128
151
  - lib/webtrap/rspec/matchers/send_request.rb