rbehave 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/CHANGELOG.txt +2 -0
- data/History.txt +0 -0
- data/Manifest.txt +31 -0
- data/NOTES.txt +11 -0
- data/README.txt +4 -0
- data/Rakefile +54 -0
- data/behaviour/everything.rb +1 -0
- data/behaviour/examples/everything.rb +3 -0
- data/behaviour/examples/helper.rb +2 -0
- data/behaviour/examples/rbehave/documenter/plain_text_documenter_behaviour.rb +58 -0
- data/behaviour/examples/rbehave/exception_behaviour.rb +27 -0
- data/behaviour/examples/rbehave/reporter/plain_text_reporter_behaviour.rb +112 -0
- data/behaviour/examples/rbehave/runner/scenario_collector_behaviour.rb +25 -0
- data/behaviour/examples/rbehave/runner/scenario_runner_behaviour.rb +143 -0
- data/behaviour/examples/rbehave/runner/story_runner_behaviour.rb +169 -0
- data/behaviour/examples/rbehave/story_behaviour.rb +20 -0
- data/behaviour/examples/rbehave/world_behaviour.rb +259 -0
- data/behaviour/examples/rspec_adapter.rb +81 -0
- data/lib/rbehave/documenter/plain_text_documenter.rb +29 -0
- data/lib/rbehave/exceptions.rb +24 -0
- data/lib/rbehave/reporter/plain_text_reporter.rb +58 -0
- data/lib/rbehave/runner/scenario_collector.rb +16 -0
- data/lib/rbehave/runner/scenario_runner.rb +40 -0
- data/lib/rbehave/runner/story_runner.rb +44 -0
- data/lib/rbehave/scenario.rb +11 -0
- data/lib/rbehave/story.rb +15 -0
- data/lib/rbehave/version.rb +9 -0
- data/lib/rbehave/world.rb +55 -0
- data/lib/rbehave.rb +72 -0
- data/setup.rb +1585 -0
- metadata +75 -0
data/lib/rbehave.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
Dir[File.join(File.dirname(__FILE__), 'rbehave/**/*.rb')].sort.each { |lib| require lib }
|
2
|
+
|
3
|
+
module RBehave
|
4
|
+
def Story(title, narrative, &body)
|
5
|
+
RBehave::Runner::story_runner.Story(title, narrative, &body)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.included(into)
|
9
|
+
RBehave::Runner.register_instance
|
10
|
+
end
|
11
|
+
|
12
|
+
module Runner
|
13
|
+
class << self
|
14
|
+
def story_runner
|
15
|
+
unless @story_runner
|
16
|
+
scenario_runner = ScenarioRunner.new
|
17
|
+
world_creator = World
|
18
|
+
@story_runner = StoryRunner.new(scenario_runner, world_creator)
|
19
|
+
if ARGV.empty?
|
20
|
+
reporter = RBehave::Reporter::PlainTextReporter.new($stdout)
|
21
|
+
scenario_runner.add_listener(reporter)
|
22
|
+
@story_runner.add_listener(reporter)
|
23
|
+
else
|
24
|
+
documenter = RBehave::Documenter::PlainTextDocumenter.new($stdout)
|
25
|
+
scenario_runner.add_listener(documenter)
|
26
|
+
@story_runner.add_listener(documenter)
|
27
|
+
world_creator.add_listener(documenter)
|
28
|
+
self.dry_run = true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
@story_runner
|
32
|
+
end
|
33
|
+
|
34
|
+
def register_instance
|
35
|
+
return if registered?
|
36
|
+
unless registered?
|
37
|
+
registered = true
|
38
|
+
Exception.add_backtrace_filter(/lib\/rbehave/)
|
39
|
+
Exception.add_backtrace_filter(/gems\/rspec/)
|
40
|
+
at_exit do
|
41
|
+
exit RBehave::Runner.run unless $! || RBehave::Runner.run?
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def registered?
|
47
|
+
@registered ||= false
|
48
|
+
end
|
49
|
+
|
50
|
+
def run?
|
51
|
+
@run ||= false
|
52
|
+
end
|
53
|
+
|
54
|
+
def run=(value)
|
55
|
+
@run = value
|
56
|
+
end
|
57
|
+
|
58
|
+
def run
|
59
|
+
story_runner.run_stories
|
60
|
+
self.run = true
|
61
|
+
end
|
62
|
+
|
63
|
+
def dry_run?
|
64
|
+
@dry_run ||= false
|
65
|
+
end
|
66
|
+
|
67
|
+
def dry_run=(value)
|
68
|
+
@dry_run = value
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|