developwithpassion_fakes-rspec 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,46 @@
1
+ module RSpec
2
+ def self.create_received_criteria_from(the_call)
3
+ return DevelopWithPassion::Fakes::RSpec::ReceivedCriteria.new(the_call)
4
+ end
5
+ def self.create_received_occurences_criteria_from(the_call,occurence)
6
+ return DevelopWithPassion::Fakes::RSpec::ReceivedOccurencesCriteria.new(create_received_criteria_from(the_call),the_call,occurence)
7
+ end
8
+
9
+ Matchers.define :have_received do|symbol,*args|
10
+ @occurence_spec = DevelopWithPassion::Fakes::RSpec::NulloSpecification.instance
11
+
12
+ chain :once do
13
+ @occurence_spec = DevelopWithPassion::Fakes::RSpec::Occurances.exact(1)
14
+ end
15
+ chain :twice do
16
+ @occurence_spec = DevelopWithPassion::Fakes::RSpec::Occurances.exact(2)
17
+ end
18
+ chain :at_least_once do
19
+ @occurence_spec = DevelopWithPassion::Fakes::RSpec::Occurances.at_least(1)
20
+ end
21
+ chain :at_least_twice do
22
+ @occurence_spec = DevelopWithPassion::Fakes::RSpec::Occurances.at_least(2)
23
+ end
24
+ chain :at_most_once do
25
+ @occurence_spec = DevelopWithPassion::Fakes::RSpec::Occurances.at_most(1)
26
+ end
27
+ chain :at_most_twice do
28
+ @occurence_spec = DevelopWithPassion::Fakes::RSpec::Occurances.at_most(2)
29
+ end
30
+ chain :at_least do|times|
31
+ @occurence_spec = DevelopWithPassion::Fakes::RSpec::Occurances.at_least(times)
32
+ end
33
+ chain :at_most do|times|
34
+ @occurence_spec = DevelopWithPassion::Fakes::RSpec::Occurances.at_most(times)
35
+ end
36
+ chain :exactly do|times|
37
+ @occurence_spec = DevelopWithPassion::Fakes::RSpec::Occurances.exact(times)
38
+ end
39
+ chain :occurs do|the_proc|
40
+ @occurence_spec = DevelopWithPassion::Fakes::RSpec::Occurances.from_block(the_proc)
41
+ end
42
+ match do|the_fake|
43
+ RSpec.create_received_occurences_criteria_from(the_fake.received(symbol),@occurence_spec).is_satisfied_by(*args)
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,12 @@
1
+ module DevelopWithPassion
2
+ module Fakes
3
+ module RSpec
4
+ class NulloSpecification
5
+ include Singleton
6
+ def is_satisfied_by(item)
7
+ return true
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,7 +1,7 @@
1
1
  module DevelopWithPassion
2
2
  module Fakes
3
3
  module RSpec
4
- VERSION = "0.0.7"
4
+ VERSION = "0.0.8"
5
5
  end
6
6
  end
7
7
  end
@@ -1,4 +1,12 @@
1
1
  require 'developwithpassion_fakes'
2
+ require 'rspec'
2
3
 
4
+ require 'singleton'
5
+ require 'core/block_criteria'
6
+ require 'core/nullo_specification'
7
+ require 'core/occurances'
3
8
  require 'core/received_criteria'
4
- require 'core/rspec_utils'
9
+ require 'core/received_occurances_criteria'
10
+ require 'core/matcher'
11
+ require 'core/received_criteria'
12
+
@@ -1,9 +1,5 @@
1
1
  require 'developwithpassion_fakes'
2
2
 
3
3
  Dir.chdir(File.join(File.dirname(__FILE__),"..,lib".split(','))) do
4
- Dir.glob("**/*.rb").each do |file|
5
- full_path = File.expand_path(file)
6
- $:.unshift File.expand_path(File.dirname(full_path))
7
- require full_path
8
- end
4
+ require 'developwithpassion_fakes-rspec'
9
5
  end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ module DevelopWithPassion
4
+ module Fakes
5
+ module RSpec
6
+ describe NulloSpecification do
7
+ subject{NulloSpecification.instance}
8
+
9
+ it "should be satisfied by anything" do
10
+ [1,10,"a",Object.new].each{|item| subject.is_satisfied_by(item).should be_true}
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -20,12 +20,78 @@ describe "using the rspec extensions" do
20
20
  item.last("other")
21
21
 
22
22
  item.should_not have_received(:hello,"world")
23
- item.should have_received_occurences(twice,:hello)
23
+ item.should have_received(:hello).twice
24
24
  item.should have_received(:hello)
25
25
  item.should_not have_received(:once_more)
26
26
  item.should_not have_received(:last,"hello")
27
- item.should have_received_occurences(once,:last,"other")
28
- item.should_not have_received_occurences(twice,:last)
27
+ item.should have_received(:last,"other").once
28
+ item.should_not have_received(:last).twice
29
+ end
30
+
31
+ it "should be able to determine if a call was made once" do
32
+ item = fake
33
+ item.hello
34
+
35
+ item.should have_received(:hello).once
36
+ end
37
+
38
+ it "should be able to determine if a call was made twice" do
39
+ item = fake
40
+ item.hello
41
+ item.hello
42
+
43
+ item.should have_received(:hello).twice
44
+ end
45
+
46
+ it "should be able to determine if a call was made at least once" do
47
+ item = fake
48
+ item.hello
49
+ item.hello
50
+
51
+ item.should have_received(:hello).at_least_once
52
+ end
53
+
54
+ it "should be able to determine if a call was made at least twice" do
55
+ item = fake
56
+ item.hello
57
+ item.hello
58
+ item.hello
59
+
60
+ item.should have_received(:hello).at_least_twice
61
+ item.should have_received(:hello).at_least_twice
62
+ end
63
+
64
+
65
+ it "should be able to determine if a call was made at most once" do
66
+ item = fake
67
+ item.hello
68
+ item.goodbye
69
+ item.goodbye
70
+
71
+ item.should have_received(:hello).at_most_once
72
+ item.should_not have_received(:goodbye).at_most_once
73
+ end
74
+
75
+ it "should be able to determine if a call was made at most twice" do
76
+ item = fake
77
+ item.hello
78
+ item.goodbye
79
+ item.goodbye
80
+ item.goodbye
81
+
82
+ item.should have_received(:hello).at_most_twice
83
+ item.should_not have_received(:goodbye).at_most_twice
84
+ end
85
+
86
+ it "should be able to determine if a call was made at least a specified number of times" do
87
+ item = fake
88
+ item.hello
89
+ item.goodbye
90
+ item.goodbye
91
+ item.goodbye
92
+
93
+ item.should have_received(:hello).at_most(1)
94
+ item.should_not have_received(:goodbye).at_most(1)
29
95
  end
30
96
  end
31
97
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: developwithpassion_fakes-rspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-27 00:00:00.000000000 Z
12
+ date: 2012-03-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70201316121600 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70201316121600
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rspec
27
- requirement: &70201316121080 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *70201316121080
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: guard
38
- requirement: &70201316120580 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '0'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *70201316120580
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: guard-rspec
49
- requirement: &70201316120060 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: '0'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *70201316120060
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: developwithpassion_fakes
60
- requirement: &70201316119480 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ! '>='
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: '0'
66
86
  type: :runtime
67
87
  prerelease: false
68
- version_requirements: *70201316119480
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: rspec
71
- requirement: &70201316118940 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ! '>='
@@ -76,7 +101,12 @@ dependencies:
76
101
  version: '0'
77
102
  type: :runtime
78
103
  prerelease: false
79
- version_requirements: *70201316118940
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
80
110
  description: Faking library that allows inspection of received calls after they have
81
111
  been made. Also supports tracking calls with multiple argument sets.
82
112
  email:
@@ -87,16 +117,16 @@ extra_rdoc_files: []
87
117
  files:
88
118
  - developwithpassion_fakes-rspec.gemspec
89
119
  - lib/core/block_criteria.rb
90
- - lib/core/example_group.rb
120
+ - lib/core/matcher.rb
121
+ - lib/core/nullo_specification.rb
91
122
  - lib/core/occurances.rb
92
123
  - lib/core/received_criteria.rb
93
124
  - lib/core/received_occurances_criteria.rb
94
- - lib/core/rspec_utils.rb
95
125
  - lib/core/version.rb
96
126
  - lib/developwithpassion_fakes-rspec.rb
97
127
  - spec/spec_helper.rb
98
128
  - spec/specs/block_criteria_spec.rb
99
- - spec/specs/example_group_specs.rb
129
+ - spec/specs/nullo_specification_spec.rb
100
130
  - spec/specs/occurances_spec.rb
101
131
  - spec/specs/received_criteria_spec.rb
102
132
  - spec/specs/received_occurences_criteria_spec.rb
@@ -121,14 +151,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
151
  version: '0'
122
152
  requirements: []
123
153
  rubyforge_project: developwithpassion_fakes-rspec
124
- rubygems_version: 1.8.17
154
+ rubygems_version: 1.8.21
125
155
  signing_key:
126
156
  specification_version: 3
127
157
  summary: Utility functions for develowithpassion_fakes when working with rSpec
128
158
  test_files:
129
159
  - spec/spec_helper.rb
130
160
  - spec/specs/block_criteria_spec.rb
131
- - spec/specs/example_group_specs.rb
161
+ - spec/specs/nullo_specification_spec.rb
132
162
  - spec/specs/occurances_spec.rb
133
163
  - spec/specs/received_criteria_spec.rb
134
164
  - spec/specs/received_occurences_criteria_spec.rb
@@ -1,36 +0,0 @@
1
- module RSpec
2
- module Core
3
- class ExampleGroup
4
- def once
5
- return DevelopWithPassion::Fakes::RSpec::Occurances.exact(1)
6
- end
7
- def twice
8
- return DevelopWithPassion::Fakes::RSpec::Occurances.exact(2)
9
- end
10
- def at_least_once
11
- return DevelopWithPassion::Fakes::RSpec::Occurances.at_least(1)
12
- end
13
- def at_least_twice
14
- return DevelopWithPassion::Fakes::RSpec::Occurances.at_least(2)
15
- end
16
- def at_most_once
17
- return DevelopWithPassion::Fakes::RSpec::Occurances.at_most(1)
18
- end
19
- def at_most_twice
20
- return DevelopWithPassion::Fakes::RSpec::Occurances.at_most(2)
21
- end
22
- def at_least(times)
23
- return DevelopWithPassion::Fakes::RSpec::Occurances.at_least(times)
24
- end
25
- def at_most(times)
26
- return DevelopWithPassion::Fakes::RSpec::Occurances.at_most(times)
27
- end
28
- def exactly(times)
29
- return DevelopWithPassion::Fakes::RSpec::Occurances.exact(times)
30
- end
31
- def occurs(match_block)
32
- return DevelopWithPassion::Fakes::RSpec::Occurances.from_block(match_block)
33
- end
34
- end
35
- end
36
- end
@@ -1,20 +0,0 @@
1
- module RSpec
2
- def self.create_received_criteria_from(the_call)
3
- return DevelopWithPassion::Fakes::RSpec::ReceivedCriteria.new(the_call)
4
- end
5
- def self.create_received_occurences_criteria_from(the_call,occurence)
6
- return DevelopWithPassion::Fakes::RSpec::ReceivedOccurencesCriteria.new(create_received_criteria_from(the_call),the_call,occurence)
7
- end
8
-
9
- Matchers.define :have_received do|symbol,*args|
10
- match do|the_fake|
11
- RSpec.create_received_criteria_from(the_fake.received(symbol)).is_satisfied_by(*args)
12
- end
13
- end
14
- Matchers.define :have_received_occurences do|occurence,symbol,*args|
15
- match do|the_fake|
16
- RSpec.create_received_occurences_criteria_from(the_fake.received(symbol),occurence).is_satisfied_by(*args)
17
- end
18
- end
19
-
20
- end
@@ -1,33 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module RSpec
4
- module Core
5
- describe ExampleGroup do
6
- context "when creating occurence matchers" do
7
- it "should be able to create matchers correctly" do
8
- once.is_satisfied_by(1).should be_true
9
- once.is_satisfied_by(2).should be_false
10
-
11
- twice.is_satisfied_by(2).should be_true
12
- twice.is_satisfied_by(1).should be_false
13
-
14
- at_least_once.is_satisfied_by(1).should be_true
15
- at_least_once.is_satisfied_by(2).should be_true
16
- at_least_once.is_satisfied_by(0).should be_false
17
-
18
- at_least_twice.is_satisfied_by(2).should be_true
19
- at_least_twice.is_satisfied_by(3).should be_true
20
- at_least_twice.is_satisfied_by(0).should be_false
21
-
22
- at_most_once.is_satisfied_by(1).should be_true
23
- at_most_once.is_satisfied_by(2).should be_false
24
- at_most_once.is_satisfied_by(0).should be_true
25
-
26
- at_most_twice.is_satisfied_by(2).should be_true
27
- at_most_twice.is_satisfied_by(3).should be_false
28
- at_most_twice.is_satisfied_by(0).should be_true
29
- end
30
- end
31
- end
32
- end
33
- end