pyrite 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,48 @@
1
+ = Pyrite - Easy Peasy Browser Testing
2
+
3
+ - http://mintdigital.github.com/pyrite
4
+ - http://github.com/mintdigital/pyrite
5
+
6
+ == Description
7
+
8
+ Pyrite is a lightweight DSL around the Selenium browser testing framework.
9
+
10
+ We found Cucumber to be awesome, but no one was reading the features. We found
11
+ Webrat to be fantastic, but way too complex for what we wanted. So, we made
12
+ Pyrite - a few selenium-client methods wrapped up in a readable way.
13
+
14
+ == Example
15
+
16
+ require 'pyrite_helper'
17
+ class BasicTest < Pyrite::PyriteTest
18
+ test "it works" do
19
+ visit root_path
20
+ follow "next page"
21
+ wait_for :page_load
22
+ assert_text "some text you should see"
23
+ end
24
+ end
25
+
26
+ == Dependencies
27
+
28
+ Pyrite has no dependencies that you should have to install manually. Gem
29
+ installation should pull in the necessary selenium libraries.
30
+
31
+ You will need an operating system and browser capable of running Selenium
32
+
33
+ == Install
34
+
35
+ We recommend you use {bundler}[http://gembundler.com]:
36
+
37
+ gem 'pyrite', '0.5.0', :require => false
38
+
39
+ Installing as a Rails plugin should also work:
40
+
41
+ script/plugin install git://github.com/mintdigital/pyrite.git
42
+
43
+ == License
44
+
45
+ Copyright (c) 2010 Mint Digital Ltd.
46
+
47
+ Released under the terms of the MIT License.
48
+ See the MIT-LICENSE file in this directory.
@@ -48,11 +48,7 @@ module Pyrite
48
48
 
49
49
  # Click anything else
50
50
  def click(locator)
51
- browser.click(locator)
52
- end
53
-
54
- def attach(field, file)
55
- browser.attach(field, "http://test.rodreegez.com/#{file}")
51
+ browser.click("css=#{locator}")
56
52
  end
57
53
 
58
54
  # Pick an option from a select element
@@ -63,9 +59,9 @@ module Pyrite
63
59
  # Wait for a specific element or the page to load
64
60
  def wait_for(element)
65
61
  if element == :page_load
66
- browser.wait_for_page_to_load
62
+ browser.wait_for_page_to_load :page
67
63
  else
68
- browser.wait_for_element(element)
64
+ browser.wait_for :element => "#{element}"
69
65
  end
70
66
  end
71
67
 
@@ -76,9 +72,9 @@ module Pyrite
76
72
 
77
73
  # Excecute commands within an iframe, then switch back to the parent frame
78
74
  # i.e.
79
- # inside_frame(iframe) do
80
- # click "Submit"
81
- # end
75
+ # inside_frame(iframe) do
76
+ # click "Submit"
77
+ # end
82
78
  def inside_iframe(frame)
83
79
  wait_for frame
84
80
  browser.select_frame(frame)
@@ -89,28 +85,37 @@ module Pyrite
89
85
 
90
86
  # Use this to consume JS alerts
91
87
  # i.e.
92
- # follow 'delete'
93
- # get_confirmation
94
- # !assert_element "h2:contains('user1')"
88
+ # follow 'delete'
89
+ # get_confirmation
90
+ # !assert_element "h2:contains('user1')"
95
91
  def get_confirmation
96
92
  browser.get_confirmation
97
93
  end
98
94
 
99
95
  # drag an css selector to the center pixel of another, e.g.
100
- # `drag_and_drop(:from => "li#element_#{my_oject.id}", :to => "div#trash")
96
+ # `drag_and_drop(:from => "li#element_#{my_oject.id}", :to => "div#trash")
101
97
  # ProTip: if you have a list of elements you wish to re-order, drag the top element down.
102
98
  def drag_and_drop(opts={})
103
99
  browser.drag_and_drop_to_object("css=#{opts[:from]}", "css=#{opts[:to]}")
104
100
  end
105
101
 
106
102
  # Capture the page and try to open it
107
- # (probably only works on os x)
103
+ # (probably only works on OS X)
108
104
  def show_me
109
105
  image = "#{Rails.root.join('tmp')}/pyrite-#{Time.now.to_i}.png"
110
106
  browser.capture_entire_page_screenshot(image, '')
111
107
  puts `open #{image}`
112
108
  end
109
+
110
+ # Write the HTML of a page to a file and open it.
111
+ # (probably only works on OS X)
112
+ def code_me
113
+ html = browser.get_html_source
114
+ filename = "#{Rails.root.join('tmp')}/pyrite-#{Time.now.to_i}.html"
115
+ code = File.open(filename, 'w') { |f| f.write(html) }
116
+ puts `open #{code}`
117
+ end
113
118
 
114
119
  end
115
120
 
116
- end
121
+ end
@@ -1,7 +1,7 @@
1
1
  module Pyrite
2
2
  module Helpers
3
3
 
4
- # Easily get the path to a fixture file
4
+ # Easily get the path to a fixture file from Rails.root/test/fixtures/<filename>
5
5
  def fixture(filename)
6
6
  File.join(Rails.root,'test','fixtures', filename)
7
7
  end
@@ -2,7 +2,7 @@ require 'pyrite/dsl'
2
2
  require 'pyrite/assertions'
3
3
  require 'pyrite/helpers'
4
4
 
5
- module Pyrite
5
+ module Pyrite
6
6
  class PyriteTest < ActionController::IntegrationTest
7
7
  include Dsl
8
8
  include Assertions
@@ -10,7 +10,7 @@ module Pyrite
10
10
 
11
11
  self.use_transactional_fixtures = false
12
12
 
13
- def browser
13
+ def browser #:nodoc:
14
14
  $browser ||= Selenium::Client::Driver.new(
15
15
  :host => Pyrite.rc_host,
16
16
  :port => 4444,
@@ -20,13 +20,13 @@ module Pyrite
20
20
  )
21
21
  end
22
22
 
23
- def setup
23
+ def setup #:nodoc:
24
24
  DatabaseCleaner.clean
25
25
  browser.start_new_browser_session
26
26
  super
27
27
  end
28
28
 
29
- def teardown
29
+ def teardown #:nodoc:
30
30
  super
31
31
  browser.close_current_browser_session
32
32
  end
@@ -9,7 +9,7 @@ namespace :pyrite do
9
9
 
10
10
  desc "Startup Selenium RC and the server for browser testing"
11
11
  task :start => 'selenium:start' do
12
- puts `thin start -e pyrite -p 2222 -d`
12
+ puts `./script/server -e pyrite -p 2222 -d`
13
13
  end
14
14
 
15
15
  desc "Shutdown Selenium RC and the server for browser testing"
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 0
9
- version: 0.5.0
8
+ - 1
9
+ version: 0.5.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Adam Rogers
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-03-26 00:00:00 -04:00
18
+ date: 2010-04-13 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -73,14 +73,15 @@ files:
73
73
  - lib/pyrite/dsl.rb
74
74
  - lib/pyrite/helpers.rb
75
75
  - lib/pyrite/pyrite_test.rb
76
- - lib/pyrite/tasks.rb
77
76
  - lib/pyrite/tasks/pyrite.rb
78
77
  - lib/pyrite/tasks/selenium.rb
78
+ - lib/pyrite/tasks.rb
79
79
  - lib/pyrite.rb
80
- - MIT-LICENSE
81
80
  - tasks/pyrite.rake
81
+ - MIT-LICENSE
82
+ - README.rdoc
82
83
  has_rdoc: true
83
- homepage: http://github.com/mintdigital/pyrite
84
+ homepage: http://mintdigital.github.com/pyrite
84
85
  licenses: []
85
86
 
86
87
  post_install_message: