contracts-rspec 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 430b7140836d0655122d1f2aa0b6f296f4127e31
4
+ data.tar.gz: f243c16f6e8df68da950ecda2b780f761ed1be6d
5
+ SHA512:
6
+ metadata.gz: a86748d0711ea06d3ff9411e365c6e5a980c9bffb4b8ea6b09df8d44d7598735d13c43e456c477a3b804bd40a1d60106500a2a11c8a3c357d33050b9bccfc1d5
7
+ data.tar.gz: 1b7833ab2a192423d05f6816ceca25464fae8d05e298b1eea0f86e9d2c5ea43e4fa62047695bf47b4e969200a33e7b22b7bc690657b5a9ff56dea63973648222
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in contracts-rspec.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Oleksii Fedorov
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 ADDED
@@ -0,0 +1,71 @@
1
+ # Contracts::Rspec
2
+
3
+ Plugin for [contracts.ruby](https://github.com/egonSchiele/contracts.ruby/) that fixes issues with rspec-mocks.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'contracts-rspec'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install contracts-rspec
20
+
21
+ ## Usage
22
+
23
+ Just `require 'contracts/rspec'` and `include Contracts::RSpec::Mocks` into your example group and you will be able to use enhanced `instance_double`:
24
+
25
+ ```ruby
26
+ require 'contracts'
27
+ require 'contracts/rspec'
28
+
29
+ class Example
30
+ include Contracts
31
+
32
+ Contract Something => Any
33
+ def do_something(something)
34
+ something.do
35
+ end
36
+ end
37
+
38
+ RSpec.describe Example do
39
+ # If you not include this, you will get ContractError, telling you
40
+ # that `RSpec::Mocks::InstanceVerifyingDouble` is not a `Something`.
41
+ include Contracts::RSpec::Mocks
42
+
43
+ subject(:example) { Example.new }
44
+ let(:something) { instance_double(Something) }
45
+
46
+ it "works" do
47
+ expect { example.do_something(something) }.not_to raise_error
48
+ end
49
+ end
50
+ ```
51
+
52
+ ## How it works
53
+
54
+ When you `include Contracts::RSpec::Mocks`, you basically make your `instance_double` calls additionally stub out `:is_a?` message, when received with specified class to return true. Which makes contract succeed.
55
+
56
+ You can do it yourself simply:
57
+
58
+ ```ruby
59
+ something = instance_double(Something)
60
+ allow(something).to receive(:is_a?).with(Something).and_return(true)
61
+ ```
62
+
63
+ This library only provides a shortcut.
64
+
65
+ ## Contributing
66
+
67
+ 1. Fork it ( https://github.com/waterlink/contracts-rspec/fork )
68
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
69
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
70
+ 4. Push to the branch (`git push origin my-new-feature`)
71
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'contracts/rspec/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "contracts-rspec"
8
+ spec.version = Contracts::Rspec::VERSION
9
+ spec.authors = ["Oleksii Fedorov"]
10
+ spec.email = ["waterlink000@gmail.com"]
11
+ spec.summary = %q{Plugin for contracts.ruby that fixes issues with rspec-mocks.}
12
+ spec.description = %q{Plugin for contracts.ruby that fixes issues with rspec-mocks.}
13
+ spec.homepage = "https://github.com/waterlink/contracts-rspec"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
@@ -0,0 +1,5 @@
1
+ module Contracts
2
+ module Rspec
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require "contracts/rspec/version"
2
+
3
+ module Contracts
4
+ module Rspec
5
+ # Your code goes here...
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: contracts-rspec
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Oleksii Fedorov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Plugin for contracts.ruby that fixes issues with rspec-mocks.
42
+ email:
43
+ - waterlink000@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - contracts-rspec.gemspec
54
+ - lib/contracts/rspec.rb
55
+ - lib/contracts/rspec/version.rb
56
+ homepage: https://github.com/waterlink/contracts-rspec
57
+ licenses:
58
+ - MIT
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.2.2
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Plugin for contracts.ruby that fixes issues with rspec-mocks.
80
+ test_files: []