rspec-its 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +16 -9
- data/Changelog.md +7 -0
- data/Gemfile +9 -1
- data/README.md +49 -15
- data/features/its.feature +51 -0
- data/features/step_definitions/additional_cli_steps.rb +11 -0
- data/lib/rspec/its.rb +37 -4
- data/lib/rspec/its/version.rb +1 -1
- data/rspec-its.gemspec +11 -3
- data/script/test_all +8 -5
- data/script/update_rubygems_and_install_bundler +22 -0
- data/spec/rspec/its_spec.rb +145 -2
- metadata +16 -12
- data/cucumber.yml +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3cfe85990115a44650dbb9504dd24e6e420d16b3d238d605ae549996a6c13875
|
4
|
+
data.tar.gz: 0c51a50090b6e2259afddc89c53d80e5b04ad3a2f097c3a5ae396f9342d4710e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f985aeec4c6eff52cf67a5dfadf97d93ddca29637323b2cda6e6411b4d0606cd535209cfad8bf332c3120af2c811585919c533117c1f93c0b58a9e5c5db630f
|
7
|
+
data.tar.gz: 16d40f864a714c522ba2433995feaa2009d093f4543980fe4b5fbe01c7292d23abbfbba624ec64bdf0d7f1b30ae51158cd29219fa08ce2373d7eb06849a346f7
|
data/.travis.yml
CHANGED
@@ -1,24 +1,31 @@
|
|
1
1
|
language: ruby
|
2
2
|
script: "script/test_all"
|
3
|
+
email: false
|
4
|
+
before_install:
|
5
|
+
- script/update_rubygems_and_install_bundler
|
3
6
|
bundler_args: "--standalone --binstubs --without documentation"
|
4
7
|
rvm:
|
5
8
|
- 1.8.7
|
6
9
|
- 1.9.2
|
7
10
|
- 1.9.3
|
8
11
|
- 2.0.0
|
9
|
-
- 2.1
|
10
|
-
- 2.
|
11
|
-
- 2.
|
12
|
-
- 2.
|
12
|
+
- 2.1
|
13
|
+
- 2.2.10
|
14
|
+
- 2.3.8
|
15
|
+
- 2.4.5
|
16
|
+
- 2.5.3
|
17
|
+
- 2.6.0
|
13
18
|
- ruby-head
|
14
19
|
- ree
|
15
|
-
- jruby-
|
16
|
-
- jruby
|
20
|
+
- jruby-9.2.5.0
|
17
21
|
- jruby-head
|
18
|
-
-
|
22
|
+
- jruby-1.7.27
|
23
|
+
- rbx-3
|
24
|
+
env:
|
25
|
+
- JRUBY_OPTS='--dev'
|
19
26
|
matrix:
|
20
27
|
allow_failures:
|
21
28
|
- rvm: jruby-head
|
22
29
|
- rvm: ruby-head
|
23
|
-
- rvm: rbx
|
24
|
-
|
30
|
+
- rvm: rbx-3
|
31
|
+
fast_finish: true
|
data/Changelog.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
### 1.3.0 / 2019-04-09
|
2
|
+
[full changelog](http://github.com/rspec/rspec-its/compare/v1.2.0...v1.3.0)
|
3
|
+
|
4
|
+
Enhancements:
|
5
|
+
* Introduced `will` and `will_not` as to allow one line block expectations.
|
6
|
+
(Russ Buchanan, #67)
|
7
|
+
|
1
8
|
### 1.2.0 / 2015-02-06
|
2
9
|
[full changelog](http://github.com/rspec/rspec-its/compare/v1.1.0...v1.2.0)
|
3
10
|
|
data/Gemfile
CHANGED
@@ -6,7 +6,7 @@ gemspec
|
|
6
6
|
%w[rspec rspec-core rspec-expectations rspec-mocks rspec-support].each do |lib|
|
7
7
|
branch = ENV.fetch('BRANCH','3-1-maintenance')
|
8
8
|
library_path = File.expand_path("../../#{lib}", __FILE__)
|
9
|
-
if File.exist?(library_path)
|
9
|
+
if File.exist?(library_path) && !ENV['USE_GIT_REPOS']
|
10
10
|
gem lib, :path => library_path
|
11
11
|
else
|
12
12
|
gem lib, :git => "git://github.com/rspec/#{lib}.git",
|
@@ -14,6 +14,14 @@ gemspec
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
if RUBY_VERSION < '2.0.0' && !!(RbConfig::CONFIG['host_os'] =~ /cygwin|mswin|mingw|bccwin|wince|emx/)
|
18
|
+
gem 'ffi', '< 1.9.15' # allow ffi to be installed on older rubies on windows
|
19
|
+
elsif RUBY_VERSION < '1.9'
|
20
|
+
gem 'ffi', '< 1.9.19' # ffi dropped Ruby 1.8 support in 1.9.19
|
21
|
+
else
|
22
|
+
gem 'ffi', '~> 1.9.25'
|
23
|
+
end
|
24
|
+
|
17
25
|
# test coverage
|
18
26
|
# gem 'simplecov', :require => false
|
19
27
|
|
data/README.md
CHANGED
@@ -6,7 +6,9 @@ RSpec::Its provides the `its` method as a short-hand to specify the expected val
|
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
|
9
|
+
```ruby
|
10
|
+
gem 'rspec-its'
|
11
|
+
```
|
10
12
|
|
11
13
|
And then execute:
|
12
14
|
|
@@ -18,50 +20,82 @@ Or install it yourself as:
|
|
18
20
|
|
19
21
|
And require it as:
|
20
22
|
|
21
|
-
|
23
|
+
```ruby
|
24
|
+
require 'rspec/its'
|
25
|
+
```
|
22
26
|
|
23
27
|
## Usage
|
24
28
|
|
25
29
|
Use the `its` method to generate a nested example group with
|
26
30
|
a single example that specifies the expected value of an attribute of the
|
27
31
|
subject using `should`, `should_not` or `is_expected`.
|
32
|
+
The `its` method can also specify the block expectations of an attribute of the
|
33
|
+
subject using `will` or `will_not`.
|
28
34
|
|
29
35
|
`its` accepts a symbol or a string, and a block representing the example.
|
30
36
|
|
31
|
-
|
32
|
-
|
37
|
+
```ruby
|
38
|
+
its(:size) { should eq(1) }
|
39
|
+
its("length") { should eq(1) }
|
40
|
+
```
|
33
41
|
|
34
42
|
You can use a string with dots to specify a nested attribute (i.e. an
|
35
43
|
attribute of the attribute of the subject).
|
36
44
|
|
37
|
-
|
45
|
+
```ruby
|
46
|
+
its("phone_numbers.size") { should_not eq(0) }
|
47
|
+
```
|
38
48
|
|
39
49
|
The following expect-style method is also available:
|
40
50
|
|
41
|
-
|
42
|
-
|
51
|
+
```ruby
|
52
|
+
its(:size) { is_expected.to eq(1) }
|
53
|
+
```
|
54
|
+
|
43
55
|
as is this alias for pluralized use:
|
44
56
|
|
45
|
-
|
46
|
-
|
57
|
+
```ruby
|
58
|
+
its(:keys) { are_expected.to eq([:key1, :key2]) }
|
59
|
+
```
|
60
|
+
|
61
|
+
The following block expect-style method is also available:
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
its(:size) { will_not raise_error }
|
65
|
+
```
|
66
|
+
|
67
|
+
as is this alias for pluralized use:
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
its(:keys) { will raise_error(NoMethodError) }
|
71
|
+
```
|
72
|
+
|
47
73
|
When the subject implements the `[]` operator, you can pass in an array with a single key to
|
48
74
|
refer to the value returned by that operator when passed that key as an argument.
|
49
75
|
|
50
|
-
|
76
|
+
```ruby
|
77
|
+
its([:key]) { is_expected.to eq(value) }
|
78
|
+
```
|
51
79
|
|
52
80
|
For hashes, multiple keys within the array will result in successive accesses into the hash. For example:
|
53
81
|
|
54
|
-
|
55
|
-
|
82
|
+
```ruby
|
83
|
+
subject { {key1: {key2: 3} } }
|
84
|
+
its([:key1, :key2]) { is_expected.to eq(3) }
|
85
|
+
```
|
56
86
|
|
57
87
|
For other objects, multiple keys within the array will be passed as separate arguments in a single method call to [], as in:
|
58
88
|
|
59
|
-
|
60
|
-
|
89
|
+
```ruby
|
90
|
+
subject { Matrix[ [:a, :b], [:c, :d] ] }
|
91
|
+
its([1,1]) { should eq(:d) }
|
92
|
+
```
|
61
93
|
|
62
94
|
Metadata arguments are supported.
|
63
95
|
|
64
|
-
|
96
|
+
```ruby
|
97
|
+
its(:size, focus: true) { should eq(1) }
|
98
|
+
```
|
65
99
|
|
66
100
|
## Contributing
|
67
101
|
|
data/features/its.feature
CHANGED
@@ -123,3 +123,54 @@ Feature: attribute of subject
|
|
123
123
|
"""
|
124
124
|
When I run rspec specifying line number 2
|
125
125
|
Then the examples should all pass
|
126
|
+
|
127
|
+
Scenario: specify a method throws an expection
|
128
|
+
Given a file named "example_spec.rb" with:
|
129
|
+
"""ruby
|
130
|
+
class Klass
|
131
|
+
def foo
|
132
|
+
true
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
describe Klass do
|
137
|
+
subject { Klass.new }
|
138
|
+
its(:foo) { will_not raise_error }
|
139
|
+
its(:bar) { will raise_error(NoMethodError) }
|
140
|
+
end
|
141
|
+
"""
|
142
|
+
When I run rspec
|
143
|
+
Then the examples should all pass
|
144
|
+
|
145
|
+
Scenario: specify a method does not throw an expection
|
146
|
+
Given a file named "example_spec.rb" with:
|
147
|
+
"""ruby
|
148
|
+
class Klass; end
|
149
|
+
|
150
|
+
describe Klass do
|
151
|
+
subject { Klass.new }
|
152
|
+
its(:foo) { will_not raise_error }
|
153
|
+
end
|
154
|
+
"""
|
155
|
+
When I run rspec
|
156
|
+
Then the example should fail
|
157
|
+
And the output should contain "Failure/Error: its(:foo) { will_not raise_error }"
|
158
|
+
And the output should contain "expected no Exception, got #<NoMethodError: undefined method `foo'"
|
159
|
+
|
160
|
+
Scenario: examples will warn when using non block expectations
|
161
|
+
Given a file named "example_spec.rb" with:
|
162
|
+
"""ruby
|
163
|
+
class Klass
|
164
|
+
def terminator
|
165
|
+
"back"
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
describe Klass do
|
170
|
+
subject { Klass.new }
|
171
|
+
its(:terminator) { will be("back") }
|
172
|
+
end
|
173
|
+
"""
|
174
|
+
When I run rspec
|
175
|
+
Then the example should fail
|
176
|
+
And the output should contain "ArgumentError:" and "`will` only supports block expectations"
|
@@ -19,3 +19,14 @@ Then /^the example(?:s)? should(?: all)? pass$/ do
|
|
19
19
|
step %q{the output should not contain "0 examples"}
|
20
20
|
step %q{the exit status should be 0}
|
21
21
|
end
|
22
|
+
|
23
|
+
Then(/^the example should fail$/) do
|
24
|
+
step %q{the output should contain "1 failure"}
|
25
|
+
step %q{the exit status should not be 0}
|
26
|
+
end
|
27
|
+
|
28
|
+
Then(/^the output should contain "(.*?)" and "(.*?)"$/) do |string1, string2|
|
29
|
+
unless [string1, string2].all? { |s| all_output.include?(s) }
|
30
|
+
fail %Q{Both "#{string1}" and "#{string2}" were found in:\n#{all_output}}
|
31
|
+
end
|
32
|
+
end
|
data/lib/rspec/its.rb
CHANGED
@@ -55,13 +55,14 @@ module RSpec
|
|
55
55
|
# its(['admin']) { should eq(:all_permissions) }
|
56
56
|
# its(['john_doe', :permissions]) { should eq([:read, :write]) }
|
57
57
|
#
|
58
|
-
# # You can still access
|
58
|
+
# # You can still access its regular methods this way:
|
59
59
|
# its(:keys) { should include(:max_users) }
|
60
60
|
# its(:count) { should eq(2) }
|
61
61
|
# end
|
62
62
|
#
|
63
63
|
# With an implicit subject, `is_expected` can be used as an alternative
|
64
|
-
# to `should` (e.g. for one-liner use)
|
64
|
+
# to `should` (e.g. for one-liner use). An `are_expected` alias is also
|
65
|
+
# supplied.
|
65
66
|
#
|
66
67
|
# @example
|
67
68
|
#
|
@@ -69,8 +70,26 @@ module RSpec
|
|
69
70
|
# its(:size) { is_expected.to eq(0) }
|
70
71
|
# end
|
71
72
|
#
|
72
|
-
#
|
73
|
-
#
|
73
|
+
# With an implicit subject, `will` can be used as an alternative
|
74
|
+
# to `expect { subject.attribute }.to matcher` (e.g. for one-liner use).
|
75
|
+
#
|
76
|
+
# @example
|
77
|
+
#
|
78
|
+
# describe Array do
|
79
|
+
# its(:foo) { will raise_error(NoMethodError) }
|
80
|
+
# end
|
81
|
+
#
|
82
|
+
# With an implicit subject, `will_not` can be used as an alternative
|
83
|
+
# to `expect { subject.attribute }.to_not matcher` (e.g. for one-liner use).
|
84
|
+
#
|
85
|
+
# @example
|
86
|
+
#
|
87
|
+
# describe Array do
|
88
|
+
# its(:size) { will_not raise_error }
|
89
|
+
# end
|
90
|
+
#
|
91
|
+
# You can pass more than one argument on the `its` block to add
|
92
|
+
# some metadata to the generated example
|
74
93
|
#
|
75
94
|
# @example
|
76
95
|
#
|
@@ -122,6 +141,20 @@ module RSpec
|
|
122
141
|
end
|
123
142
|
alias_method :are_expected, :is_expected
|
124
143
|
|
144
|
+
def will(matcher=nil, message=nil)
|
145
|
+
unless matcher.supports_block_expectations?
|
146
|
+
raise ArgumentError, "`will` only supports block expectations"
|
147
|
+
end
|
148
|
+
expect { __its_subject }.to matcher, message
|
149
|
+
end
|
150
|
+
|
151
|
+
def will_not(matcher=nil, message=nil)
|
152
|
+
unless matcher.supports_block_expectations?
|
153
|
+
raise ArgumentError, "`will_not` only supports block expectations"
|
154
|
+
end
|
155
|
+
expect { __its_subject }.to_not matcher, message
|
156
|
+
end
|
157
|
+
|
125
158
|
def should(matcher=nil, message=nil)
|
126
159
|
RSpec::Expectations::PositiveExpectationHandler.handle_matcher(__its_subject, matcher, message)
|
127
160
|
end
|
data/lib/rspec/its/version.rb
CHANGED
data/rspec-its.gemspec
CHANGED
@@ -13,16 +13,24 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "https://github.com/rspec/rspec-its"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
-
spec.
|
16
|
+
spec.metadata = {
|
17
|
+
'bug_tracker_uri' => 'https://github.com/rspec/rspec-its/issues',
|
18
|
+
'changelog_uri' => "https://github.com/rspec/rspec-its/blob/v#{spec.version}/Changelog.md",
|
19
|
+
'documentation_uri' => "https://www.rubydoc.info/gems/rspec-its/#{spec.version}",
|
20
|
+
'mailing_list_uri' => 'https://groups.google.com/forum/#!forum/rspec',
|
21
|
+
'source_code_uri' => 'https://github.com/rspec/rspec-its',
|
22
|
+
}
|
23
|
+
|
24
|
+
spec.files = `git ls-files`.split($/) - %w[cucumber.yml]
|
17
25
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
26
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
27
|
spec.require_paths = ["lib"]
|
20
28
|
|
21
29
|
spec.add_runtime_dependency 'rspec-core', '>= 3.0.0'
|
22
30
|
spec.add_runtime_dependency 'rspec-expectations', '>= 3.0.0'
|
23
|
-
spec.add_development_dependency 'bundler', '
|
31
|
+
spec.add_development_dependency 'bundler', '> 1.3.0'
|
24
32
|
spec.add_development_dependency 'rake', '~> 10.1.0'
|
25
33
|
spec.add_development_dependency 'cucumber', '~> 1.3.8'
|
26
|
-
spec.add_development_dependency
|
34
|
+
spec.add_development_dependency "aruba", "~> 0.6.2" # 0.7 is broken on ruby 1.8.7
|
27
35
|
|
28
36
|
end
|
data/script/test_all
CHANGED
@@ -13,8 +13,11 @@ echo "Running rspec specs"
|
|
13
13
|
bin/rspec spec --format progress --profile
|
14
14
|
|
15
15
|
echo "Running cucumber specs"
|
16
|
-
|
17
|
-
|
18
|
-
#
|
19
|
-
|
20
|
-
bundle exec cucumber
|
16
|
+
|
17
|
+
if ruby -e "exit(defined?(RUBY_PLATFORM) && RUBY_PLATFORM == 'java')"; then
|
18
|
+
# This is JRUBY which requires this one weird path trick...
|
19
|
+
PATH="${PWD}/bin:$PATH" \
|
20
|
+
bundle exec cucumber --strict
|
21
|
+
else
|
22
|
+
bundle exec cucumber --strict
|
23
|
+
fi;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
# This file was generated on 2019-01-03T20:34:23+00:00 from the rspec-dev repo.
|
3
|
+
# DO NOT modify it by hand as your changes will get lost the next time it is generated.
|
4
|
+
|
5
|
+
set -e
|
6
|
+
|
7
|
+
function is_ruby_23_plus {
|
8
|
+
if ruby -e "exit(RUBY_VERSION.to_f >= 2.3)"; then
|
9
|
+
return 0
|
10
|
+
else
|
11
|
+
return 1
|
12
|
+
fi
|
13
|
+
}
|
14
|
+
|
15
|
+
if is_ruby_23_plus; then
|
16
|
+
gem update --system
|
17
|
+
gem install bundler
|
18
|
+
else
|
19
|
+
echo "Warning installing older versions of Rubygems / Bundler"
|
20
|
+
gem update --system '2.7.8'
|
21
|
+
gem install bundler -v '1.17.3'
|
22
|
+
fi
|
data/spec/rspec/its_spec.rb
CHANGED
@@ -55,7 +55,11 @@ module RSpec
|
|
55
55
|
end
|
56
56
|
its("name") { should eq("John") }
|
57
57
|
its("name.size") { should eq(4) }
|
58
|
-
|
58
|
+
if RUBY_VERSION >= "2.4.0"
|
59
|
+
its("name.size.class") { should eq(Integer) }
|
60
|
+
else
|
61
|
+
its("name.size.class") { should eq(Fixnum) }
|
62
|
+
end
|
59
63
|
|
60
64
|
context "using should_not" do
|
61
65
|
its("name") { should_not eq("Paul") }
|
@@ -65,6 +69,10 @@ module RSpec
|
|
65
69
|
its("name") { is_expected.to eq("John") }
|
66
70
|
end
|
67
71
|
|
72
|
+
context "using will_not" do
|
73
|
+
its("name") { will_not raise_error }
|
74
|
+
end
|
75
|
+
|
68
76
|
context "using are_expected" do
|
69
77
|
its("name.chars.to_a") { are_expected.to eq(%w[J o h n]) }
|
70
78
|
end
|
@@ -86,7 +94,11 @@ module RSpec
|
|
86
94
|
end
|
87
95
|
its([:a]) { should eq("Symbol: a") }
|
88
96
|
its(['a']) { should eq("String: a") }
|
89
|
-
|
97
|
+
if RUBY_VERSION >= "2.4.0"
|
98
|
+
its([:b, 'c', 4]) { should eq("Symbol: b; String: c; Integer: 4") }
|
99
|
+
else
|
100
|
+
its([:b, 'c', 4]) { should eq("Symbol: b; String: c; Fixnum: 4") }
|
101
|
+
end
|
90
102
|
its(:name) { should eq("George") }
|
91
103
|
context "when referring to an attribute that doesn't exist" do
|
92
104
|
context "it raises an error" do
|
@@ -95,6 +107,10 @@ module RSpec
|
|
95
107
|
should eq(64)
|
96
108
|
end.to raise_error(NoMethodError)
|
97
109
|
end
|
110
|
+
|
111
|
+
context "using will" do
|
112
|
+
its(:age) { will raise_error(NoMethodError) }
|
113
|
+
end
|
98
114
|
end
|
99
115
|
end
|
100
116
|
|
@@ -109,6 +125,10 @@ module RSpec
|
|
109
125
|
its([:not_here]) { should be_nil }
|
110
126
|
its([:a, :ghost]) { should be_nil }
|
111
127
|
its([:deep, :ghost]) { expect { should eq("missing") }.to raise_error(NoMethodError) }
|
128
|
+
|
129
|
+
context "using will" do
|
130
|
+
its([:deep, :ghost]) { will raise_error(NoMethodError) }
|
131
|
+
end
|
112
132
|
end
|
113
133
|
end
|
114
134
|
end
|
@@ -122,6 +142,10 @@ module RSpec
|
|
122
142
|
should eq("Symbol: a")
|
123
143
|
end.to raise_error(NoMethodError)
|
124
144
|
end
|
145
|
+
|
146
|
+
context "using will" do
|
147
|
+
its([:a]) { will raise_error(NoMethodError) }
|
148
|
+
end
|
125
149
|
end
|
126
150
|
end
|
127
151
|
|
@@ -232,6 +256,125 @@ module RSpec
|
|
232
256
|
end
|
233
257
|
end
|
234
258
|
end
|
259
|
+
|
260
|
+
context "when expecting errors" do
|
261
|
+
subject do
|
262
|
+
Class.new do
|
263
|
+
def good; end
|
264
|
+
|
265
|
+
def bad
|
266
|
+
raise ArgumentError, "message"
|
267
|
+
end
|
268
|
+
end.new
|
269
|
+
end
|
270
|
+
|
271
|
+
its(:good) { will_not raise_error }
|
272
|
+
its(:bad) { will raise_error }
|
273
|
+
its(:bad) { will raise_error(ArgumentError) }
|
274
|
+
its(:bad) { will raise_error("message") }
|
275
|
+
its(:bad) { will raise_error(ArgumentError, "message") }
|
276
|
+
end
|
277
|
+
|
278
|
+
context "when expecting throws" do
|
279
|
+
subject do
|
280
|
+
Class.new do
|
281
|
+
def good; end
|
282
|
+
|
283
|
+
def bad
|
284
|
+
throw :abort, "message"
|
285
|
+
end
|
286
|
+
end.new
|
287
|
+
end
|
288
|
+
|
289
|
+
its(:good) { will_not throw_symbol }
|
290
|
+
its(:bad) { will throw_symbol }
|
291
|
+
its(:bad) { will throw_symbol(:abort) }
|
292
|
+
its(:bad) { will throw_symbol(:abort, "message") }
|
293
|
+
end
|
294
|
+
|
295
|
+
context "with change observation" do
|
296
|
+
subject do
|
297
|
+
Class.new do
|
298
|
+
attr_reader :count
|
299
|
+
|
300
|
+
def initialize
|
301
|
+
@count = 0
|
302
|
+
end
|
303
|
+
|
304
|
+
def increment
|
305
|
+
@count += 1
|
306
|
+
end
|
307
|
+
|
308
|
+
def noop; end
|
309
|
+
end.new
|
310
|
+
end
|
311
|
+
|
312
|
+
its(:increment) { will change { subject.count }.by(1) }
|
313
|
+
its(:increment) { will change { subject.count }.from(0) }
|
314
|
+
its(:increment) { will change { subject.count }.from(0).to(1) }
|
315
|
+
its(:increment) { will change { subject.count }.by_at_least(1) }
|
316
|
+
its(:increment) { will change { subject.count }.by_at_most(1) }
|
317
|
+
|
318
|
+
its(:noop) { will_not change { subject.count } }
|
319
|
+
its(:noop) { will_not change { subject.count }.from(0) }
|
320
|
+
|
321
|
+
its(:increment) do
|
322
|
+
expect { will_not change { subject.count }.by(0) }.to \
|
323
|
+
raise_error(NotImplementedError, '`expect { }.not_to change { }.by()` is not supported')
|
324
|
+
end
|
325
|
+
|
326
|
+
its(:increment) do
|
327
|
+
expect { will_not change { subject.count }.by_at_least(2) }.to \
|
328
|
+
raise_error(NotImplementedError, '`expect { }.not_to change { }.by_at_least()` is not supported')
|
329
|
+
end
|
330
|
+
|
331
|
+
its(:increment) do
|
332
|
+
expect { will_not change { subject.count }.by_at_most(3) }.to \
|
333
|
+
raise_error(NotImplementedError, '`expect { }.not_to change { }.by_at_most()` is not supported')
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
context "with output capture" do
|
338
|
+
subject do
|
339
|
+
Class.new do
|
340
|
+
def stdout
|
341
|
+
print "some output"
|
342
|
+
end
|
343
|
+
|
344
|
+
def stderr
|
345
|
+
$stderr.print "some error"
|
346
|
+
end
|
347
|
+
|
348
|
+
def noop; end
|
349
|
+
end.new
|
350
|
+
end
|
351
|
+
|
352
|
+
its(:stdout) { will output("some output").to_stdout }
|
353
|
+
its(:stderr) { will output("some error").to_stderr }
|
354
|
+
|
355
|
+
its(:noop) { will_not output("some error").to_stderr }
|
356
|
+
its(:noop) { will_not output("some output").to_stdout }
|
357
|
+
end
|
358
|
+
|
359
|
+
context "#will with non block expectations" do
|
360
|
+
subject do
|
361
|
+
Class.new do
|
362
|
+
def terminator
|
363
|
+
"back"
|
364
|
+
end
|
365
|
+
end.new
|
366
|
+
end
|
367
|
+
|
368
|
+
its(:terminator) do
|
369
|
+
expect { will be("back") }.to \
|
370
|
+
raise_error(ArgumentError, '`will` only supports block expectations')
|
371
|
+
end
|
372
|
+
|
373
|
+
its(:terminator) do
|
374
|
+
expect { will_not be("back") }.to \
|
375
|
+
raise_error(ArgumentError, '`will_not` only supports block expectations')
|
376
|
+
end
|
377
|
+
end
|
235
378
|
end
|
236
379
|
end
|
237
380
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-its
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Alfvin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec-core
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 1.3.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:
|
54
|
+
version: 1.3.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 0.6.2
|
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:
|
96
|
+
version: 0.6.2
|
97
97
|
description: RSpec extension gem for attribute matching
|
98
98
|
email:
|
99
99
|
- palfvin@gmail.com
|
@@ -109,7 +109,6 @@ files:
|
|
109
109
|
- LICENSE.txt
|
110
110
|
- README.md
|
111
111
|
- Rakefile
|
112
|
-
- cucumber.yml
|
113
112
|
- features/its.feature
|
114
113
|
- features/step_definitions/additional_cli_steps.rb
|
115
114
|
- features/support/env.rb
|
@@ -117,12 +116,18 @@ files:
|
|
117
116
|
- lib/rspec/its/version.rb
|
118
117
|
- rspec-its.gemspec
|
119
118
|
- script/test_all
|
119
|
+
- script/update_rubygems_and_install_bundler
|
120
120
|
- spec/rspec/its_spec.rb
|
121
121
|
- spec/spec_helper.rb
|
122
122
|
homepage: https://github.com/rspec/rspec-its
|
123
123
|
licenses:
|
124
124
|
- MIT
|
125
|
-
metadata:
|
125
|
+
metadata:
|
126
|
+
bug_tracker_uri: https://github.com/rspec/rspec-its/issues
|
127
|
+
changelog_uri: https://github.com/rspec/rspec-its/blob/v1.3.0/Changelog.md
|
128
|
+
documentation_uri: https://www.rubydoc.info/gems/rspec-its/1.3.0
|
129
|
+
mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
|
130
|
+
source_code_uri: https://github.com/rspec/rspec-its
|
126
131
|
post_install_message:
|
127
132
|
rdoc_options: []
|
128
133
|
require_paths:
|
@@ -138,8 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
143
|
- !ruby/object:Gem::Version
|
139
144
|
version: '0'
|
140
145
|
requirements: []
|
141
|
-
|
142
|
-
rubygems_version: 2.4.3
|
146
|
+
rubygems_version: 3.0.3
|
143
147
|
signing_key:
|
144
148
|
specification_version: 4
|
145
149
|
summary: Provides "its" method formerly part of rspec-core
|
data/cucumber.yml
DELETED