gimme 0.3.5 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
+ install: bundle install --path vendor/bundle
2
3
  rvm:
3
4
  - 1.8.7
4
5
  - 1.9.2
@@ -6,6 +7,4 @@ rvm:
6
7
  - 2.0.0
7
8
  - jruby-18mode # JRuby in 1.8 mode
8
9
  - jruby-19mode # JRuby in 1.9 mode
9
- - rbx-18mode
10
- # - rbx-19mode # see https://github.com/rubinius/rubinius/issues/1575
11
10
  - ree
data/Gemfile CHANGED
@@ -13,6 +13,7 @@ group :development, :test do
13
13
  gem "rspec-given"
14
14
  gem "cucumber"
15
15
  gem "simplecov", :require => false
16
+ gem 'coveralls', :require => false
16
17
  gem 'jeweler'
17
18
 
18
19
  gem "guard-cucumber", :require => false
data/Gemfile.lock CHANGED
@@ -3,6 +3,13 @@ GEM
3
3
  specs:
4
4
  builder (3.0.0)
5
5
  coderay (1.0.5)
6
+ colorize (0.5.8)
7
+ coveralls (0.6.7)
8
+ colorize
9
+ multi_json (~> 1.3)
10
+ rest-client
11
+ simplecov (>= 0.7)
12
+ thor
6
13
  cucumber (1.1.9)
7
14
  builder (>= 2.1.2)
8
15
  diff-lcs (>= 1.1.2)
@@ -30,7 +37,8 @@ GEM
30
37
  rdoc
31
38
  json (1.6.5)
32
39
  method_source (0.7.0)
33
- multi_json (1.1.0)
40
+ mime-types (1.23)
41
+ multi_json (1.7.3)
34
42
  pry (0.9.8)
35
43
  coderay (~> 1.0.5)
36
44
  method_source (~> 0.7)
@@ -39,6 +47,8 @@ GEM
39
47
  rb-fsevent (0.9.0)
40
48
  rdoc (3.12)
41
49
  json (~> 1.4)
50
+ rest-client (1.6.7)
51
+ mime-types (>= 1.16)
42
52
  rspec (2.8.0)
43
53
  rspec-core (~> 2.8.0)
44
54
  rspec-expectations (~> 2.8.0)
@@ -49,10 +59,10 @@ GEM
49
59
  rspec-given (1.4.2)
50
60
  rspec (> 1.2.8)
51
61
  rspec-mocks (2.8.0)
52
- simplecov (0.6.1)
62
+ simplecov (0.7.1)
53
63
  multi_json (~> 1.0)
54
- simplecov-html (~> 0.5.3)
55
- simplecov-html (0.5.3)
64
+ simplecov-html (~> 0.7.1)
65
+ simplecov-html (0.7.1)
56
66
  slop (2.4.3)
57
67
  term-ansicolor (1.0.7)
58
68
  thor (0.14.6)
@@ -61,6 +71,7 @@ PLATFORMS
61
71
  ruby
62
72
 
63
73
  DEPENDENCIES
74
+ coveralls
64
75
  cucumber
65
76
  growl
66
77
  guard-cucumber
data/README.markdown CHANGED
@@ -1,5 +1,7 @@
1
1
  # Gimme
2
2
 
3
+ [![Build Status](https://travis-ci.org/searls/gimme.png?branch=master)](https://travis-ci.org/searls/gimme) [![Coverage Status](https://coveralls.io/repos/searls/gimme/badge.png)](https://coveralls.io/r/searls/gimme)
4
+
3
5
  Gimme is a very lightweight test double library for ruby. Written to be an opinionated (but not noisy) means to facilitate test-driving by enabling the author to specify only what she cares about. If I could only feed Google one thing at this point, it would be: "[Mockito](http://mockito.org/) for Ruby"
4
6
 
5
7
  You can read the (possibly stale) documentation below or the (fresh) [gimme Cucumber features on Relish](http://relishapp.com/searls/gimme)
@@ -100,6 +102,28 @@ You can also specify how many times a specific invocation should have occurred (
100
102
  verify(double,2).equal?(:fruit)
101
103
  verify(double,2.times).equal?(:fruit) # N.times syntax needs ruby >= 1.8.7
102
104
 
105
+ #### Stubbing class methods
106
+
107
+ Is to be noted that in the previous examples stubing is done on instance methods. If you need to stub a class method for example ```Dog::habilities```:
108
+
109
+ ```ruby
110
+ class Dog
111
+ self.habilities
112
+ # (...)
113
+ end
114
+ end
115
+ ```
116
+
117
+ you can:
118
+
119
+ ```ruby
120
+ give(Dog).habilities { [:bark, :drool] }
121
+
122
+ Dog.habilities #=> [:bark, :drool]
123
+
124
+ verify(Dog).habilities #=> passes
125
+ ```
126
+
103
127
  ### Using Argument Matchers
104
128
 
105
129
  Gimme includes several argument matchers which can be used to control which invocations will satisfy a particular stubbing or verification.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.5
1
+ 0.4.0
data/gimme.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "gimme"
8
- s.version = "0.3.5"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin Searls"]
12
- s.date = "2013-03-06"
12
+ s.date = "2013-12-17"
13
13
  s.description = "gimme attempts to bring to Ruby a test double workflow akin to Mockito in Java. Major distinctions include preserving arrange-act-assert in tests, fast feedback for methods the double's real counterpart may not know how to respond to, no string/symbolic representations of methods, argument captors, and strong opinions (weakly held). "
14
14
  s.email = "searls@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -91,7 +91,7 @@ Gem::Specification.new do |s|
91
91
  s.homepage = "http://github.com/searls/gimme"
92
92
  s.licenses = ["MIT"]
93
93
  s.require_paths = ["lib"]
94
- s.rubygems_version = "1.8.24"
94
+ s.rubygems_version = "1.8.23"
95
95
  s.summary = "gimme \u{2014}\u{a0}a low-specification test double library for Ruby"
96
96
 
97
97
  if s.respond_to? :specification_version then
@@ -105,6 +105,7 @@ Gem::Specification.new do |s|
105
105
  s.add_development_dependency(%q<rspec-given>, [">= 0"])
106
106
  s.add_development_dependency(%q<cucumber>, [">= 0"])
107
107
  s.add_development_dependency(%q<simplecov>, [">= 0"])
108
+ s.add_development_dependency(%q<coveralls>, [">= 0"])
108
109
  s.add_development_dependency(%q<jeweler>, [">= 0"])
109
110
  s.add_development_dependency(%q<guard-cucumber>, [">= 0"])
110
111
  s.add_development_dependency(%q<guard-rspec>, [">= 0"])
@@ -120,6 +121,7 @@ Gem::Specification.new do |s|
120
121
  s.add_dependency(%q<rspec-given>, [">= 0"])
121
122
  s.add_dependency(%q<cucumber>, [">= 0"])
122
123
  s.add_dependency(%q<simplecov>, [">= 0"])
124
+ s.add_dependency(%q<coveralls>, [">= 0"])
123
125
  s.add_dependency(%q<jeweler>, [">= 0"])
124
126
  s.add_dependency(%q<guard-cucumber>, [">= 0"])
125
127
  s.add_dependency(%q<guard-rspec>, [">= 0"])
@@ -136,6 +138,7 @@ Gem::Specification.new do |s|
136
138
  s.add_dependency(%q<rspec-given>, [">= 0"])
137
139
  s.add_dependency(%q<cucumber>, [">= 0"])
138
140
  s.add_dependency(%q<simplecov>, [">= 0"])
141
+ s.add_dependency(%q<coveralls>, [">= 0"])
139
142
  s.add_dependency(%q<jeweler>, [">= 0"])
140
143
  s.add_dependency(%q<guard-cucumber>, [">= 0"])
141
144
  s.add_dependency(%q<guard-rspec>, [">= 0"])
@@ -4,9 +4,9 @@ module Gimme
4
4
  @finder = FindsStubbings.new(stubbed_thing)
5
5
  end
6
6
 
7
- def invoke(method, args)
7
+ def invoke(method, args, block = nil)
8
8
  if blk = @finder.find(method, args)
9
- blk.call
9
+ blk.call(block)
10
10
  elsif method.to_s[-1,1] == '?'
11
11
  false
12
12
  else
@@ -21,7 +21,7 @@ module Gimme
21
21
  def method_missing(method, *args, &block)
22
22
  method = ResolvesMethods.new(self.cls, method, args).resolve(false)
23
23
  Gimme.invocations.increment(self, method, args)
24
- InvokesSatisfiedStubbing.new(self).invoke(method, args)
24
+ InvokesSatisfiedStubbing.new(self).invoke(method, args, block)
25
25
  end
26
26
 
27
27
  def inspect(*args, &blk)
@@ -40,7 +40,13 @@ module Gimme
40
40
  Then { subject.name.should == "pants" }
41
41
  end
42
42
 
43
+ context "when called with a block" do
44
+ subject { gimme }
45
+ Given { @number = 1 }
46
+ Given { give(subject).process(:three) {|blk| blk.call(3) } }
47
+ When { subject.process(:three) { |n| @number += n } }
48
+ Then { @number.should == 4 }
49
+ end
43
50
  end
44
-
45
51
  end
46
- end
52
+ end
data/spec/spec_helper.rb CHANGED
@@ -3,6 +3,9 @@ SimpleCov.start do
3
3
  add_filter "/spec/"
4
4
  end
5
5
 
6
+ require 'coveralls'
7
+ Coveralls.wear!
8
+
6
9
  require 'gimme'
7
10
  require 'rspec/given'
8
11
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gimme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-06 00:00:00.000000000 Z
12
+ date: 2013-12-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pry
@@ -123,6 +123,22 @@ dependencies:
123
123
  - - ! '>='
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: coveralls
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
126
142
  - !ruby/object:Gem::Dependency
127
143
  name: jeweler
128
144
  requirement: !ruby/object:Gem::Requirement
@@ -332,7 +348,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
332
348
  version: '0'
333
349
  segments:
334
350
  - 0
335
- hash: -660060900159398141
351
+ hash: -3352423184536608461
336
352
  required_rubygems_version: !ruby/object:Gem::Requirement
337
353
  none: false
338
354
  requirements:
@@ -341,7 +357,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
341
357
  version: '0'
342
358
  requirements: []
343
359
  rubyforge_project:
344
- rubygems_version: 1.8.24
360
+ rubygems_version: 1.8.23
345
361
  signing_key:
346
362
  specification_version: 3
347
363
  summary: gimme — a low-specification test double library for Ruby