cavalle-pickle 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +10 -0
- data/lib/pickle.rb +28 -0
- data/spec/acceptance/acceptance_helper.rb +54 -0
- data/spec/acceptance/basic_spec.rb +51 -0
- data/spec/acceptance/rails_spec.rb +41 -0
- metadata +66 -0
data/README.rdoc
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
=Pickle
|
2
|
+
|
3
|
+
"A pickled cucumber, most often simply called a pickle in the United States and Canada, is a cucumber that has been pickled in a brine, vinegar, or other solutions and left to ferment for a period of time." -- Wikipedia
|
4
|
+
|
5
|
+
==Usage
|
6
|
+
|
7
|
+
This plugin is WORK IN PROGRESS and HIGHLY EXPERIMENTAL. You'll find some examples in its specs.
|
8
|
+
|
9
|
+
|
10
|
+
Copyright (c) 2009 Luismi Cavallé, released under the MIT license
|
data/lib/pickle.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spec'
|
3
|
+
|
4
|
+
module Spec::Example::ExampleGroupMethods
|
5
|
+
alias scenario example
|
6
|
+
alias background before
|
7
|
+
end
|
8
|
+
|
9
|
+
module Spec::DSL::Main
|
10
|
+
alias feature describe
|
11
|
+
end
|
12
|
+
|
13
|
+
if ENV['RAILS_ENV']
|
14
|
+
require 'spec/rails'
|
15
|
+
|
16
|
+
module Spec::Rails::Example
|
17
|
+
class AcceptanceExampleGroup < IntegrationExampleGroup
|
18
|
+
include ActionController::RecordIdentifier
|
19
|
+
Spec::Example::ExampleGroupFactory.register(:acceptance, self)
|
20
|
+
|
21
|
+
def method_missing(sym, *args, &block)
|
22
|
+
return Spec::Matchers::Be.new(sym, *args) if sym.to_s =~ /^be_/
|
23
|
+
return Spec::Matchers::Has.new(sym, *args) if sym.to_s =~ /^have_/
|
24
|
+
super
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spec'
|
3
|
+
require File.dirname(__FILE__) + "/../../lib/pickle"
|
4
|
+
require 'tempfile'
|
5
|
+
|
6
|
+
module Factories
|
7
|
+
def create_spec(options)
|
8
|
+
options = {:content => options} unless options.is_a?(Hash)
|
9
|
+
path = (options[:path] || Dir.tmpdir) + "/#{String.random}_spec.rb"
|
10
|
+
File.open(path, "w") do |file|
|
11
|
+
file.write options[:content]
|
12
|
+
end
|
13
|
+
path
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_rails_app
|
17
|
+
path = Dir.tmpdir + "rails_app_#{String.random}"
|
18
|
+
FileUtils.rm_rf path
|
19
|
+
`rails #{path}`
|
20
|
+
File.open(path + "/config/environments/test.rb", "a") do |file|
|
21
|
+
file.write "\nconfig.gem 'rspec-rails', :lib => false\n"
|
22
|
+
end
|
23
|
+
Dir.chdir path do
|
24
|
+
`script/generate rspec`
|
25
|
+
end
|
26
|
+
FileUtils.cp_r File.dirname(__FILE__) + "/../../", path + "/vendor/plugins/pickle"
|
27
|
+
FileUtils.mkdir_p path + "/spec/acceptance"
|
28
|
+
File.open(path + "/spec/acceptance/acceptance_helper.rb", "w") do |file|
|
29
|
+
file.write <<-EOF
|
30
|
+
require File.dirname(__FILE__) + "/../spec_helper.rb"
|
31
|
+
require 'pickle'
|
32
|
+
EOF
|
33
|
+
end
|
34
|
+
|
35
|
+
path
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
module HelperMethods
|
41
|
+
def run_spec(file_path)
|
42
|
+
`spec #{file_path} 2>&1`
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class String
|
47
|
+
CHARS = ('a'..'z').to_a + ('A'..'Z').to_a
|
48
|
+
def self.random(size = 8)
|
49
|
+
(0..size).map{ CHARS[rand(CHARS.length)] }.join
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
Spec::Runner.configuration.include(Factories)
|
54
|
+
Spec::Runner.configuration.include(HelperMethods)
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/acceptance_helper.rb"
|
2
|
+
|
3
|
+
feature "Acceptance spec execution", %q{
|
4
|
+
In order to write better software
|
5
|
+
As a ruby developer
|
6
|
+
I want to execute acceptance specs
|
7
|
+
} do
|
8
|
+
|
9
|
+
scenario "Minimal acceptance spec" do
|
10
|
+
spec_file = create_spec <<-SPEC
|
11
|
+
require '#{File.dirname(__FILE__) + "/../../lib/pickle"}'
|
12
|
+
feature "Minimal spec" do
|
13
|
+
scenario "First scenario" do
|
14
|
+
true.should be_true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
SPEC
|
18
|
+
output = run_spec spec_file
|
19
|
+
output.should =~ /1 example, 0 failures/
|
20
|
+
end
|
21
|
+
|
22
|
+
scenario "Minimal acceptance spec that fails" do
|
23
|
+
spec_file = create_spec <<-SPEC
|
24
|
+
require '#{File.dirname(__FILE__) + "/../../lib/pickle"}'
|
25
|
+
feature "Minimal spec" do
|
26
|
+
scenario "First scenario" do
|
27
|
+
true.should be_false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
SPEC
|
31
|
+
output = run_spec spec_file
|
32
|
+
output.should =~ /1 example, 1 failure/
|
33
|
+
end
|
34
|
+
|
35
|
+
scenario "Acceptance spec with background" do
|
36
|
+
spec_file = create_spec <<-SPEC
|
37
|
+
require '#{File.dirname(__FILE__) + "/../../lib/pickle"}'
|
38
|
+
feature "Minimal spec" do
|
39
|
+
background do
|
40
|
+
@value = 17
|
41
|
+
end
|
42
|
+
scenario "First scenario" do
|
43
|
+
@value.should == 17
|
44
|
+
end
|
45
|
+
end
|
46
|
+
SPEC
|
47
|
+
output = run_spec spec_file
|
48
|
+
output.should =~ /1 example, 0 failures/
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/acceptance_helper.rb"
|
2
|
+
|
3
|
+
feature "Acceptance spec execution", %q{
|
4
|
+
In order to write better web apps
|
5
|
+
As a rails developer
|
6
|
+
I want to execute acceptance specs
|
7
|
+
} do
|
8
|
+
|
9
|
+
scenario "Minimal acceptance spec" do
|
10
|
+
rails_app = create_rails_app
|
11
|
+
spec_file = create_spec :path => rails_app + "/spec/acceptance",
|
12
|
+
:content => <<-SPEC
|
13
|
+
require File.dirname(__FILE__) + "/acceptance_helper.rb"
|
14
|
+
feature "Minimal spec" do
|
15
|
+
scenario "First scenario" do
|
16
|
+
RAILS_ENV.should_not be_empty
|
17
|
+
RAILS_ENV.should == "test"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
SPEC
|
21
|
+
output = run_spec spec_file
|
22
|
+
output.should =~ /1 example, 0 failures/
|
23
|
+
end
|
24
|
+
|
25
|
+
scenario "Integration stuff" do
|
26
|
+
rails_app = create_rails_app
|
27
|
+
spec_file = create_spec :path => rails_app + "/spec/acceptance",
|
28
|
+
:content => <<-SPEC
|
29
|
+
require File.dirname(__FILE__) + "/acceptance_helper.rb"
|
30
|
+
feature "Minimal spec" do
|
31
|
+
scenario "First scenario" do
|
32
|
+
get "/"
|
33
|
+
response.should have_text(/No route matches/)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
SPEC
|
37
|
+
output = run_spec spec_file
|
38
|
+
output.should =~ /1 example, 0 failures/
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cavalle-pickle
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "Luismi Cavall\xC3\xA9"
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-08-30 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec-rails
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.7.1
|
24
|
+
version:
|
25
|
+
description: Acceptance specs for Rails
|
26
|
+
email: luismi@lmcavalle.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README.rdoc
|
33
|
+
files:
|
34
|
+
- README.rdoc
|
35
|
+
- lib/pickle.rb
|
36
|
+
has_rdoc: false
|
37
|
+
homepage: http://github.com/cavalle/pickle
|
38
|
+
licenses:
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options:
|
41
|
+
- --charset=UTF-8
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: "0"
|
49
|
+
version:
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "0"
|
55
|
+
version:
|
56
|
+
requirements: []
|
57
|
+
|
58
|
+
rubyforge_project:
|
59
|
+
rubygems_version: 1.3.5
|
60
|
+
signing_key:
|
61
|
+
specification_version: 3
|
62
|
+
summary: A pickle is a cucumber fermented in vinegar or brine
|
63
|
+
test_files:
|
64
|
+
- spec/acceptance/acceptance_helper.rb
|
65
|
+
- spec/acceptance/basic_spec.rb
|
66
|
+
- spec/acceptance/rails_spec.rb
|