stirlitz 0.0.0.1 → 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/.rdebugrc +3 -0
- data/Gemfile +7 -0
- data/README.rdoc +30 -0
- data/Rakefile +25 -0
- data/lib/stirlitz/matchers.rb +52 -0
- data/lib/stirlitz/spy.rb +16 -0
- data/lib/stirlitz/version.rb +5 -0
- data/lib/stirlitz.rb +13 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/stirlitz/matchers_spec.rb +20 -0
- data/spec/stirlitz/spy_spec.rb +18 -0
- data/stirlitz.gemspec +28 -0
- metadata +46 -10
data/.gitignore
ADDED
data/.rdebugrc
ADDED
data/Gemfile
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
= Stirlitz 0.0.1
|
2
|
+
|
3
|
+
A Test Spy extension to rspec-mocks.
|
4
|
+
|
5
|
+
== Installing
|
6
|
+
|
7
|
+
gem install stirlitz
|
8
|
+
|
9
|
+
or add following in your Gemfile
|
10
|
+
|
11
|
+
gem 'stirlitz', :group => :test
|
12
|
+
|
13
|
+
== Examples
|
14
|
+
|
15
|
+
With Stirlitz installed you can verify your mocks post calls
|
16
|
+
|
17
|
+
it "lets me know if a call had been made" do
|
18
|
+
a_spy = spy(:spy)
|
19
|
+
a_spy.a_method
|
20
|
+
a_spy.should have_received(:a_method)
|
21
|
+
a_spy.should_not have_received(:no_method)
|
22
|
+
end
|
23
|
+
|
24
|
+
It is also possible to verify the arguments passed while method invocation
|
25
|
+
|
26
|
+
it "lets me know if certain arguments were used" do
|
27
|
+
a_spy = spy(:spy)
|
28
|
+
a_spy.a_method(10, 20)
|
29
|
+
a_spy.should have_received(:a_method).with(10, 20)
|
30
|
+
end
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
|
3
|
+
Bundler::GemHelper.install_tasks
|
4
|
+
|
5
|
+
require 'rake'
|
6
|
+
|
7
|
+
require 'rspec/core'
|
8
|
+
require 'rspec/core/rake_task'
|
9
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
10
|
+
t.pattern = "spec/**/*_spec.rb"
|
11
|
+
end
|
12
|
+
|
13
|
+
task :default => :spec
|
14
|
+
|
15
|
+
require 'rake/rdoctask'
|
16
|
+
Rake::RDocTask.new do |rdoc|
|
17
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
18
|
+
|
19
|
+
rdoc.rdoc_dir = 'rdoc'
|
20
|
+
rdoc.title = "something-new #{version}"
|
21
|
+
rdoc.rdoc_files.include('README*')
|
22
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
end
|
24
|
+
|
25
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Stirlitz
|
2
|
+
module Matchers
|
3
|
+
# :call-seq:
|
4
|
+
# should have_received(expected_method)
|
5
|
+
# should have_received(expected_method).with(args)
|
6
|
+
# should_not have_received(expected)
|
7
|
+
#
|
8
|
+
# Passes if actual had expected invoked on it. You can also
|
9
|
+
# pass args to verify that they were called with them
|
10
|
+
#
|
11
|
+
# == Examples
|
12
|
+
#
|
13
|
+
# mock_object.should have_received(:save)
|
14
|
+
# mock_object.should have_received(:update_attributes).with({:name => 'new name'})
|
15
|
+
# mock_object.should_not have_received(:destroy)
|
16
|
+
def have_received(expected)
|
17
|
+
HaveReceived.new(expected)
|
18
|
+
end
|
19
|
+
|
20
|
+
class HaveReceived
|
21
|
+
def initialize(expected)
|
22
|
+
@expected = expected
|
23
|
+
end
|
24
|
+
|
25
|
+
def matches?(actual)
|
26
|
+
@actual = actual
|
27
|
+
if @args
|
28
|
+
actual.received_message?(@expected, *@args)
|
29
|
+
else
|
30
|
+
actual.received_message?(@expected)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def with(*args)
|
35
|
+
@args = args
|
36
|
+
self
|
37
|
+
end
|
38
|
+
|
39
|
+
def failure_message_for_should
|
40
|
+
"#{@actual} should have been called on #{@expected.inspect}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def failure_message_for_should_not
|
44
|
+
"#{@actual} should not have been called on #{@expected.inspect}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
RSpec.configure do |config|
|
51
|
+
config.include Stirlitz::Matchers
|
52
|
+
end
|
data/lib/stirlitz/spy.rb
ADDED
data/lib/stirlitz.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Stirlitz
|
4
|
+
describe Matchers do
|
5
|
+
it "lets me know if a call had been made" do
|
6
|
+
a_spy = spy(:spy)
|
7
|
+
a_spy.a_method
|
8
|
+
a_spy.should have_received(:a_method)
|
9
|
+
lambda do
|
10
|
+
a_spy.should_not have_received(:a_method)
|
11
|
+
end.should raise_error
|
12
|
+
end
|
13
|
+
|
14
|
+
it "lets me know if certain arguments were used" do
|
15
|
+
a_spy = spy(:spy)
|
16
|
+
a_spy.a_method(10, 20)
|
17
|
+
a_spy.should have_received(:a_method).with(10, 20)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Stirlitz
|
4
|
+
describe Spy do
|
5
|
+
it "extends rspec mock" do
|
6
|
+
a_spy = spy("something", :method_1 => 1, :method_two => 'two')
|
7
|
+
a_spy.method_1.should == 1
|
8
|
+
a_spy.method_two.should == 'two'
|
9
|
+
end
|
10
|
+
|
11
|
+
it "doesn't complain about undeclared methods" do
|
12
|
+
a_spy = spy("something", :method_1 => 1, :method_two => 'two')
|
13
|
+
lambda do
|
14
|
+
a_spy.a_method_no_one_knows_about.should
|
15
|
+
end.should_not raise_error
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/stirlitz.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
3
|
+
require "stirlitz/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "stirlitz"
|
7
|
+
s.version = Stirlitz::Version::STRING
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Srushti Ambekallu", "Niranjan Paranjape"]
|
10
|
+
s.email = "srushti@c42.in"
|
11
|
+
s.homepage = "http://github.com/srushti/stirlitz"
|
12
|
+
s.summary = "stirlitz-#{Stirlitz::Version::STRING}"
|
13
|
+
s.description = "Test spy extension to rspec-mocks"
|
14
|
+
|
15
|
+
s.rubygems_version = "1.3.7"
|
16
|
+
s.rubyforge_project = "stirlitz"
|
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{ |f| File.basename(f) }
|
21
|
+
s.extra_rdoc_files = [ "README.rdoc" ]
|
22
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
23
|
+
s.require_path = "lib"
|
24
|
+
|
25
|
+
s.add_runtime_dependency "rspec", ["~> 2.5.0"]
|
26
|
+
s.add_runtime_dependency "rspec-mocks", ["~> 2.5.0"]
|
27
|
+
end
|
28
|
+
|
metadata
CHANGED
@@ -2,28 +2,62 @@
|
|
2
2
|
name: stirlitz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Srushti Ambekallu
|
9
|
+
- Niranjan Paranjape
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
13
|
|
13
14
|
date: 2011-03-23 00:00:00 +05:30
|
14
15
|
default_executable:
|
15
|
-
dependencies:
|
16
|
-
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
18
|
+
name: rspec
|
19
|
+
prerelease: false
|
20
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
21
|
+
none: false
|
22
|
+
requirements:
|
23
|
+
- - ~>
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 2.5.0
|
26
|
+
type: :runtime
|
27
|
+
version_requirements: *id001
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rspec-mocks
|
30
|
+
prerelease: false
|
31
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
32
|
+
none: false
|
33
|
+
requirements:
|
34
|
+
- - ~>
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 2.5.0
|
37
|
+
type: :runtime
|
38
|
+
version_requirements: *id002
|
17
39
|
description: Test spy extension to rspec-mocks
|
18
40
|
email: srushti@c42.in
|
19
41
|
executables: []
|
20
42
|
|
21
43
|
extensions: []
|
22
44
|
|
23
|
-
extra_rdoc_files:
|
24
|
-
|
25
|
-
files:
|
26
|
-
|
45
|
+
extra_rdoc_files:
|
46
|
+
- README.rdoc
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- .rdebugrc
|
50
|
+
- Gemfile
|
51
|
+
- README.rdoc
|
52
|
+
- Rakefile
|
53
|
+
- lib/stirlitz.rb
|
54
|
+
- lib/stirlitz/matchers.rb
|
55
|
+
- lib/stirlitz/spy.rb
|
56
|
+
- lib/stirlitz/version.rb
|
57
|
+
- spec/spec_helper.rb
|
58
|
+
- spec/stirlitz/matchers_spec.rb
|
59
|
+
- spec/stirlitz/spy_spec.rb
|
60
|
+
- stirlitz.gemspec
|
27
61
|
has_rdoc: true
|
28
62
|
homepage: http://github.com/srushti/stirlitz
|
29
63
|
licenses: []
|
@@ -51,6 +85,8 @@ rubyforge_project: stirlitz
|
|
51
85
|
rubygems_version: 1.6.2
|
52
86
|
signing_key:
|
53
87
|
specification_version: 3
|
54
|
-
summary: stirlitz-0.0.
|
55
|
-
test_files:
|
56
|
-
|
88
|
+
summary: stirlitz-0.0.1
|
89
|
+
test_files:
|
90
|
+
- spec/spec_helper.rb
|
91
|
+
- spec/stirlitz/matchers_spec.rb
|
92
|
+
- spec/stirlitz/spy_spec.rb
|