page_magic 1.0.0.alpha6 → 1.0.0.alpha7
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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/page_magic/elements.rb +14 -10
- data/spec/page_magic/elements_spec.rb +29 -6
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 41a82b83827dad40deb585e1dbf95b666630dfa4
         | 
| 4 | 
            +
              data.tar.gz: 15441bd24c7ebb9ca36b8c62254e5db21874ea63
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 169bccf3af8aabefb37196e9b609cf6ba4839a4ad5e002caa4b21c8000c9683523112c595426bc13cd7e32a3c343ce789dc081fb4743489615c5d1b5fb3f1b52
         | 
| 7 | 
            +
              data.tar.gz: 57fc09f6c058bb04b39a7a78d18865946f81959a36621a22d0b89012cdd59270c91dae7900df94b5c543b7c1ae2e90ca4d58f90ad09a6d767addc60dfbf4731c
         | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            1.0.0. | 
| 1 | 
            +
            1.0.0.alpha7
         | 
    
        data/lib/page_magic/elements.rb
    CHANGED
    
    | @@ -41,19 +41,23 @@ module PageMagic | |
| 41 41 | 
             
                        options[:browser_element] = object
         | 
| 42 42 | 
             
                      end
         | 
| 43 43 |  | 
| 44 | 
            -
                      add_element_definition(name) do |* | 
| 45 | 
            -
                         | 
| 46 | 
            -
             | 
| 47 | 
            -
                         | 
| 44 | 
            +
                      add_element_definition(name) do |*e_args|
         | 
| 45 | 
            +
                        Element.new(name, e_args.delete_at(0), options).tap do |section|
         | 
| 46 | 
            +
                          section.expand(*e_args, &(block || proc {}))
         | 
| 47 | 
            +
                        end
         | 
| 48 48 | 
             
                      end
         | 
| 49 49 |  | 
| 50 | 
            -
                    elsif first_arg <  | 
| 51 | 
            -
                      section_class | 
| 50 | 
            +
                    elsif first_arg < Element
         | 
| 51 | 
            +
                      section_class = args.delete_at(0)
         | 
| 52 52 |  | 
| 53 | 
            -
                       | 
| 54 | 
            -
             | 
| 55 | 
            -
             | 
| 56 | 
            -
                       | 
| 53 | 
            +
                      selector = args.find{|arg| arg.is_a?(Hash)}
         | 
| 54 | 
            +
                      args.delete(selector)
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                      name = args.last
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                      selector = section_class.selector unless selector
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                      name = section_class.name.demodulize.to_snake_case.to_sym unless name
         | 
| 57 61 |  | 
| 58 62 | 
             
                      add_element_definition(name) do |parent_browser_element|
         | 
| 59 63 | 
             
                        section_class.new(name, parent_browser_element, type: :section, selector: (selector || section_class.selector))
         | 
| @@ -5,7 +5,7 @@ describe PageMagic::Elements do | |
| 5 5 | 
             
                end
         | 
| 6 6 | 
             
              end
         | 
| 7 7 |  | 
| 8 | 
            -
              let(:selector) { { | 
| 8 | 
            +
              let(:selector) { {id: 'id'} }
         | 
| 9 9 | 
             
              let(:browser_element) { double('browser_element', find: :browser_element) }
         | 
| 10 10 | 
             
              let(:parent_page_element) do
         | 
| 11 11 | 
             
                double('parent_page_element', browser_element: browser_element)
         | 
| @@ -25,12 +25,13 @@ describe PageMagic::Elements do | |
| 25 25 | 
             
                    Class.new(PageMagic::Element) do
         | 
| 26 26 | 
             
                      def ==(other)
         | 
| 27 27 | 
             
                        other.name == name &&
         | 
| 28 | 
            -
             | 
| 28 | 
            +
                            other.browser_element == browser_element
         | 
| 29 29 | 
             
                      end
         | 
| 30 30 | 
             
                    end
         | 
| 31 31 | 
             
                  end
         | 
| 32 32 |  | 
| 33 33 | 
             
                  context 'using a predefined class' do
         | 
| 34 | 
            +
             | 
| 34 35 | 
             
                    it 'should add a section' do
         | 
| 35 36 | 
             
                      expected_section = section_class.new(:page_section, parent_page_element, type: :section, selector: selector)
         | 
| 36 37 |  | 
| @@ -38,11 +39,33 @@ describe PageMagic::Elements do | |
| 38 39 | 
             
                      page_elements.elements(parent_page_element).first.should == expected_section
         | 
| 39 40 | 
             
                    end
         | 
| 40 41 |  | 
| 42 | 
            +
                    describe 'selector' do
         | 
| 43 | 
            +
                      it 'uses the supplied selector' do
         | 
| 44 | 
            +
                        page_elements.section section_class, :alias, selector
         | 
| 45 | 
            +
                        expect(page_elements.elements(parent_page_element).first.selector).to eq(selector)
         | 
| 46 | 
            +
                      end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                      context 'with no selector supplied' do
         | 
| 49 | 
            +
                        it 'defaults the selector to the one on the class' do
         | 
| 50 | 
            +
                          section_class.selector selector
         | 
| 51 | 
            +
                          page_elements.section section_class, :alias
         | 
| 52 | 
            +
                          expect(page_elements.elements(parent_page_element).first.selector).to eq(selector)
         | 
| 53 | 
            +
                        end
         | 
| 54 | 
            +
                      end
         | 
| 55 | 
            +
                    end
         | 
| 56 | 
            +
             | 
| 41 57 | 
             
                    context 'name' do
         | 
| 42 | 
            -
                       | 
| 43 | 
            -
                         | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
| 58 | 
            +
                      context 'with no name supplied' do
         | 
| 59 | 
            +
                        it 'should default to the name of the class if one is not supplied' do
         | 
| 60 | 
            +
                          section_class.stub(:name).and_return('PageSection')
         | 
| 61 | 
            +
                          page_elements.section section_class, selector
         | 
| 62 | 
            +
                          page_elements.elements(parent_page_element).first.name.should == :page_section
         | 
| 63 | 
            +
                        end
         | 
| 64 | 
            +
                      end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                      it 'should use the supplied name' do
         | 
| 67 | 
            +
                        page_elements.section section_class, :alias, selector
         | 
| 68 | 
            +
                        expect(page_elements.elements(parent_page_element).first.name).to eq(:alias)
         | 
| 46 69 | 
             
                      end
         | 
| 47 70 | 
             
                    end
         | 
| 48 71 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: page_magic
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0.0. | 
| 4 | 
            +
              version: 1.0.0.alpha7
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Leon Davis
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2015-09- | 
| 11 | 
            +
            date: 2015-09-21 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: capybara
         |