lucid 0.3.3 → 0.4.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.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.md +13 -9
  3. data/README.md +2 -6
  4. data/lib/lucid.rb +22 -3
  5. data/lib/lucid/{term/ansicolor.rb → ansicolor.rb} +34 -41
  6. data/lib/lucid/ast.rb +2 -2
  7. data/lib/lucid/ast/outline_table.rb +2 -2
  8. data/lib/lucid/ast/{specs.rb → spec.rb} +10 -1
  9. data/lib/lucid/ast/step.rb +3 -3
  10. data/lib/lucid/ast/step_invocation.rb +16 -16
  11. data/lib/lucid/ast/table.rb +1 -1
  12. data/lib/lucid/ast/{tdl_walker.rb → walker.rb} +15 -16
  13. data/lib/lucid/cli/app.rb +23 -21
  14. data/lib/lucid/cli/{configuration.rb → context.rb} +66 -38
  15. data/lib/lucid/cli/options.rb +59 -40
  16. data/lib/lucid/{configuration.rb → context.rb} +2 -3
  17. data/lib/lucid/{runtime.rb → context_loader.rb} +58 -61
  18. data/lib/lucid/{runtime/facade.rb → facade.rb} +5 -6
  19. data/lib/lucid/formatter/ansicolor.rb +15 -14
  20. data/lib/lucid/formatter/debug.rb +1 -1
  21. data/lib/lucid/formatter/usage.rb +2 -2
  22. data/lib/lucid/interface.rb +121 -0
  23. data/lib/lucid/{runtime/interface_io.rb → interface_io.rb} +2 -2
  24. data/lib/lucid/interface_rb/rb_language.rb +6 -23
  25. data/lib/lucid/interface_rb/rb_step_definition.rb +1 -2
  26. data/lib/lucid/{core_ext/instance_exec.rb → lang_extend.rb} +112 -69
  27. data/lib/lucid/{runtime/orchestrator.rb → orchestrator.rb} +36 -24
  28. data/lib/lucid/platform.rb +1 -1
  29. data/lib/lucid/{runtime/results.rb → results.rb} +10 -10
  30. data/lib/lucid/{tdl_builder.rb → spec_builder.rb} +26 -22
  31. data/lib/lucid/spec_file.rb +33 -13
  32. data/lib/lucid/{runtime/specs_loader.rb → spec_loader.rb} +13 -22
  33. data/lib/lucid/{step_definition_light.rb → step_definition_usage.rb} +2 -4
  34. data/lib/lucid/step_definitions.rb +4 -4
  35. data/spec/lucid/app_spec.rb +6 -18
  36. data/spec/lucid/ast/background_spec.rb +4 -4
  37. data/spec/lucid/ast/feature_spec.rb +7 -7
  38. data/spec/lucid/ast/scenario_outline_spec.rb +9 -9
  39. data/spec/lucid/ast/specs_spec.rb +8 -8
  40. data/spec/lucid/ast/step_spec.rb +5 -5
  41. data/spec/lucid/ast/tdl_walker_spec.rb +5 -5
  42. data/spec/lucid/{configuration_spec.rb → context_spec.rb} +78 -78
  43. data/spec/lucid/facade_spec.rb +7 -7
  44. data/spec/lucid/orchestrator_spec.rb +7 -7
  45. data/spec/lucid/pending_spec.rb +3 -3
  46. data/spec/lucid/progress_spec.rb +3 -3
  47. data/spec/lucid/rb_step_definition_spec.rb +4 -4
  48. data/spec/lucid/results_spec.rb +2 -2
  49. data/spec/lucid/runtime_spec.rb +7 -7
  50. metadata +20 -32
  51. data/bin/lucid-gen +0 -4
  52. data/lib/lucid/core_ext/proc.rb +0 -36
  53. data/lib/lucid/core_ext/string.rb +0 -9
  54. data/lib/lucid/generator.rb +0 -21
  55. data/lib/lucid/generators/project.rb +0 -64
  56. data/lib/lucid/generators/project/Gemfile.tt +0 -6
  57. data/lib/lucid/generators/project/browser-fluent.rb +0 -37
  58. data/lib/lucid/generators/project/driver-fluent.rb +0 -1
  59. data/lib/lucid/generators/project/errors.rb +0 -26
  60. data/lib/lucid/generators/project/events-fluent.rb +0 -33
  61. data/lib/lucid/interface_methods.rb +0 -125
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'lucid'
4
- <% if driver.downcase == 'fluent' -%>gem 'fluent'<% end -%>
5
- gem 'syntax'
6
- gem 'rspec'
@@ -1,37 +0,0 @@
1
- begin
2
- require 'fluent'
3
- rescue LoadError
4
- STDOUT.puts ['The Fluent test execution library is not installed.',
5
- 'The driver file is currently set to use the Fluent library but',
6
- 'that gem was not found. Run the following command:', '',
7
- ' gem install fluent'].join("\n")
8
- Kernel.exit(1)
9
- end
10
-
11
- Domain(Fluent::Factory)
12
-
13
- module Fluent
14
- module Browser
15
-
16
- @@browser = false
17
-
18
- def self.start
19
- unless @@browser
20
- target = ENV['BROWSER'] || 'firefox'
21
- @@browser = watir_browser(target)
22
- end
23
- @@browser
24
- end
25
-
26
- def self.stop
27
- @@browser.quit if @@browser
28
- @@browser = false
29
- end
30
-
31
- private
32
-
33
- def self.watir_browser(target)
34
- Watir::Browser.new(target.to_sym)
35
- end
36
- end
37
- end
@@ -1 +0,0 @@
1
- # Environment Driver File
@@ -1,26 +0,0 @@
1
- class InvalidDataConditionError < StandardError
2
- end
3
-
4
- class NecessaryDataNotAvailableError < StandardError
5
- end
6
-
7
- class NecessaryDataAlreadyAvailableError < StandardError
8
- end
9
-
10
- class NotSpecificEnoughDataError < StandardError
11
- end
12
-
13
- class PossibleDataContextError < StandardError
14
- end
15
-
16
- class ContextCannotBeFulfilledError < StandardError
17
- end
18
-
19
- class DataValidationError < StandardError
20
- end
21
-
22
- class UnexpectedDataFoundError < StandardError
23
- end
24
-
25
- class TestDataNotFoundError < StandardError
26
- end
@@ -1,33 +0,0 @@
1
- AfterConfiguration do |config|
2
- puts("Specs are being executed from: #{config.spec_location}")
3
- end
4
-
5
- Before('~@practice','~@sequence') do
6
- @browser = Fluent::Browser.start
7
- end
8
-
9
- AfterStep('@pause') do
10
- print 'Press ENTER to continue...'
11
- STDIN.getc
12
- end
13
-
14
- After do |scenario|
15
- if scenario.failed?
16
- Dir::mkdir('results') if not File.directory?('results')
17
- screenshot = "./results/FAILED_#{scenario.name.gsub(' ','_').gsub(/[^0-9A-Za-z_]/, '')}.png"
18
-
19
- if @browser
20
- # This way attempts to save the screenshot as a file.
21
- #@browser.driver.save_screenshot(screenshot)
22
-
23
- # This way the image is encoded into the results.
24
- encoded_img = @browser.driver.screenshot_as(:base64)
25
- embed("data:image/png;base64,#{encoded_img}", 'image/png')
26
- end
27
- end
28
- Fluent::Browser.stop
29
- end
30
-
31
- at_exit do
32
- Fluent::Browser.stop
33
- end
@@ -1,125 +0,0 @@
1
- require 'lucid/step_match'
2
- require 'lucid/step_definition_light'
3
-
4
- module Lucid
5
- module Interface
6
- module InterfaceMethods
7
- def around(scenario)
8
- execute_around(scenario) do
9
- yield
10
- end
11
- end
12
-
13
- def before(scenario)
14
- begin_scenario(scenario)
15
- execute_before(scenario)
16
- end
17
-
18
- def after(scenario)
19
- execute_after(scenario)
20
- end_scenario
21
- end
22
-
23
- def after_configuration(configuration)
24
- hooks[:after_configuration].each do |hook|
25
- hook.invoke('AfterConfiguration', configuration)
26
- end
27
- end
28
-
29
- def execute_after_step(scenario)
30
- hooks_for(:after_step, scenario).each do |hook|
31
- invoke(hook, 'AfterStep', scenario, false)
32
- end
33
- end
34
-
35
- def execute_transforms(args)
36
- args.map do |arg|
37
- matching_transform = transforms.detect {|transform| transform.match(arg) }
38
- matching_transform ? matching_transform.invoke(arg) : arg
39
- end
40
- end
41
-
42
- def add_hook(phase, hook)
43
- hooks[phase.to_sym] << hook
44
- hook
45
- end
46
-
47
- def clear_hooks
48
- @hooks = nil
49
- end
50
-
51
- def add_transform(transform)
52
- transforms.unshift transform
53
- transform
54
- end
55
-
56
- def hooks_for(phase, scenario) #:nodoc:
57
- hooks[phase.to_sym].select{|hook| scenario.accept_hook?(hook)}
58
- end
59
-
60
- def unmatched_step_definitions
61
- available_step_definition_hash.keys - invoked_step_definition_hash.keys
62
- end
63
-
64
- def available_step_definition(regexp_source, file_colon_line)
65
- available_step_definition_hash[StepDefinitionLight.new(regexp_source, file_colon_line)] = nil
66
- end
67
-
68
- def invoked_step_definition(regexp_source, file_colon_line)
69
- invoked_step_definition_hash[StepDefinitionLight.new(regexp_source, file_colon_line)] = nil
70
- end
71
-
72
- private
73
-
74
- def available_step_definition_hash
75
- @available_step_definition_hash ||= {}
76
- end
77
-
78
- def invoked_step_definition_hash
79
- @invoked_step_definition_hash ||= {}
80
- end
81
-
82
- def hooks
83
- @hooks ||= Hash.new{|h,k| h[k] = []}
84
- end
85
-
86
- def transforms
87
- @transforms ||= []
88
- end
89
-
90
- def execute_around(scenario, &block)
91
- hooks_for(:around, scenario).reverse.inject(block) do |blk, hook|
92
- proc do
93
- invoke(hook, 'Around', scenario, true) do
94
- blk.call(scenario)
95
- end
96
- end
97
- end.call
98
- end
99
-
100
- def execute_before(scenario)
101
- hooks_for(:before, scenario).each do |hook|
102
- invoke(hook, 'Before', scenario, true)
103
- end
104
- end
105
-
106
- def execute_after(scenario)
107
- hooks_for(:after, scenario).reverse_each do |hook|
108
- invoke(hook, 'After', scenario, true)
109
- end
110
- end
111
-
112
- def invoke(hook, location, scenario, exception_fails_scenario, &block)
113
- begin
114
- hook.invoke(location, scenario, &block)
115
- rescue Exception => exception
116
- if exception_fails_scenario
117
- scenario.fail!(exception)
118
- else
119
- raise
120
- end
121
- end
122
- end
123
- end
124
- end
125
- end