rspec-given 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
1
  source 'https://rubygems.org'
2
- gem 'rspec', '>= 2.0'
2
+ gem 'rspec', '>= 2.12'
3
3
  gem 'rake', '>= 0.9.2.2'
data/Gemfile.lock CHANGED
@@ -3,18 +3,18 @@ GEM
3
3
  specs:
4
4
  diff-lcs (1.1.3)
5
5
  rake (0.9.2.2)
6
- rspec (2.11.0)
7
- rspec-core (~> 2.11.0)
8
- rspec-expectations (~> 2.11.0)
9
- rspec-mocks (~> 2.11.0)
10
- rspec-core (2.11.1)
11
- rspec-expectations (2.11.2)
6
+ rspec (2.12.0)
7
+ rspec-core (~> 2.12.0)
8
+ rspec-expectations (~> 2.12.0)
9
+ rspec-mocks (~> 2.12.0)
10
+ rspec-core (2.12.0)
11
+ rspec-expectations (2.12.0)
12
12
  diff-lcs (~> 1.1.3)
13
- rspec-mocks (2.11.2)
13
+ rspec-mocks (2.12.0)
14
14
 
15
15
  PLATFORMS
16
16
  ruby
17
17
 
18
18
  DEPENDENCIES
19
19
  rake (>= 0.9.2.2)
20
- rspec (>= 2.0)
20
+ rspec (>= 2.12)
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # rspec-given
2
2
 
3
- Covering rspec-given, version 2.2.0.
3
+ Covering rspec-given, version 2.2.1.
4
4
 
5
5
  rspec-given is an RSpec extension to allow Given/When/Then notation in
6
6
  RSpec specifications. It is a natural extension of the experimental
@@ -10,6 +10,10 @@ module RSpec
10
10
  @exception = exception
11
11
  end
12
12
 
13
+ def is_a?(klass)
14
+ klass == Failure
15
+ end
16
+
13
17
  def method_missing(sym, *args, &block)
14
18
  ::Kernel.raise @exception
15
19
  end
@@ -2,22 +2,61 @@ module RSpec
2
2
  module Given
3
3
  module HaveFailed
4
4
 
5
- # Alias for raise_error(...), but reads a bit better when using
5
+ # Specializes the RaiseError matcher to handle
6
+ # Failure/non-failure objects.
7
+
8
+ # The implementation of RaiseError changed between RSpec 2.11 and 2.12.
9
+ if RSpec::Matchers::BuiltIn::RaiseError.instance_methods.include?(:does_not_match?)
10
+
11
+ class HaveFailedMatcher < RSpec::Matchers::BuiltIn::RaiseError
12
+ def matches?(given_proc, negative_expectation = false)
13
+ if given_proc.is_a?(Failure)
14
+ super
15
+ else
16
+ super(lambda { }, negative_expectation)
17
+ end
18
+ end
19
+
20
+ def does_not_match?(given_proc)
21
+ if given_proc.is_a?(Failure)
22
+ super(given_proc)
23
+ else
24
+ super(lambda { })
25
+ end
26
+ end
27
+ end
28
+
29
+ else
30
+
31
+ class HaveFailedMatcher < RSpec::Matchers::BuiltIn::RaiseError
32
+ def matches?(given_proc)
33
+ if given_proc.is_a?(Failure)
34
+ super
35
+ else
36
+ super(lambda { })
37
+ end
38
+ end
39
+ end
40
+
41
+ end
42
+
43
+ # Simular to raise_error(...), but reads a bit better when using
6
44
  # a failure result from a when clause.
7
45
  #
8
- # NOTE: This is new for 1.6.0.beta.1. A name change for this
9
- # method is possible.
10
- #
11
46
  # Typical Usage:
12
47
  #
13
48
  # When(:result) { fail "OUCH" }
14
49
  # Then { result.should have_failed(StandardError, /OUCH/) }
15
50
  #
51
+ # When(:result) { good_code }
52
+ # Then { result.should_not have_failed }
53
+ #
16
54
  # :call-seq:
17
55
  # have_failed([exception_class [, message_pattern]])
56
+ # have_failed([exception_class [, message_pattern]]) { |ex| ... }
18
57
  #
19
- def have_failed(*args, &block)
20
- raise_error(*args, &block)
58
+ def have_failed(error=Exception, message=nil, &block)
59
+ HaveFailedMatcher.new(error, message, &block)
21
60
  end
22
61
  end
23
62
  end
@@ -3,7 +3,7 @@ module RSpec
3
3
  VERSION_NUMBERS = [
4
4
  VERSION_MAJOR = 2,
5
5
  VERSION_MINOR = 2,
6
- VERSION_BUILD = 0,
6
+ VERSION_BUILD = 1,
7
7
  ]
8
8
  VERSION = VERSION_NUMBERS.join(".")
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-given
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
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: 2012-11-15 00:00:00.000000000 Z
12
+ date: 2012-11-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -72,10 +72,9 @@ files:
72
72
  - Gemfile
73
73
  - Gemfile.lock
74
74
  - MIT-LICENSE
75
- - README.md
76
75
  - Rakefile
76
+ - README.md
77
77
  - lib/rspec-given.rb
78
- - lib/rspec/given.rb
79
78
  - lib/rspec/given/configure.rb
80
79
  - lib/rspec/given/extensions.rb
81
80
  - lib/rspec/given/failure.rb
@@ -85,6 +84,7 @@ files:
85
84
  - lib/rspec/given/module_methods.rb
86
85
  - lib/rspec/given/rspec1_given.rb
87
86
  - lib/rspec/given/version.rb
87
+ - lib/rspec/given.rb
88
88
  - examples/example_helper.rb
89
89
  - examples/integration/and_spec.rb
90
90
  - examples/integration/focused_line_spec.rb
@@ -112,6 +112,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
112
  - - ! '>='
113
113
  - !ruby/object:Gem::Version
114
114
  version: '0'
115
+ segments:
116
+ - 0
117
+ hash: 3954842768326946335
115
118
  required_rubygems_version: !ruby/object:Gem::Requirement
116
119
  none: false
117
120
  requirements: