lucid 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. data/.gitignore +30 -10
  2. data/.rspec +1 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +15 -0
  6. data/Gemfile +4 -2
  7. data/HISTORY.md +22 -0
  8. data/{LICENSE.txt → LICENSE} +6 -3
  9. data/README.md +22 -8
  10. data/Rakefile +2 -1
  11. data/bin/lucid +10 -10
  12. data/bin/lucid-gen +4 -0
  13. data/lib/autotest/discover.rb +11 -0
  14. data/lib/autotest/lucid.rb +6 -0
  15. data/lib/autotest/lucid_mixin.rb +135 -0
  16. data/lib/autotest/lucid_rails.rb +6 -0
  17. data/lib/autotest/lucid_rails_rspec.rb +6 -0
  18. data/lib/autotest/lucid_rails_rspec2.rb +6 -0
  19. data/lib/autotest/lucid_rspec.rb +6 -0
  20. data/lib/autotest/lucid_rspec2.rb +6 -0
  21. data/lib/lucid.rb +32 -1
  22. data/lib/lucid/ast.rb +20 -0
  23. data/lib/lucid/ast/background.rb +116 -0
  24. data/lib/lucid/ast/comment.rb +24 -0
  25. data/lib/lucid/ast/doc_string.rb +44 -0
  26. data/lib/lucid/ast/empty_background.rb +33 -0
  27. data/lib/lucid/ast/examples.rb +49 -0
  28. data/lib/lucid/ast/feature.rb +99 -0
  29. data/lib/lucid/ast/has_steps.rb +74 -0
  30. data/lib/lucid/ast/location.rb +41 -0
  31. data/lib/lucid/ast/multiline_argument.rb +31 -0
  32. data/lib/lucid/ast/names.rb +13 -0
  33. data/lib/lucid/ast/outline_table.rb +194 -0
  34. data/lib/lucid/ast/scenario.rb +103 -0
  35. data/lib/lucid/ast/scenario_outline.rb +144 -0
  36. data/lib/lucid/ast/specs.rb +38 -0
  37. data/lib/lucid/ast/step.rb +122 -0
  38. data/lib/lucid/ast/step_collection.rb +92 -0
  39. data/lib/lucid/ast/step_invocation.rb +196 -0
  40. data/lib/lucid/ast/table.rb +730 -0
  41. data/lib/lucid/ast/tags.rb +28 -0
  42. data/lib/lucid/ast/tdl_walker.rb +195 -0
  43. data/lib/lucid/cli/app.rb +78 -0
  44. data/lib/lucid/cli/configuration.rb +261 -0
  45. data/lib/lucid/cli/options.rb +463 -0
  46. data/lib/lucid/cli/profile.rb +101 -0
  47. data/lib/lucid/configuration.rb +53 -0
  48. data/lib/lucid/core_ext/disable_autorunners.rb +15 -0
  49. data/lib/lucid/core_ext/instance_exec.rb +70 -0
  50. data/lib/lucid/core_ext/proc.rb +36 -0
  51. data/lib/lucid/core_ext/string.rb +9 -0
  52. data/lib/lucid/errors.rb +40 -0
  53. data/lib/lucid/factory.rb +43 -0
  54. data/lib/lucid/formatter/ansicolor.rb +168 -0
  55. data/lib/lucid/formatter/console.rb +218 -0
  56. data/lib/lucid/formatter/debug.rb +33 -0
  57. data/lib/lucid/formatter/duration.rb +11 -0
  58. data/lib/lucid/formatter/gherkin_formatter_adapter.rb +94 -0
  59. data/lib/lucid/formatter/gpretty.rb +24 -0
  60. data/lib/lucid/formatter/html.rb +610 -0
  61. data/lib/lucid/formatter/interceptor.rb +66 -0
  62. data/lib/lucid/formatter/io.rb +31 -0
  63. data/lib/lucid/formatter/jquery-min.js +154 -0
  64. data/lib/lucid/formatter/json.rb +19 -0
  65. data/lib/lucid/formatter/json_pretty.rb +10 -0
  66. data/lib/lucid/formatter/junit.rb +177 -0
  67. data/lib/lucid/formatter/lucid.css +283 -0
  68. data/lib/lucid/formatter/lucid.sass +244 -0
  69. data/lib/lucid/formatter/ordered_xml_markup.rb +24 -0
  70. data/lib/lucid/formatter/progress.rb +95 -0
  71. data/lib/lucid/formatter/rerun.rb +91 -0
  72. data/lib/lucid/formatter/standard.rb +235 -0
  73. data/lib/lucid/formatter/stepdefs.rb +14 -0
  74. data/lib/lucid/formatter/steps.rb +49 -0
  75. data/lib/lucid/formatter/summary.rb +35 -0
  76. data/lib/lucid/formatter/unicode.rb +53 -0
  77. data/lib/lucid/formatter/usage.rb +132 -0
  78. data/lib/lucid/generator.rb +21 -0
  79. data/lib/lucid/generators/project.rb +70 -0
  80. data/lib/lucid/generators/project/Gemfile.tt +6 -0
  81. data/lib/lucid/generators/project/browser-symbiont.rb +24 -0
  82. data/lib/lucid/generators/project/driver-symbiont.rb +4 -0
  83. data/lib/lucid/generators/project/errors.rb +26 -0
  84. data/lib/lucid/generators/project/events-symbiont.rb +36 -0
  85. data/lib/lucid/generators/project/lucid-symbiont.yml +6 -0
  86. data/lib/lucid/interface.rb +8 -0
  87. data/lib/lucid/interface_methods.rb +125 -0
  88. data/lib/lucid/interface_rb/matcher.rb +108 -0
  89. data/lib/lucid/interface_rb/rb_hook.rb +18 -0
  90. data/lib/lucid/interface_rb/rb_language.rb +190 -0
  91. data/lib/lucid/interface_rb/rb_lucid.rb +119 -0
  92. data/lib/lucid/interface_rb/rb_step_definition.rb +122 -0
  93. data/lib/lucid/interface_rb/rb_transform.rb +57 -0
  94. data/lib/lucid/interface_rb/rb_world.rb +136 -0
  95. data/lib/lucid/interface_rb/regexp_argument_matcher.rb +21 -0
  96. data/lib/lucid/load_path.rb +13 -0
  97. data/lib/lucid/parser.rb +2 -126
  98. data/lib/lucid/platform.rb +27 -0
  99. data/lib/lucid/rspec/allow_doubles.rb +20 -0
  100. data/lib/lucid/rspec/disallow_options.rb +27 -0
  101. data/lib/lucid/runtime.rb +200 -0
  102. data/lib/lucid/runtime/facade.rb +60 -0
  103. data/lib/lucid/runtime/interface_io.rb +60 -0
  104. data/lib/lucid/runtime/orchestrator.rb +218 -0
  105. data/lib/lucid/runtime/results.rb +64 -0
  106. data/lib/lucid/runtime/specs_loader.rb +79 -0
  107. data/lib/lucid/spec_file.rb +112 -0
  108. data/lib/lucid/step_definition_light.rb +20 -0
  109. data/lib/lucid/step_definitions.rb +13 -0
  110. data/lib/lucid/step_match.rb +99 -0
  111. data/lib/lucid/tdl_builder.rb +282 -0
  112. data/lib/lucid/term/ansicolor.rb +118 -0
  113. data/lib/lucid/unit.rb +11 -0
  114. data/lib/lucid/wire_support/configuration.rb +38 -0
  115. data/lib/lucid/wire_support/connection.rb +61 -0
  116. data/lib/lucid/wire_support/request_handler.rb +32 -0
  117. data/lib/lucid/wire_support/wire_exception.rb +32 -0
  118. data/lib/lucid/wire_support/wire_language.rb +54 -0
  119. data/lib/lucid/wire_support/wire_packet.rb +34 -0
  120. data/lib/lucid/wire_support/wire_protocol.rb +43 -0
  121. data/lib/lucid/wire_support/wire_protocol/requests.rb +125 -0
  122. data/lib/lucid/wire_support/wire_step_definition.rb +26 -0
  123. data/lucid.gemspec +25 -14
  124. metadata +220 -12
  125. data/lib/lucid/app.rb +0 -103
  126. data/lib/lucid/options.rb +0 -168
  127. data/lib/lucid/version.rb +0 -3
  128. data/lucid.yml +0 -8
data/.gitignore CHANGED
@@ -1,17 +1,37 @@
1
- *.gem
2
- *.rbc
3
- .bundle
1
+ .eprj
2
+ .idea
3
+ .rvmrc
4
4
  .config
5
+ .bundle
5
6
  .yardoc
7
+ .tmtags
8
+ .DS_Store
9
+ .sass-cache
6
10
  Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
11
  pkg
12
+ doc
13
+ tmp
14
+ tags
13
15
  rdoc
14
- spec/reports
16
+ target
17
+ coverage
15
18
  test/tmp
19
+ nbproject
20
+ spec/reports
21
+ InstalledFiles
22
+ lib/bundler/man
16
23
  test/version_tmp
17
- tmp
24
+ rerun.txt
25
+ *.log
26
+ *.pid
27
+ *~
28
+ *.swp
29
+ *.swo
30
+ *.tmproj
31
+ .#*
32
+ *.pyc
33
+ *.rbc
34
+ ._*
35
+ *.tgz
36
+ *.gem
37
+ *.rbc
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color --backtrace
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ lucid
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 1.9.3
data/.travis.yml ADDED
@@ -0,0 +1,15 @@
1
+ script: "rake"
2
+
3
+ rvm:
4
+ - 2.0.0
5
+ - 1.9.3
6
+ - jruby
7
+
8
+ branches:
9
+ only:
10
+ - master
11
+ - develop
12
+
13
+ notifications:
14
+ recipients:
15
+ - jeffnyman@gmail.com
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in lucid.gemspec
3
+ # All gem dependencies are specified in lucid.gemspec
4
4
  gemspec
5
+
6
+ # gem 'gherkin', :path => '../gherkin'
data/HISTORY.md ADDED
@@ -0,0 +1,22 @@
1
+ Change Log and History
2
+ ======================
3
+
4
+ Version 0.0.5 / 2013-05-04
5
+ --------------------------
6
+
7
+ This is the first version of Lucid that attempts to be a clone of BDD tools like Cucumber. There are some changes that Lucid will provide out of the starting gate. Here are a few of those:
8
+
9
+ * The `env.rb` file is now called `driver.rb`.
10
+ * The repository directory is now called `specs` rather than `features`.
11
+ * The extension type for files is now `.spec` rather than `.feature`.
12
+ * There is a project generator that will create a new type of proposed file structure.
13
+
14
+ Lucid is aiming to be more flexible than other tools, so certain elements -- like the extension for files and the repository directory -- are configurable. As time goes on, Lucid will diverge in some ways from other BDD tools. In other ways, however, it will remain consistent with them. For example, Lucid does adhere to the Gherkin API just as Cucumber and SpecFlow do. Lucid does not, however, currently fully support the wire protocol as Cucumber does.
15
+
16
+ This is very much an alpha release to determine how feasible Lucid is as a tool.
17
+
18
+
19
+ Versions 0.0.1 to 0.0.4
20
+ -----------------------
21
+
22
+ These initial versions of Lucid were designed to serve as nothing more than a wrapper for Cucumber. The goal was to allow for an easier way to work around the opinionated nature of tools like Cucumber in terms of how they expected your projects to be setup.
@@ -1,6 +1,9 @@
1
- Copyright (c) 2013 Jeff Nyman
1
+ The MIT License
2
2
 
3
- MIT License
3
+ Copyright (c) 2012, 2013 Jeff Nyman
4
+
5
+ Any Cucumber-derived elements
6
+ Copyright (c) 2008,2009,2010,2011,2012,2013 Aslak Hellesøy and contributors.
4
7
 
5
8
  Permission is hereby granted, free of charge, to any person obtaining
6
9
  a copy of this software and associated documentation files (the
@@ -19,4 +22,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
22
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
23
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
24
  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.
25
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,12 +1,16 @@
1
- # Lucid
1
+ Lucid
2
+ =====
2
3
 
3
- Lucid is a shiv around BDD tools. Currently the only such tool that Lucid intercepts calls to is Cucumber. The reason for this is that many of these BDD tools are highly opinionated in their structure. While most tools do have a way to force the structure to be your way, how this is done is not always consistent.
4
+ Description
5
+ -----------
4
6
 
5
- By way of example, Cucumber expects features to live in a directory called features and step definitions to live in a directory called step_definitions that is under the features directory. When running a feature, all step definitions are loaded unless you explicitly require just the ones you want. If you structure your project differently from how Cucumber expects, then you have to require files explicitly.
7
+ Lucid is a Test Description Language (TDL) execution engine. It is, in many ways, a clone of the popular tool [Cucumber](http://cukes.info/). Lucid is diverging in many ways from Cucumber and similar tools but it does owe much of its initial structure to them.
6
8
 
7
- Lucid allows you to specify configuration options that are then passed to Cucumber.
9
+ This is an alpha release of Lucid as it strives to become its own entity in the world of BDD tools.
8
10
 
9
- ## Installation
11
+
12
+ Installation
13
+ ------------
10
14
 
11
15
  Add this line to your application's Gemfile:
12
16
 
@@ -20,11 +24,21 @@ Or install it yourself as:
20
24
 
21
25
  $ gem install lucid
22
26
 
23
- ## Usage
24
27
 
25
- Lucid can be configured project by project through the use of a lucid.yml file that lives in the root of your project. This file will contain configurable options. These options will be indicated by specific declarations.
28
+ Using Lucid
29
+ -----------
30
+
31
+ Much more detail on how to use Lucid will be coming soon. One way to get started however is to use the Lucid project generator. If you wanted to create a project directory called 'tutorial' for example, you could do this:
32
+
33
+ $ lucid-gen project tutorial
34
+
35
+ In order to to check what options are available to you from the command line, do this:
36
+
37
+ $ lucid --help
38
+
26
39
 
27
- ## Contributing
40
+ Contributing
41
+ ------------
28
42
 
29
43
  1. Fork it
30
44
  2. Create your feature branch (`git checkout -b my-new-feature`)
data/Rakefile CHANGED
@@ -1 +1,2 @@
1
- require "bundler/gem_tasks"
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/bin/lucid CHANGED
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
+
2
3
  app_lib = File.expand_path('../lib', File.dirname(__FILE__))
3
4
  $LOAD_PATH.unshift(app_lib) unless $LOAD_PATH.include?(app_lib)
4
5
 
5
- require 'lucid/app'
6
-
7
- begin
8
- Lucid::App.new.run
9
- rescue SystemExit
10
- # noop
11
- rescue Exception => e
12
- STDERR.puts("#{e.message} (#{e.class})")
13
- STDERR.puts(e.backtrace.join("\n"))
14
- Kernel.exit(1)
6
+ if(ENV['SIMPLECOV'] && RUBY_VERSION =~ /1\.9/)
7
+ require 'simplecov'
8
+ SimpleCov.root(File.expand_path(File.dirname(__FILE__) + '/..'))
9
+ SimpleCov.start
15
10
  end
11
+
12
+ require 'lucid/rspec/disallow_options'
13
+ require 'lucid/cli/app'
14
+
15
+ Lucid::CLI::App.new(ARGV.dup).start
data/bin/lucid-gen ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'lucid/generator'
4
+ Lucid::Generator.start
@@ -0,0 +1,11 @@
1
+ Autotest.add_discovery do
2
+ if File.directory?('features')
3
+ if ENV['AUTOFEATURE'] =~ /true/i
4
+ "lucid"
5
+ elsif ENV['AUTOFEATURE'] =~ /false/i
6
+ # noop
7
+ else
8
+ puts "(Not running features. To run features in autotest, set AUTOFEATURE=true.)"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ require 'autotest'
2
+ require 'autotest/lucid_mixin'
3
+
4
+ class Autotest::Lucid < Autotest
5
+ include LucidMixin
6
+ end
@@ -0,0 +1,135 @@
1
+ require 'autotest'
2
+ require 'tempfile'
3
+ require 'lucid'
4
+ require 'lucid/cli/profile'
5
+
6
+ module Autotest::LucidMixin
7
+ def self.included(receiver)
8
+ receiver::ALL_HOOKS << [:run_features, :ran_features]
9
+ end
10
+
11
+ attr_accessor :features_to_run
12
+
13
+ def initialize
14
+ super
15
+ reset_features
16
+ end
17
+
18
+ def run
19
+ hook :initialize
20
+ reset
21
+ reset_features
22
+ add_sigint_handler
23
+
24
+ self.last_mtime = Time.now if $f
25
+
26
+ loop do # ^c handler
27
+ begin
28
+ get_to_green
29
+ if self.tainted then
30
+ rerun_all_tests
31
+ rerun_all_features if all_good
32
+ else
33
+ hook :all_good
34
+ end
35
+ wait_for_changes
36
+ # Once tests and features are green, reset features every
37
+ # time a file is changed to see if anything breaks.
38
+ reset_features
39
+ rescue Interrupt
40
+ break if self.wants_to_quit
41
+ reset
42
+ reset_features
43
+ end
44
+ end
45
+ hook :quit
46
+ end
47
+
48
+ def all_features_good
49
+ features_to_run == ""
50
+ end
51
+
52
+ def get_to_green
53
+ begin
54
+ super
55
+ run_features
56
+ wait_for_changes unless all_features_good
57
+ end until all_features_good
58
+ end
59
+
60
+ def rerun_all_features
61
+ reset_features
62
+ run_features
63
+ end
64
+
65
+ def reset_features
66
+ self.features_to_run = :all
67
+ end
68
+
69
+ def run_features
70
+ hook :run_features
71
+ Tempfile.open('autotest-lucid') do |dirty_features_file|
72
+ cmd = self.make_lucid_cmd(self.features_to_run, dirty_features_file.path)
73
+ return if cmd.empty?
74
+ puts cmd unless $q
75
+ old_sync = $stdout.sync
76
+ $stdout.sync = true
77
+ self.results = []
78
+ line = []
79
+ begin
80
+ open("| #{cmd}", "r") do |f|
81
+ until f.eof? do
82
+ c = f.getc or break
83
+ if RUBY_VERSION >= "1.9" then
84
+ print c
85
+ else
86
+ putc c
87
+ end
88
+ line << c
89
+ if c == ?\n then
90
+ self.results << if RUBY_VERSION >= "1.9" then
91
+ line.join
92
+ else
93
+ line.pack "c*"
94
+ end
95
+ line.clear
96
+ end
97
+ end
98
+ end
99
+ ensure
100
+ $stdout.sync = old_sync
101
+ end
102
+ self.features_to_run = dirty_features_file.read.strip
103
+ self.tainted = true unless self.features_to_run == ''
104
+ end
105
+ hook :ran_features
106
+ end
107
+
108
+ def make_lucid_cmd(features_to_run, dirty_features_filename)
109
+ return '' if features_to_run == ''
110
+
111
+ profile_loader = Lucid::CLI::Profile.new
112
+
113
+ profile ||= "autotest-all" if profile_loader.has_profile?("autotest-all") && features_to_run == :all
114
+ profile ||= "autotest" if profile_loader.has_profile?("autotest")
115
+ profile ||= nil
116
+
117
+ if profile
118
+ args = ["--profile", profile]
119
+ else
120
+ args = %w{--format} << (features_to_run == :all ? "progress" : "standard")
121
+ end
122
+ # No --color option as some IDEs (Netbeans) don't output them very well (1 failed step)
123
+ args += %w{--format rerun --out} << dirty_features_filename
124
+ args << (features_to_run == :all ? "" : features_to_run)
125
+
126
+ # Unless I do this, all the steps turn up undefined during the rerun...
127
+ unless features_to_run == :all
128
+ args << 'steps' << 'common'
129
+ end
130
+
131
+ args = args.join(' ')
132
+
133
+ return "#{Lucid::RUBY_BINARY} #{Lucid::BINARY} #{args}"
134
+ end
135
+ end
@@ -0,0 +1,6 @@
1
+ require 'autotest/rails'
2
+ require 'autotest/lucid_mixin'
3
+
4
+ class Autotest::LucidRails < Autotest::Rails
5
+ include LucidMixin
6
+ end
@@ -0,0 +1,6 @@
1
+ require 'autotest/lucid_mixin'
2
+ require 'autotest/rails_rspec'
3
+
4
+ class Autotest::LucidRailsRspec < Autotest::RailsRspec
5
+ include LucidMixin
6
+ end
@@ -0,0 +1,6 @@
1
+ require 'autotest/lucid_mixin'
2
+ require 'autotest/rails_rspec2'
3
+
4
+ class Autotest::LucidRailsRspec2 < Autotest::RailsRspec2
5
+ include LucidMixin
6
+ end
@@ -0,0 +1,6 @@
1
+ require 'autotest/lucid_mixin'
2
+ require 'autotest/rspec'
3
+
4
+ class Autotest::LucidRspec < Autotest::Rspec
5
+ include LucidMixin
6
+ end
@@ -0,0 +1,6 @@
1
+ require 'autotest/lucid_mixin'
2
+ require 'autotest/rspec2'
3
+
4
+ class Autotest::LucidRspec2 < Autotest::Rspec2
5
+ include LucidMixin
6
+ end
data/lib/lucid.rb CHANGED
@@ -1,4 +1,35 @@
1
- require "lucid/version"
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'yaml'
5
+ require 'logger'
6
+ require 'lucid/platform'
7
+ require 'lucid/parser'
8
+ require 'lucid/runtime'
9
+ require 'lucid/cli/app'
10
+ require 'lucid/step_definitions'
11
+ require 'lucid/term/ansicolor'
2
12
 
3
13
  module Lucid
14
+ class << self
15
+ attr_accessor :wants_to_quit
16
+
17
+ def logger
18
+ return @log if @log
19
+ @log = Logger.new(STDOUT)
20
+ @log.level = Logger::INFO
21
+ @log
22
+ end
23
+
24
+ def logger=(logger)
25
+ @log = logger
26
+ end
27
+ end
28
+
29
+ class LogFormatter < ::Logger::Formatter
30
+ def call(severity, time, progname, msg)
31
+ "\n[ LUCID (#{severity}) ] #{msg}"
32
+ end
33
+ end
34
+
4
35
  end