dryspec 0.1.1 → 0.2.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
- SHA1:
3
- metadata.gz: 86d5786cc24a5f8ff16e60a244b370d657356106
4
- data.tar.gz: fcb9867e8779b528ad8452f48a1da114381956cb
2
+ SHA256:
3
+ metadata.gz: 659e72601dbaa9734f5e7fc828a08622a193c5d3df8a4aa133396924854e64e6
4
+ data.tar.gz: 673a7246fc887519e1e7485f4f93f898393ee0fb615ab22286295c5d22804fa4
5
5
  SHA512:
6
- metadata.gz: d73cd73b915be44f1f42f64f735cf6668b66fa836b2142dfd76637849756c6d4ef4bc8d7b77351215c41796b5b07fd9b5ecf907cfc8a24065dadee2cb7ac3486
7
- data.tar.gz: df876741d6edd5cea736e2598b6c922c6f40ae324d1bd5c63f29a0a21ffb75d25f7542350056e43093a6576362370eb2e77af62515c6abc240d5e6103ab43af9
6
+ metadata.gz: ac5fd0a33a14448352847ff269ee32f8124441ddb834b3eb5783b2f05631b281ce14152121355276b7967d87b0e0f2cd9ec593902e12e42d6c469248259d16c1
7
+ data.tar.gz: 7189e61bf5dd333ccb7c3c00814550ad60241bc5c47bf92fc7c08b889b15b67831ceec0acdd6a0e5a36d8028917fca60b19ce215314767d8f65c0aeecc0af2bd
@@ -3,3 +3,6 @@ language: ruby
3
3
  rvm:
4
4
  - 2.3.1
5
5
  before_install: gem install bundler -v 1.14.6
6
+ script:
7
+ - rubocop -D
8
+ - rspec -fd
data/README.md CHANGED
@@ -55,6 +55,32 @@ By default when you give `let_context` a `Hash`, the `#inspect` of the `Hash` be
55
55
  let_context('Negative number', value: -1) { it { should eq 1 } }
56
56
  let_context('Big negative number', value: -10) { it { should eq -8 } }
57
57
 
58
+ ### `subject_for`
59
+
60
+ A shortcut for a combination of `context` and `subject`
61
+
62
+ let(:foo) { 55 }
63
+ let(:bar) { 66 }
64
+
65
+ # Before
66
+ context 'subject: foo' do
67
+ subject { foo }
68
+
69
+ it { should eq(55) }
70
+ end
71
+
72
+ context 'subject: bar' do
73
+ subject { bar }
74
+
75
+ it { should eq(66) }
76
+ end
77
+
78
+ # After
79
+ for_subject(:foo) { it { should eq(55) } }
80
+ for_subject(:bar) { it { should eq(66) } }
81
+
82
+ In the above the before and after are equivilent. The `for_subject` helper automatically generates a context with the string `"subject: #{argument}"`.
83
+
58
84
  ### `subject_should_(not_)raise`
59
85
 
60
86
  The `subject_should_raise` and `subject_should_not_raise` are simply helpers which allow you to create an RSpec example which asserts if the subject of your tests will raise an exception. For example:
@@ -1,6 +1,4 @@
1
- # coding: utf-8
2
-
3
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
4
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
3
  require 'dryspec/version'
6
4
 
@@ -23,10 +21,10 @@ Gem::Specification.new do |spec|
23
21
  spec.require_paths = ['lib']
24
22
 
25
23
  spec.add_development_dependency 'bundler', '~> 1.14'
24
+ spec.add_development_dependency 'guard-rspec', '~> 4.7.3'
25
+ spec.add_development_dependency 'guard-rubocop', '~> 1.2.0'
26
+ spec.add_development_dependency 'guard-yard', '~> 2.2.0'
26
27
  spec.add_development_dependency 'rake', '~> 10.0'
27
28
  spec.add_development_dependency 'rspec', '~> 3.0'
28
- spec.add_development_dependency 'guard-rubocop', '~> 1.2.0'
29
29
  spec.add_development_dependency 'yard', '~> 0.9.9'
30
- spec.add_development_dependency 'guard-yard', '~> 2.2.0'
31
- spec.add_development_dependency 'guard-rspec', '~> 4.7.3'
32
30
  end
@@ -100,5 +100,36 @@ module DRYSpec
100
100
  expect { subject }.not_to raise_error error, message
101
101
  end
102
102
  end
103
+
104
+ # A shortcut for a combination of `context` and `subject`
105
+ #
106
+ # @example Multiple subjects from let variables
107
+ #
108
+ # let(:foo) { 55 }
109
+ # let(:bar) { 66 }
110
+ #
111
+ # # Before
112
+ # context 'subject: foo' do
113
+ # subject { foo }
114
+ #
115
+ # it { should eq(55) }
116
+ # end
117
+ #
118
+ # context 'subject: bar' do
119
+ # subject { bar }
120
+ #
121
+ # it { should eq(66) }
122
+ # end
123
+ #
124
+ # # After
125
+ # for_subject(:foo) { it { should eq(55) } }
126
+ # for_subject(:bar) { it { should eq(66) } }
127
+ def for_subject(variable, &block)
128
+ context "subject: #{variable}" do
129
+ subject { send(variable) }
130
+
131
+ instance_eval(&block)
132
+ end
133
+ end
103
134
  end
104
135
  end
@@ -1,3 +1,3 @@
1
1
  module DRYSpec
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dryspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Team Northwoods
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-24 00:00:00.000000000 Z
11
+ date: 2018-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -25,89 +25,89 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.14'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: guard-rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: 4.7.3
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: 4.7.3
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec
42
+ name: guard-rubocop
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.0'
47
+ version: 1.2.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.0'
54
+ version: 1.2.0
55
55
  - !ruby/object:Gem::Dependency
56
- name: guard-rubocop
56
+ name: guard-yard
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.2.0
61
+ version: 2.2.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.2.0
68
+ version: 2.2.0
69
69
  - !ruby/object:Gem::Dependency
70
- name: yard
70
+ name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.9.9
75
+ version: '10.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.9.9
82
+ version: '10.0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: guard-yard
84
+ name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 2.2.0
89
+ version: '3.0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 2.2.0
96
+ version: '3.0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: guard-rspec
98
+ name: yard
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 4.7.3
103
+ version: 0.9.9
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 4.7.3
110
+ version: 0.9.9
111
111
  description: A Ruby gem to introduce RSpec helpers which can help you DRY up your
112
112
  specs
113
113
  email:
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  version: '0'
153
153
  requirements: []
154
154
  rubyforge_project:
155
- rubygems_version: 2.6.8
155
+ rubygems_version: 2.7.7
156
156
  signing_key:
157
157
  specification_version: 4
158
158
  summary: A Ruby gem to introduce RSpec helpers which can help you DRY up your specs