contracts-rspec 0.0.1 → 0.1.0

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: 430b7140836d0655122d1f2aa0b6f296f4127e31
4
- data.tar.gz: f243c16f6e8df68da950ecda2b780f761ed1be6d
3
+ metadata.gz: 1528141ebd5cbb253829fab70250c9755c743537
4
+ data.tar.gz: 60a75b31482c53037d9dbb26e2e48bb5f3731081
5
5
  SHA512:
6
- metadata.gz: a86748d0711ea06d3ff9411e365c6e5a980c9bffb4b8ea6b09df8d44d7598735d13c43e456c477a3b804bd40a1d60106500a2a11c8a3c357d33050b9bccfc1d5
7
- data.tar.gz: 1b7833ab2a192423d05f6816ceca25464fae8d05e298b1eea0f86e9d2c5ea43e4fa62047695bf47b4e969200a33e7b22b7bc690657b5a9ff56dea63973648222
6
+ metadata.gz: 483803f6a45f8313da364dddd62a68c8ae08fdb179037167ef150cdbf907819fdf468cc3d81dba601c25051de8315f96bf76b3822f01c626cd2bf762a60dbed1
7
+ data.tar.gz: f062000a4f3cdae27194ee1df4af83041cd19b0264c2e31fb1c1463c6d71f92475025a671856347a7e1ae5b1ba855a6317e7ce0fe28903bd18dea3124a723796
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile CHANGED
@@ -2,3 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in contracts-rspec.gemspec
4
4
  gemspec
5
+
6
+ gem "rspec"
7
+ gem "contracts"
data/README.md CHANGED
@@ -31,7 +31,7 @@ class Example
31
31
 
32
32
  Contract Something => Any
33
33
  def do_something(something)
34
- something.do
34
+ something.call
35
35
  end
36
36
  end
37
37
 
@@ -5,7 +5,7 @@ require 'contracts/rspec/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "contracts-rspec"
8
- spec.version = Contracts::Rspec::VERSION
8
+ spec.version = Contracts::RSpec::VERSION
9
9
  spec.authors = ["Oleksii Fedorov"]
10
10
  spec.email = ["waterlink000@gmail.com"]
11
11
  spec.summary = %q{Plugin for contracts.ruby that fixes issues with rspec-mocks.}
@@ -1,7 +1,8 @@
1
1
  require "contracts/rspec/version"
2
+ require "contracts/rspec/mocks"
2
3
 
3
4
  module Contracts
4
- module Rspec
5
+ module RSpec
5
6
  # Your code goes here...
6
7
  end
7
8
  end
@@ -0,0 +1,11 @@
1
+ module Contracts
2
+ module RSpec
3
+ module Mocks
4
+ def instance_double(klass, *args)
5
+ super.tap do |double|
6
+ allow(double).to receive(:is_a?).with(klass).and_return(true)
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  module Contracts
2
- module Rspec
3
- VERSION = "0.0.1"
2
+ module RSpec
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -0,0 +1,36 @@
1
+ class Something
2
+ include Contracts
3
+
4
+ Contract None => :something_is_done
5
+ def call
6
+ :something_is_done
7
+ end
8
+ end
9
+
10
+ class Example
11
+ include Contracts
12
+
13
+ Contract Something => :something_is_done
14
+ def do_something(something)
15
+ something.call
16
+ end
17
+ end
18
+
19
+ RSpec.describe Example do
20
+ let(:something) { instance_double(Something, call: :something_is_done) }
21
+
22
+ context "without Contracts::RSpec::Mocks included" do
23
+ it "violates contract" do
24
+ expect { Example.new.do_something(something) }
25
+ .to raise_error(ContractError, /Expected: Something/)
26
+ end
27
+ end
28
+
29
+ context "with Contracts::RSpec::Mocks included" do
30
+ include Contracts::RSpec::Mocks
31
+
32
+ it "succeeds contract" do
33
+ expect(Example.new.do_something(something)).to eq(:something_is_done)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,29 @@
1
+ require "contracts"
2
+ require "contracts/rspec"
3
+
4
+ RSpec.configure do |config|
5
+ config.expect_with :rspec do |expectations|
6
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
7
+ end
8
+
9
+ config.mock_with :rspec do |mocks|
10
+ mocks.verify_partial_doubles = true
11
+ end
12
+
13
+ config.filter_run :focus
14
+ config.run_all_when_everything_filtered = true
15
+
16
+ config.disable_monkey_patching!
17
+
18
+ config.warnings = false
19
+
20
+ if config.files_to_run.one?
21
+ config.default_formatter = 'doc'
22
+ end
23
+
24
+ config.profile_examples = 10
25
+
26
+ config.order = :random
27
+
28
+ Kernel.srand config.seed
29
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contracts-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleksii Fedorov
@@ -46,13 +46,17 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - ".gitignore"
49
+ - ".rspec"
49
50
  - Gemfile
50
51
  - LICENSE.txt
51
52
  - README.md
52
53
  - Rakefile
53
54
  - contracts-rspec.gemspec
54
55
  - lib/contracts/rspec.rb
56
+ - lib/contracts/rspec/mocks.rb
55
57
  - lib/contracts/rspec/version.rb
58
+ - spec/contracts/rspec/mocks_spec.rb
59
+ - spec/spec_helper.rb
56
60
  homepage: https://github.com/waterlink/contracts-rspec
57
61
  licenses:
58
62
  - MIT
@@ -77,4 +81,6 @@ rubygems_version: 2.2.2
77
81
  signing_key:
78
82
  specification_version: 4
79
83
  summary: Plugin for contracts.ruby that fixes issues with rspec-mocks.
80
- test_files: []
84
+ test_files:
85
+ - spec/contracts/rspec/mocks_spec.rb
86
+ - spec/spec_helper.rb