contracts-rspec 0.0.1 → 0.1.0
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 +4 -4
- data/.rspec +2 -0
- data/Gemfile +3 -0
- data/README.md +1 -1
- data/contracts-rspec.gemspec +1 -1
- data/lib/contracts/rspec.rb +2 -1
- data/lib/contracts/rspec/mocks.rb +11 -0
- data/lib/contracts/rspec/version.rb +2 -2
- data/spec/contracts/rspec/mocks_spec.rb +36 -0
- data/spec/spec_helper.rb +29 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1528141ebd5cbb253829fab70250c9755c743537
|
4
|
+
data.tar.gz: 60a75b31482c53037d9dbb26e2e48bb5f3731081
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 483803f6a45f8313da364dddd62a68c8ae08fdb179037167ef150cdbf907819fdf468cc3d81dba601c25051de8315f96bf76b3822f01c626cd2bf762a60dbed1
|
7
|
+
data.tar.gz: f062000a4f3cdae27194ee1df4af83041cd19b0264c2e31fb1c1463c6d71f92475025a671856347a7e1ae5b1ba855a6317e7ce0fe28903bd18dea3124a723796
|
data/.rspec
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
data/contracts-rspec.gemspec
CHANGED
@@ -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::
|
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.}
|
data/lib/contracts/rspec.rb
CHANGED
@@ -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
|
data/spec/spec_helper.rb
ADDED
@@ -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
|
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
|