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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e0a158fa38987dd01a9bbaf40198b81caa6d3ee
4
- data.tar.gz: 67aacda193709e3afd2478e75560238b88507c76
3
+ metadata.gz: 41a82b83827dad40deb585e1dbf95b666630dfa4
4
+ data.tar.gz: 15441bd24c7ebb9ca36b8c62254e5db21874ea63
5
5
  SHA512:
6
- metadata.gz: a9bc3934674edb7855550fdc421f6f9a9188839b909689e95abeb5884cc0e8bb2a4fe055a00a2a35e49fa7e95280d69e9fc20452da2f1810fe761341b964669c
7
- data.tar.gz: c600d28f6ac0ef148d964bcad5cd6318d12c53c82b59d3657b9172b98ca9fcce0e78a2579b3812c1a6e1726c93db7a308ddee42a88b4b570597bcb3ce9ab8096
6
+ metadata.gz: 169bccf3af8aabefb37196e9b609cf6ba4839a4ad5e002caa4b21c8000c9683523112c595426bc13cd7e32a3c343ce789dc081fb4743489615c5d1b5fb3f1b52
7
+ data.tar.gz: 57fc09f6c058bb04b39a7a78d18865946f81959a36621a22d0b89012cdd59270c91dae7900df94b5c543b7c1ae2e90ca4d58f90ad09a6d767addc60dfbf4731c
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0.alpha6
1
+ 1.0.0.alpha7
@@ -41,19 +41,23 @@ module PageMagic
41
41
  options[:browser_element] = object
42
42
  end
43
43
 
44
- add_element_definition(name) do |*args_for_block|
45
- page_section = PageMagic::Element.new name, args_for_block.delete_at(0), options
46
- page_section.expand *args_for_block, &(block || proc {})
47
- page_section
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 < PageMagic::Element
51
- section_class, name, selector = args
50
+ elsif first_arg < Element
51
+ section_class = args.delete_at(0)
52
52
 
53
- unless selector
54
- selector = section_class.selector
55
- name = section_class.name.demodulize.to_snake_case.to_sym
56
- end
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) { { id: 'id' } }
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
- other.browser_element == browser_element
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
- it 'should default to the name of the class if one is not supplied' do
43
- section_class.stub(:name).and_return('PageSection')
44
- page_elements.section section_class, selector
45
- page_elements.elements(parent_page_element).first.name.should == :page_section
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.alpha6
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-18 00:00:00.000000000 Z
11
+ date: 2015-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara