developwithpassion_fakes-rspec 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rvmrc +1 -0
- data/Gemfile +3 -0
- data/Guardfile +5 -0
- data/README.md +28 -0
- data/Rakefile +1 -0
- data/developwithpassion_fakes-rspec.gemspec +27 -0
- data/lib/core/received_criteria.rb +16 -0
- data/lib/core/rspec_utils.rb +7 -0
- data/lib/core/version.rb +7 -0
- data/lib/developwithpassion_fakes-rspec.rb +4 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/specs/received_criteria_spec.rb +41 -0
- data/spec/specs/usage_spec.rb +16 -0
- metadata +118 -0
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm 1.9.3@developwithpassion_fakes-rspec --create
|
data/Gemfile
ADDED
data/Guardfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#developwithpassion_fakes-rspec
|
2
|
+
|
3
|
+
This is a library to aid in the usage of [developwithpassion_fakes](http://github.com/developwithpassion/developwithpassion_fakes) when using [RSpec](https://github.com/rspec/rspec). It basically just adds the convienience matcher: have_received which you would use as follows:
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
it "should be able to determine if a call was made on a fake" do
|
7
|
+
the_fake = fake
|
8
|
+
fake.hello("World")
|
9
|
+
|
10
|
+
fake.should have_received(:hello) #true
|
11
|
+
fake.should have_received(:hello,"World") #true
|
12
|
+
fake.should have_received(:hello,"Other") #false
|
13
|
+
end
|
14
|
+
```
|
15
|
+
Or conversely:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
it "should be able to determine if a call was never made on a fake" do
|
19
|
+
the_fake = fake
|
20
|
+
fake.hello("World")
|
21
|
+
|
22
|
+
fake.should_not have_received(:goodbye) #true
|
23
|
+
fake.should_not have_received(:hello,"Earth") #true
|
24
|
+
fake.should_not have_received(:hello) #false
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
[Develop With Passion®](http://www.developwithpassion.com)
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib",__FILE__)
|
3
|
+
require "core/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "developwithpassion_fakes-rspec"
|
7
|
+
s.version = DevelopWithPassion::Fakes::RSpec::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Develop With Passion®"]
|
10
|
+
s.email = ["open_source@developwithpassion.com"]
|
11
|
+
s.homepage = "http://www.developwithpassion.com"
|
12
|
+
s.summary = %q{Utility functions for develowithpassion_fakes when working with rSpec}
|
13
|
+
s.description = %q{Faking library that allows inspection of received calls after they have been made. Also supports tracking calls with multiple argument sets.}
|
14
|
+
s.rubyforge_project = "developwithpassion_fakes-rspec"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
s.add_development_dependency "rake"
|
23
|
+
s.add_development_dependency "guard"
|
24
|
+
s.add_development_dependency "guard-rspec"
|
25
|
+
s.add_runtime_dependency "developwithpassion_fakes"
|
26
|
+
s.add_runtime_dependency "rspec"
|
27
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module DevelopWithPassion
|
2
|
+
module Fakes
|
3
|
+
module RSpec
|
4
|
+
class ReceivedCriteria
|
5
|
+
def initialize(the_call)
|
6
|
+
@the_call = the_call
|
7
|
+
end
|
8
|
+
|
9
|
+
def is_satified_by(*args)
|
10
|
+
return false if @the_call == nil
|
11
|
+
return args.count == 0 ? true : @the_call.called_with(*args) != nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/core/version.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'developwithpassion_fakes'
|
2
|
+
require 'rspec'
|
3
|
+
|
4
|
+
Dir.chdir(File.join(File.dirname(__FILE__),"..,lib".split(','))) do
|
5
|
+
Dir.glob("**/*.rb").each do |file|
|
6
|
+
full_path = File.expand_path(file)
|
7
|
+
$:.unshift File.expand_path(File.dirname(full_path))
|
8
|
+
require full_path
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module DevelopWithPassion
|
4
|
+
module Fakes
|
5
|
+
module RSpec
|
6
|
+
describe ReceivedCriteria do
|
7
|
+
context "when matching a call made without arguments" do
|
8
|
+
it "should match if the call was made" do
|
9
|
+
item = fake
|
10
|
+
item.hello
|
11
|
+
|
12
|
+
sut = ReceivedCriteria.new(item.received(:hello))
|
13
|
+
|
14
|
+
sut.is_satified_by.should be_true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
context "when matching a call made with arguments" do
|
18
|
+
let(:item){fake}
|
19
|
+
before (:each) do
|
20
|
+
item.hello("world")
|
21
|
+
@sut = ReceivedCriteria.new(item.received(:hello))
|
22
|
+
end
|
23
|
+
context "and we care about the arguments it was called with" do
|
24
|
+
it "should match if it received the correct call" do
|
25
|
+
@sut.is_satified_by("world").should be_true
|
26
|
+
end
|
27
|
+
it "should not match if the arguments provided are not in the call history" do
|
28
|
+
@sut.is_satified_by("yo").should be_false
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
context "and we don't care about the arguments it was called with" do
|
33
|
+
it "should match if it received a call to the method" do
|
34
|
+
@sut.is_satified_by.should be_true
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "using the rspec extensions" do
|
4
|
+
it "should be able to determine if a call has not been made" do
|
5
|
+
item = fake
|
6
|
+
item.hello
|
7
|
+
item.last("other")
|
8
|
+
|
9
|
+
item.should_not have_received(:hello,"world")
|
10
|
+
item.should have_received(:hello)
|
11
|
+
item.should_not have_received(:once_more)
|
12
|
+
item.should_not have_received(:last,"hello")
|
13
|
+
item.should have_received(:last,"other")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: developwithpassion_fakes-rspec
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Develop With Passion®
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: &70132420731960 !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: *70132420731960
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: guard
|
27
|
+
requirement: &70132420731420 !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: *70132420731420
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: guard-rspec
|
38
|
+
requirement: &70132420730960 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70132420730960
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: developwithpassion_fakes
|
49
|
+
requirement: &70132420730420 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70132420730420
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rspec
|
60
|
+
requirement: &70132420730000 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70132420730000
|
69
|
+
description: Faking library that allows inspection of received calls after they have
|
70
|
+
been made. Also supports tracking calls with multiple argument sets.
|
71
|
+
email:
|
72
|
+
- open_source@developwithpassion.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- .rvmrc
|
79
|
+
- Gemfile
|
80
|
+
- Guardfile
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- developwithpassion_fakes-rspec.gemspec
|
84
|
+
- lib/core/received_criteria.rb
|
85
|
+
- lib/core/rspec_utils.rb
|
86
|
+
- lib/core/version.rb
|
87
|
+
- lib/developwithpassion_fakes-rspec.rb
|
88
|
+
- spec/spec_helper.rb
|
89
|
+
- spec/specs/received_criteria_spec.rb
|
90
|
+
- spec/specs/usage_spec.rb
|
91
|
+
homepage: http://www.developwithpassion.com
|
92
|
+
licenses: []
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
105
|
+
requirements:
|
106
|
+
- - ! '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project: developwithpassion_fakes-rspec
|
111
|
+
rubygems_version: 1.8.17
|
112
|
+
signing_key:
|
113
|
+
specification_version: 3
|
114
|
+
summary: Utility functions for develowithpassion_fakes when working with rSpec
|
115
|
+
test_files:
|
116
|
+
- spec/spec_helper.rb
|
117
|
+
- spec/specs/received_criteria_spec.rb
|
118
|
+
- spec/specs/usage_spec.rb
|