shoulda-context 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- OWFjNDc2MDE5Njc1ZWQwNDhhZDFlMTk5MjNlMTIxYmFmMWQ0YjNiZg==
5
- data.tar.gz: !binary |-
6
- NWM1ZGJkMTM2NzJlOTAxMzgwZmIwMzBkMDFhNTM2MzkyZWJiYzI3ZA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- NTlmNjFmNTE3M2RmMTM5NjZmYWFkMDhkYmUwNTRlZDA3YjQyODE3ZTM5OTk5
10
- YTg4ZjIxMDJmNmVlZDRiMWFiZmMyMDM4NDRkYTk4ODFiNjM0ZTZjZDhhYTk1
11
- NzNlMDkwNWI0YTdjOTE2OWMwMjQ3MGM0NjY2NDFlYzVjNDQ2MzQ=
12
- data.tar.gz: !binary |-
13
- MjM1MDRhZDkyMmQ4YjQ5NGM1NjcyZGQ4YTkxOWExZTZkYWNlYWJkMGRjMzVl
14
- YzViMzg1YTA5ZWEyZWY1OGYwZjdkMDQ5NGUxODI3NDFiNzA1MzllMjM2NTcx
15
- MjkyNWFiZjE2NzJiN2JlNDk0OWNjNzM4MTQzMGNlYjk1ZDFjYWM=
2
+ SHA1:
3
+ metadata.gz: 41b60644837ba1b4d4168e7bdab013f4bc834e67
4
+ data.tar.gz: d9a1a81ea9625b792003edd12afcd6f6f7eacb9f
5
+ SHA512:
6
+ metadata.gz: 57eb54533d9edb1aca3f479e1e516f2625706294e53fe164e6779f7f6c7e177fa0b4267a20151e4a122dfe834d24dfdcdeea5702da1d379ef1293d6035dc8e10
7
+ data.tar.gz: 33ab273a78b588d99b4d34e5b09bee1ab2068f2157e3883edea8f4b8fa1c24b14d01c3cbb1debe8b82c8a0597ced79922d3efc79d0ab9b5bfb414af581e9be41
@@ -52,14 +52,14 @@ module Shoulda # :nodoc:
52
52
  end
53
53
 
54
54
  if matcher.matches?(target)
55
- assert_block { true }
55
+ safe_assert_block { true }
56
56
  if options[:message]
57
57
  message = matcher.respond_to?(:failure_message_for_should_not) ? matcher.failure_message_for_should_not : matcher.negative_failure_message
58
58
  assert_match options[:message], message
59
59
  end
60
60
  else
61
61
  message = matcher.respond_to?(:failure_message_for_should) ? matcher.failure_message_for_should : matcher.failure_message
62
- assert_block(message) { false }
62
+ safe_assert_block(message) { false }
63
63
  end
64
64
  end
65
65
 
@@ -73,14 +73,22 @@ module Shoulda # :nodoc:
73
73
  not_match = matcher.respond_to?(:does_not_match?) ? matcher.does_not_match?(target) : !matcher.matches?(target)
74
74
 
75
75
  if not_match
76
- assert_block { true }
76
+ safe_assert_block { true }
77
77
  if options[:message]
78
78
  message = matcher.respond_to?(:failure_message_for_should) ? matcher.failure_message_for_should : matcher.failure_message
79
79
  assert_match options[:message], message
80
80
  end
81
81
  else
82
82
  message = matcher.respond_to?(:failure_message_for_should_not) ? matcher.failure_message_for_should_not : matcher.negative_failure_message
83
- assert_block(message) { false }
83
+ safe_assert_block(message) { false }
84
+ end
85
+ end
86
+
87
+ def safe_assert_block(message = nil, &block)
88
+ if respond_to?(:assert_block)
89
+ assert_block message, &block
90
+ else
91
+ assert yield, message
84
92
  end
85
93
  end
86
94
  end
@@ -385,7 +385,7 @@ module Shoulda
385
385
  test_name = ["test:", full_name, "should", "#{should[:name]}. "].flatten.join(' ').to_sym
386
386
 
387
387
  if test_methods[test_unit_class][test_name.to_s] then
388
- warn " * WARNING: '#{test_name}' is already defined"
388
+ raise DuplicateTestError, "'#{test_name}' is defined more than once."
389
389
  end
390
390
 
391
391
  test_methods[test_unit_class][test_name.to_s] = true
@@ -450,3 +450,5 @@ module Shoulda
450
450
  end
451
451
  end
452
452
  end
453
+
454
+ class DuplicateTestError < RuntimeError; end
@@ -1,5 +1,5 @@
1
1
  module Shoulda
2
2
  module Context
3
- VERSION = '1.1.2'.freeze
3
+ VERSION = '1.1.3'.freeze
4
4
  end
5
5
  end
@@ -1,26 +1,25 @@
1
1
  begin
2
- # if present, then also loads MiniTest::Unit::TestCase
2
+ # if present, load and set base_test_case
3
3
  ActiveSupport::TestCase
4
+ if defined?([ActiveSupport::TestCase, MiniTest::Unit::TestCase]) &&
5
+ (ActiveSupport::TestCase.ancestors.include?(MiniTest::Unit::TestCase))
6
+ base_test_case = MiniTest::Unit::TestCase
7
+ end
4
8
  rescue
5
9
  end
6
10
 
7
- if defined?([ActiveSupport::TestCase, MiniTest::Unit::TestCase]) && (ActiveSupport::TestCase.ancestors.include?(MiniTest::Unit::TestCase))
8
- base_test_case = MiniTest::Unit::TestCase
9
- else
10
- if !defined?(Test::Unit::TestCase)
11
- require 'test/unit/testcase'
12
- end
11
+ # no base_test_case set, using Test:Unit:TestCase
12
+ unless base_test_case
13
+ require 'test/unit/testcase' unless defined?(Test::Unit::TestCase)
13
14
  base_test_case = Test::Unit::TestCase
14
15
  end
15
16
 
16
-
17
17
  require 'shoulda/context/version'
18
18
  require 'shoulda/context/proc_extensions'
19
19
  require 'shoulda/context/assertions'
20
20
  require 'shoulda/context/context'
21
21
  require 'shoulda/context/autoload_macros'
22
22
 
23
-
24
23
  module ShouldaContextLoadable
25
24
  def self.included(base)
26
25
  base.class_eval do
@@ -46,7 +46,6 @@ class ShouldTest < Test::Unit::TestCase # :nodoc:
46
46
  end
47
47
 
48
48
  context "Context" do
49
-
50
49
  should_see_class_methods
51
50
  should_see_a_context_block_like_a_Test_Unit_class
52
51
  should_be_able_to_make_context_macros("Context ")
@@ -155,6 +154,20 @@ class ShouldTest < Test::Unit::TestCase # :nodoc:
155
154
  assert_equal "Parent Child GrandChild", grandchild.full_name
156
155
  end
157
156
 
157
+ def test_should_raise_on_duplicate_naming
158
+ tu_class = Test::Unit::TestCase
159
+ context = Shoulda::Context::Context.new("DupContext", tu_class) do
160
+ should "dup" do; end
161
+ should "dup" do; end
162
+ end
163
+
164
+ names = context.shoulds.map {|s| s[:name]}
165
+ assert_equal 1, names.uniq.length
166
+ assert_raise DuplicateTestError do
167
+ context.build
168
+ end
169
+ end
170
+
158
171
  # Should statements
159
172
 
160
173
  def test_should_have_should_hashes_when_given_should_statements
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shoulda-context
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoughtbot, inc.
@@ -13,78 +13,78 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2013-05-16 00:00:00.000000000 Z
16
+ date: 2013-06-21 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
+ name: appraisal
19
20
  requirement: !ruby/object:Gem::Requirement
20
21
  requirements:
21
22
  - - ~>
22
23
  - !ruby/object:Gem::Version
23
24
  version: '0.5'
25
+ type: :development
26
+ prerelease: false
24
27
  version_requirements: !ruby/object:Gem::Requirement
25
28
  requirements:
26
29
  - - ~>
27
30
  - !ruby/object:Gem::Version
28
31
  version: '0.5'
29
- type: :development
30
- prerelease: false
31
- name: appraisal
32
32
  - !ruby/object:Gem::Dependency
33
+ name: rails
33
34
  requirement: !ruby/object:Gem::Requirement
34
35
  requirements:
35
- - - ! '>='
36
+ - - '>='
36
37
  - !ruby/object:Gem::Version
37
38
  version: '3.0'
39
+ type: :development
40
+ prerelease: false
38
41
  version_requirements: !ruby/object:Gem::Requirement
39
42
  requirements:
40
- - - ! '>='
43
+ - - '>='
41
44
  - !ruby/object:Gem::Version
42
45
  version: '3.0'
43
- type: :development
44
- prerelease: false
45
- name: rails
46
46
  - !ruby/object:Gem::Dependency
47
+ name: mocha
47
48
  requirement: !ruby/object:Gem::Requirement
48
49
  requirements:
49
50
  - - ~>
50
51
  - !ruby/object:Gem::Version
51
52
  version: 0.9.10
53
+ type: :development
54
+ prerelease: false
52
55
  version_requirements: !ruby/object:Gem::Requirement
53
56
  requirements:
54
57
  - - ~>
55
58
  - !ruby/object:Gem::Version
56
59
  version: 0.9.10
57
- type: :development
58
- prerelease: false
59
- name: mocha
60
60
  - !ruby/object:Gem::Dependency
61
+ name: rake
61
62
  requirement: !ruby/object:Gem::Requirement
62
63
  requirements:
63
- - - ! '>='
64
+ - - '>='
64
65
  - !ruby/object:Gem::Version
65
66
  version: '0'
67
+ type: :development
68
+ prerelease: false
66
69
  version_requirements: !ruby/object:Gem::Requirement
67
70
  requirements:
68
- - - ! '>='
71
+ - - '>='
69
72
  - !ruby/object:Gem::Version
70
73
  version: '0'
71
- type: :development
72
- prerelease: false
73
- name: rake
74
74
  - !ruby/object:Gem::Dependency
75
+ name: test-unit
75
76
  requirement: !ruby/object:Gem::Requirement
76
77
  requirements:
77
78
  - - ~>
78
79
  - !ruby/object:Gem::Version
79
80
  version: 2.1.0
81
+ type: :development
82
+ prerelease: false
80
83
  version_requirements: !ruby/object:Gem::Requirement
81
84
  requirements:
82
85
  - - ~>
83
86
  - !ruby/object:Gem::Version
84
87
  version: 2.1.0
85
- type: :development
86
- prerelease: false
87
- name: test-unit
88
88
  description: Context framework extracted from Shoulda
89
89
  email: support@thoughtbot.com
90
90
  executables:
@@ -143,17 +143,17 @@ require_paths:
143
143
  - lib
144
144
  required_ruby_version: !ruby/object:Gem::Requirement
145
145
  requirements:
146
- - - ! '>='
146
+ - - '>='
147
147
  - !ruby/object:Gem::Version
148
148
  version: '0'
149
149
  required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  requirements:
151
- - - ! '>='
151
+ - - '>='
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0'
154
154
  requirements: []
155
155
  rubyforge_project:
156
- rubygems_version: 2.0.3
156
+ rubygems_version: 2.0.2
157
157
  signing_key:
158
158
  specification_version: 4
159
159
  summary: Context framework extracted from Shoulda