cucumber-sinatra 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +13 -0
- data/README.md +42 -0
- data/Rakefile +148 -0
- data/bin/cucumber-sinatra +7 -0
- data/cucumber-sinatra.gemspec +51 -0
- data/lib/cucumber/sinatra/generators.rb +38 -0
- data/lib/cucumber/sinatra/templates/app.rbt +7 -0
- data/lib/cucumber/sinatra/templates/config.ru +4 -0
- data/lib/cucumber/sinatra/templates/features/support/env.rbt +15 -0
- data/lib/cucumber/sinatra.rb +5 -0
- metadata +85 -0
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright (c) 2010 Bernd Ahlers <bernd@tuneafish.de>
|
2
|
+
|
3
|
+
Permission to use, copy, modify, and distribute this software for any
|
4
|
+
purpose with or without fee is hereby granted, provided that the above
|
5
|
+
copyright notice and this permission notice appear in all copies.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
10
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
12
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
13
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
cucumber-sinatra
|
2
|
+
================
|
3
|
+
|
4
|
+
# Description
|
5
|
+
|
6
|
+
This little gem will help you to initialize a cucumber environment for a sinatra
|
7
|
+
application. It will generate the required files from templates.
|
8
|
+
|
9
|
+
For now it's generating an `env.rb` that is using [rspec](http://github.com/dchelimsky/rspec)
|
10
|
+
and [capybara](http://github.com/jnicklas/capybara). More options might be added later.
|
11
|
+
|
12
|
+
# Installation
|
13
|
+
|
14
|
+
It's available as a gem that can be installed with the following command.
|
15
|
+
|
16
|
+
gem install cucumber-sinatra
|
17
|
+
|
18
|
+
# Usage
|
19
|
+
|
20
|
+
To initialize the cucumber environment, just execute `cucumber-sinatra` like this:
|
21
|
+
|
22
|
+
# cucumber-sinatra init MyApp lib/my_app.rb
|
23
|
+
[ADDED] features/step_definitions
|
24
|
+
[ADDED] features/support/env.rb
|
25
|
+
#
|
26
|
+
|
27
|
+
* The first argument is the class name of your application.
|
28
|
+
* The second argument is the path to the application file that should be required.
|
29
|
+
|
30
|
+
Using the `--app` option with `init` will also generate the given application file
|
31
|
+
and a working `config.ru`.
|
32
|
+
|
33
|
+
# cucumber-sinatra init --app MyApp lib/my_app.rb
|
34
|
+
[ADDED] features/step_definitions
|
35
|
+
[ADDED] features/support/env.rb
|
36
|
+
[ADDED] lib/my_app.rb
|
37
|
+
[ADDED] config.ru
|
38
|
+
#
|
39
|
+
|
40
|
+
# Copyright
|
41
|
+
|
42
|
+
Copyright (c) 2010 Bernd Ahlers. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
#############################################################################
|
6
|
+
#
|
7
|
+
# Helper functions
|
8
|
+
#
|
9
|
+
#############################################################################
|
10
|
+
|
11
|
+
def name
|
12
|
+
@name ||= Dir['*.gemspec'].first.split('.').first
|
13
|
+
end
|
14
|
+
|
15
|
+
def name_path
|
16
|
+
name.gsub('-', '/')
|
17
|
+
end
|
18
|
+
|
19
|
+
def version
|
20
|
+
line = File.read("lib/#{name_path}.rb")[/^\s*VERSION\s*=\s*.*/]
|
21
|
+
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
22
|
+
end
|
23
|
+
|
24
|
+
def date
|
25
|
+
Date.today.to_s
|
26
|
+
end
|
27
|
+
|
28
|
+
def rubyforge_project
|
29
|
+
name
|
30
|
+
end
|
31
|
+
|
32
|
+
def gemspec_file
|
33
|
+
"#{name}.gemspec"
|
34
|
+
end
|
35
|
+
|
36
|
+
def gem_file
|
37
|
+
"#{name}-#{version}.gem"
|
38
|
+
end
|
39
|
+
|
40
|
+
def replace_header(head, header_name)
|
41
|
+
head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
|
42
|
+
end
|
43
|
+
|
44
|
+
#############################################################################
|
45
|
+
#
|
46
|
+
# Standard tasks
|
47
|
+
#
|
48
|
+
#############################################################################
|
49
|
+
|
50
|
+
task :default => :test
|
51
|
+
|
52
|
+
require 'rake/testtask'
|
53
|
+
Rake::TestTask.new(:test) do |test|
|
54
|
+
test.libs << 'lib' << 'test'
|
55
|
+
test.pattern = 'test/**/test_*.rb'
|
56
|
+
test.verbose = true
|
57
|
+
end
|
58
|
+
|
59
|
+
desc "Generate RCov test coverage and open in your browser"
|
60
|
+
task :coverage do
|
61
|
+
require 'rcov'
|
62
|
+
sh "rm -fr coverage"
|
63
|
+
sh "rcov test/test_*.rb"
|
64
|
+
sh "open coverage/index.html"
|
65
|
+
end
|
66
|
+
|
67
|
+
require 'rake/rdoctask'
|
68
|
+
Rake::RDocTask.new do |rdoc|
|
69
|
+
rdoc.rdoc_dir = 'rdoc'
|
70
|
+
rdoc.title = "#{name} #{version}"
|
71
|
+
rdoc.rdoc_files.include('README*')
|
72
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
73
|
+
end
|
74
|
+
|
75
|
+
desc "Open an irb session preloaded with this library"
|
76
|
+
task :console do
|
77
|
+
sh "irb -rubygems -r ./lib/#{name_path}.rb"
|
78
|
+
end
|
79
|
+
|
80
|
+
#############################################################################
|
81
|
+
#
|
82
|
+
# Custom tasks (add your own tasks here)
|
83
|
+
#
|
84
|
+
#############################################################################
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
#############################################################################
|
89
|
+
#
|
90
|
+
# Packaging tasks
|
91
|
+
#
|
92
|
+
#############################################################################
|
93
|
+
|
94
|
+
desc "Update gemspec, build gem, commit with 'Release x.x.x', create tag, push to github and gemcutter"
|
95
|
+
task :release => :build do
|
96
|
+
unless `git branch` =~ /^\* master$/
|
97
|
+
puts "You must be on the master branch to release!"
|
98
|
+
exit!
|
99
|
+
end
|
100
|
+
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
101
|
+
sh "git tag v#{version}"
|
102
|
+
sh "git push origin master"
|
103
|
+
sh "git push v#{version}"
|
104
|
+
sh "gem push pkg/#{name}-#{version}.gem"
|
105
|
+
end
|
106
|
+
|
107
|
+
desc "Update gemspec and build gem"
|
108
|
+
task :build => :gemspec do
|
109
|
+
sh "mkdir -p pkg"
|
110
|
+
sh "gem build #{gemspec_file}"
|
111
|
+
sh "mv #{gem_file} pkg"
|
112
|
+
end
|
113
|
+
|
114
|
+
desc "Update gemspec with the latest version and file list"
|
115
|
+
task :gemspec => :validate do
|
116
|
+
# read spec file and split out manifest section
|
117
|
+
spec = File.read(gemspec_file)
|
118
|
+
head, manifest, tail = spec.split(" # = MANIFEST =\n")
|
119
|
+
|
120
|
+
# replace name version and date
|
121
|
+
replace_header(head, :name)
|
122
|
+
replace_header(head, :version)
|
123
|
+
replace_header(head, :date)
|
124
|
+
#comment this out if your rubyforge_project has a different name
|
125
|
+
replace_header(head, :rubyforge_project)
|
126
|
+
|
127
|
+
# determine file list from git ls-files
|
128
|
+
files = `git ls-files`.
|
129
|
+
split("\n").
|
130
|
+
sort.
|
131
|
+
reject { |file| file =~ /^\./ }.
|
132
|
+
reject { |file| file =~ /^(rdoc|pkg)/ }.
|
133
|
+
map { |file| " #{file}" }.
|
134
|
+
join("\n")
|
135
|
+
|
136
|
+
# piece file back together and write
|
137
|
+
manifest = " s.files = %w[\n#{files}\n ]\n"
|
138
|
+
spec = [head, manifest, tail].join(" # = MANIFEST =\n")
|
139
|
+
File.open(gemspec_file, 'w') { |io| io.write(spec) }
|
140
|
+
puts "Updated #{gemspec_file}"
|
141
|
+
end
|
142
|
+
|
143
|
+
task :validate do
|
144
|
+
unless Dir['VERSION*'].empty?
|
145
|
+
puts "A `VERSION` file at root level violates Gem best practices."
|
146
|
+
exit!
|
147
|
+
end
|
148
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.specification_version = 2 if s.respond_to? :specification_version=
|
3
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
4
|
+
s.rubygems_version = '1.3.5'
|
5
|
+
|
6
|
+
## Leave these as is they will be modified for you by the rake gemspec task.
|
7
|
+
## If your rubyforge_project name is different, then edit it and comment out
|
8
|
+
## the sub! line in the Rakefile
|
9
|
+
s.name = 'cucumber-sinatra'
|
10
|
+
s.version = '0.1.0'
|
11
|
+
s.date = '2010-05-20'
|
12
|
+
s.rubyforge_project = 'cucumber-sinatra'
|
13
|
+
|
14
|
+
s.summary = "Initialize a cucumber environment for sinatra"
|
15
|
+
s.description = "This little gem will help you to initialize a cucumber environment for a sinatra application. It will generate the required files from templates."
|
16
|
+
|
17
|
+
s.authors = ["Bernd Ahlers"]
|
18
|
+
s.email = 'bernd@tuneafish.de'
|
19
|
+
s.homepage = 'http://github.com/bernd/cucumber-sinatra'
|
20
|
+
|
21
|
+
## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
|
22
|
+
## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
|
23
|
+
s.require_paths = %w[lib]
|
24
|
+
|
25
|
+
s.executables = ["cucumber-sinatra"]
|
26
|
+
s.default_executable = 'cucumber-sinatra'
|
27
|
+
|
28
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
29
|
+
s.extra_rdoc_files = %w[README.md LICENSE]
|
30
|
+
|
31
|
+
s.add_dependency('templater', [">= 1.0.0"])
|
32
|
+
|
33
|
+
# = MANIFEST =
|
34
|
+
s.files = %w[
|
35
|
+
LICENSE
|
36
|
+
README.md
|
37
|
+
Rakefile
|
38
|
+
bin/cucumber-sinatra
|
39
|
+
cucumber-sinatra.gemspec
|
40
|
+
lib/cucumber/sinatra.rb
|
41
|
+
lib/cucumber/sinatra/generators.rb
|
42
|
+
lib/cucumber/sinatra/templates/app.rbt
|
43
|
+
lib/cucumber/sinatra/templates/config.ru
|
44
|
+
lib/cucumber/sinatra/templates/features/support/env.rbt
|
45
|
+
]
|
46
|
+
# = MANIFEST =
|
47
|
+
|
48
|
+
## Test files will be grabbed from the file list. Make sure the path glob
|
49
|
+
## matches what you actually use.
|
50
|
+
#s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
|
51
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'templater'
|
2
|
+
|
3
|
+
module Cucumber
|
4
|
+
module Sinatra
|
5
|
+
module Generators
|
6
|
+
extend Templater::Manifold
|
7
|
+
|
8
|
+
class InitGenerator < Templater::Generator
|
9
|
+
def self.source_root
|
10
|
+
File.join(File.dirname(__FILE__), 'templates')
|
11
|
+
end
|
12
|
+
|
13
|
+
desc <<-DESC
|
14
|
+
Initialize a cucumber environment for a sinatra application.
|
15
|
+
cucumber-sinatra MyApp lib/myapp.rb
|
16
|
+
DESC
|
17
|
+
|
18
|
+
first_argument :app_class, :required => true, :desc => 'Application class'
|
19
|
+
second_argument :app_file, :required => true, :desc => 'Application file'
|
20
|
+
|
21
|
+
option :app, :as => :boolean, :default => false, :desc => 'Create the application files as well.'
|
22
|
+
|
23
|
+
template :env, 'features/support/env.rb'
|
24
|
+
template :app_file, 'app.rbt', '%app_file_path%', :app => true
|
25
|
+
template :rackup_file, 'config.ru', 'config.ru', :app => true
|
26
|
+
|
27
|
+
empty_directory :step_definitions, 'features/step_definitions'
|
28
|
+
|
29
|
+
def app_file_path
|
30
|
+
app_file
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "Generators to simplify the usage of cucumber with sinatra."
|
35
|
+
add :init, InitGenerator
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Generated by cucumber-sinatra. (<%= Time.now %>)
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), '..', '..', '<%= app_file -%>')
|
4
|
+
|
5
|
+
require 'capybara'
|
6
|
+
require 'capybara/cucumber'
|
7
|
+
require 'spec'
|
8
|
+
|
9
|
+
World do
|
10
|
+
Capybara.app = <%= app_class -%>
|
11
|
+
|
12
|
+
include Capybara
|
13
|
+
include Spec::Expectations
|
14
|
+
include Spec::Matchers
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cucumber-sinatra
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Bernd Ahlers
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-05-20 00:00:00 +02:00
|
18
|
+
default_executable: cucumber-sinatra
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: templater
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 0
|
30
|
+
- 0
|
31
|
+
version: 1.0.0
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
description: This little gem will help you to initialize a cucumber environment for a sinatra application. It will generate the required files from templates.
|
35
|
+
email: bernd@tuneafish.de
|
36
|
+
executables:
|
37
|
+
- cucumber-sinatra
|
38
|
+
extensions: []
|
39
|
+
|
40
|
+
extra_rdoc_files:
|
41
|
+
- README.md
|
42
|
+
- LICENSE
|
43
|
+
files:
|
44
|
+
- LICENSE
|
45
|
+
- README.md
|
46
|
+
- Rakefile
|
47
|
+
- bin/cucumber-sinatra
|
48
|
+
- cucumber-sinatra.gemspec
|
49
|
+
- lib/cucumber/sinatra.rb
|
50
|
+
- lib/cucumber/sinatra/generators.rb
|
51
|
+
- lib/cucumber/sinatra/templates/app.rbt
|
52
|
+
- lib/cucumber/sinatra/templates/config.ru
|
53
|
+
- lib/cucumber/sinatra/templates/features/support/env.rbt
|
54
|
+
has_rdoc: true
|
55
|
+
homepage: http://github.com/bernd/cucumber-sinatra
|
56
|
+
licenses: []
|
57
|
+
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options:
|
60
|
+
- --charset=UTF-8
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
version: "0"
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
version: "0"
|
77
|
+
requirements: []
|
78
|
+
|
79
|
+
rubyforge_project: cucumber-sinatra
|
80
|
+
rubygems_version: 1.3.6
|
81
|
+
signing_key:
|
82
|
+
specification_version: 2
|
83
|
+
summary: Initialize a cucumber environment for sinatra
|
84
|
+
test_files: []
|
85
|
+
|