rspec-given 2.3.1.beta.1 → 2.3.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # rspec-given
2
2
 
3
- Covering rspec-given, version 2.3.1.beta.1.
3
+ Covering rspec-given, version 2.3.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
@@ -105,7 +105,7 @@ module RSpec
105
105
  passed = instance_eval(&block)
106
106
  if ! passed && _rg_na_configured? && ! RSpec::Given.matcher_called
107
107
  nassert = NaturalAssertion.new(block, binding, self.class._rgc_lines)
108
- ::RSpec::Expectations.fail_with nassert.message if _rg_need_na_message?(nassert)
108
+ RSpec::Given.fail_with nassert.message if _rg_need_na_message?(nassert)
109
109
  end
110
110
  end
111
111
  end
@@ -144,9 +144,9 @@ module RSpec
144
144
 
145
145
  # *DEPRECATED:*
146
146
  #
147
- # The Scenario command is deprecated. Using Scenario in a spec
148
- # will result in a warning message. Eventually the command will
149
- # be removed.
147
+ # The Scenario command is deprecated. Using Scenario in an
148
+ # example will result in a warning message. Eventually the
149
+ # command will be removed.
150
150
  #
151
151
  # Declare a scenario to contain Given/When/Then declarations. A
152
152
  # Scenario is essentially an RSpec context, with the additional
@@ -206,7 +206,7 @@ module RSpec
206
206
  begin
207
207
  _rg_establish_givens
208
208
  instance_eval(&block)
209
- rescue RSpec::Core::Pending::PendingDeclaredInExample => ex
209
+ rescue RSpec::Given.pending_error => ex
210
210
  raise
211
211
  rescue Exception => ex
212
212
  Failure.new(ex)
@@ -15,7 +15,7 @@ module RSpec
15
15
  end
16
16
 
17
17
  def ==(other)
18
- if other.is_a?(::RSpec::Given::HaveFailed::HaveFailedMatcher)
18
+ if failed_matcher?(other)
19
19
  other.matches?(self)
20
20
  else
21
21
  die
@@ -23,20 +23,27 @@ module RSpec
23
23
  end
24
24
 
25
25
  def !=(other)
26
- if other.is_a?(::RSpec::Given::HaveFailed::HaveFailedMatcher)
26
+ if failed_matcher?(other)
27
27
  ! other.matches?(self)
28
28
  else
29
29
  die
30
30
  end
31
31
  end
32
32
 
33
+ def method_missing(sym, *args, &block)
34
+ die
35
+ end
36
+
37
+ private
38
+
33
39
  def die
34
40
  ::Kernel.raise @exception
35
41
  end
36
42
 
37
- def method_missing(sym, *args, &block)
38
- die
43
+ def failed_matcher?(other)
44
+ other.is_a?(::RSpec::Given::HaveFailed::HaveFailedMatcher)
39
45
  end
46
+
40
47
  end
41
48
  end
42
49
  end
@@ -1,13 +1,14 @@
1
1
  module RSpec
2
2
  module Given
3
+ # Does this platform support natural assertions?
3
4
  NATURAL_ASSERTIONS_SUPPORTED = ! defined?(JRUBY_VERSION)
4
5
 
5
6
  def self.matcher_called
6
- @matcher_called
7
+ @_matcher_called
7
8
  end
8
9
 
9
10
  def self.matcher_called=(value)
10
- @matcher_called = value
11
+ @_matcher_called = value
11
12
  end
12
13
 
13
14
  def self.source_caching_disabled
@@ -18,24 +19,49 @@ module RSpec
18
19
  @_rg_source_caching_disabled = value
19
20
  end
20
21
 
22
+ # Detect the formatting requested in the given configuration object.
23
+ #
24
+ # If the format requires it, source caching will be enabled.
21
25
  def self.detect_formatters(c)
22
26
  format_active = c.formatters.any? { |f| f.class.name !~ /ProgressFormatter/ }
23
27
  RSpec::Given.source_caching_disabled = ! format_active
24
28
  end
25
29
 
30
+ # Globally enable/disable natural assertions.
31
+ #
32
+ # There is a similar function in Extensions that works at a
33
+ # describe or context scope.
26
34
  def self.use_natural_assertions(enabled=true)
27
35
  ok_to_use_natural_assertions(enabled)
28
36
  @natural_assertions_enabled = enabled
29
37
  end
30
38
 
39
+ # TRUE if natural assertions are globally enabled?
40
+ def self.natural_assertions_enabled?
41
+ @natural_assertions_enabled
42
+ end
43
+
44
+ # Is is OK to use natural assertions on this platform.
45
+ #
46
+ # An error is raised if the the platform does not support natural
47
+ # assertions and the flag is attempting to enable them.
31
48
  def self.ok_to_use_natural_assertions(enabled)
32
49
  if enabled && ! NATURAL_ASSERTIONS_SUPPORTED
33
50
  fail ArgumentError, "Natural Assertions are disabled for JRuby"
34
51
  end
35
52
  end
36
53
 
37
- def self.natural_assertions_enabled?
38
- @natural_assertions_enabled
54
+ # Fail an example with the given messages.
55
+ #
56
+ # This should be the only place we reference the RSpec function.
57
+ # Everywhere else in rspec-given should be calling this function.
58
+ def self.fail_with(*args)
59
+ ::RSpec::Expectations.fail_with(*args)
60
+ end
61
+
62
+ # Error object used by RSpec to indicate a pending example.
63
+ def self.pending_error
64
+ RSpec::Core::Pending::PendingDeclaredInExample
39
65
  end
40
66
  end
41
67
  end
@@ -4,7 +4,6 @@ module RSpec
4
4
  VERSION_MAJOR = 2,
5
5
  VERSION_MINOR = 3,
6
6
  VERSION_BUILD = 1,
7
- 'beta', 1
8
7
  ]
9
8
  VERSION = VERSION_NUMBERS.join(".")
10
9
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-given
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1.beta.1
5
- prerelease: 6
4
+ version: 2.3.1
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jim Weirich
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-24 00:00:00.000000000 Z
12
+ date: 2013-01-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -138,9 +138,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
138
  required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  none: false
140
140
  requirements:
141
- - - ! '>'
141
+ - - ! '>='
142
142
  - !ruby/object:Gem::Version
143
- version: 1.3.1
143
+ version: '0'
144
144
  requirements: []
145
145
  rubyforge_project: given
146
146
  rubygems_version: 1.8.24