cello 0.0.17 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -3
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +4 -0
  5. data/Gemfile +2 -0
  6. data/LICENCE +1 -1
  7. data/README.md +3 -3
  8. data/Rakefile +7 -1
  9. data/cello.gemspec +5 -0
  10. data/features/browser.feature +1 -0
  11. data/features/element.feature +8 -8
  12. data/features/get_html_attributes.feature +4 -4
  13. data/features/pages/firefox.rb +0 -1
  14. data/features/pages/headless.rb +11 -0
  15. data/features/pages/input_fields.rb +2 -7
  16. data/features/step_definitions/access_element.rb +6 -8
  17. data/features/step_definitions/browser.rb +5 -6
  18. data/features/step_definitions/checkbox.rb +9 -11
  19. data/features/step_definitions/common_steps.rb +6 -28
  20. data/features/step_definitions/element.rb +12 -14
  21. data/features/step_definitions/html_attributes.rb +4 -3
  22. data/features/step_definitions/radio.rb +19 -23
  23. data/features/step_definitions/select.rb +12 -18
  24. data/features/step_definitions/textarea.rb +27 -29
  25. data/features/step_definitions/textfield.rb +32 -34
  26. data/lib/cello/structure/browser.rb +1 -5
  27. data/lib/cello/structure/html_elements/element_helper.rb +33 -11
  28. data/lib/cello/structure/html_elements/logger.rb +34 -0
  29. data/lib/cello/structure/html_elements/select_helper.rb +18 -8
  30. data/lib/cello/structure/page.rb +11 -4
  31. data/lib/cello/version.rb +1 -1
  32. data/lib/cello.rb +1 -1
  33. data/spec/checkbox_spec.rb +10 -2
  34. data/spec/element_spec.rb +13 -7
  35. data/spec/mock/page.rb +25 -0
  36. data/spec/select_spec.rb +11 -4
  37. data/spec/textarea_spec.rb +15 -3
  38. data/spec/textfield_spec.rb +13 -1
  39. metadata +190 -206
  40. data/travis.yml +0 -7
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 67bd151cb71e969f4df8da32909adc3daf0a4b1e
4
+ data.tar.gz: 4feabc3cbf257c091d75de65d3c3a41dc56308ff
5
+ SHA512:
6
+ metadata.gz: 549d76e7ce6d9bd7a9ca225972825b2796dc4e09279f6a9e2b385fcb38bf64a1d10270c4b88d01e7878ac2274baff094d8abbb596c421b04dc85cf4218500411
7
+ data.tar.gz: 1d5b5d37fb87ce83004d309486475e1f4abe6e2d857dce327ececeb8c7026a80548162717385428393e60788835749508e43ee01ab2aed10f8225520021d1cdd
data/.gitignore CHANGED
@@ -1,5 +1,3 @@
1
1
  *.sw*
2
+ Gemfile.lock
2
3
  *.gem
3
- *.lock
4
- screenshot.png
5
- coverage/*
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.0.0-p247@cello
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
data/Gemfile CHANGED
@@ -7,5 +7,7 @@ gem 'cucumber'
7
7
  gem 'rake'
8
8
  gem 'headless'
9
9
  gem 'rspec'
10
+ gem "nyan-cat-formatter"
11
+ gem "sourcify", "~> 0.5.0"
10
12
 
11
13
  gemspec
data/LICENCE CHANGED
@@ -1,7 +1,7 @@
1
1
  LICENCE
2
2
  =======
3
3
 
4
- Copyright 2012 Camilo Ribeiro cribeiro@thoughtworks.com
4
+ Copyright 2012-2013 Camilo Ribeiro camilo@camiloribeiro.com
5
5
 
6
6
  This file is part of Cello.
7
7
 
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
- CELLO
1
+ CELLO ♩♪ ♮ d[^_^]b ♫ ♬ ♭♯
2
2
  =====
3
3
 
4
- [![Build Status](https://secure.travis-ci.org/camiloribeiro/cello.png)](http://travis-ci.org/camiloribeiro/cello])
4
+ [![Build Status](https://secure.travis-ci.org/camiloribeiro/cello.png)](http://travis-ci.org/camiloribeiro/cello)
5
5
 
6
6
  What?
7
7
  -----
@@ -91,7 +91,7 @@ ROADMAP
91
91
  LICENSE
92
92
  =======
93
93
 
94
- Copyright 2012 Camilo Ribeiro cribeiro@thoughtworks.com
94
+ Copyright 2012 - 2013 Camilo Ribeiro camilo@camiloribeiro.com
95
95
 
96
96
  This file is part of Cello.
97
97
 
data/Rakefile CHANGED
@@ -3,7 +3,13 @@ require 'rspec/core/rake_task'
3
3
 
4
4
  task :default => [:spec,:run]
5
5
 
6
- Spec::Rake::SpecTask.new(:spec)
6
+ RSpec::Core::RakeTask .new(:spec) do |task|
7
+ task.rspec_opts = ["--format documentation"]
8
+ end
9
+
10
+ RSpec::Core::RakeTask .new(:nyan) do |task|
11
+ task.rspec_opts = ["--format NyanCatFormater"]
12
+ end
7
13
 
8
14
  Cucumber::Rake::Task.new(:run) do |task|
9
15
  task.cucumber_opts = ["-t","~@pending","features --format pretty"]
data/cello.gemspec CHANGED
@@ -8,6 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.authors = ["Camilo Ribeiro"]
9
9
  s.email = ["cribeiro@thoughtworks.com"]
10
10
  s.homepage = "http://github.com/camiloribeiro/cello"
11
+ s.license = "Apache 2.0"
11
12
  s.summary = %q{Fast and simple Page-Object with BDD}
12
13
  s.description = %q{Cello is a framework that allows automate acceptance tests using page-object}
13
14
 
@@ -27,8 +28,12 @@ Gem::Specification.new do |s|
27
28
  s.add_development_dependency 'rake'
28
29
  s.add_development_dependency 'rspec'
29
30
  s.add_development_dependency 'headless'
31
+ s.add_development_dependency 'nyan-cat-formatter'
30
32
 
31
33
  s.add_dependency 'cucumber'
32
34
  s.add_dependency 'rspec'
33
35
  s.add_dependency 'watir-webdriver'
36
+ s.add_dependency 'sourcify'
37
+ s.add_dependency 'icecream'
38
+
34
39
  end
@@ -14,6 +14,7 @@ Feature: Browser
14
14
  Then I should see the filled textfield
15
15
  And I should be able to close the browser
16
16
 
17
+ @pending @bugado
17
18
  Scenario: Pass by two different contexts
18
19
  Given I am in the inputs context
19
20
  When I ask for fill the textfield
@@ -3,7 +3,7 @@ Feature: Element
3
3
  I want use element to run my tests
4
4
 
5
5
  Scenario: Click at the element
6
- Given I am on a page that has a element
6
+ Given I am on a page that has an element
7
7
  And that element is named as:
8
8
  | checkbox |
9
9
  | text_field |
@@ -12,7 +12,7 @@ Feature: Element
12
12
  Then I want click on this element
13
13
 
14
14
  Scenario: Know if the element is visible
15
- Given I am on a page that has a element
15
+ Given I am on a page that has an element
16
16
  And that element is named as:
17
17
  | checkbox |
18
18
  | text_field |
@@ -21,7 +21,7 @@ Feature: Element
21
21
  Then I want know if this element is visible
22
22
 
23
23
  Scenario: Know if the element is enable
24
- Given I am on a page that has a element
24
+ Given I am on a page that has an element
25
25
  And that element is named as:
26
26
  | checkbox |
27
27
  | text_field |
@@ -30,7 +30,7 @@ Feature: Element
30
30
  Then I want know if this element is enable
31
31
 
32
32
  Scenario: Know if the element exists
33
- Given I am on a page that has a element
33
+ Given I am on a page that has an element
34
34
  And that element is named as:
35
35
  | checkbox |
36
36
  | text_field |
@@ -39,7 +39,7 @@ Feature: Element
39
39
  Then I want know if this element exists
40
40
 
41
41
  Scenario: Right click at the element
42
- Given I am on a page that has a element
42
+ Given I am on a page that has an element
43
43
  And that element is named as:
44
44
  | checkbox |
45
45
  | text_field |
@@ -49,7 +49,7 @@ Feature: Element
49
49
 
50
50
  @pending
51
51
  Scenario: Wait until the element is gone
52
- Given I am on a page that has a element
52
+ Given I am on a page that has an element
53
53
  And that element is named as:
54
54
  | checkbox |
55
55
  | text_field |
@@ -58,7 +58,7 @@ Feature: Element
58
58
 
59
59
  @pending
60
60
  Scenario: Wait until the element is present
61
- Given I am on a page that has a element
61
+ Given I am on a page that has an element
62
62
  And that element is named as:
63
63
  | checkbox |
64
64
  | text_field |
@@ -67,7 +67,7 @@ Feature: Element
67
67
 
68
68
  @pending
69
69
  Scenario: get the location of it
70
- Given I am on a page that has a element
70
+ Given I am on a page that has an element
71
71
  And that element is named as:
72
72
  | checkbox |
73
73
  | text_field |
@@ -3,28 +3,28 @@ Feature: Getting HTML Atributes
3
3
  I want to get HTML atributs from elements
4
4
 
5
5
  Scenario: Get the value of a html element
6
- Given I am on a page that has a element
6
+ Given I am on a page that has an element
7
7
  And the textfield has the value "text value"
8
8
  When I ask for the "value" of it element
9
9
  Then I should see the value of it
10
10
 
11
11
  @pending
12
12
  Scenario: Get the text of a html element
13
- Given I am on a page that has a element
13
+ Given I am on a page that has an element
14
14
  And the textfield has the text "text text"
15
15
  When I ask for the "text" of it element
16
16
  Then I should see the text of it
17
17
 
18
18
  @pending
19
19
  Scenario: Get the class of a html element
20
- Given I am on a page that has a element
20
+ Given I am on a page that has an element
21
21
  And the textfield has the class "text_class"
22
22
  When I ask for the "class" of it element
23
23
  Then I should see the class of it
24
24
 
25
25
  @pending
26
26
  Scenario: Get the tilte of a html element
27
- Given I am on a page that has a element
27
+ Given I am on a page that has an element
28
28
  And the textfield has the title "text title"
29
29
  When I ask for the "title" of it element
30
30
  Then I should see the title of it
@@ -3,7 +3,6 @@ require File.join(File.dirname(__FILE__), '../../lib/cello')
3
3
  module StaticPages
4
4
  module Site
5
5
  class Firefox < Cello::Structure::Browser
6
-
7
6
  def initialize
8
7
  super :firefox
9
8
  end
@@ -0,0 +1,11 @@
1
+ require "cello"
2
+
3
+ module StaticPages
4
+ module Site
5
+ class Phantom < Cello::Structure::Browser
6
+ def initialize
7
+ super :phantomjs
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), '../../lib/cello')
1
+ require "cello"
2
2
 
3
3
  module StaticPages
4
4
  module Site
@@ -12,13 +12,8 @@ module StaticPages
12
12
  element :select, :select, :id => 'select1'
13
13
  element :link, :link, :id => 'link1'
14
14
 
15
- def get_url
16
- 'file://' + File.dirname(__FILE__) + '/../site/inputs.html'
17
- end
15
+ url('file://' + File.dirname(__FILE__) + '/../site/inputs.html')
18
16
 
19
- def initialize(teste)
20
- super(teste)
21
- end
22
17
  end
23
18
  end
24
19
  end
@@ -1,15 +1,13 @@
1
- Dir[File.dirname(__FILE__) + "/../../pages/*.rb"].each do |file|
2
- require file
3
- end
1
+ require "cello"
4
2
 
5
3
  Then /^I should be able to write "(.*?)" in a element using id$/ do |text|
6
- @page.text_field_fill_with(text)
7
- @page.close
4
+ @browser.text_field_fill_with(text)
5
+ @browser.close
8
6
  end
9
7
 
10
8
  Then /^I should be able to write "(.*?)" in a element using name$/ do |text|
11
- @page.text_fieldname_fill_with(text)
12
- @page.close
9
+ @browser.text_fieldname_fill_with(text)
10
+ @browser.close
13
11
  end
14
12
 
15
13
  Then /^I should be able to write "(.*?)" in a element using label$/ do |text|
@@ -18,7 +16,7 @@ end
18
16
 
19
17
  Then /^I should be able to write "(.*?)" in a element using xpath$/ do |text|
20
18
  #pending
21
- @page.text_fieldxpath_fill_with(text)
19
+ @browser.text_fieldxpath_fill_with(text)
22
20
  end
23
21
 
24
22
 
@@ -1,9 +1,7 @@
1
- Dir[File.dirname(__FILE__) + "/../../pages/*.rb"].each do |file|
2
- require file
3
- end
1
+ require "cello"
4
2
 
5
3
  Given /^I have a browser with no context \(blank page\)$/ do
6
- @browser = StaticPages::Site::Firefox.new
4
+ @browser = StaticPages::Site::Phantom.new
7
5
  end
8
6
 
9
7
  When /^I ask for the context inputs$/ do
@@ -20,8 +18,9 @@ Then /^I should see the page inputs$/ do
20
18
  end
21
19
 
22
20
  Given /^I am in the inputs context$/ do
23
- @browser = StaticPages::Site::Firefox.new
24
- @browser.context StaticPages::Site::InputPage
21
+ steps %Q{
22
+ Given I have a browser with no context (blank page)
23
+ When I ask for the context inputs}
25
24
  @browser.visit
26
25
  @browser.title.should == "Inputs page"
27
26
  end
@@ -1,24 +1,22 @@
1
- Dir[File.dirname(__FILE__) + "/../../pages/*.rb"].each do |file|
2
- require file
3
- end
1
+ require "cello"
4
2
 
5
3
  Then /^I should be able to verify if it is checked$/ do
6
- @page.checkbox_is_checked?
7
- @page.close
4
+ @browser.checkbox_is_checked?
5
+ @browser.close
8
6
  end
9
7
 
10
8
  Then /^I should be able to verify if it is unchecked$/ do
11
- @page.checkbox_is_unchecked?
12
- @page.close
9
+ @browser.checkbox_is_unchecked?
10
+ @browser.close
13
11
  end
14
12
 
15
13
  Then /^I should be able to check it$/ do
16
- @page.checkbox_check
17
- @page.close
14
+ @browser.checkbox_check
15
+ @browser.close
18
16
  end
19
17
 
20
18
  Then /^I should be able to uncheck it$/ do
21
- @page.checkbox_uncheck
22
- @page.close
19
+ @browser.checkbox_uncheck
20
+ @browser.close
23
21
  end
24
22
 
@@ -1,39 +1,17 @@
1
- Dir[File.dirname(__FILE__) + "/../../pages/*.rb"].each do |file|
2
- require file
3
- end
4
-
5
- Given /^I am on a page that has a element$/ do
6
- @page = StaticPages::Site::Firefox.new
7
- @page.context StaticPages::Site::InputPage
8
- @page.visit
9
- end
10
-
11
- Given /^I am on a page that has a textfield$/ do
12
- @page = StaticPages::Site::Firefox.new
13
- @page.context StaticPages::Site::InputPage
14
- @page.visit
15
- end
16
-
17
- Given /^I am on a page that has a textarea$/ do
18
- @page = StaticPages::Site::Firefox.new
19
- @page.context StaticPages::Site::InputPage
20
- @page.visit
21
- end
1
+ require "cello"
22
2
 
23
- Given /^I am on a page that has a checkbox$/ do
24
- @page = StaticPages::Site::Firefox.new
25
- @page.context StaticPages::Site::InputPage
26
- @page.visit
3
+ Given /^I am on a page that has (?:a|an) (?:select|element|checkbox|textfield|textarea)$/ do
4
+ step "I am in the inputs context"
27
5
  end
28
6
 
29
7
  And /^There is a textfield with the text "(.*?)"$/ do |text|
30
- @page.text_field_fill_with(text)
8
+ @browser.text_field_fill_with(text)
31
9
  end
32
10
 
33
11
  And /^There is a textarea with the text "(.*?)"$/ do |text|
34
- @page.textarea_fill_with(text)
12
+ @browser.textarea_fill_with(text)
35
13
  end
36
14
 
37
15
  And /^There is a checkbox checked$/ do
38
- @page.checkbox_check
16
+ @browser.checkbox_check
39
17
  end
@@ -1,45 +1,43 @@
1
- Dir[File.dirname(__FILE__) + "/../../pages/*.rb"].each do |file|
2
- require file
3
- end
1
+ require "cello"
4
2
 
5
3
  Given /^that element is named as:$/ do |elements|
6
4
  elements.raw.each do |name|
7
- @page.send("#{name.first}_is_real?")
5
+ @browser.send("#{name.first}_is_real?")
8
6
  end
9
7
  @elements = elements
10
8
  end
11
9
 
12
10
  Then /^I want click on this element$/ do
13
11
  @elements.raw.each do |name|
14
- @page.send("#{name.first}_click")
12
+ @browser.send("#{name.first}_click")
15
13
  end
16
- @page.close
14
+ @browser.close
17
15
  end
18
16
 
19
17
  Then /^I want know if this element is visible$/ do
20
18
  @elements.raw.each do |name|
21
- @page.send("#{name.first}_is_visible?")
19
+ @browser.send("#{name.first}_is_visible?")
22
20
  end
23
- @page.close
21
+ @browser.close
24
22
  end
25
23
 
26
24
  Then /^I want know if this element is enable$/ do
27
25
  @elements.raw.each do |name|
28
- @page.send("#{name.first}_is_enable?")
26
+ @browser.send("#{name.first}_is_enable?")
29
27
  end
30
- @page.close
28
+ @browser.close
31
29
  end
32
30
 
33
31
  Then /^I want know if this element exists$/ do
34
32
  @elements.raw.each do |name|
35
- @page.send("#{name.first}_is_real?")
33
+ @browser.send("#{name.first}_is_real?")
36
34
  end
37
- @page.close
35
+ @browser.close
38
36
  end
39
37
 
40
38
  Then /^I shoud be able to click with the right button in this element$/ do
41
39
  @elements.raw.each do |name|
42
- @page.send("#{name.first}_right_click")
40
+ @browser.send("#{name.first}_right_click")
43
41
  end
44
- @page.close
42
+ @browser.close
45
43
  end
@@ -1,13 +1,14 @@
1
1
  Given /^the textfield has the value "(.*?)"$/ do |value|
2
- @page.text_field_fill_with(value)
2
+ # require "pry"; binding.pry
3
+ @browser.text_field_fill_with(value)
3
4
  @value == value
4
5
  end
5
6
 
6
7
  When /^I ask for the "(.*?)" of it element$/ do |att|
7
- @text_value == @page.text_field_get(att)
8
+ @text_value == @browser.text_field_get(att)
8
9
  end
9
10
 
10
11
  Then /^I should see the value of it$/ do
11
12
  @text_value.should == @value
12
- @page.close
13
+ @browser.close
13
14
  end
@@ -1,55 +1,51 @@
1
- Dir[File.dirname(__FILE__) + "/../../pages/*.rb"].each do |file|
2
- require file
3
- end
1
+ require "cello"
4
2
 
5
3
  Given /^I am on a page that has a radio group with the follow opitions:$/ do |radios|
6
- @page = StaticPages::Site::Firefox.new
7
- @page.context StaticPages::Site::InputPage
8
- @page.visit
4
+ step "I am in the inputs context"
9
5
  radios.raw.each do |radio|
10
- @page.radios_contains(radio)
6
+ @browser.radios_contains(radio)
11
7
  end
12
8
  end
13
9
 
14
10
  Given /^the option "(.*?)" is setted$/ do |option|
15
- @page.radios_set(option)
16
- @page.radios_checked_option_is?(option).should be_true
11
+ @browser.radios_set(option)
12
+ @browser.radios_checked_option_is?(option).should be_true
17
13
  end
18
14
 
19
15
  Then /^I should be able to know that the option "(.*?)" is setted$/ do |option|
20
- @page.radios_checked_option?.should include(option)
16
+ @browser.radios_checked_option?.should include(option)
21
17
  end
22
18
 
23
19
  Then /^I should be able to know if the option "(.*?)" is not setted$/ do |option|
24
- @page.radios_checked_option_is_not?(option).should be_true
25
- @page.close
20
+ @browser.radios_checked_option_is_not?(option).should be_true
21
+ @browser.close
26
22
  end
27
23
 
28
24
  Then /^I should fail when ask if the the option "(.*?)" is not setted$/ do |option|
29
- @page.radios_checked_option_is_not?(option).should be_false
30
- @page.close
25
+ @browser.radios_checked_option_is_not?(option).should be_false
26
+ @browser.close
31
27
  end
32
28
 
33
29
  Then /^I should be able to know if the option "(.*?)" is setted$/ do |option|
34
- @page.radios_checked_option_is?(option).should be_true
35
- @page.close
30
+ @browser.radios_checked_option_is?(option).should be_true
31
+ @browser.close
36
32
  end
37
33
 
38
34
  Then /^I should fail when ask if the option "(.*?)" is setted$/ do |option|
39
- @page.radios_checked_option_is?(option).should be_false
40
- @page.close
35
+ @browser.radios_checked_option_is?(option).should be_false
36
+ @browser.close
41
37
  end
42
38
 
43
39
  Then /^I should be able to know if there is some options setted$/ do
44
- @page.radios_has_selected_option?.should be_true
45
- @page.close
40
+ @browser.radios_has_selected_option?.should be_true
41
+ @browser.close
46
42
  end
47
43
 
48
44
  Then /^I should fail when ask if there is some options setted$/ do
49
- @page.radios_has_selected_option?.should be_false
50
- @page.close
45
+ @browser.radios_has_selected_option?.should be_false
46
+ @browser.close
51
47
  end
52
48
 
53
49
  Then /^I should be able to select the option "(.*?)"$/ do |option|
54
- @page.radios_set(option)
50
+ @browser.radios_set(option)
55
51
  end
@@ -1,39 +1,33 @@
1
- Given /^I am on a page that has a select$/ do
2
- @page = StaticPages::Site::Firefox.new
3
- @page.context StaticPages::Site::InputPage
4
- @page.visit
5
- end
6
-
7
1
  Then /^I should be able to get the options available of it$/ do
8
- @page.select_get_options.should == ["...","Cello","Cucumber","Ruby","Rspec","QA Rocks!"]
9
- @page.close
2
+ @browser.select_get_options.should == ["...","Cello","Cucumber","Ruby","Rspec","QA Rocks!"]
3
+ @browser.close
10
4
  end
11
5
 
12
6
  Then /^I should be able to select an option on it$/ do
13
- @page.select_select("Cucumber")
7
+ @browser.select_select("Cucumber")
14
8
  end
15
9
 
16
10
  Then /^be sure that the option setted is the option selected$/ do
17
- @page.select_is("Cucumber").should be_true
18
- @page.close
11
+ @browser.select_is("Cucumber").should be_true
12
+ @browser.close
19
13
  end
20
14
 
21
15
  Given /^the option "(.*?)" is selected$/ do |option|
22
- @page.select_select option
16
+ @browser.select_select option
23
17
  end
24
18
 
25
19
  Then /^I should be able to know the option "(.*?)" is selected$/ do |option|
26
- @page.select_selected.should == option
27
- @page.close
20
+ @browser.select_selected.should == option
21
+ @browser.close
28
22
  end
29
23
 
30
24
  Then /^I should fail when ask if the option "(.*?)" is selected$/ do |option|
31
- @page.select_selected.should_not == option
32
- @page.close
25
+ @browser.select_selected.should_not == option
26
+ @browser.close
33
27
  end
34
28
 
35
29
  Then /^I should be able to go to the default option of it$/ do
36
- @page.select_clear
37
- @page.select_selected.should == "..."
30
+ @browser.select_clear
31
+ @browser.select_selected.should == "..."
38
32
  end
39
33