rspec-must 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.
- data/.gitignore +2 -0
- data/Gemfile +3 -0
- data/LICENSE +23 -0
- data/README.md +34 -0
- data/features/must.feature +59 -0
- data/features/must_receive.feature +39 -0
- data/features/steps/rspec_steps.rb +17 -0
- data/features/support/env.rb +1 -0
- data/lib/rspec/must.rb +2 -0
- data/lib/rspec/must/extensions.rb +1 -0
- data/lib/rspec/must/extensions/kernel.rb +4 -0
- data/lib/rspec/must/mocks.rb +1 -0
- data/lib/rspec/must/mocks/methods.rb +7 -0
- data/lib/rspec/must/version.rb +5 -0
- data/rspec-must.gemspec +26 -0
- data/spec/rspec/expectations/extensions/kernel_spec.rb +15 -0
- data/spec/rspec/mocks/methods_spec.rb +10 -0
- data/spec/spec_helper.rb +2 -0
- metadata +97 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright 2011 Thibault Jouan. All rights reserved.
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
4
|
+
modification, are permitted provided that the following conditions are met:
|
5
|
+
* Redistributions of source code must retain the above copyright notice, this
|
6
|
+
list of conditions and the following disclaimer.
|
7
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
8
|
+
this list of conditions and the following disclaimer in the documentation
|
9
|
+
and/or other materials provided with the distribution.
|
10
|
+
* Neither the name of the software nor the names of its contributors may be
|
11
|
+
used to endorse or promote products derived from this software without
|
12
|
+
specific prior written permission.
|
13
|
+
|
14
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS "AS IS" AND ANY
|
15
|
+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
16
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
17
|
+
DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY
|
18
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
19
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
20
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
21
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
22
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
23
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
rspec-must
|
2
|
+
==========
|
3
|
+
|
4
|
+
rspec-must allows you to use #must instead of #should instance method
|
5
|
+
in your specs. Currently it also provides #must_not and #must_receive,
|
6
|
+
respectively aliased on #should_not and #should_receive.
|
7
|
+
|
8
|
+
Using "should" verb in specs may feel "wrong" to you. Especially if
|
9
|
+
you are used to reading or implementing RFC, you will know about
|
10
|
+
RFC 2119.
|
11
|
+
|
12
|
+
|
13
|
+
Usage
|
14
|
+
-----
|
15
|
+
|
16
|
+
You need to require 'rspec' in your spec_helper *before* requiring
|
17
|
+
'rspec/must' because rspec-must reopen a module created by
|
18
|
+
rspec-mocks:
|
19
|
+
|
20
|
+
require 'rspec'
|
21
|
+
require 'rspec/must'
|
22
|
+
|
23
|
+
#must* methods will be available where equivalent #should* methods
|
24
|
+
are.
|
25
|
+
|
26
|
+
|
27
|
+
Installation
|
28
|
+
------------
|
29
|
+
|
30
|
+
rspec-must is a ruby gem, so you can use rubygems:
|
31
|
+
|
32
|
+
gem install rspec-must
|
33
|
+
|
34
|
+
Or if you use bundler, add it to your Gemfile.
|
@@ -0,0 +1,59 @@
|
|
1
|
+
Feature: must
|
2
|
+
|
3
|
+
So that I can write accurate specifications
|
4
|
+
As an RSpec user
|
5
|
+
I want to be able to use #must instead of #should
|
6
|
+
|
7
|
+
Scenario: #must with matching matcher
|
8
|
+
Given a file named "must_matching_spec.rb" with:
|
9
|
+
"""
|
10
|
+
require 'rspec'
|
11
|
+
require 'rspec/must'
|
12
|
+
|
13
|
+
describe true do
|
14
|
+
it { must be_true }
|
15
|
+
end
|
16
|
+
"""
|
17
|
+
When I run `rspec must_matching_spec.rb`
|
18
|
+
Then the example must pass
|
19
|
+
|
20
|
+
Scenario: #must with non-matching matcher
|
21
|
+
Given a file named "must_non-matching_spec.rb" with:
|
22
|
+
"""
|
23
|
+
require 'rspec'
|
24
|
+
require 'rspec/must'
|
25
|
+
|
26
|
+
describe true do
|
27
|
+
it { must be_false }
|
28
|
+
end
|
29
|
+
"""
|
30
|
+
When I run `rspec must_non-matching_spec.rb`
|
31
|
+
Then the example must fail
|
32
|
+
And the output must match /expected.+to be false/
|
33
|
+
|
34
|
+
Scenario: #must_not with matching matcher
|
35
|
+
Given a file named "must_not_matching_spec.rb" with:
|
36
|
+
"""
|
37
|
+
require 'rspec'
|
38
|
+
require 'rspec/must'
|
39
|
+
|
40
|
+
describe true do
|
41
|
+
it { must_not be_false }
|
42
|
+
end
|
43
|
+
"""
|
44
|
+
When I run `rspec must_not_matching_spec.rb`
|
45
|
+
Then the example must pass
|
46
|
+
|
47
|
+
Scenario: #must_not with non-matching matcher
|
48
|
+
Given a file named "must_not_non-matching_spec.rb" with:
|
49
|
+
"""
|
50
|
+
require 'rspec'
|
51
|
+
require 'rspec/must'
|
52
|
+
|
53
|
+
describe true do
|
54
|
+
it { must_not be_true }
|
55
|
+
end
|
56
|
+
"""
|
57
|
+
When I run `rspec must_not_non-matching_spec.rb`
|
58
|
+
Then the example must fail
|
59
|
+
And the output must match /expected.+to be true/
|
@@ -0,0 +1,39 @@
|
|
1
|
+
Feature: must_receive
|
2
|
+
|
3
|
+
So that I can write accurate specifications
|
4
|
+
As an RSpec user
|
5
|
+
I want to be able to use #must_receive instead of #should_receive
|
6
|
+
|
7
|
+
Scenario: #must_receive when expectation is met
|
8
|
+
Given a file named "must_receive_met_spec.rb" with:
|
9
|
+
"""
|
10
|
+
require 'rspec'
|
11
|
+
require 'rspec/must'
|
12
|
+
|
13
|
+
describe Object do
|
14
|
+
it 'receives a message' do
|
15
|
+
o = double('object')
|
16
|
+
o.must_receive :class
|
17
|
+
o.class
|
18
|
+
end
|
19
|
+
end
|
20
|
+
"""
|
21
|
+
When I run `rspec must_receive_met_spec.rb`
|
22
|
+
Then the example must pass
|
23
|
+
|
24
|
+
Scenario: #must_receive when expectation is not met
|
25
|
+
Given a file named "must_receive_not-met_spec.rb" with:
|
26
|
+
"""
|
27
|
+
require 'rspec'
|
28
|
+
require 'rspec/must'
|
29
|
+
|
30
|
+
describe Object do
|
31
|
+
it 'receives a message' do
|
32
|
+
o = double('object')
|
33
|
+
o.must_receive :class
|
34
|
+
end
|
35
|
+
end
|
36
|
+
"""
|
37
|
+
When I run `rspec must_receive_not-met_spec.rb`
|
38
|
+
Then the example must fail
|
39
|
+
And the output must contain "received: 0 times"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Then /^the example must pass$/ do
|
2
|
+
step %q{the output should contain "0 failures"}
|
3
|
+
step %q{the exit status should be 0}
|
4
|
+
end
|
5
|
+
|
6
|
+
Then /^the example must fail$/ do
|
7
|
+
step %q{the output should contain "1 failure"}
|
8
|
+
step %q{the exit status should not be 0}
|
9
|
+
end
|
10
|
+
|
11
|
+
Then /^the output must match \/([^\/]*)\/$/ do |expected|
|
12
|
+
step %{the output should match /#{expected}/}
|
13
|
+
end
|
14
|
+
|
15
|
+
Then /^the output must contain "([^"]*)"$/ do |expected|
|
16
|
+
step %{the output should contain "#{expected}"}
|
17
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'aruba/cucumber'
|
data/lib/rspec/must.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'rspec/must/extensions/kernel'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'rspec/must/mocks/methods'
|
data/rspec-must.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '/lib')
|
2
|
+
require 'rspec/must/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'rspec-must'
|
6
|
+
s.version = RSpec::Must::VERSION
|
7
|
+
s.summary = "rspec-must-#{RSpec::Must::VERSION}"
|
8
|
+
s.description = <<-eoh.gsub(/^ +/, '')
|
9
|
+
rspec-must allows you to use #must instead of #should instance method
|
10
|
+
in your specs. Currently it also provides #must_not and #must_receive,
|
11
|
+
respectively aliased on #should_not and #should_receive.
|
12
|
+
eoh
|
13
|
+
s.homepage = 'https://rubygems.org/gems/rspec-must'
|
14
|
+
|
15
|
+
s.author = 'Thibault Jouan'
|
16
|
+
s.email = 'tj@a13.fr'
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split "\n"
|
19
|
+
s.test_files = `git ls-files -- {spec,features}/*`.split "\n"
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map do |f|
|
21
|
+
File.basename(f)
|
22
|
+
end
|
23
|
+
|
24
|
+
s.add_development_dependency 'aruba'
|
25
|
+
s.add_development_dependency 'rspec'
|
26
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Object do
|
4
|
+
describe '#must' do
|
5
|
+
it 'is an alias for #should' do
|
6
|
+
Object.method(:must).must == Object.method(:should)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#must_not' do
|
11
|
+
it 'is an alias for #should_not' do
|
12
|
+
Object.method(:must_not).must == Object.method(:should_not)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-must
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Thibault Jouan
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-12-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: aruba
|
16
|
+
requirement: &69782160 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *69782160
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &69781930 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *69781930
|
36
|
+
description: ! 'rspec-must allows you to use #must instead of #should instance method
|
37
|
+
|
38
|
+
in your specs. Currently it also provides #must_not and #must_receive,
|
39
|
+
|
40
|
+
respectively aliased on #should_not and #should_receive.
|
41
|
+
|
42
|
+
'
|
43
|
+
email: tj@a13.fr
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE
|
51
|
+
- README.md
|
52
|
+
- features/must.feature
|
53
|
+
- features/must_receive.feature
|
54
|
+
- features/steps/rspec_steps.rb
|
55
|
+
- features/support/env.rb
|
56
|
+
- lib/rspec/must.rb
|
57
|
+
- lib/rspec/must/extensions.rb
|
58
|
+
- lib/rspec/must/extensions/kernel.rb
|
59
|
+
- lib/rspec/must/mocks.rb
|
60
|
+
- lib/rspec/must/mocks/methods.rb
|
61
|
+
- lib/rspec/must/version.rb
|
62
|
+
- rspec-must.gemspec
|
63
|
+
- spec/rspec/expectations/extensions/kernel_spec.rb
|
64
|
+
- spec/rspec/mocks/methods_spec.rb
|
65
|
+
- spec/spec_helper.rb
|
66
|
+
homepage: https://rubygems.org/gems/rspec-must
|
67
|
+
licenses: []
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 1.8.11
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: rspec-must-0.0.1
|
90
|
+
test_files:
|
91
|
+
- features/must.feature
|
92
|
+
- features/must_receive.feature
|
93
|
+
- features/steps/rspec_steps.rb
|
94
|
+
- features/support/env.rb
|
95
|
+
- spec/rspec/expectations/extensions/kernel_spec.rb
|
96
|
+
- spec/rspec/mocks/methods_spec.rb
|
97
|
+
- spec/spec_helper.rb
|