rspec-something 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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/lib/rspec/something/proxy.rb +32 -0
- data/lib/rspec/something/version.rb +5 -0
- data/lib/rspec/something.rb +32 -0
- data/rspec-something.gemspec +24 -0
- data/spec/lib/something_spec.rb +28 -0
- data/spec/spec_helper.rb +10 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c7042322fd48fb78261bcf47650669c91d711263
|
4
|
+
data.tar.gz: 0beb0a381d034c420fa8a17c18ebcec7104f9ad9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 631abf1a56d2a6ed5ef3eb14622a1c9fa1c5d064ea0fe2ff754925dab0a66c21cb46a2ebc58b50d567eb5f168bd497f84dd0aa1e633acaa5dad8bdd39d9c4772
|
7
|
+
data.tar.gz: 63fcdf5e37b78d2d086b1402f233ab70cfd3b2d820e8bfea1667fab4fcd5aa6ec9268fd5881ad49ba57734a8995ad8f92cd65ca0634ed7c9d6b764d4a9ea980b
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Fujimura Daisuke
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# rspec-something [](https://travis-ci.org/fujimura/rspec-something)
|
2
|
+
|
3
|
+
Something expects one message in your example.
|
4
|
+
|
5
|
+
## What is this?
|
6
|
+
|
7
|
+
Without rspec-something:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
mail = double
|
11
|
+
mail.should_receive :deliver
|
12
|
+
UserMailer.should_receive(:hello).and_return mail
|
13
|
+
```
|
14
|
+
|
15
|
+
With rspec-something:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
UserMailer.should_receive(:hello).and_return something.deliver
|
19
|
+
```
|
20
|
+
|
21
|
+
Congrats. You saved two lines.
|
22
|
+
|
23
|
+
## Installation
|
24
|
+
|
25
|
+
Add this line to your application's Gemfile:
|
26
|
+
|
27
|
+
gem 'rspec-something'
|
28
|
+
|
29
|
+
And then execute:
|
30
|
+
|
31
|
+
$ bundle
|
32
|
+
|
33
|
+
Or install it yourself as:
|
34
|
+
|
35
|
+
$ gem install rspec-something
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
1. Fork it
|
40
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
41
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
42
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
43
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
module Rspec
|
2
|
+
module Something
|
3
|
+
class Proxy
|
4
|
+
|
5
|
+
def initialize(_double)
|
6
|
+
@_won_t = false
|
7
|
+
@double = _double
|
8
|
+
end
|
9
|
+
|
10
|
+
# set expectation to double at first method invocation
|
11
|
+
# and return double itself.
|
12
|
+
#
|
13
|
+
def method_missing(name, *args)
|
14
|
+
(should_be_received? ? @double.should_receive(name) : @double.should_not_receive(name))
|
15
|
+
.tap {|o| o.with(*args) unless args.empty? }
|
16
|
+
|
17
|
+
@double
|
18
|
+
end
|
19
|
+
|
20
|
+
def won_t
|
21
|
+
@_won_t = true
|
22
|
+
self
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def should_be_received?
|
28
|
+
!@_won_t
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require "rspec/something/version"
|
3
|
+
require "rspec/something/proxy"
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
include Rspec::Something
|
7
|
+
end
|
8
|
+
|
9
|
+
module Rspec
|
10
|
+
module Something
|
11
|
+
|
12
|
+
# Return something should receive a message.
|
13
|
+
#
|
14
|
+
# This
|
15
|
+
#
|
16
|
+
# UserMailer.should_receive(:hello).and_return something.deliver
|
17
|
+
#
|
18
|
+
# is same as
|
19
|
+
#
|
20
|
+
# mail = double
|
21
|
+
# mail.should_receive :deliver
|
22
|
+
# UserMailer.should_receive(:hello).and_return mail
|
23
|
+
#
|
24
|
+
# To assert that the message won't be received, insert `won_t` like:
|
25
|
+
#
|
26
|
+
# something.won_t.deliver
|
27
|
+
#
|
28
|
+
def something
|
29
|
+
Rspec::Something::Proxy.new(double)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rspec/something/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rspec-something"
|
8
|
+
spec.version = Rspec::Something::VERSION
|
9
|
+
spec.authors = ["Fujimura Daisuke"]
|
10
|
+
spec.email = ["me@fujimuradaisuke.com"]
|
11
|
+
spec.description = %q{Something expects one message in your example}
|
12
|
+
spec.summary = %q{Something expects one message in your example}
|
13
|
+
spec.homepage = "https://github.com/fujimura/rspec-something"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec", "~> 2.13"
|
24
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Mailer
|
4
|
+
def deliver; end
|
5
|
+
end
|
6
|
+
|
7
|
+
describe "Something" do
|
8
|
+
|
9
|
+
it "should assert that the message was received" do
|
10
|
+
Mailer.should_receive(:new).and_return something.deliver
|
11
|
+
Mailer.new.deliver
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should assert that the message was received with given args" do
|
15
|
+
Mailer.should_receive(:new).and_return something.register(true)
|
16
|
+
Mailer.new.register(true)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should assert that the message wasn't received" do
|
20
|
+
Mailer.should_receive(:new).and_return something.won_t.deliver
|
21
|
+
Mailer.new
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should assert that the message wasn't received with given args" do
|
25
|
+
Mailer.should_receive(:new).and_return something.won_t.register(false)
|
26
|
+
Mailer.new.register(true)
|
27
|
+
end
|
28
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-something
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fujimura Daisuke
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-06-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.13'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.13'
|
55
|
+
description: Something expects one message in your example
|
56
|
+
email:
|
57
|
+
- me@fujimuradaisuke.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- .travis.yml
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- lib/rspec/something.rb
|
69
|
+
- lib/rspec/something/proxy.rb
|
70
|
+
- lib/rspec/something/version.rb
|
71
|
+
- rspec-something.gemspec
|
72
|
+
- spec/lib/something_spec.rb
|
73
|
+
- spec/spec_helper.rb
|
74
|
+
homepage: https://github.com/fujimura/rspec-something
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.0.2
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: Something expects one message in your example
|
98
|
+
test_files:
|
99
|
+
- spec/lib/something_spec.rb
|
100
|
+
- spec/spec_helper.rb
|
101
|
+
has_rdoc:
|