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 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
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 1.9.2
3
+ - 1.9.3
4
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rspec-something.gemspec
4
+ gemspec
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 [![Build Status](https://travis-ci.org/fujimura/rspec-something.png)](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,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -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,5 @@
1
+ module Rspec
2
+ module Something
3
+ VERSION = "0.0.1"
4
+ end
5
+ 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
@@ -0,0 +1,10 @@
1
+ $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
2
+ $LOAD_PATH << File.join(File.dirname(__FILE__))
3
+
4
+ require 'rspec'
5
+ require 'rspec/autorun'
6
+ require 'rspec/something'
7
+
8
+ RSpec.configure do |config|
9
+ config.order = "random"
10
+ end
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: