rspec-expectations 2.0.0.a6 → 2.0.0.a7

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -4,3 +4,4 @@ coverage
4
4
  rdoc
5
5
  pkg
6
6
  doc
7
+ tmp
data/Rakefile CHANGED
@@ -9,11 +9,14 @@ begin
9
9
  Jeweler::Tasks.new do |gem|
10
10
  gem.name = "rspec-expectations"
11
11
  gem.version = Rspec::Expectations::Version::STRING
12
- gem.summary = "rspec expectations (should[_not] and matchers)"
12
+ gem.summary = "rspec-expectations-#{Rspec::Expectations::Version::STRING}"
13
+ gem.description = "rspec expectations (should[_not] and matchers)"
13
14
  gem.rubyforge_project = "rspec"
14
15
  gem.email = "dchelimsky@gmail.com;chad.humphries@gmail.com"
15
16
  gem.homepage = "http://github.com/rspec/expectations"
16
17
  gem.authors = ["David Chelimsky", "Chad Humphries"]
18
+ gem.add_development_dependency('cucumber', ">= 0.6.2")
19
+ gem.add_development_dependency('aruba', ">= 0.1.1")
17
20
  gem.add_development_dependency('rspec-core', ">= #{Rspec::Expectations::Version::STRING}")
18
21
  gem.add_development_dependency('rspec-mocks', ">= #{Rspec::Expectations::Version::STRING}")
19
22
  end
@@ -31,7 +34,14 @@ rescue LoadError
31
34
  puts "Rspec core or one of its dependencies is not installed. Install it with: gem install rspec-meta"
32
35
  end
33
36
 
34
- task :default => [:check_dependencies, :spec]
37
+ require 'cucumber/rake/task'
38
+
39
+ Cucumber::Rake::Task.new do |t|
40
+ t.cucumber_opts = %w{--format progress}
41
+ end
42
+
43
+
44
+ task :default => [:check_dependencies, :spec, :cucumber]
35
45
 
36
46
  require 'rake/rdoctask'
37
47
  Rake::RDocTask.new do |rdoc|
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 2.0.0.a7
@@ -0,0 +1,56 @@
1
+ Feature: customized message
2
+
3
+ In order to get the feedback I want
4
+ As an RSpec user
5
+ I want to customize the failure message per example
6
+
7
+ Scenario: one additional method
8
+ Given a file named "node_spec.rb" with:
9
+ """
10
+ require "rspec/expectations"
11
+
12
+ class Node
13
+ def initialize(state=:waiting)
14
+ @state = state
15
+ end
16
+ def state
17
+ @state
18
+ end
19
+ def waiting?
20
+ @state == :waiting
21
+ end
22
+ def started?
23
+ @state == :started
24
+ end
25
+ def start
26
+ @state = :started
27
+ end
28
+ end
29
+
30
+ describe "a new Node" do
31
+ it "should be waiting" do
32
+ node = Node.new(:started) #start w/ started to trigger failure
33
+ node.should be_waiting, "node.state: #{node.state} (first example)"
34
+ end
35
+
36
+ it "should not be started" do
37
+ node = Node.new(:started) #start w/ started to trigger failure
38
+ node.should_not be_started, "node.state: #{node.state} (second example)"
39
+ end
40
+ end
41
+
42
+ describe "node.start" do
43
+ it "should change the state" do
44
+ node = Node.new(:started) #start w/ started to trigger failure
45
+ lambda {node.start}.should change{node.state}, "expected a change"
46
+ end
47
+ end
48
+
49
+ """
50
+ When I run "rspec node_spec.rb --format n"
51
+ Then I should see "3 examples, 3 failures"
52
+ And I should not see "to return true, got false"
53
+ And I should not see "to return false, got true"
54
+ And I should see "node.state: started (first example)"
55
+ And I should see "node.state: started (second example)"
56
+ And I should see "expected a change"
@@ -0,0 +1,193 @@
1
+ Feature: define matcher
2
+
3
+ In order to express my domain clearly in my code examples
4
+ As an RSpec user
5
+ I want a shortcut to define custom matchers
6
+
7
+ Scenario: define a matcher with default messages
8
+ Given a file named "matcher_with_default_message_spec.rb" with:
9
+ """
10
+ require 'rspec/expectations'
11
+
12
+ Rspec::Matchers.define :be_a_multiple_of do |expected|
13
+ match do |actual|
14
+ actual % expected == 0
15
+ end
16
+ end
17
+
18
+ describe 9 do
19
+ it {should be_a_multiple_of(3)}
20
+ end
21
+
22
+ describe 9 do
23
+ it {should_not be_a_multiple_of(4)}
24
+ end
25
+
26
+ # fail intentionally to generate expected output
27
+ describe 9 do
28
+ it {should be_a_multiple_of(4)}
29
+ end
30
+
31
+ # fail intentionally to generate expected output
32
+ describe 9 do
33
+ it {should_not be_a_multiple_of(3)}
34
+ end
35
+
36
+ """
37
+ When I run "rspec matcher_with_default_message_spec.rb --format specdoc"
38
+ Then the exit status should not be 0
39
+
40
+ And I should see "should be a multiple of 3"
41
+ And I should see "should not be a multiple of 4"
42
+ And I should see "Failure/Error: it {should be_a_multiple_of(4)}"
43
+ And I should see "Failure/Error: it {should_not be_a_multiple_of(3)}"
44
+
45
+ And I should see "4 examples, 2 failures"
46
+ And I should see "expected 9 to be a multiple of 4"
47
+ And I should see "expected 9 not to be a multiple of 3"
48
+
49
+ Scenario: overriding the failure_message_for_should
50
+ Given a file named "matcher_with_failure_message_spec.rb" with:
51
+ """
52
+ require 'rspec/expectations'
53
+
54
+ Rspec::Matchers.define :be_a_multiple_of do |expected|
55
+ match do |actual|
56
+ actual % expected == 0
57
+ end
58
+ failure_message_for_should do |actual|
59
+ "expected that #{actual} would be a multiple of #{expected}"
60
+ end
61
+ end
62
+
63
+ # fail intentionally to generate expected output
64
+ describe 9 do
65
+ it {should be_a_multiple_of(4)}
66
+ end
67
+ """
68
+ When I run "rspec matcher_with_failure_message_spec.rb"
69
+ Then the exit status should not be 0
70
+ And the stdout should contain "1 example, 1 failure"
71
+ And the stdout should contain "expected that 9 would be a multiple of 4"
72
+
73
+ Scenario: overriding the failure_message_for_should_not
74
+ Given a file named "matcher_with_failure_for_message_spec.rb" with:
75
+ """
76
+ require 'rspec/expectations'
77
+
78
+ Rspec::Matchers.define :be_a_multiple_of do |expected|
79
+ match do |actual|
80
+ actual % expected == 0
81
+ end
82
+ failure_message_for_should_not do |actual|
83
+ "expected that #{actual} would not be a multiple of #{expected}"
84
+ end
85
+ end
86
+
87
+ # fail intentionally to generate expected output
88
+ describe 9 do
89
+ it {should_not be_a_multiple_of(3)}
90
+ end
91
+ """
92
+ When I run "rspec matcher_with_failure_for_message_spec.rb"
93
+ Then the exit status should not be 0
94
+ And the stdout should contain "1 example, 1 failure"
95
+ And the stdout should contain "expected that 9 would not be a multiple of 3"
96
+
97
+ Scenario: overriding the description
98
+ Given a file named "matcher_overriding_description_spec.rb" with:
99
+ """
100
+ require 'rspec/expectations'
101
+
102
+ Rspec::Matchers.define :be_a_multiple_of do |expected|
103
+ match do |actual|
104
+ actual % expected == 0
105
+ end
106
+ description do
107
+ "be multiple of #{expected}"
108
+ end
109
+ end
110
+
111
+ describe 9 do
112
+ it {should be_a_multiple_of(3)}
113
+ end
114
+
115
+ describe 9 do
116
+ it {should_not be_a_multiple_of(4)}
117
+ end
118
+ """
119
+ When I run "rspec matcher_overriding_description_spec.rb --format specdoc"
120
+ Then the exit status should be 0
121
+ And the stdout should contain "2 examples, 0 failures"
122
+ And the stdout should contain "should be multiple of 3"
123
+ And the stdout should contain "should not be multiple of 4"
124
+
125
+ Scenario: with no args
126
+ Given a file named "matcher_with_no_args_spec.rb" with:
127
+ """
128
+ require 'rspec/expectations'
129
+
130
+ Rspec::Matchers.define :have_7_fingers do
131
+ match do |thing|
132
+ thing.fingers.length == 7
133
+ end
134
+ end
135
+
136
+ class Thing
137
+ def fingers; (1..7).collect {"finger"}; end
138
+ end
139
+
140
+ describe Thing do
141
+ it {should have_7_fingers}
142
+ end
143
+ """
144
+ When I run "rspec matcher_with_no_args_spec.rb --format specdoc"
145
+ Then the exit status should be 0
146
+ And the stdout should contain "1 example, 0 failures"
147
+ And the stdout should contain "should have 7 fingers"
148
+
149
+ Scenario: with multiple args
150
+ Given a file named "matcher_with_multiple_args_spec.rb" with:
151
+ """
152
+ require 'rspec/expectations'
153
+
154
+ Rspec::Matchers.define :be_the_sum_of do |a,b,c,d|
155
+ match do |sum|
156
+ a + b + c + d == sum
157
+ end
158
+ end
159
+
160
+ describe 10 do
161
+ it {should be_the_sum_of(1,2,3,4)}
162
+ end
163
+ """
164
+ When I run "rspec matcher_with_multiple_args_spec.rb --format specdoc"
165
+ Then the exit status should be 0
166
+ And the stdout should contain "1 example, 0 failures"
167
+ And the stdout should contain "should be the sum of 1, 2, 3, and 4"
168
+
169
+ Scenario: with helper methods
170
+ Given a file named "matcher_with_internal_helper_spec.rb" with:
171
+ """
172
+ require 'rspec/expectations'
173
+
174
+ Rspec::Matchers.define :have_same_elements_as do |sample|
175
+ match do |actual|
176
+ similar?(sample, actual)
177
+ end
178
+
179
+ def similar?(a, b)
180
+ a.sort == b.sort
181
+ end
182
+ end
183
+
184
+ describe "these two arrays" do
185
+ specify "should be similar" do
186
+ [1,2,3].should have_same_elements_as([2,3,1])
187
+ end
188
+ end
189
+ """
190
+ When I run "rspec matcher_with_internal_helper_spec.rb"
191
+ Then the exit status should be 0
192
+ And the stdout should contain "1 example, 0 failures"
193
+
@@ -0,0 +1,38 @@
1
+ Feature: define matcher outside rspec
2
+
3
+ In order to express my domain clearly in my code examples
4
+ As a non-rspec user
5
+ I want a shortcut to define custom matchers
6
+
7
+ Scenario: define a matcher with default messages
8
+ Given a file named "test_multiples.rb" with:
9
+ """
10
+ require "rspec/expectations"
11
+ require "test/unit"
12
+
13
+ Rspec::Matchers.define :be_a_multiple_of do |expected|
14
+ match do |actual|
15
+ actual % expected == 0
16
+ end
17
+ end
18
+
19
+ class Test::Unit::TestCase
20
+ include Rspec::Matchers
21
+ end
22
+
23
+ class TestMultiples < Test::Unit::TestCase
24
+
25
+ def test_9_should_be_a_multiple_of_3
26
+ 9.should be_a_multiple_of(3)
27
+ end
28
+
29
+ def test_9_should_be_a_multiple_of_4
30
+ 9.should be_a_multiple_of(4)
31
+ end
32
+
33
+ end
34
+ """
35
+ When I run "ruby test_multiples.rb"
36
+ Then the exit status should not be 0
37
+ And I should see "expected 9 to be a multiple of 4"
38
+ And I should see "2 tests, 0 assertions, 0 failures, 1 errors"
@@ -0,0 +1,5 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../../lib', __FILE__)
2
+ require 'rspec/expectations'
3
+ require 'aruba'
4
+
5
+
@@ -1,16 +1,7 @@
1
1
  module Rspec # :nodoc:
2
2
  module Expectations # :nodoc:
3
3
  module Version # :nodoc:
4
- unless defined?(MAJOR)
5
- MAJOR = 2
6
- MINOR = 0
7
- TINY = 0
8
- PRE = 'a6'
9
-
10
- STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
11
-
12
- SUMMARY = "rspec-expectations " + STRING
13
- end
4
+ STRING = File.read(File.expand_path('../../../../VERSION', __FILE__))
14
5
  end
15
6
  end
16
7
  end
@@ -190,5 +190,10 @@ module Rspec
190
190
  # config.include(CustomGameMatchers)
191
191
  # end
192
192
  #
193
- module Matchers; end
193
+ module Matchers
194
+ if Rspec.respond_to?(:configure)
195
+ Rspec.configure {|c| c.include self}
196
+ end
197
+ end
194
198
  end
199
+
@@ -5,11 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rspec-expectations}
8
- s.version = "2.0.0.a6"
8
+ s.version = "2.0.0.a7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["David Chelimsky", "Chad Humphries"]
12
- s.date = %q{2010-02-15}
12
+ s.date = %q{2010-02-20}
13
+ s.description = %q{rspec expectations (should[_not] and matchers)}
13
14
  s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
14
15
  s.extra_rdoc_files = [
15
16
  "README.markdown"
@@ -21,6 +22,11 @@ Gem::Specification.new do |s|
21
22
  "README.markdown",
22
23
  "Rakefile",
23
24
  "Upgrade.markdown",
25
+ "VERSION",
26
+ "features/expectations/customized_message.feature",
27
+ "features/matchers/define_matcher.feature",
28
+ "features/matchers/define_matcher_outside_rspec.feature",
29
+ "features/support/env.rb",
24
30
  "lib/rspec/expectations.rb",
25
31
  "lib/rspec/expectations/differs/default.rb",
26
32
  "lib/rspec/expectations/differs/load-diff-lcs.rb",
@@ -97,7 +103,7 @@ Gem::Specification.new do |s|
97
103
  s.require_paths = ["lib"]
98
104
  s.rubyforge_project = %q{rspec}
99
105
  s.rubygems_version = %q{1.3.5}
100
- s.summary = %q{rspec expectations (should[_not] and matchers)}
106
+ s.summary = %q{rspec-expectations-2.0.0.a7}
101
107
  s.test_files = [
102
108
  "spec/rspec/expectations/differs/default_spec.rb",
103
109
  "spec/rspec/expectations/extensions/kernel_spec.rb",
@@ -137,15 +143,21 @@ Gem::Specification.new do |s|
137
143
  s.specification_version = 3
138
144
 
139
145
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
140
- s.add_development_dependency(%q<rspec-core>, [">= 2.0.0.a6"])
141
- s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.a6"])
146
+ s.add_development_dependency(%q<cucumber>, [">= 0.6.2"])
147
+ s.add_development_dependency(%q<aruba>, [">= 0.1.1"])
148
+ s.add_development_dependency(%q<rspec-core>, [">= 2.0.0.a7"])
149
+ s.add_development_dependency(%q<rspec-mocks>, [">= 2.0.0.a7"])
142
150
  else
143
- s.add_dependency(%q<rspec-core>, [">= 2.0.0.a6"])
144
- s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.a6"])
151
+ s.add_dependency(%q<cucumber>, [">= 0.6.2"])
152
+ s.add_dependency(%q<aruba>, [">= 0.1.1"])
153
+ s.add_dependency(%q<rspec-core>, [">= 2.0.0.a7"])
154
+ s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.a7"])
145
155
  end
146
156
  else
147
- s.add_dependency(%q<rspec-core>, [">= 2.0.0.a6"])
148
- s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.a6"])
157
+ s.add_dependency(%q<cucumber>, [">= 0.6.2"])
158
+ s.add_dependency(%q<aruba>, [">= 0.1.1"])
159
+ s.add_dependency(%q<rspec-core>, [">= 2.0.0.a7"])
160
+ s.add_dependency(%q<rspec-mocks>, [">= 2.0.0.a7"])
149
161
  end
150
162
  end
151
163
 
@@ -38,6 +38,5 @@ end
38
38
  Rspec::configure do |config|
39
39
  config.mock_with(:rspec)
40
40
  config.include Rspec::Mocks::Methods
41
- config.include Rspec::Matchers
42
41
  config.color_enabled = true
43
42
  end
@@ -1,12 +1,6 @@
1
1
  # This file contains various classes used by the specs.
2
2
  module Rspec
3
3
  module Expectations
4
- # class ClassWithMultiWordPredicate
5
- # def multi_word_predicate?
6
- # true
7
- # end
8
- # end
9
- #
10
4
  module Helper
11
5
  class CollectionWithSizeMethod
12
6
  def initialize; @list = []; end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-expectations
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.a6
4
+ version: 2.0.0.a7
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chelimsky
@@ -10,9 +10,29 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-02-15 00:00:00 -04:00
13
+ date: 2010-02-20 00:00:00 -06:00
14
14
  default_executable:
15
15
  dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: cucumber
18
+ type: :development
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 0.6.2
25
+ version:
26
+ - !ruby/object:Gem::Dependency
27
+ name: aruba
28
+ type: :development
29
+ version_requirement:
30
+ version_requirements: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 0.1.1
35
+ version:
16
36
  - !ruby/object:Gem::Dependency
17
37
  name: rspec-core
18
38
  type: :development
@@ -21,7 +41,7 @@ dependencies:
21
41
  requirements:
22
42
  - - ">="
23
43
  - !ruby/object:Gem::Version
24
- version: 2.0.0.a6
44
+ version: 2.0.0.a7
25
45
  version:
26
46
  - !ruby/object:Gem::Dependency
27
47
  name: rspec-mocks
@@ -31,9 +51,9 @@ dependencies:
31
51
  requirements:
32
52
  - - ">="
33
53
  - !ruby/object:Gem::Version
34
- version: 2.0.0.a6
54
+ version: 2.0.0.a7
35
55
  version:
36
- description:
56
+ description: rspec expectations (should[_not] and matchers)
37
57
  email: dchelimsky@gmail.com;chad.humphries@gmail.com
38
58
  executables: []
39
59
 
@@ -48,6 +68,11 @@ files:
48
68
  - README.markdown
49
69
  - Rakefile
50
70
  - Upgrade.markdown
71
+ - VERSION
72
+ - features/expectations/customized_message.feature
73
+ - features/matchers/define_matcher.feature
74
+ - features/matchers/define_matcher_outside_rspec.feature
75
+ - features/support/env.rb
51
76
  - lib/rspec/expectations.rb
52
77
  - lib/rspec/expectations/differs/default.rb
53
78
  - lib/rspec/expectations/differs/load-diff-lcs.rb
@@ -145,7 +170,7 @@ rubyforge_project: rspec
145
170
  rubygems_version: 1.3.5
146
171
  signing_key:
147
172
  specification_version: 3
148
- summary: rspec expectations (should[_not] and matchers)
173
+ summary: rspec-expectations-2.0.0.a7
149
174
  test_files:
150
175
  - spec/rspec/expectations/differs/default_spec.rb
151
176
  - spec/rspec/expectations/extensions/kernel_spec.rb