Class: JLDrill::StoryMemento
- Inherits:
-
Object
- Object
- JLDrill::StoryMemento
- Defined in:
- lib/jldrill/spec/StoryMemento.rb
Overview
This is a helper class for the tests. It makes it easier to set up and tear down the test. It also keeps track of the state of the app.
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#mainContext ⇒ Object
readonly
Returns the value of attribute mainContext.
-
#mainView ⇒ Object
readonly
Returns the value of attribute mainView.
-
#storyName ⇒ Object
readonly
Returns the value of attribute storyName.
-
#view ⇒ Object
readonly
Returns the value of attribute view.
Instance Method Summary collapse
-
#getNewView ⇒ Object
Create a new view after the old one has been destroyed.
-
#initialize(storyName) ⇒ StoryMemento
constructor
A new instance of StoryMemento.
- #restart ⇒ Object
- #setup(type) ⇒ Object
-
#shutdown ⇒ Object
This is very important to call when using setupGtk because otherwise you will leave windows hanging open.
- #start ⇒ Object
- #stepName(step) ⇒ Object
- #useChineseTestDictionary ⇒ Object
- #useTestDictionary ⇒ Object
Constructor Details
#initialize(storyName) ⇒ StoryMemento
Returns a new instance of StoryMemento.
14 15 16 17 |
# File 'lib/jldrill/spec/StoryMemento.rb', line 14 def initialize(storyName) @storyName = storyName restart end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
11 12 13 |
# File 'lib/jldrill/spec/StoryMemento.rb', line 11 def app @app end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
11 12 13 |
# File 'lib/jldrill/spec/StoryMemento.rb', line 11 def context @context end |
#mainContext ⇒ Object (readonly)
Returns the value of attribute mainContext.
11 12 13 |
# File 'lib/jldrill/spec/StoryMemento.rb', line 11 def mainContext @mainContext end |
#mainView ⇒ Object (readonly)
Returns the value of attribute mainView.
11 12 13 |
# File 'lib/jldrill/spec/StoryMemento.rb', line 11 def mainView @mainView end |
#storyName ⇒ Object (readonly)
Returns the value of attribute storyName.
11 12 13 |
# File 'lib/jldrill/spec/StoryMemento.rb', line 11 def storyName @storyName end |
#view ⇒ Object (readonly)
Returns the value of attribute view.
11 12 13 |
# File 'lib/jldrill/spec/StoryMemento.rb', line 11 def view @view end |
Instance Method Details
#getNewView ⇒ Object
Create a new view after the old one has been destroyed
66 67 68 |
# File 'lib/jldrill/spec/StoryMemento.rb', line 66 def getNewView @view = @context.peekAtView end |
#restart ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/jldrill/spec/StoryMemento.rb', line 19 def restart @app = nil @mainContext = nil @mainView = nil @context = nil @view = nil end |
#setup(type) ⇒ Object
31 32 33 34 35 |
# File 'lib/jldrill/spec/StoryMemento.rb', line 31 def setup(type) @app = JLDrill::Fakes::App.new(type, JLDrill::MainContext) @mainContext = @app.mainContext @mainView = @mainContext.peekAtView end |
#shutdown ⇒ Object
This is very important to call when using setupGtk because otherwise you will leave windows hanging open.
60 61 62 63 |
# File 'lib/jldrill/spec/StoryMemento.rb', line 60 def shutdown @mainContext.exit restart end |
#start ⇒ Object
54 55 56 |
# File 'lib/jldrill/spec/StoryMemento.rb', line 54 def start @app.enter end |
#stepName(step) ⇒ Object
27 28 29 |
# File 'lib/jldrill/spec/StoryMemento.rb', line 27 def stepName(step) @storyName + " - " + step end |
#useChineseTestDictionary ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/jldrill/spec/StoryMemento.rb', line 45 def useChineseTestDictionary @mainContext.quiz..language = "Chinese" # Override with the small test dictionary rc = @mainContext.loadReferenceContext def rc.dictionaryName() return File.join("tests", "cedict.utf") end end |
#useTestDictionary ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/jldrill/spec/StoryMemento.rb', line 37 def useTestDictionary # Override with the small test dictionary rc = @mainContext.loadReferenceContext def rc.dictionaryName() return File.join("tests", "edict.utf") end end |