lucent 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/HISTORY.md +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/lucent.rb +7 -0
- data/lib/lucent/api.rb +122 -0
- data/lib/lucent/assert.rb +46 -0
- data/lib/lucent/cli.rb +16 -0
- data/lib/lucent/steps.rb +23 -0
- data/lib/lucent/tester.rb +50 -0
- data/lib/lucent/version.rb +3 -0
- data/lucent.gemspec +25 -0
- metadata +108 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/HISTORY.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Change Log and History
|
2
|
+
======================
|
3
|
+
|
4
|
+
Version 0.0.1 / 2013-08-25
|
5
|
+
--------------------------
|
6
|
+
|
7
|
+
This is the initial release of the Lucent tool. The main goal of the initial release was to allow me to run Lucid test specifications. This is being done in coordination with updating the Lucid test framework with its own executable specifications. The functionality is currently somewhat rough, essentially doing a very simple check for the output of Lucid events.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Jeff Nyman
|
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,29 @@
|
|
1
|
+
# Lucent
|
2
|
+
|
3
|
+
Lucent is a test execution framework for the [Lucid](https://github.com/jnyman/lucid) tool. Lucent is actually Lucid, testing itself.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'lucent'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install lucent
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
More instructions will be coming as Lucent is fleshed out.
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/lucent.rb
ADDED
data/lib/lucent/api.rb
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'rbconfig'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'lucent'
|
4
|
+
require 'lucent/assert'
|
5
|
+
require 'lucent/cli'
|
6
|
+
|
7
|
+
module Lucent
|
8
|
+
module API
|
9
|
+
|
10
|
+
def run_standard(command)
|
11
|
+
run(command) do |process|
|
12
|
+
stop_process(process)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def run(command)
|
17
|
+
@commands ||= []
|
18
|
+
@commands << command
|
19
|
+
puts "DEBUG: @commands = #{@commands}"
|
20
|
+
|
21
|
+
command = create_ruby_command(command)
|
22
|
+
puts "DEBUG: (ruby) command = #{command}"
|
23
|
+
|
24
|
+
puts "DEBUG: Lucent.process = #{Lucent.process}"
|
25
|
+
|
26
|
+
in_lucent_directory do
|
27
|
+
process = Lucent.process.new(command)
|
28
|
+
|
29
|
+
puts "DEBUG: Process = #{process.inspect}"
|
30
|
+
|
31
|
+
register_process(command, process)
|
32
|
+
process.run
|
33
|
+
|
34
|
+
puts "DEBUG: Block given for run standard? #{block_given?}"
|
35
|
+
|
36
|
+
block_given? ? yield(process) : process
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def last_exit_status
|
41
|
+
return @last_exit_status if @last_exit_status
|
42
|
+
stop_processes
|
43
|
+
@last_exit_status
|
44
|
+
end
|
45
|
+
|
46
|
+
def all_output
|
47
|
+
all_stdout << all_stderr
|
48
|
+
end
|
49
|
+
|
50
|
+
def all_stdout
|
51
|
+
stop_processes
|
52
|
+
only_processes.inject('') { |out, ps| out << ps.stdout }
|
53
|
+
end
|
54
|
+
|
55
|
+
def all_stderr
|
56
|
+
stop_processes
|
57
|
+
only_processes.inject('') { |out, ps| out << ps.stderr }
|
58
|
+
end
|
59
|
+
|
60
|
+
def processes
|
61
|
+
@processes ||= []
|
62
|
+
end
|
63
|
+
|
64
|
+
def register_process(command, process)
|
65
|
+
processes << [command, process]
|
66
|
+
end
|
67
|
+
|
68
|
+
def stop_process(process)
|
69
|
+
@last_exit_status = process.stop
|
70
|
+
end
|
71
|
+
|
72
|
+
def stop_processes
|
73
|
+
processes.each do |command, process|
|
74
|
+
stop_process(process)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def only_processes
|
79
|
+
processes.collect { |command, process| process }
|
80
|
+
end
|
81
|
+
|
82
|
+
# @was in_current_dir
|
83
|
+
def in_lucent_directory(&block)
|
84
|
+
create_path_for(lucent_directory)
|
85
|
+
Dir.chdir(lucent_directory, &block)
|
86
|
+
end
|
87
|
+
|
88
|
+
# @was current_dir
|
89
|
+
def lucent_directory
|
90
|
+
File.join(*lucent_path)
|
91
|
+
end
|
92
|
+
|
93
|
+
# @was dirs
|
94
|
+
# Note: @path was @dirs
|
95
|
+
def lucent_path
|
96
|
+
@path ||= %w(tmp lucent)
|
97
|
+
end
|
98
|
+
|
99
|
+
# @was _mkdir
|
100
|
+
def create_path_for(name)
|
101
|
+
FileUtils.mkdir_p(name) unless File.directory?(name)
|
102
|
+
end
|
103
|
+
|
104
|
+
def unescape(string)
|
105
|
+
string = string.gsub(/\e\[\d+(?>(;\d+)*)m/, '')
|
106
|
+
string
|
107
|
+
end
|
108
|
+
|
109
|
+
def create_ruby_command(command)
|
110
|
+
if command =~ /^ruby\s/
|
111
|
+
command.gsub(/^ruby\s/, "#{system_ruby} ")
|
112
|
+
else
|
113
|
+
command
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def system_ruby
|
118
|
+
File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rspec/expectations'
|
2
|
+
|
3
|
+
module Lucent
|
4
|
+
module API
|
5
|
+
include RSpec::Matchers
|
6
|
+
|
7
|
+
def assert_exit_status_and_output(expect_pass, expected, expect_exact)
|
8
|
+
assert_success(expect_pass)
|
9
|
+
if expect_exact
|
10
|
+
assert_exact_output(expected, all_output)
|
11
|
+
else
|
12
|
+
assert_partial_output(expected, all_output)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def assert_failing_with(expected)
|
17
|
+
assert_success(false)
|
18
|
+
assert_output(expected, all_output)
|
19
|
+
end
|
20
|
+
|
21
|
+
def assert_success(expect_success)
|
22
|
+
expect_success ? assert_exit_status(0) : assert_not_exit_status(0)
|
23
|
+
end
|
24
|
+
|
25
|
+
def assert_output(expected, actual)
|
26
|
+
actual.should include(expected)
|
27
|
+
end
|
28
|
+
|
29
|
+
def assert_partial_output(expected, actual)
|
30
|
+
unescape(actual).should include(unescape(expected))
|
31
|
+
end
|
32
|
+
|
33
|
+
def assert_exact_output(expected, actual)
|
34
|
+
unescape(actual).should == unescape(expected)
|
35
|
+
end
|
36
|
+
|
37
|
+
def assert_exit_status(value)
|
38
|
+
last_exit_status.should eq(value), "Exit status was #{last_exit_status} but expected it to be #{value}."
|
39
|
+
end
|
40
|
+
|
41
|
+
def assert_not_exit_status(value)
|
42
|
+
last_exit_status.should_not eq(value), "Exit status was #{last_exit_status} which was not expected."
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
data/lib/lucent/cli.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Lucent
|
2
|
+
module API
|
3
|
+
|
4
|
+
def write_file(name, content)
|
5
|
+
create_file(name, content)
|
6
|
+
end
|
7
|
+
|
8
|
+
def create_file(name, content)
|
9
|
+
in_lucent_directory do
|
10
|
+
create_path_for(File.dirname(name))
|
11
|
+
File.open(name, 'w') { |f| f << content }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
data/lib/lucent/steps.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'lucent/api'
|
2
|
+
|
3
|
+
Domain(Lucent::API)
|
4
|
+
|
5
|
+
Given (/^lucent exists$/) do
|
6
|
+
puts 'Lucent is present.'
|
7
|
+
end
|
8
|
+
|
9
|
+
Given (/^a file named "(.*?)" with:$/) do |file, content|
|
10
|
+
write_file(file, content)
|
11
|
+
end
|
12
|
+
|
13
|
+
Then (/^it should fail with:$/) do |output|
|
14
|
+
assert_failing_with(output)
|
15
|
+
end
|
16
|
+
|
17
|
+
Then (/^it should pass with exactly:$/) do |output|
|
18
|
+
assert_exit_status_and_output(true, output, true)
|
19
|
+
end
|
20
|
+
|
21
|
+
Then (/^it should pass with:$/) do |output|
|
22
|
+
assert_exit_status_and_output(true, output, false)
|
23
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'stringio'
|
2
|
+
require 'shellwords'
|
3
|
+
|
4
|
+
module Lucent
|
5
|
+
class Tester
|
6
|
+
include Shellwords
|
7
|
+
|
8
|
+
def self.app_class=(name)
|
9
|
+
@@app_class = name
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(command)
|
13
|
+
args = shellwords(command)
|
14
|
+
@argv = args[1..-1]
|
15
|
+
@stdin = StringIO.new
|
16
|
+
@stdout = StringIO.new
|
17
|
+
@stderr = StringIO.new
|
18
|
+
@kernel = MockKernel.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def run
|
22
|
+
@@app_class.new(@argv, @stdin, @stdout, @stderr, @kernel).start
|
23
|
+
end
|
24
|
+
|
25
|
+
def stop
|
26
|
+
@kernel.exitstatus
|
27
|
+
end
|
28
|
+
|
29
|
+
def stdout
|
30
|
+
@stdout.string
|
31
|
+
end
|
32
|
+
|
33
|
+
def stderr
|
34
|
+
@stderr.string
|
35
|
+
end
|
36
|
+
|
37
|
+
class MockKernel
|
38
|
+
attr_reader :exitstatus
|
39
|
+
|
40
|
+
def initialize
|
41
|
+
@exitstatus = 0
|
42
|
+
end
|
43
|
+
|
44
|
+
def exit(status)
|
45
|
+
@exitstatus = status
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
data/lucent.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'lucent/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "lucent"
|
8
|
+
spec.version = Lucent::VERSION
|
9
|
+
spec.authors = ["Jeff Nyman"]
|
10
|
+
spec.email = ["jeffnyman@gmail.com"]
|
11
|
+
spec.description = %q{A Test Execution Framework for Lucid}
|
12
|
+
spec.summary = %q{A Test Execution Framework for Lucid}
|
13
|
+
spec.homepage = "https://github.com/jnyman/lucent"
|
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{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'rspec-expectations'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lucent
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jeff Nyman
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-08-25 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec-expectations
|
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: '1.3'
|
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: '1.3'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
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
|
+
description: A Test Execution Framework for Lucid
|
63
|
+
email:
|
64
|
+
- jeffnyman@gmail.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
71
|
+
- HISTORY.md
|
72
|
+
- LICENSE.txt
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- lib/lucent.rb
|
76
|
+
- lib/lucent/api.rb
|
77
|
+
- lib/lucent/assert.rb
|
78
|
+
- lib/lucent/cli.rb
|
79
|
+
- lib/lucent/steps.rb
|
80
|
+
- lib/lucent/tester.rb
|
81
|
+
- lib/lucent/version.rb
|
82
|
+
- lucent.gemspec
|
83
|
+
homepage: https://github.com/jnyman/lucent
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 1.8.24
|
105
|
+
signing_key:
|
106
|
+
specification_version: 3
|
107
|
+
summary: A Test Execution Framework for Lucid
|
108
|
+
test_files: []
|