coppola 0.1.0
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 +18 -0
- data/.rvmrc +34 -0
- data/Gemfile +4 -0
- data/coppola.gemspec +29 -0
- data/lib/coppola.rb +54 -0
- data/lib/coppola/actor.rb +24 -0
- data/lib/coppola/configuration.rb +11 -0
- data/lib/coppola/find_definitions.rb +25 -0
- data/lib/coppola/registry.rb +38 -0
- data/lib/coppola/reload.rb +6 -0
- data/lib/coppola/scene.rb +22 -0
- data/lib/coppola/syntax.rb +27 -0
- data/lib/coppola/version.rb +3 -0
- data/spec/spec_helper.rb +7 -0
- metadata +123 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
+
# Only full ruby name is supported here, for short names use:
|
8
|
+
# echo "rvm use 1.9.3" > .rvmrc
|
9
|
+
environment_id="ruby-1.9.3-p327@coppola"
|
10
|
+
|
11
|
+
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
+
# rvmrc_rvm_version="1.17.0 (stable)" # 1.10.1 seams as a safe start
|
13
|
+
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
+
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
+
# return 1
|
16
|
+
# }
|
17
|
+
|
18
|
+
# First we attempt to load the desired environment directly from the environment
|
19
|
+
# file. This is very fast and efficient compared to running through the entire
|
20
|
+
# CLI and selector. If you want feedback on which environment was used then
|
21
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
+
then
|
25
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
+
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
27
|
+
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
28
|
+
else
|
29
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
30
|
+
rvm --create "$environment_id" || {
|
31
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
32
|
+
return 1
|
33
|
+
}
|
34
|
+
fi
|
data/Gemfile
ADDED
data/coppola.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'coppola/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "coppola"
|
8
|
+
s.version = Coppola::VERSION
|
9
|
+
s.authors = ["Cédric Darné"]
|
10
|
+
s.email = ["cedric.darne@gmail.com"]
|
11
|
+
s.description = "Functional and load testing library for APIs"
|
12
|
+
s.summary = "Define API scenarii and launch blockbusters!"
|
13
|
+
s.homepage = "https://github.com/cdarne/coppola"
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split($/)
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
# s.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
19
|
+
# s.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.required_ruby_version = ">= 1.9.2"
|
23
|
+
|
24
|
+
s.add_dependency('httparty')
|
25
|
+
|
26
|
+
s.add_development_dependency('bundler')
|
27
|
+
s.add_development_dependency('pry')
|
28
|
+
s.add_development_dependency('rspec')
|
29
|
+
end
|
data/lib/coppola.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'coppola/version'
|
2
|
+
|
3
|
+
require 'coppola/registry'
|
4
|
+
|
5
|
+
require 'coppola/actor'
|
6
|
+
require 'coppola/configuration'
|
7
|
+
require 'coppola/scene'
|
8
|
+
require 'coppola/syntax'
|
9
|
+
|
10
|
+
require 'coppola/find_definitions'
|
11
|
+
require 'coppola/reload'
|
12
|
+
|
13
|
+
|
14
|
+
module Coppola
|
15
|
+
def self.configuration
|
16
|
+
@configuration ||= Configuration.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.reset_configuration
|
20
|
+
@configuration = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
class << self
|
24
|
+
extend Forwardable
|
25
|
+
def_delegators :configuration, :scenarii, :scenes, :actors
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.register_scenario(scenario)
|
29
|
+
scenarii.register(scenario.name, scenario)
|
30
|
+
scenario
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.scenario_by_name(name)
|
34
|
+
scenarii.find(name)
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.register_scene(scene)
|
38
|
+
scenes.register(scene.name, scene)
|
39
|
+
scene
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.scene_by_name(name)
|
43
|
+
scenes.find(name)
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.register_actor(actor)
|
47
|
+
actors.register(actor.name, actor)
|
48
|
+
actor
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.actor_by_name(name)
|
52
|
+
actors.find(name)
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "httparty"
|
2
|
+
|
3
|
+
module Coppola
|
4
|
+
class Actor
|
5
|
+
include HTTParty
|
6
|
+
|
7
|
+
class << self
|
8
|
+
attr_accessor :name
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.build name, options, &block
|
12
|
+
parent = self
|
13
|
+
if options[:parent]
|
14
|
+
actor = Coppola.actor_by_name(options[:parent])
|
15
|
+
parent = actor if actor
|
16
|
+
end
|
17
|
+
klass = Class.new(parent) do
|
18
|
+
instance_eval(&block) if block_given?
|
19
|
+
end
|
20
|
+
klass.name = name
|
21
|
+
klass
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Coppola
|
2
|
+
class << self
|
3
|
+
# An Array of strings specifying locations that should be searched for
|
4
|
+
# factory definitions. By default, factory_girl will attempt to require
|
5
|
+
# "factories," "test/factories," and "spec/factories." Only the first
|
6
|
+
# existing file will be loaded.
|
7
|
+
attr_accessor :definition_file_paths
|
8
|
+
end
|
9
|
+
|
10
|
+
self.definition_file_paths = %w(coppola)
|
11
|
+
|
12
|
+
def self.find_definitions
|
13
|
+
absolute_definition_file_paths = definition_file_paths.map {|path| File.expand_path(path) }
|
14
|
+
|
15
|
+
absolute_definition_file_paths.uniq.each do |path|
|
16
|
+
load("#{path}.rb") if File.exists?("#{path}.rb")
|
17
|
+
|
18
|
+
if File.directory? path
|
19
|
+
Dir[File.join(path, '**', '*.rb')].sort.each do |file|
|
20
|
+
load file
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Coppola
|
2
|
+
class Registry
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
attr_reader :name
|
6
|
+
|
7
|
+
def initialize(name)
|
8
|
+
@name = name
|
9
|
+
@items = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def clear
|
13
|
+
@items.clear
|
14
|
+
end
|
15
|
+
|
16
|
+
def each(&block)
|
17
|
+
@items.values.uniq.each(&block)
|
18
|
+
end
|
19
|
+
|
20
|
+
def find(name)
|
21
|
+
if registered?(name)
|
22
|
+
@items[name]
|
23
|
+
else
|
24
|
+
raise ArgumentError, "#{@name} not registered: #{name}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
alias :[] :find
|
29
|
+
|
30
|
+
def register(name, item)
|
31
|
+
@items[name] = item
|
32
|
+
end
|
33
|
+
|
34
|
+
def registered?(name)
|
35
|
+
@items.key?(name)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "benchmark"
|
2
|
+
|
3
|
+
module Coppola
|
4
|
+
class Scene
|
5
|
+
attr_reader :name
|
6
|
+
|
7
|
+
def initialize name, options, &block
|
8
|
+
@name = name
|
9
|
+
@block = block
|
10
|
+
end
|
11
|
+
|
12
|
+
def run(actor)
|
13
|
+
puts "Running scene '#{name}'..."
|
14
|
+
resp = nil
|
15
|
+
time = Benchmark.realtime do
|
16
|
+
resp = @block.call(actor)
|
17
|
+
end
|
18
|
+
puts "Scene '#{name}' finished in #{time} seconds"
|
19
|
+
resp
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Coppola
|
2
|
+
module Syntax
|
3
|
+
def define(&block)
|
4
|
+
DSL.run(block)
|
5
|
+
end
|
6
|
+
|
7
|
+
class DSL
|
8
|
+
def scenario name, options={}, &block
|
9
|
+
Coppola.register_scenario(Scenario.new(name, options, &block))
|
10
|
+
end
|
11
|
+
|
12
|
+
def scene name, options={}, &block
|
13
|
+
Coppola.register_scene(Scene.new(name, options, &block))
|
14
|
+
end
|
15
|
+
|
16
|
+
def actor name, options={}, &block
|
17
|
+
Coppola.register_actor(Actor.build(name, options, &block))
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.run(block)
|
21
|
+
new.instance_eval(&block)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
extend Syntax
|
27
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: coppola
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Cédric Darné
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: httparty
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
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: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
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: pry
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
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: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
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
|
+
description: Functional and load testing library for APIs
|
79
|
+
email:
|
80
|
+
- cedric.darne@gmail.com
|
81
|
+
executables: []
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files: []
|
84
|
+
files:
|
85
|
+
- .gitignore
|
86
|
+
- .rvmrc
|
87
|
+
- Gemfile
|
88
|
+
- coppola.gemspec
|
89
|
+
- lib/coppola.rb
|
90
|
+
- lib/coppola/actor.rb
|
91
|
+
- lib/coppola/configuration.rb
|
92
|
+
- lib/coppola/find_definitions.rb
|
93
|
+
- lib/coppola/registry.rb
|
94
|
+
- lib/coppola/reload.rb
|
95
|
+
- lib/coppola/scene.rb
|
96
|
+
- lib/coppola/syntax.rb
|
97
|
+
- lib/coppola/version.rb
|
98
|
+
- spec/spec_helper.rb
|
99
|
+
homepage: https://github.com/cdarne/coppola
|
100
|
+
licenses: []
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.9.2
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ! '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 1.8.24
|
120
|
+
signing_key:
|
121
|
+
specification_version: 3
|
122
|
+
summary: Define API scenarii and launch blockbusters!
|
123
|
+
test_files: []
|