gnawrnip 0.0.1

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/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ vendor
19
+ example/vendor
20
+ example/report.html
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ script: bundle exec rspec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gnawrnip.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Wataru MIYAGUNI
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # Gnawrnip
2
+
3
+ Gnawrnip is a [TurnipFormatter](https://github.com/gongo/turnip_formatter) Add-on that provides put a screen shot to report use [Capybara](https://github.com/jnicklas/capybara)
4
+
5
+ [![Build Status](https://travis-ci.org/gongo/gnawrnip.png?branch=master)](https://travis-ci.org/gongo/gnawrnip)
6
+ [![Coverage Status](https://coveralls.io/repos/gongo/gnawrnip/badge.png?branch=master)](https://coveralls.io/r/gongo/gnawrnip)
7
+ [![Code Climate](https://codeclimate.com/github/gongo/gnawrnip.png)](https://codeclimate.com/github/gongo/gnawrnip)
8
+ [![Dependency Status](https://gemnasium.com/gongo/gnawrnip.png)](https://gemnasium.com/gongo/gnawrnip)
9
+
10
+
11
+ ## Requirements
12
+
13
+ * Ruby
14
+ * `~> 1.9.3`
15
+ * `~> 2.0.0`
16
+ * RubyGems
17
+ * capybara `~> 2.1.0`
18
+ * turnip_formatter
19
+
20
+ ## Installation
21
+
22
+ Add this line to your application's Gemfile:
23
+
24
+ gem 'gnawrnip'
25
+
26
+ And then execute:
27
+
28
+ $ bundle
29
+
30
+ Or install it yourself as:
31
+
32
+ $ gem install gnawrnip
33
+
34
+ ## Usage
35
+
36
+ Edit the `.rspec` file in your project directory (create it if doesn't exist), and add the following line:
37
+
38
+ -r turnip
39
+ -r turnip/capybara
40
+ -r gnawrnip
41
+
42
+ And run this command.
43
+
44
+ $ rspec --format RSpecTurnipFormatter --out report.html
45
+
46
+
47
+ ## Example
48
+
49
+ see https://github.com/gongo/gnawrnip/tree/master/example
50
+
51
+ ## License
52
+
53
+ MIT License. see LICENSE.txt
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/example/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --colour
2
+ -r turnip
3
+ -r turnip/capybara
4
+ -r gnawrnip
data/example/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'sinatra'
4
+ gem 'capybara', '~> 2.1.0'
5
+ gem 'rspec'
6
+ gem 'turnip'
7
+ gem 'turnip_formatter'
8
+ gem 'gnawrnip'
9
+ gem 'poltergeist'
data/example/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # Gnawrnip demo
2
+
3
+ ## Requirements
4
+
5
+ * Poltergeist
6
+ * see [Installing PhantomJS](https://github.com/jonleighton/poltergeist#installing-phantomjs)
7
+
8
+ ## Usage
9
+
10
+ $ cd /path/to/gnawrnip/example
11
+ $ bundle install --path vendor/bundle
12
+ $ bundle exec rspec
13
+
14
+ memo: It raises an error for demo.
15
+
16
+ And open report file.
17
+
18
+ $ open report.html
@@ -0,0 +1,27 @@
1
+ Feature: Access
2
+
3
+ Scenario: / (Success)
4
+ When I am on the "/"
5
+ Then I should see "Hello World"
6
+
7
+ Scenario: / (Failed...)
8
+ When I am on the "/"
9
+ Then I should see "Hoge World"
10
+
11
+ Scenario: /form (Success)
12
+ When I am on the "/form"
13
+ And type "Gongo" to "name"
14
+ And click "Go!"
15
+ Then I should see "Gongo"
16
+
17
+ Scenario: /form (Failed...)
18
+ When I am on the "/form"
19
+ And type "Gongo" to "name"
20
+ And click "Go!"
21
+ Then I should see "Gengo"
22
+
23
+ Scenario: /form (Failed...)
24
+ When I am on the "/form"
25
+ And type "Gongo" to "name"
26
+ And click "Push"
27
+ Then I should see "Gongo"
@@ -0,0 +1,19 @@
1
+ require 'turnip/rspec'
2
+ require 'turnip_formatter'
3
+ require 'rspec/expectations'
4
+ require 'capybara'
5
+ require 'turnip/capybara'
6
+ require 'gnawrnip'
7
+ require 'capybara/poltergeist'
8
+
9
+ # Load turnip steps
10
+ Dir.glob(File.dirname(__FILE__) + "/steps/**/*steps.rb") { |f| load f, true }
11
+
12
+ RSpec.configure do |config|
13
+ config.add_formatter RSpecTurnipFormatter, 'report.html'
14
+ config.add_formatter 'progress'
15
+ end
16
+
17
+ require_relative '../web'
18
+ Capybara.app = Sinatra::Application.new
19
+ Capybara.default_driver = :poltergeist
@@ -0,0 +1,15 @@
1
+ step 'I am on the :path' do |path|
2
+ visit path
3
+ end
4
+
5
+ step 'I should see :text' do |text|
6
+ expect(page).to have_content(text)
7
+ end
8
+
9
+ step 'type :text to :field' do |text, field|
10
+ fill_in field, with: text
11
+ end
12
+
13
+ step 'click :button' do |button|
14
+ click_button button
15
+ end
data/example/web.rb ADDED
@@ -0,0 +1,35 @@
1
+ require 'sinatra'
2
+ require 'erb'
3
+
4
+ get '/' do
5
+ "Hello World!!"
6
+ end
7
+
8
+ get '/form' do
9
+ erb :index
10
+ end
11
+
12
+ post '/result' do
13
+ erb :index
14
+ end
15
+
16
+
17
+ __END__
18
+
19
+ @@ index
20
+ <!DOCTYPE html>
21
+ <html>
22
+ <head>
23
+ <style>
24
+ body { background-color: #aaaaaa; }
25
+ div#result { color: red; }
26
+ </style>
27
+ </head>
28
+ <body>
29
+ <div id="result"><%= params[:name] %></div>
30
+ <form method="POST" action="/result">
31
+ <label>Name: <input type="text" name="name"></label>
32
+ <input type="submit" value="Go!" />
33
+ </form>
34
+ </body>
35
+ </html>
data/gnawrnip.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gnawrnip/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gnawrnip"
8
+ spec.version = Gnawrnip::VERSION
9
+ spec.authors = ["Wataru MIYAGUNI"]
10
+ spec.email = ["gonngo@gmail.com"]
11
+ spec.description = %q{Gnawrnip is a TurnipFormatter Add-on that provides put a screen shot to report use Capybara}
12
+ spec.summary = %q{Add-on for TurnipFormatter with Capybara}
13
+ spec.homepage = "https://github.com/gongo/gnawrnip"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^spec/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'capybara', "~> 2.1"
22
+ spec.add_dependency 'turnip_formatter'
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency 'rspec'
26
+ spec.add_development_dependency 'coveralls'
27
+ end
@@ -0,0 +1,15 @@
1
+ require 'rspec'
2
+ require 'tempfile'
3
+ require 'base64'
4
+
5
+ RSpec.configure do |config|
6
+ config.after do
7
+ if example.exception
8
+ temp = Tempfile.new(['gnawrnip', '.png'])
9
+ save_screenshot(temp.path)
10
+ example.metadata[:turnip] ||= {}
11
+ example.metadata[:turnip][:screenshot] = Base64.encode64(File.read(temp.path))
12
+ temp.close!
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ require 'turnip_formatter/step/failure'
2
+
3
+ module Gnawrnip
4
+ module StepScreenshot
5
+ #
6
+ # @param [String] png_file base64 encoded
7
+ #
8
+ def self.build(png_file)
9
+ img = '<img src="data:image/png;base64,'
10
+ img += png_file
11
+ img += '" style="width: 90%; border: 2px solid black;" />'
12
+ img
13
+ end
14
+ end
15
+ end
16
+
17
+ TurnipFormatter::Step::Failure.add_template :screenshot, Gnawrnip::StepScreenshot do
18
+ example.metadata[:turnip][:screenshot]
19
+ end
@@ -0,0 +1,3 @@
1
+ module Gnawrnip
2
+ VERSION = "0.0.1"
3
+ end
data/lib/gnawrnip.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "gnawrnip/version"
2
+
3
+ module Gnawrnip
4
+ require 'gnawrnip/step_screenshot'
5
+ require 'gnawrnip/rspec'
6
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+ require 'gnawrnip/rspec'
3
+
4
+ module Gnawrnip
5
+ describe 'Rspec' do
6
+ let(:example) do
7
+ group = ::RSpec::Core::ExampleGroup.describe('Feature')
8
+ example = group.example('example', {}) { expect(true).to be_false }
9
+ group.run(
10
+ Class.new do
11
+ def self.method_missing(name, *args, &block)
12
+ # nooooooop
13
+ end
14
+ end
15
+ )
16
+ example
17
+ end
18
+
19
+ it 'should save screen shot at error' do
20
+ expect(example.metadata[:turnip][:screenshot]).to eq "c2NyZWVuc2hvdA==\n"
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+ require 'gnawrnip/step_screenshot'
3
+
4
+ module Gnawrnip
5
+ describe StepScreenshot do
6
+ let :template do
7
+ StepScreenshot
8
+ end
9
+
10
+ it 'exists failure step template' do
11
+ expect(TurnipFormatter::Step::Failure.templates).to have_key :screenshot
12
+ end
13
+
14
+ describe '.build' do
15
+ subject { template.build('aiueo') }
16
+ it { should match %r{<img src="data:image/png;base64,aiueo"} }
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
4
+ require 'gnawrnip'
5
+
6
+ RSpec.configure do |config|
7
+ config.include(
8
+ Module.new do
9
+ # stub Capybara::Session.save_screenshot
10
+ def save_screenshot(file_path)
11
+ File.open(file_path, 'w') do |fp|
12
+ fp.print 'screenshot'
13
+ end
14
+ end
15
+ end
16
+ )
17
+ end
metadata ADDED
@@ -0,0 +1,173 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gnawrnip
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Wataru MIYAGUNI
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capybara
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '2.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '2.1'
30
+ - !ruby/object:Gem::Dependency
31
+ name: turnip_formatter
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: bundler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '1.3'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: coveralls
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: Gnawrnip is a TurnipFormatter Add-on that provides put a screen shot
111
+ to report use Capybara
112
+ email:
113
+ - gonngo@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - .travis.yml
120
+ - Gemfile
121
+ - LICENSE.txt
122
+ - README.md
123
+ - Rakefile
124
+ - example/.rspec
125
+ - example/Gemfile
126
+ - example/README.md
127
+ - example/spec/features/hello.feature
128
+ - example/spec/spec_helper.rb
129
+ - example/spec/steps/hello_steps.rb
130
+ - example/web.rb
131
+ - gnawrnip.gemspec
132
+ - lib/gnawrnip.rb
133
+ - lib/gnawrnip/rspec.rb
134
+ - lib/gnawrnip/step_screenshot.rb
135
+ - lib/gnawrnip/version.rb
136
+ - spec/gnawrnip/rspec_spec.rb
137
+ - spec/gnawrnip/step_screenshot_spec.rb
138
+ - spec/spec_helper.rb
139
+ homepage: https://github.com/gongo/gnawrnip
140
+ licenses:
141
+ - MIT
142
+ post_install_message:
143
+ rdoc_options: []
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ none: false
148
+ requirements:
149
+ - - ! '>='
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ segments:
153
+ - 0
154
+ hash: -4385151438016363353
155
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
+ none: false
157
+ requirements:
158
+ - - ! '>='
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ segments:
162
+ - 0
163
+ hash: -4385151438016363353
164
+ requirements: []
165
+ rubyforge_project:
166
+ rubygems_version: 1.8.23
167
+ signing_key:
168
+ specification_version: 3
169
+ summary: Add-on for TurnipFormatter with Capybara
170
+ test_files:
171
+ - spec/gnawrnip/rspec_spec.rb
172
+ - spec/gnawrnip/step_screenshot_spec.rb
173
+ - spec/spec_helper.rb