shared_should 0.5.3 → 0.5.4

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.3
1
+ 0.5.4
data/lib/shared_should.rb CHANGED
@@ -1,16 +1,16 @@
1
1
  require 'shoulda'
2
2
 
3
3
  class Shoulda::Context
4
+ alias :method_mission_without_shared_method_check :method_missing
4
5
  def method_missing(method, *args, &blk)
5
6
  current_context = self
6
7
  while current_context && (current_context.kind_of?(Shoulda::Context) || current_context < Test::Unit::TestCase) do
7
8
  if Test::Unit::TestCase.shared_context_block_owner(current_context).shared_context_blocks[method.to_s]
8
- current_context.send(method, args[0], self, &blk)
9
- return
9
+ return current_context.send(method, args[0], self, &blk)
10
10
  end
11
11
  current_context = current_context.parent
12
12
  end
13
- super
13
+ method_mission_without_shared_method_check(method, *args, &blk)
14
14
  end
15
15
  end
16
16
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{shared_should}
8
- s.version = "0.5.3"
8
+ s.version = "0.5.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Pearce"]
@@ -1,6 +1,7 @@
1
1
  require 'helper'
2
2
 
3
3
  class TestSharedShould < Test::Unit::TestCase
4
+ # check that setup instance method is executed
4
5
  def setup
5
6
  super
6
7
  @setup_instance_method_executed = true
@@ -10,24 +11,6 @@ class TestSharedShould < Test::Unit::TestCase
10
11
  assert @setup_instance_method_executed
11
12
  end
12
13
 
13
- begin
14
- invalid_method do
15
- end
16
- raise "Should have raised a NoMethodError"
17
- rescue NoMethodError
18
- # successfully raised NoMethodError
19
- end
20
-
21
- context "NoMethodError check" do
22
- begin
23
- invalid_method do
24
- end
25
- raise "Should have raised a NoMethodError"
26
- rescue NoMethodError
27
- # successfully raised NoMethodError
28
- end
29
- end
30
-
31
14
  context ".shared_context_for" do
32
15
  context "without params" do
33
16
  shared_context_for "a valid value" do
@@ -379,12 +362,38 @@ class TestSharedShould < Test::Unit::TestCase
379
362
  should_be("a valid context test in class")
380
363
 
381
364
 
382
- # ensure test methods are created
383
- test_method_names = suite.tests.inject({}) do |test_method_names, test_case|
384
- test_method_names[test_case.method_name] = true
385
- test_method_names
365
+ # ensure should macros work
366
+ def self.should_be_a_valid_macro
367
+ should "be a valid macro" do
368
+ assert true
369
+ end
370
+ end
371
+
372
+ context "shoulda macro" do
373
+ should_be_a_valid_macro
374
+ end
375
+
376
+ # ensure NoMethodError called when method not found
377
+ begin
378
+ invalid_method do
379
+ end
380
+ raise "Should have raised a NoMethodError"
381
+ rescue NoMethodError
382
+ # successfully raised NoMethodError
386
383
  end
387
- [
384
+
385
+ context "NoMethodError check" do
386
+ begin
387
+ invalid_method do
388
+ end
389
+ raise "Should have raised a NoMethodError"
390
+ rescue NoMethodError
391
+ # successfully raised NoMethodError
392
+ end
393
+ end
394
+
395
+ # ensure test methods are created
396
+ expected_method_names = [
388
397
  "test: .shared_context_for with params when true for a valid specified value should call setup in shared context. ",
389
398
  "test: .shared_context_for with params when true for a valid specified value should call setup in shared context. ",
390
399
  "test: .shared_context_for with params when true for a valid specified value should have specified value. ",
@@ -417,8 +426,21 @@ class TestSharedShould < Test::Unit::TestCase
417
426
  "test: parameterized block with an array should be be valid with shared should. ",
418
427
  "test: should be a valid should test in class. ",
419
428
  "test: for a valid context test in class should have a true value. ",
420
- "test: SharedShould should execute setup instance method. "
421
- ].each do |method_name|
422
- raise "Test method not found: '#{method_name}'" unless test_method_names.include?(method_name)
429
+ "test: SharedShould should execute setup instance method. ",
430
+ "test: shoulda macro should be a valid macro. "
431
+ ].inject({}) do |hash, expected_method_name|
432
+ hash[expected_method_name] = true
433
+ hash
434
+ end
435
+ actual_method_names = suite.tests.inject({}) do |hash, test_case|
436
+ hash[test_case.method_name] = true
437
+ hash
438
+ end
439
+
440
+ expected_method_names.each do |method_name, value|
441
+ raise "Test method not found: '#{method_name}'" unless actual_method_names.include?(method_name)
442
+ end
443
+ actual_method_names.each do |method_name, value|
444
+ raise "Unexpected test method: '#{method_name}'" unless expected_method_names.include?(method_name)
423
445
  end
424
446
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shared_should
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 3
10
- version: 0.5.3
9
+ - 4
10
+ version: 0.5.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Pearce