shared_should 0.6.2 → 0.6.3
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 +10 -10
 - data/VERSION +1 -1
 - data/lib/shared_should.rb +19 -13
 - data/shared_should.gemspec +2 -2
 - data/test/test_shared_should.rb +74 -60
 - data/test/test_shared_should_helper.rb +1 -1
 - metadata +4 -4
 
    
        data/README.md
    CHANGED
    
    | 
         @@ -114,7 +114,7 @@ Some rules: 
     | 
|
| 
       114 
114 
     | 
    
         | 
| 
       115 
115 
     | 
    
         
             
            ### Initialization Block
         
     | 
| 
       116 
116 
     | 
    
         | 
| 
       117 
     | 
    
         
            -
            The shared invocation accepts an initialization block by chaining <tt>when</tt> followed by a block. This block can be used to create or modify instance variables used by the shared functionality. It always executes before the shared functionality.
         
     | 
| 
      
 117 
     | 
    
         
            +
            The shared invocation accepts an initialization block by chaining <tt>with</tt> (or its alias <tt>when</tt>) followed by a block. This block can be used to create or modify instance variables used by the shared functionality. It always executes before the shared functionality.
         
     | 
| 
       118 
118 
     | 
    
         | 
| 
       119 
119 
     | 
    
         
             
                context "Book" do
         
     | 
| 
       120 
120 
     | 
    
         
             
                    setup { @book = Book.new(:quantity => 1, :price => 10_00) }
         
     | 
| 
         @@ -123,7 +123,7 @@ The shared invocation accepts an initialization block by chaining <tt>when</tt> 
     | 
|
| 
       123 
123 
     | 
    
         | 
| 
       124 
124 
     | 
    
         
             
                    context "with a rentable book" do
         
     | 
| 
       125 
125 
     | 
    
         
             
                        # when share_should "be available for checkout" is executed, @book will have rentable equal to true
         
     | 
| 
       126 
     | 
    
         
            -
                        use_should("be available for checkout"). 
     | 
| 
      
 126 
     | 
    
         
            +
                        use_should("be available for checkout").with("a rentable book") { @book.rentable = true }
         
     | 
| 
       127 
127 
     | 
    
         
             
                    end
         
     | 
| 
       128 
128 
     | 
    
         | 
| 
       129 
129 
     | 
    
         
             
                    context "with a purchasable book" do
         
     | 
| 
         @@ -133,7 +133,7 @@ The shared invocation accepts an initialization block by chaining <tt>when</tt> 
     | 
|
| 
       133 
133 
     | 
    
         | 
| 
       134 
134 
     | 
    
         
             
            ### Parameterizing Shares
         
     | 
| 
       135 
135 
     | 
    
         | 
| 
       136 
     | 
    
         
            -
            Shared functions can also be parameterized using block parameters. This can be done for shared setups, shoulds, and the setups and shoulds contained within a shared context. The value passed to the shared function is the return value of the <tt> 
     | 
| 
      
 136 
     | 
    
         
            +
            Shared functions can also be parameterized using block parameters. This can be done for shared setups, shoulds, and the setups and shoulds contained within a shared context. The value passed to the shared function is the return value of the <tt>given</tt> parameterization block. The below example parameterizes a shared setup.
         
     | 
| 
       137 
137 
     | 
    
         | 
| 
       138 
138 
     | 
    
         
             
                context "Book" do
         
     | 
| 
       139 
139 
     | 
    
         
             
                    share_setup "for an in-stock book" do |rentable|
         
     | 
| 
         @@ -142,7 +142,7 @@ Shared functions can also be parameterized using block parameters. This can be d 
     | 
|
| 
       142 
142 
     | 
    
         | 
| 
       143 
143 
     | 
    
         
             
                    context "with rentable book" do
         
     | 
| 
       144 
144 
     | 
    
         
             
                        # the return value of the block is "true" which will be passed as the block parameter "rentable"
         
     | 
| 
       145 
     | 
    
         
            -
                        use_setup("for an in-stock book"). 
     | 
| 
      
 145 
     | 
    
         
            +
                        use_setup("for an in-stock book").given { true }
         
     | 
| 
       146 
146 
     | 
    
         | 
| 
       147 
147 
     | 
    
         
             
                        should "be available for checkout" { assert @book.available_for_checkout? }
         
     | 
| 
       148 
148 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -159,8 +159,8 @@ Here is a parameterized shared should. 
     | 
|
| 
       159 
159 
     | 
    
         
             
                            assert_false @book.available_for_checkout?
         
     | 
| 
       160 
160 
     | 
    
         
             
                        end
         
     | 
| 
       161 
161 
     | 
    
         | 
| 
       162 
     | 
    
         
            -
                        use_should("be unavailable for checkout for price"). 
     | 
| 
       163 
     | 
    
         
            -
                        use_should("be unavailable for checkout for price"). 
     | 
| 
      
 162 
     | 
    
         
            +
                        use_should("be unavailable for checkout for price").given("zero") { 0 }
         
     | 
| 
      
 163 
     | 
    
         
            +
                        use_should("be unavailable for checkout for price").given("a negative price") { -1 }
         
     | 
| 
       164 
164 
     | 
    
         
             
                    end
         
     | 
| 
       165 
165 
     | 
    
         
             
                end
         
     | 
| 
       166 
166 
     | 
    
         | 
| 
         @@ -180,7 +180,7 @@ And a parameterized shared context. 
     | 
|
| 
       180 
180 
     | 
    
         
             
                            should "be rentable or purchasable" { assert @book.rentable || @book.purchasable }
         
     | 
| 
       181 
181 
     | 
    
         
             
                        end
         
     | 
| 
       182 
182 
     | 
    
         | 
| 
       183 
     | 
    
         
            -
                        use_context("for a book available for checkout at price"). 
     | 
| 
      
 183 
     | 
    
         
            +
                        use_context("for a book available for checkout at price").given("a positive price") { 10_00 }
         
     | 
| 
       184 
184 
     | 
    
         
             
                    end
         
     | 
| 
       185 
185 
     | 
    
         
             
                end
         
     | 
| 
       186 
186 
     | 
    
         | 
| 
         @@ -196,8 +196,8 @@ The shared functions also accept multiple parameters when the parameterization b 
     | 
|
| 
       196 
196 
     | 
    
         
             
                            assert_false @book.available_for_checkout?
         
     | 
| 
       197 
197 
     | 
    
         
             
                        end
         
     | 
| 
       198 
198 
     | 
    
         | 
| 
       199 
     | 
    
         
            -
                        use_should("be unavailable for checkout for quantity and price"). 
     | 
| 
       200 
     | 
    
         
            -
                        use_should("be unavailable for checkout for quantity and price"). 
     | 
| 
      
 199 
     | 
    
         
            +
                        use_should("be unavailable for checkout for quantity and price").given("a zero quantity") { [0, 10_00] }
         
     | 
| 
      
 200 
     | 
    
         
            +
                        use_should("be unavailable for checkout for quantity and price").given("a zero price") { [1, 0] }
         
     | 
| 
       201 
201 
     | 
    
         
             
                    end
         
     | 
| 
       202 
202 
     | 
    
         
             
                end
         
     | 
| 
       203 
203 
     | 
    
         | 
| 
         @@ -217,7 +217,7 @@ In your test file: 
     | 
|
| 
       217 
217 
     | 
    
         | 
| 
       218 
218 
     | 
    
         
             
                class BookTest < Test::Unit::TestCase
         
     | 
| 
       219 
219 
     | 
    
         
             
                    context "with an in-stock book" do
         
     | 
| 
       220 
     | 
    
         
            -
                        use_setup("for an in-stock book"). 
     | 
| 
      
 220 
     | 
    
         
            +
                        use_setup("for an in-stock book").given { [true, true] }
         
     | 
| 
       221 
221 
     | 
    
         | 
| 
       222 
222 
     | 
    
         
             
                        should "be in stock" { assert @book.quantity > 0 }
         
     | 
| 
       223 
223 
     | 
    
         
             
                    end
         
     | 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            0.6. 
     | 
| 
      
 1 
     | 
    
         
            +
            0.6.3
         
     | 
    
        data/lib/shared_should.rb
    CHANGED
    
    | 
         @@ -18,8 +18,8 @@ end 
     | 
|
| 
       18 
18 
     | 
    
         
             
            class Test::Unit::TestCase
         
     | 
| 
       19 
19 
     | 
    
         
             
              attr_accessor :shared_value
         
     | 
| 
       20 
20 
     | 
    
         
             
              attr_accessor :shared_name
         
     | 
| 
       21 
     | 
    
         
            -
              @@shared_proxies_executed =  
     | 
| 
       22 
     | 
    
         
            -
              @@setup_blocks =  
     | 
| 
      
 21 
     | 
    
         
            +
              @@shared_proxies_executed = {}
         
     | 
| 
      
 22 
     | 
    
         
            +
              @@setup_blocks = {}
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
              class << self
         
     | 
| 
       25 
25 
     | 
    
         
             
                # these methods need to be aliased for both the test class and the should context
         
     | 
| 
         @@ -27,11 +27,12 @@ class Test::Unit::TestCase 
     | 
|
| 
       27 
27 
     | 
    
         
             
              end
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
29 
     | 
    
         
             
              def self.suite
         
     | 
| 
       30 
     | 
    
         
            -
                 
     | 
| 
      
 30 
     | 
    
         
            +
                # assuming 'suite' is called before executing any tests - may be a poor assumption. Find something better?
         
     | 
| 
      
 31 
     | 
    
         
            +
                unless @@shared_proxies_executed[self]
         
     | 
| 
       31 
32 
     | 
    
         
             
                  shared_proxies.each do |shared_proxy|
         
     | 
| 
       32 
33 
     | 
    
         
             
                    shared_proxy.execute(self)
         
     | 
| 
       33 
34 
     | 
    
         
             
                  end
         
     | 
| 
       34 
     | 
    
         
            -
                  @@shared_proxies_executed = true
         
     | 
| 
      
 35 
     | 
    
         
            +
                  @@shared_proxies_executed[self] = true
         
     | 
| 
       35 
36 
     | 
    
         
             
                end
         
     | 
| 
       36 
37 
     | 
    
         | 
| 
       37 
38 
     | 
    
         
             
                suite_without_shared_should_execute
         
     | 
| 
         @@ -42,13 +43,14 @@ class Test::Unit::TestCase 
     | 
|
| 
       42 
43 
     | 
    
         
             
              end
         
     | 
| 
       43 
44 
     | 
    
         | 
| 
       44 
45 
     | 
    
         
             
              def setup
         
     | 
| 
       45 
     | 
    
         
            -
                @@setup_blocks.each do |setup_block|
         
     | 
| 
      
 46 
     | 
    
         
            +
                (@@setup_blocks[self.class] || []).each do |setup_block|
         
     | 
| 
       46 
47 
     | 
    
         
             
                  setup_block.bind(self).call
         
     | 
| 
       47 
48 
     | 
    
         
             
                end
         
     | 
| 
       48 
49 
     | 
    
         
             
              end
         
     | 
| 
       49 
50 
     | 
    
         | 
| 
       50 
51 
     | 
    
         
             
              def self.setup(&setup_block)
         
     | 
| 
       51 
     | 
    
         
            -
                @@setup_blocks  
     | 
| 
      
 52 
     | 
    
         
            +
                @@setup_blocks[self] = [] unless @@setup_blocks[self]
         
     | 
| 
      
 53 
     | 
    
         
            +
                @@setup_blocks[self] << setup_block
         
     | 
| 
       52 
54 
     | 
    
         
             
              end
         
     | 
| 
       53 
55 
     | 
    
         | 
| 
       54 
56 
     | 
    
         
             
              def setup_shared_values(name, initialization_block)
         
     | 
| 
         @@ -317,14 +319,16 @@ class Shoulda::SharedProxy 
     | 
|
| 
       317 
319 
     | 
    
         
             
                self.initialization_blocks = []
         
     | 
| 
       318 
320 
     | 
    
         
             
              end
         
     | 
| 
       319 
321 
     | 
    
         | 
| 
      
 322 
     | 
    
         
            +
              def with(description = nil, &initialization_block)
         
     | 
| 
      
 323 
     | 
    
         
            +
                with_helper("with", description, &initialization_block)
         
     | 
| 
      
 324 
     | 
    
         
            +
              end
         
     | 
| 
      
 325 
     | 
    
         
            +
              
         
     | 
| 
       320 
326 
     | 
    
         
             
              def when(description = nil, &initialization_block)
         
     | 
| 
       321 
     | 
    
         
            -
                 
     | 
| 
       322 
     | 
    
         
            -
                return self
         
     | 
| 
      
 327 
     | 
    
         
            +
                with_helper("when", description, &initialization_block)
         
     | 
| 
       323 
328 
     | 
    
         
             
              end
         
     | 
| 
       324 
329 
     | 
    
         | 
| 
       325 
     | 
    
         
            -
              def  
     | 
| 
       326 
     | 
    
         
            -
                 
     | 
| 
       327 
     | 
    
         
            -
                return nil
         
     | 
| 
      
 330 
     | 
    
         
            +
              def given(description = nil, &initialization_block)
         
     | 
| 
      
 331 
     | 
    
         
            +
                with_helper("given", description, :disable_and => true, &initialization_block)
         
     | 
| 
       328 
332 
     | 
    
         
             
              end
         
     | 
| 
       329 
333 
     | 
    
         | 
| 
       330 
334 
     | 
    
         
             
              def execute(context)
         
     | 
| 
         @@ -341,10 +345,12 @@ class Shoulda::SharedProxy 
     | 
|
| 
       341 
345 
     | 
    
         | 
| 
       342 
346 
     | 
    
         
             
              private
         
     | 
| 
       343 
347 
     | 
    
         | 
| 
       344 
     | 
    
         
            -
              def  
     | 
| 
      
 348 
     | 
    
         
            +
              def with_helper(conditional, description, options = {}, &initialization_block)
         
     | 
| 
       345 
349 
     | 
    
         
             
                if description
         
     | 
| 
       346 
     | 
    
         
            -
                   
     | 
| 
      
 350 
     | 
    
         
            +
                  and_text = options[:disable_and] ? ' ' : ' and '
         
     | 
| 
      
 351 
     | 
    
         
            +
                  self.description = "#{self.description}#{self.description.nil? ? nil : and_text}#{conditional} #{description}"
         
     | 
| 
       347 
352 
     | 
    
         
             
                end
         
     | 
| 
       348 
353 
     | 
    
         
             
                self.initialization_blocks << initialization_block
         
     | 
| 
      
 354 
     | 
    
         
            +
                return self
         
     | 
| 
       349 
355 
     | 
    
         
             
              end
         
     | 
| 
       350 
356 
     | 
    
         
             
            end
         
     | 
    
        data/shared_should.gemspec
    CHANGED
    
    | 
         @@ -5,11 +5,11 @@ 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       7 
7 
     | 
    
         
             
              s.name = %q{shared_should}
         
     | 
| 
       8 
     | 
    
         
            -
              s.version = "0.6. 
     | 
| 
      
 8 
     | 
    
         
            +
              s.version = "0.6.3"
         
     | 
| 
       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"]
         
     | 
| 
       12 
     | 
    
         
            -
              s.date = %q{2011-03- 
     | 
| 
      
 12 
     | 
    
         
            +
              s.date = %q{2011-03-18}
         
     | 
| 
       13 
13 
     | 
    
         
             
              s.description = %q{Share and reuse shoulds, contexts, and setup in Shoulda.}
         
     | 
| 
       14 
14 
     | 
    
         
             
              s.email = %q{michael.pearce@bookrenter.com}
         
     | 
| 
       15 
15 
     | 
    
         
             
              s.extra_rdoc_files = [
         
     | 
    
        data/test/test_shared_should.rb
    CHANGED
    
    | 
         @@ -64,7 +64,7 @@ class TestSharedShould < Test::Unit::TestCase 
     | 
|
| 
       64 
64 
     | 
    
         
             
                    end
         
     | 
| 
       65 
65 
     | 
    
         
             
                  end
         
     | 
| 
       66 
66 
     | 
    
         | 
| 
       67 
     | 
    
         
            -
                  use_context("for a valid specified value"). 
     | 
| 
      
 67 
     | 
    
         
            +
                  use_context("for a valid specified value").given("true") { true }
         
     | 
| 
       68 
68 
     | 
    
         | 
| 
       69 
69 
     | 
    
         
             
                  context "with chaining" do
         
     | 
| 
       70 
70 
     | 
    
         
             
                    share_context "for a chained value" do
         
     | 
| 
         @@ -74,7 +74,8 @@ class TestSharedShould < Test::Unit::TestCase 
     | 
|
| 
       74 
74 
     | 
    
         
             
                      end
         
     | 
| 
       75 
75 
     | 
    
         
             
                    end
         
     | 
| 
       76 
76 
     | 
    
         | 
| 
       77 
     | 
    
         
            -
                    use_context("for a chained value"). 
     | 
| 
      
 77 
     | 
    
         
            +
                    use_context("for a chained value").with("an initialization chain") { @chain = true }.given("true") { true }
         
     | 
| 
      
 78 
     | 
    
         
            +
                    use_context("for a chained value").when("using initialization chain") { @chain = true }.given("true") { true }
         
     | 
| 
       78 
79 
     | 
    
         
             
                  end
         
     | 
| 
       79 
80 
     | 
    
         
             
                end
         
     | 
| 
       80 
81 
     | 
    
         
             
              end
         
     | 
| 
         @@ -162,7 +163,7 @@ class TestSharedShould < Test::Unit::TestCase 
     | 
|
| 
       162 
163 
     | 
    
         
             
                    assert_equal value, @value
         
     | 
| 
       163 
164 
     | 
    
         
             
                  end
         
     | 
| 
       164 
165 
     | 
    
         | 
| 
       165 
     | 
    
         
            -
                  use_should("be a valid specified value"). 
     | 
| 
      
 166 
     | 
    
         
            +
                  use_should("be a valid specified value").given("true") { true }
         
     | 
| 
       166 
167 
     | 
    
         | 
| 
       167 
168 
     | 
    
         
             
                  context "with chaining" do
         
     | 
| 
       168 
169 
     | 
    
         
             
                    share_should "be a valid specified value" do |value|
         
     | 
| 
         @@ -170,8 +171,8 @@ class TestSharedShould < Test::Unit::TestCase 
     | 
|
| 
       170 
171 
     | 
    
         
             
                      assert value
         
     | 
| 
       171 
172 
     | 
    
         
             
                    end
         
     | 
| 
       172 
173 
     | 
    
         | 
| 
       173 
     | 
    
         
            -
                    use_should("be a valid specified value").when("using initialization chain") { @chain = true }. 
     | 
| 
       174 
     | 
    
         
            -
                    use_should("be a valid specified value"). 
     | 
| 
      
 174 
     | 
    
         
            +
                    use_should("be a valid specified value").when("using initialization chain") { @chain = true }.given("true") { true }
         
     | 
| 
      
 175 
     | 
    
         
            +
                    use_should("be a valid specified value").with("an initialization chain") { @chain = true }.given("true") { true }
         
     | 
| 
       175 
176 
     | 
    
         
             
                  end
         
     | 
| 
       176 
177 
     | 
    
         
             
                end
         
     | 
| 
       177 
178 
     | 
    
         
             
              end
         
     | 
| 
         @@ -288,7 +289,7 @@ class TestSharedShould < Test::Unit::TestCase 
     | 
|
| 
       288 
289 
     | 
    
         
             
                      @value = false
         
     | 
| 
       289 
290 
     | 
    
         
             
                    end
         
     | 
| 
       290 
291 
     | 
    
         | 
| 
       291 
     | 
    
         
            -
                    use_setup("for value"). 
     | 
| 
      
 292 
     | 
    
         
            +
                    use_setup("for value").given("true") { true }
         
     | 
| 
       292 
293 
     | 
    
         | 
| 
       293 
294 
     | 
    
         
             
                    should "have a true value from shared setup" do
         
     | 
| 
       294 
295 
     | 
    
         
             
                      assert @value
         
     | 
| 
         @@ -305,7 +306,8 @@ class TestSharedShould < Test::Unit::TestCase 
     | 
|
| 
       305 
306 
     | 
    
         
             
                      @value = value
         
     | 
| 
       306 
307 
     | 
    
         
             
                    end
         
     | 
| 
       307 
308 
     | 
    
         | 
| 
       308 
     | 
    
         
            -
                    use_setup("for value").when("using initialization chain") { @chain = true }. 
     | 
| 
      
 309 
     | 
    
         
            +
                    use_setup("for value").when("using initialization chain") { @chain = true }.given("true") { true }
         
     | 
| 
      
 310 
     | 
    
         
            +
                    use_setup("for value").with("an initialization chain") { @chain = true }.given("true") { true }
         
     | 
| 
       309 
311 
     | 
    
         | 
| 
       310 
312 
     | 
    
         
             
                    should "have used share with chain and params" do
         
     | 
| 
       311 
313 
     | 
    
         
             
                      assert @chain
         
     | 
| 
         @@ -431,58 +433,70 @@ class TestSharedShould < Test::Unit::TestCase 
     | 
|
| 
       431 
433 
     | 
    
         
             
                end
         
     | 
| 
       432 
434 
     | 
    
         
             
              end
         
     | 
| 
       433 
435 
     | 
    
         | 
| 
       434 
     | 
    
         
            -
               
     | 
| 
       435 
     | 
    
         
            -
             
     | 
| 
       436 
     | 
    
         
            -
                   
     | 
| 
       437 
     | 
    
         
            -
                   
     | 
| 
       438 
     | 
    
         
            -
             
     | 
| 
       439 
     | 
    
         
            -
             
     | 
| 
       440 
     | 
    
         
            -
             
     | 
| 
       441 
     | 
    
         
            -
             
     | 
| 
       442 
     | 
    
         
            -
             
     | 
| 
       443 
     | 
    
         
            -
             
     | 
| 
       444 
     | 
    
         
            -
             
     | 
| 
       445 
     | 
    
         
            -
             
     | 
| 
       446 
     | 
    
         
            -
             
     | 
| 
       447 
     | 
    
         
            -
             
     | 
| 
       448 
     | 
    
         
            -
             
     | 
| 
       449 
     | 
    
         
            -
             
     | 
| 
       450 
     | 
    
         
            -
             
     | 
| 
       451 
     | 
    
         
            -
             
     | 
| 
       452 
     | 
    
         
            -
             
     | 
| 
       453 
     | 
    
         
            -
             
     | 
| 
       454 
     | 
    
         
            -
             
     | 
| 
       455 
     | 
    
         
            -
             
     | 
| 
       456 
     | 
    
         
            -
             
     | 
| 
       457 
     | 
    
         
            -
             
     | 
| 
       458 
     | 
    
         
            -
             
     | 
| 
       459 
     | 
    
         
            -
             
     | 
| 
       460 
     | 
    
         
            -
             
     | 
| 
       461 
     | 
    
         
            -
             
     | 
| 
       462 
     | 
    
         
            -
             
     | 
| 
       463 
     | 
    
         
            -
             
     | 
| 
       464 
     | 
    
         
            -
             
     | 
| 
       465 
     | 
    
         
            -
             
     | 
| 
       466 
     | 
    
         
            -
             
     | 
| 
       467 
     | 
    
         
            -
             
     | 
| 
       468 
     | 
    
         
            -
             
     | 
| 
       469 
     | 
    
         
            -
             
     | 
| 
       470 
     | 
    
         
            -
             
     | 
| 
       471 
     | 
    
         
            -
             
     | 
| 
       472 
     | 
    
         
            -
             
     | 
| 
       473 
     | 
    
         
            -
             
     | 
| 
       474 
     | 
    
         
            -
             
     | 
| 
       475 
     | 
    
         
            -
             
     | 
| 
       476 
     | 
    
         
            -
             
     | 
| 
       477 
     | 
    
         
            -
             
     | 
| 
       478 
     | 
    
         
            -
             
     | 
| 
       479 
     | 
    
         
            -
             
     | 
| 
       480 
     | 
    
         
            -
             
     | 
| 
       481 
     | 
    
         
            -
             
     | 
| 
       482 
     | 
    
         
            -
             
     | 
| 
       483 
     | 
    
         
            -
             
     | 
| 
       484 
     | 
    
         
            -
             
     | 
| 
       485 
     | 
    
         
            -
               
     | 
| 
       486 
     | 
    
         
            -
             
     | 
| 
      
 436 
     | 
    
         
            +
              context "expected methods" do
         
     | 
| 
      
 437 
     | 
    
         
            +
                should "have expected methods in test" do
         
     | 
| 
      
 438 
     | 
    
         
            +
                  # ensure test methods are created
         
     | 
| 
      
 439 
     | 
    
         
            +
                  expected_method_names = [
         
     | 
| 
      
 440 
     | 
    
         
            +
                      'test:  should be a valid should test in class. ',
         
     | 
| 
      
 441 
     | 
    
         
            +
                      'test: .share_context without params with value in initializer when a true value for a valid value should call setup in shared context. ',
         
     | 
| 
      
 442 
     | 
    
         
            +
                      'test: .share_context without params with value in initializer when a true value for a valid value should have true value. ',
         
     | 
| 
      
 443 
     | 
    
         
            +
                      'test: .share_context without params with value in setup for a valid value should call setup in shared context. ',
         
     | 
| 
      
 444 
     | 
    
         
            +
                      'test: .share_context without params with value in setup for a valid value should have true value. ',
         
     | 
| 
      
 445 
     | 
    
         
            +
                      'test: .share_setup with param block with chaining should have used share with chain and params. ',
         
     | 
| 
      
 446 
     | 
    
         
            +
                      'test: .share_setup with param block with shared setup value should have a true value from shared setup. ',
         
     | 
| 
      
 447 
     | 
    
         
            +
                      'test: .share_setup without params with initialization block should have a true value from shared setup. ',
         
     | 
| 
      
 448 
     | 
    
         
            +
                      'test: .share_setup without params without initialization block should have a true value from shared setup. ',
         
     | 
| 
      
 449 
     | 
    
         
            +
                      'test: .share_should without params when value in initializer when value is true should be a true value. ',
         
     | 
| 
      
 450 
     | 
    
         
            +
                      'test: .share_should without params with value in initializer when value is true should be a true value. ',
         
     | 
| 
      
 451 
     | 
    
         
            +
                      'test: .share_should without params with value in setup should be a true value. ',
         
     | 
| 
      
 452 
     | 
    
         
            +
                      'test: .shared_context_should with params be valid for specified value should call setup in shared context. ',
         
     | 
| 
      
 453 
     | 
    
         
            +
                      'test: .shared_context_should with params be valid for specified value should have specified value. ',
         
     | 
| 
      
 454 
     | 
    
         
            +
                      'test: .shared_context_should with params be valid for specified value should setup @expected_value. ',
         
     | 
| 
      
 455 
     | 
    
         
            +
                      'test: .shared_context_should without params be valid should call setup in shared context. ',
         
     | 
| 
      
 456 
     | 
    
         
            +
                      'test: .shared_context_should without params be valid should have true value. ',
         
     | 
| 
      
 457 
     | 
    
         
            +
                      'test: .shared_setup with params with shared setup value should have a true value from shared setup. ',
         
     | 
| 
      
 458 
     | 
    
         
            +
                      'test: .shared_setup without params with shared setup value should have a true value from shared setup. ',
         
     | 
| 
      
 459 
     | 
    
         
            +
                      'test: .shared_should with params should have specified value. ',
         
     | 
| 
      
 460 
     | 
    
         
            +
                      'test: .shared_should without params should have true value. ',
         
     | 
| 
      
 461 
     | 
    
         
            +
                      'test: SharedShould should execute setup instance method. ',
         
     | 
| 
      
 462 
     | 
    
         
            +
                      'test: context directly under test class for a valid context test should have a true value. ',
         
     | 
| 
      
 463 
     | 
    
         
            +
                      'test: context directly under test class should be a valid should test. ',
         
     | 
| 
      
 464 
     | 
    
         
            +
                      'test: for a valid context test in class should have a true value. ',
         
     | 
| 
      
 465 
     | 
    
         
            +
                      'test: parameterized block with an array be valid with shared context should do something with shared_value. ',
         
     | 
| 
      
 466 
     | 
    
         
            +
                      'test: parameterized block with an array be valid with shared context should do something with value block param. ',
         
     | 
| 
      
 467 
     | 
    
         
            +
                      'test: parameterized block with an array be valid with shared context should do something with value block params. ',
         
     | 
| 
      
 468 
     | 
    
         
            +
                      'test: parameterized block with an array should be valid with shared should. ',
         
     | 
| 
      
 469 
     | 
    
         
            +
                      'test: shoulda macro should be a valid macro. ',
         
     | 
| 
      
 470 
     | 
    
         
            +
                      'test: expected methods should have expected methods in test. ',
         
     | 
| 
      
 471 
     | 
    
         
            +
                      "test: .share_context with params given true for a valid specified value should call setup in shared context. ",
         
     | 
| 
      
 472 
     | 
    
         
            +
                      "test: .share_context with params with chaining with an initialization chain given true for a chained value should chain initialization block and be with params. ",
         
     | 
| 
      
 473 
     | 
    
         
            +
                      "test: .share_context with params given true for a valid specified value should setup @expected_value. ",
         
     | 
| 
      
 474 
     | 
    
         
            +
                      "test: .share_should with params with chaining with an initialization chain given true should be a valid specified value. ",
         
     | 
| 
      
 475 
     | 
    
         
            +
                      "test: .share_context with params given true for a valid specified value should have specified value. ",
         
     | 
| 
      
 476 
     | 
    
         
            +
                      "test: .share_context with params with chaining when using initialization chain given true for a chained value should chain initialization block and be with params. ",
         
     | 
| 
      
 477 
     | 
    
         
            +
                      "test: .share_should with params with chaining when using initialization chain given true should be a valid specified value. ",
         
     | 
| 
      
 478 
     | 
    
         
            +
                      "test: .share_should with params given true should be a valid specified value. "
         
     | 
| 
      
 479 
     | 
    
         
            +
                    ].inject({}) do |hash, expected_method_name|
         
     | 
| 
      
 480 
     | 
    
         
            +
                    hash[expected_method_name] = true
         
     | 
| 
      
 481 
     | 
    
         
            +
                    hash
         
     | 
| 
      
 482 
     | 
    
         
            +
                  end
         
     | 
| 
      
 483 
     | 
    
         
            +
                  actual_method_names = self.class.suite.tests.inject({}) do |hash, test_case|
         
     | 
| 
      
 484 
     | 
    
         
            +
                    hash[test_case.method_name] = true
         
     | 
| 
      
 485 
     | 
    
         
            +
                    hash
         
     | 
| 
      
 486 
     | 
    
         
            +
                  end
         
     | 
| 
      
 487 
     | 
    
         
            +
              
         
     | 
| 
      
 488 
     | 
    
         
            +
                  actual_methods_not_found = []
         
     | 
| 
      
 489 
     | 
    
         
            +
                  actual_method_names.each do |method_name, value|
         
     | 
| 
      
 490 
     | 
    
         
            +
                    actual_methods_not_found << method_name unless expected_method_names.include?(method_name)
         
     | 
| 
      
 491 
     | 
    
         
            +
                  end
         
     | 
| 
      
 492 
     | 
    
         
            +
                  assert_equal [], actual_methods_not_found, "Unknown methods exist in the test suite"
         
     | 
| 
      
 493 
     | 
    
         
            +
                  
         
     | 
| 
      
 494 
     | 
    
         
            +
                  expected_methods_not_found = []
         
     | 
| 
      
 495 
     | 
    
         
            +
                  expected_method_names.each do |method_name, value|
         
     | 
| 
      
 496 
     | 
    
         
            +
                     expected_methods_not_found << method_name unless actual_method_names.include?(method_name)
         
     | 
| 
      
 497 
     | 
    
         
            +
                  end
         
     | 
| 
      
 498 
     | 
    
         
            +
                  assert_equal [], expected_methods_not_found, "Unknown methods exist in the list of expected tests"
         
     | 
| 
      
 499 
     | 
    
         
            +
                  
         
     | 
| 
      
 500 
     | 
    
         
            +
                end
         
     | 
| 
       487 
501 
     | 
    
         
             
              end
         
     | 
| 
       488 
502 
     | 
    
         
             
            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:  
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 1
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
              segments: 
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 0
         
     | 
| 
       8 
8 
     | 
    
         
             
              - 6
         
     | 
| 
       9 
     | 
    
         
            -
              -  
     | 
| 
       10 
     | 
    
         
            -
              version: 0.6. 
     | 
| 
      
 9 
     | 
    
         
            +
              - 3
         
     | 
| 
      
 10 
     | 
    
         
            +
              version: 0.6.3
         
     | 
| 
       11 
11 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
12 
     | 
    
         
             
            authors: 
         
     | 
| 
       13 
13 
     | 
    
         
             
            - Michael Pearce
         
     | 
| 
         @@ -15,7 +15,7 @@ autorequire: 
     | 
|
| 
       15 
15 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       16 
16 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
            date: 2011-03- 
     | 
| 
      
 18 
     | 
    
         
            +
            date: 2011-03-18 00:00:00 -07:00
         
     | 
| 
       19 
19 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       20 
20 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       21 
21 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     |