capy 1.4.3 → 1.4.4

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 CHANGED
@@ -39,12 +39,20 @@ and capy with '-w' option
39
39
 
40
40
  $ capy -w example.capy
41
41
 
42
- ### To access the elements within iframe
42
+ ### To access the elements within IFrame
43
43
 
44
44
  within_frame('IFRAME_ID') do
45
45
  click_on 'link'
46
46
  end
47
47
 
48
+ ### Take Screenshot
49
+
50
+ take_screenshot
51
+
52
+ or
53
+
54
+ take_screenshot 'foo.png'
55
+
48
56
  ### JavaScript Mode
49
57
 
50
58
  # example.js
@@ -0,0 +1,7 @@
1
+ visit 'http://twitter.com/'
2
+ fill_in 'session[username_or_email]', :with => USERNAME
3
+ fill_in 'session[password]', :with => PASSWORD
4
+ click_on 'Sign in'
5
+ browser.keyboard.send_keys('n')
6
+ browser.keyboard.send_keys('Tweet from capy!')
7
+ click_on 'Tweet'
@@ -150,9 +150,15 @@ module Capy
150
150
  instance_eval script
151
151
  end
152
152
 
153
- def save_screenshot(png_path = nil)
154
- png_path = gen_uniq_file_name('png') unless png_path
155
- browser.save_screenshot(png_path)
153
+ def take_screenshot(png_path = nil)
154
+ png_path = gen_uniq_file_name('Screen Shot', 'png') unless png_path
155
+ case Capybara.current_driver
156
+ when :webkit
157
+ driver.render(png_path)
158
+ else
159
+ browser.save_screenshot(png_path)
160
+ end
161
+ png_path
156
162
  end
157
163
 
158
164
  def driver
@@ -173,8 +179,8 @@ module Capy
173
179
 
174
180
  private
175
181
 
176
- def gen_uniq_file_name(extension)
177
- file_name = Time.now.to_s
182
+ def gen_uniq_file_name(prefix, extension)
183
+ file_name = "#{prefix} #{Time.now}"
178
184
  i = 2
179
185
  while File.exists?("#{file_name}.#{extension}")
180
186
  file_name = if file_name =~ /\(\d+\)$/
@@ -1,3 +1,3 @@
1
1
  module Capy
2
- VERSION = "1.4.3"
2
+ VERSION = "1.4.4"
3
3
  end
@@ -102,15 +102,15 @@ describe Capy do
102
102
 
103
103
  context 'when file does not exists' do
104
104
  it do
105
- evaluater.send(:gen_uniq_file_name, :png).should == "#{now}.png"
105
+ evaluater.send(:gen_uniq_file_name, 'Foo', :png).should == "Foo #{now}.png"
106
106
  end
107
107
  end
108
108
 
109
109
  context 'when file already exists' do
110
110
  it do
111
- mock(File).exists?("#{now}.png") { true }
112
- mock(File).exists?("#{now} (2).png") { false }
113
- evaluater.send(:gen_uniq_file_name, :png).should == "#{now} (2).png"
111
+ mock(File).exists?("Foo #{now}.png") { true }
112
+ mock(File).exists?("Foo #{now} (2).png") { false }
113
+ evaluater.send(:gen_uniq_file_name, 'Foo', :png).should == "Foo #{now} (2).png"
114
114
  end
115
115
  end
116
116
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.3
4
+ version: 1.4.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-04-25 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: slop
16
- requirement: &70367040411320 !ruby/object:Gem::Requirement
16
+ requirement: &70245184336920 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70367040411320
24
+ version_requirements: *70245184336920
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: capybara
27
- requirement: &70367040410880 !ruby/object:Gem::Requirement
27
+ requirement: &70245184336300 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70367040410880
35
+ version_requirements: *70245184336300
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: colored
38
- requirement: &70367040410420 !ruby/object:Gem::Requirement
38
+ requirement: &70245184335660 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70367040410420
46
+ version_requirements: *70245184335660
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &70367040409960 !ruby/object:Gem::Requirement
49
+ requirement: &70245184334940 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70367040409960
57
+ version_requirements: *70245184334940
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rr
60
- requirement: &70367040409520 !ruby/object:Gem::Requirement
60
+ requirement: &70245184333980 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70367040409520
68
+ version_requirements: *70245184333980
69
69
  description: Capybara Script Runner
70
70
  email:
71
71
  - jugyo.org@gmail.com
@@ -82,7 +82,7 @@ files:
82
82
  - bin/capy
83
83
  - capy.gemspec
84
84
  - examples/google_search.capy
85
- - examples/twitter.js
85
+ - examples/twitter.capy
86
86
  - examples/wikipedia_search.capy
87
87
  - lib/capy.rb
88
88
  - lib/capy/version.rb
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env capy -s -j
2
- location.href = 'http://twitter.com'