graffle 0.1.9 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +9 -0
- data/Manifest.txt +15 -8
- data/Rakefile.hoe +1 -2
- data/bin/interpret-intentions.rb +51 -0
- data/examples/objects with notes.rb +1 -0
- data/examples/old-style-rails-workflow-test.expected +11 -0
- data/examples/old-style-rails-workflow-test.rb +43 -0
- data/examples/rails-workflow-test.rb +7 -6
- data/examples/sheet with key.expected +5 -0
- data/examples/sheet with key.graffle +0 -0
- data/examples/sheet with key.rb +38 -0
- data/graffle.tmproj +242 -75
- data/lib/graffle.rb +11 -2
- data/lib/graffle/nodoc/hacks.rb +1 -0
- data/lib/graffle/point.rb +1 -0
- data/lib/graffle/stereotypes.rb +34 -3
- data/lib/graffle/version.rb +3 -1
- data/lib/graphical_tests_for_rails.rb +11 -9
- data/lib/graphical_tests_for_rails/jumbled-string-canonicalizer.rb +117 -0
- data/lib/graphical_tests_for_rails/orderings.rb +1 -2
- data/lib/graphical_tests_for_rails/picture-applier.rb +257 -0
- data/lib/graphical_tests_for_rails/stereotype-extensions.rb +111 -0
- data/lib/graphical_tests_for_rails/text-appliers.rb +10 -84
- data/lib/graphical_tests_for_rails/user-intention.rb +250 -0
- data/test/abstract-graphic-tests.rb +10 -0
- data/test/container-tests.rb +29 -0
- data/test/graphical_tests_for_rails/jumbled-string-canonicalizer-tests.rb +174 -0
- data/test/graphical_tests_for_rails/new-style-picture-applier-tests.rb +286 -0
- data/test/graphical_tests_for_rails/old-style-picture-applier-tests.rb +129 -0
- data/test/graphical_tests_for_rails/user-intention-tests.rb +389 -0
- data/test/graphical_tests_for_rails/util.rb +9 -0
- data/test/sheet-tests.rb +21 -0
- data/test/text-tests.rb +6 -0
- metadata +25 -26
- data/design-notes/graphical-tests-for-rails-objects.graffle +0 -644
- data/lib/graphical_tests_for_rails/graphic-volunteers.rb +0 -75
- data/lib/graphical_tests_for_rails/picture-appliers.rb +0 -225
- data/lib/graphical_tests_for_rails/volunteer-pool.rb +0 -115
- data/test/graphical_tests_for_rails/deprecated-graphic-interpreter-tests.rb +0 -121
- data/test/graphical_tests_for_rails/graphic-volunteer-tests.rb +0 -218
- data/test/graphical_tests_for_rails/picture-applier-tests.rb +0 -215
- data/test/graphical_tests_for_rails/text-applier-tests.rb +0 -111
@@ -1,218 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Created by Brian Marick on 2007-07-20.
|
4
|
-
# Copyright (c) 2007. All rights reserved.
|
5
|
-
|
6
|
-
require 'test/unit'
|
7
|
-
require 's4t-utils'
|
8
|
-
include S4tUtils
|
9
|
-
|
10
|
-
require "../set-standalone-test-paths.rb" unless $started_from_rakefile
|
11
|
-
|
12
|
-
require 'graphical_tests_for_rails/graphic-volunteers'
|
13
|
-
require 'graphical_tests_for_rails/volunteer-pool'
|
14
|
-
require 'graffle'
|
15
|
-
|
16
|
-
class GraphicVolunteerTest < Test::Unit::TestCase
|
17
|
-
include GraphicalTestsForRails
|
18
|
-
include Graffle::Builders
|
19
|
-
|
20
|
-
def setup
|
21
|
-
@pool = GraphicVolunteerPool.new
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_untrained_volunteer_wants_to_handle_everything
|
25
|
-
assert_true(GraphicVolunteer.new('irrelevant').likes?(Object.new))
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_untrained_volunteer_does_not_even_try_to_extract_lines
|
29
|
-
assert_equal([], GraphicVolunteer.new('irrelevent').extract_lines(Object.new))
|
30
|
-
end
|
31
|
-
|
32
|
-
# Trained volunteers will be fetched from the pool, then tested.
|
33
|
-
|
34
|
-
def test_volunteers_must_be_fetched_with_known_names
|
35
|
-
assert_raises(StandardError) {
|
36
|
-
@pool.mobilize_form_watcher('nothing')
|
37
|
-
}
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
def test_some_volunteers_go_for_shaped_graphic_content
|
43
|
-
volunteer = @pool.mobilize_form_watcher('shaped graphic content')
|
44
|
-
|
45
|
-
assert_false(volunteer.likes?(abstract_graphic))
|
46
|
-
assert_false(volunteer.likes?(shaped_graphic))
|
47
|
-
assert_false(volunteer.likes?(shaped_graphic { with_note "hello" }))
|
48
|
-
assert_true(volunteer.likes?(shaped_graphic { with_content "hello" }))
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_those_volunteers_extract_only_shaped_graphic_content_lines
|
52
|
-
volunteer = @pool.mobilize_form_watcher('shaped graphic content')
|
53
|
-
graphic = shaped_graphic {
|
54
|
-
with_content "expected"
|
55
|
-
with_note "not expected"
|
56
|
-
}
|
57
|
-
|
58
|
-
assert_equal(["expected"], volunteer.extract_lines(graphic))
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_som_volunteers_go_for_line_label_content
|
62
|
-
# Here are the pieces of the structure that matter:
|
63
|
-
empty_label = good_label = no_label = nil
|
64
|
-
|
65
|
-
s = sheet {
|
66
|
-
with label_without_text = line_label {
|
67
|
-
for_line 1
|
68
|
-
}
|
69
|
-
with label_with_fine_text = line_label {
|
70
|
-
for_line 2
|
71
|
-
with_content "hi"
|
72
|
-
}
|
73
|
-
with empty_label = line_graphic { graffle_id_is 1 }
|
74
|
-
with good_label = line_graphic { graffle_id_is 2 }
|
75
|
-
with no_label = line_graphic { graffle_id_is 3 }
|
76
|
-
}
|
77
|
-
|
78
|
-
volunteer = @pool.mobilize_form_watcher('line label content')
|
79
|
-
|
80
|
-
assert_false(volunteer.likes?(shaped_graphic { with_content 'foo' }))
|
81
|
-
assert_false(volunteer.likes?(empty_label))
|
82
|
-
assert_false(volunteer.likes?(no_label))
|
83
|
-
assert_true(volunteer.likes?(good_label))
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_those_volunteers_extract_only_line_label_content_lines
|
87
|
-
volunteer = @pool.mobilize_form_watcher('line label content')
|
88
|
-
|
89
|
-
s = sheet {
|
90
|
-
with line_graphic {
|
91
|
-
graffle_id_is 1
|
92
|
-
}
|
93
|
-
|
94
|
-
with line_label {
|
95
|
-
for_line 1
|
96
|
-
with_content "expected"
|
97
|
-
with_note "not expected"
|
98
|
-
}
|
99
|
-
}
|
100
|
-
|
101
|
-
assert_equal(["expected"], volunteer.extract_lines(s.find_by_id(1)))
|
102
|
-
end
|
103
|
-
|
104
|
-
|
105
|
-
def test_some_volunteers_go_for_notes_attached_to_anything
|
106
|
-
# Here are the pieces of the structure that matter:
|
107
|
-
shaped_with_note = shaped_graphic {
|
108
|
-
graffle_id_is 1
|
109
|
-
with_note "this matches"
|
110
|
-
}
|
111
|
-
shaped_without_note = shaped_graphic {
|
112
|
-
graffle_id_is 2
|
113
|
-
with_content "this does not"
|
114
|
-
}
|
115
|
-
line_graphic_with_nothing = line_graphic
|
116
|
-
line_graphic_with_only_label_text = line_graphic {
|
117
|
-
# label added below.
|
118
|
-
graffle_id_is 999
|
119
|
-
}
|
120
|
-
line_graphic_with_note = line_graphic {
|
121
|
-
# label added below
|
122
|
-
graffle_id_is 888
|
123
|
-
}
|
124
|
-
|
125
|
-
s = sheet {
|
126
|
-
with shaped_with_note
|
127
|
-
with shaped_without_note
|
128
|
-
with line_graphic_with_nothing
|
129
|
-
with line_graphic_with_only_label_text
|
130
|
-
with line_graphic_with_note
|
131
|
-
|
132
|
-
with line_label {
|
133
|
-
for_line line_graphic_with_only_label_text.graffle_id
|
134
|
-
with_content "unmatching line label"
|
135
|
-
}
|
136
|
-
with line_label {
|
137
|
-
for_line line_graphic_with_note.graffle_id
|
138
|
-
with_note "matching line label - has note"
|
139
|
-
}
|
140
|
-
}
|
141
|
-
|
142
|
-
volunteer = @pool.mobilize_form_watcher('note')
|
143
|
-
assert_true(volunteer.likes?(shaped_with_note))
|
144
|
-
assert_false(volunteer.likes?(shaped_without_note))
|
145
|
-
assert_false(volunteer.likes?(line_graphic_with_nothing))
|
146
|
-
assert_false(volunteer.likes?(line_graphic_with_only_label_text))
|
147
|
-
assert_true(volunteer.likes?(line_graphic_with_note))
|
148
|
-
end
|
149
|
-
|
150
|
-
def test_those_volunteers_extract_only_note_lines
|
151
|
-
shaped_with_note = shaped_graphic { with_note "expected" }
|
152
|
-
line_with_label_note = line_graphic { graffle_id_is 1 } # label added later
|
153
|
-
line_with_own_note = line_graphic { with_note "expected"}
|
154
|
-
line_with_both = line_graphic {
|
155
|
-
graffle_id = 999
|
156
|
-
with_note "expected"
|
157
|
-
}
|
158
|
-
|
159
|
-
s = sheet {
|
160
|
-
with shaped_with_note
|
161
|
-
with line_with_label_note
|
162
|
-
with line_with_own_note
|
163
|
-
with line_with_both
|
164
|
-
with line_label {
|
165
|
-
for_line line_with_label_note.graffle_id
|
166
|
-
with_note "expected"
|
167
|
-
}
|
168
|
-
with line_label {
|
169
|
-
for_line line_with_both.graffle_id
|
170
|
-
with_note "NOT expected - line note takes precedence"
|
171
|
-
}
|
172
|
-
}
|
173
|
-
|
174
|
-
volunteer = @pool.mobilize_form_watcher('note')
|
175
|
-
|
176
|
-
assert_equal(["expected"], volunteer.extract_lines(shaped_with_note))
|
177
|
-
assert_equal(["expected"], volunteer.extract_lines(line_with_label_note))
|
178
|
-
assert_equal(["expected"], volunteer.extract_lines(line_with_own_note))
|
179
|
-
assert_equal(["expected"], volunteer.extract_lines(line_with_both))
|
180
|
-
end
|
181
|
-
|
182
|
-
#
|
183
|
-
# Content volunteers look at lines of text, not graphics.
|
184
|
-
# They don't extract lines, so that's not tested.
|
185
|
-
#
|
186
|
-
|
187
|
-
def test_some_content_volunteers_go_for_text_with_ellipses
|
188
|
-
volunteer = @pool.mobilize_content_watcher('text...')
|
189
|
-
|
190
|
-
assert_true(volunteer.likes?(["foo..."]))
|
191
|
-
assert_true(volunteer.likes?(["foo.."])) # allow typos
|
192
|
-
assert_true(volunteer.likes?(["foo...."]))
|
193
|
-
assert_true(volunteer.likes?(["foo.... "]))
|
194
|
-
assert_false(volunteer.likes?(["foo...b"]))
|
195
|
-
end
|
196
|
-
|
197
|
-
def test_some_content_volunteers_go_for_text_to_be_ignored
|
198
|
-
volunteer = @pool.mobilize_content_watcher('ignore')
|
199
|
-
|
200
|
-
assert_true(volunteer.likes?(["ignore"]))
|
201
|
-
assert_true(volunteer.likes?([" ignore "]))
|
202
|
-
assert_false(volunteer.likes?(["something else"]))
|
203
|
-
assert_true(volunteer.likes?(["something else", "ignore"]))
|
204
|
-
end
|
205
|
-
|
206
|
-
def test_content_volunteers_are_chained_after_form_volunteers
|
207
|
-
graphic_volunteer = @pool.mobilize_form_watcher('note')
|
208
|
-
text_volunteer = @pool.mobilize_content_watcher('text...')
|
209
|
-
|
210
|
-
g = shaped_graphic { with_note "no ellipses" }
|
211
|
-
assert_true(graphic_volunteer.likes?(g))
|
212
|
-
graphic_volunteer.next = text_volunteer
|
213
|
-
assert_false(graphic_volunteer.likes?(g))
|
214
|
-
|
215
|
-
assert_true(graphic_volunteer.likes?(shaped_graphic{ with_note "..."}))
|
216
|
-
end
|
217
|
-
|
218
|
-
end
|
@@ -1,215 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Created by Brian Marick on 2007-07-20.
|
4
|
-
# Copyright (c) 2007. All rights reserved.
|
5
|
-
|
6
|
-
require 'test/unit'
|
7
|
-
require 's4t-utils'
|
8
|
-
include S4tUtils
|
9
|
-
|
10
|
-
require "../set-standalone-test-paths.rb" unless $started_from_rakefile
|
11
|
-
|
12
|
-
require 'extensions/string'
|
13
|
-
require 'test/graphical_tests_for_rails/util'
|
14
|
-
require 'graffle'
|
15
|
-
require 'graphical_tests_for_rails/picture-appliers'
|
16
|
-
|
17
|
-
class PictureApplierTest < Test::Unit::TestCase
|
18
|
-
include Graffle
|
19
|
-
include Graffle::Builders
|
20
|
-
include GraphicalTestsForRails
|
21
|
-
include GraphicalTestsForRails::TextAppliers
|
22
|
-
|
23
|
-
def setup
|
24
|
-
@sheet = sheet {
|
25
|
-
with shaped_graphic {
|
26
|
-
graffle_id_is 1
|
27
|
-
with_content 'shaped graphic text...'
|
28
|
-
}
|
29
|
-
with line_label {
|
30
|
-
for_line 22
|
31
|
-
with_content 'line label text...'
|
32
|
-
}
|
33
|
-
with line_graphic {
|
34
|
-
graffle_id_is 22
|
35
|
-
}
|
36
|
-
with shaped_graphic { # no text
|
37
|
-
graffle_id_is 333
|
38
|
-
}
|
39
|
-
with line_graphic { # no label
|
40
|
-
graffle_id_is 4444
|
41
|
-
}
|
42
|
-
}
|
43
|
-
end
|
44
|
-
|
45
|
-
def shaped_graphic_with_content; @sheet.find_by_id(1); end
|
46
|
-
def shaped_graphic_without_text; @sheet.find_by_id(333); end
|
47
|
-
def line_graphic_with_label; @sheet.find_by_id(22); end
|
48
|
-
def line_graphic_without_label; @sheet.find_by_id(4444); end
|
49
|
-
|
50
|
-
|
51
|
-
def test_empty_applier_produces_eager_but_useless_volunteer
|
52
|
-
@applier = PictureApplier.new
|
53
|
-
g = shaped_graphic { with_content 'foo' }
|
54
|
-
assert_equal(EagerButUselessVolunteer, @applier.find_volunteer_for(g).class)
|
55
|
-
# Or, as shorthand:
|
56
|
-
assert_eager_but_useless_volunteer_for(g)
|
57
|
-
end
|
58
|
-
|
59
|
-
def assert_eager_but_useless_volunteer_for(graphic)
|
60
|
-
assert_equal(EagerButUselessVolunteer, @applier.find_volunteer_for(graphic).class)
|
61
|
-
end
|
62
|
-
|
63
|
-
def assert_trained_volunteer_for(graphic)
|
64
|
-
assert_not_equal(EagerButUselessVolunteer, @applier.find_volunteer_for(graphic).class)
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_useless_volunteer_does_nothing
|
68
|
-
# ... so we can just test for it rather than having it do something.
|
69
|
-
@applier = PictureApplier.new
|
70
|
-
g = shaped_graphic { with_note 'foo' }
|
71
|
-
@applier.apply([g], "will blow up if used")
|
72
|
-
end
|
73
|
-
|
74
|
-
|
75
|
-
# Some examples of how a PictureApplier can use the Volunteer
|
76
|
-
# mechanism to prepare volunteers trained for certain kinds
|
77
|
-
# of graphics.
|
78
|
-
def test_can_recruit_trained_volunteers_for_shaped_graphic_contents
|
79
|
-
@applier = PictureApplier.new {
|
80
|
-
given('shaped graphic content') # ... chained methods go here
|
81
|
-
}
|
82
|
-
|
83
|
-
assert_trained_volunteer_for(shaped_graphic_with_content)
|
84
|
-
assert_eager_but_useless_volunteer_for(shaped_graphic_without_text)
|
85
|
-
assert_eager_but_useless_volunteer_for(line_graphic_with_label)
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_can_recruit_trained_volunteers_for_line_graphic_labels
|
89
|
-
@applier = PictureApplier.new {
|
90
|
-
given('line label content') # ... chained methods go here
|
91
|
-
}
|
92
|
-
|
93
|
-
assert_trained_volunteer_for(line_graphic_with_label)
|
94
|
-
assert_eager_but_useless_volunteer_for(line_graphic_without_label)
|
95
|
-
assert_eager_but_useless_volunteer_for(shaped_graphic_with_content)
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_there_is_a_fixed_set_of_graphically_oriented_volunteers
|
99
|
-
assert_raises(StandardError) {
|
100
|
-
PictureApplier.new { given 'oopsla' }
|
101
|
-
}
|
102
|
-
end
|
103
|
-
|
104
|
-
|
105
|
-
# Examples of using the 'matching' clause to augment a
|
106
|
-
# graphically-oriented volunteer with a textually-oriented one.
|
107
|
-
|
108
|
-
def test_can_augment_a_volunteer_to_look_for_ellipses
|
109
|
-
@applier = PictureApplier.new {
|
110
|
-
given('shaped graphic content').matching('text...') # ... chained methods go here
|
111
|
-
}
|
112
|
-
|
113
|
-
assert_trained_volunteer_for(shaped_graphic { with_content "blah..." })
|
114
|
-
assert_eager_but_useless_volunteer_for(shaped_graphic { with_content "blah" })
|
115
|
-
assert_eager_but_useless_volunteer_for(shaped_graphic)
|
116
|
-
assert_eager_but_useless_volunteer_for(line_graphic_with_label)
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_there_is_a_fixed_set_of_textually_oriented_volunteers
|
120
|
-
ok_so_far = PictureApplier.new { given 'shaped graphic content' }
|
121
|
-
assert_raises(StandardError) {
|
122
|
-
ok_so_far.matching('something never defined')
|
123
|
-
}
|
124
|
-
end
|
125
|
-
|
126
|
-
# An example of how it's all put together to send messages to targets.
|
127
|
-
|
128
|
-
class Echoer < AbstractTextApplier
|
129
|
-
def message_and_args_from(string)
|
130
|
-
[:echo, string]
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
def test_application_of_matches
|
135
|
-
@applier = PictureApplier.new {
|
136
|
-
given('note').matching('text...').skip
|
137
|
-
given('note').use(Echoer.new)
|
138
|
-
}
|
139
|
-
|
140
|
-
s = sheet {
|
141
|
-
with shaped_graphic { with_notes 'hello world' }
|
142
|
-
with line_graphic
|
143
|
-
with shaped_graphic { with_notes "waiting..."}
|
144
|
-
with line_graphic { with_notes "goodbye world" }
|
145
|
-
}
|
146
|
-
|
147
|
-
target = CommandRecorder.new
|
148
|
-
@applier.apply(s.graphics, target)
|
149
|
-
assert_equal(['echo("hello world")', 'echo("goodbye world")'],
|
150
|
-
target.record)
|
151
|
-
end
|
152
|
-
|
153
|
-
|
154
|
-
class ThriceThenDie
|
155
|
-
include Test::Unit::Assertions
|
156
|
-
|
157
|
-
def initialize
|
158
|
-
@count = 0
|
159
|
-
end
|
160
|
-
|
161
|
-
def echo(value)
|
162
|
-
@count += 1
|
163
|
-
assert_equal("right", "wrong") if @count >= 4
|
164
|
-
end
|
165
|
-
|
166
|
-
end
|
167
|
-
|
168
|
-
def four_counting_shaped_graphics
|
169
|
-
sheet {
|
170
|
-
with shaped_graphic { with_content "first" }
|
171
|
-
with shaped_graphic { with_content "second" }
|
172
|
-
with shaped_graphic { with_content "third" }
|
173
|
-
with shaped_graphic { with_content "yikes!"}
|
174
|
-
}.graphics
|
175
|
-
end
|
176
|
-
|
177
|
-
def four_graphic_contents
|
178
|
-
four_counting_shaped_graphics.collect { |g| g.content.as_plain_text }
|
179
|
-
end
|
180
|
-
|
181
|
-
def assert_thrice_then_die_log(exc, expected_echoed)
|
182
|
-
assert_match(/right.*expected.*was.*wrong/m, exc.message)
|
183
|
-
expected = expected_echoed.collect do |w|
|
184
|
-
"echo\\(" + w.inspect + "\\)"
|
185
|
-
end.join('.*')
|
186
|
-
assert_match(/#{expected}/m, exc.message)
|
187
|
-
end
|
188
|
-
|
189
|
-
def test_logging_prints_list_of_calls_into_target
|
190
|
-
@applier = PictureApplier.new {
|
191
|
-
given('shaped graphic content').use(Echoer.new)
|
192
|
-
}
|
193
|
-
begin
|
194
|
-
@applier.apply(four_counting_shaped_graphics, ThriceThenDie.new)
|
195
|
-
rescue Test::Unit::AssertionFailedError => e
|
196
|
-
assert_thrice_then_die_log(e, four_graphic_contents)
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
def test_log_can_be_injected
|
201
|
-
def test_logging_prints_list_of_calls_into_target
|
202
|
-
@applier = PictureApplier.new {
|
203
|
-
given('shaped graphic content').use(Echoer.new)
|
204
|
-
}
|
205
|
-
begin
|
206
|
-
@applier.apply(four_counting_shaped_graphics,
|
207
|
-
ThriceThenDie.new,
|
208
|
-
['echo("prior value of log")'])
|
209
|
-
rescue Test::Unit::AssertionFailedError => e
|
210
|
-
assert_thrice_then_die_log(e, ["prior value of log"] + four_graphic_contents)
|
211
|
-
end
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
end
|
@@ -1,111 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Created by Brian Marick on 2007-07-11.
|
4
|
-
# Copyright (c) 2007. All rights reserved.
|
5
|
-
|
6
|
-
require "../set-standalone-test-paths.rb" unless $started_from_rakefile
|
7
|
-
|
8
|
-
require 'test/unit'
|
9
|
-
require 's4t-utils'
|
10
|
-
include S4tUtils
|
11
|
-
|
12
|
-
require 'extensions/string'
|
13
|
-
require 'graphical_tests_for_rails'
|
14
|
-
|
15
|
-
|
16
|
-
class TestProductionOfMessages < Test::Unit::TestCase
|
17
|
-
include GraphicalTestsForRails
|
18
|
-
|
19
|
-
def assert_translation(expected, original)
|
20
|
-
actual = @interpreter.message_and_args_from(original)
|
21
|
-
assert_equal(expected, actual)
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_messages_whose_arguments_come_from_quoted_text
|
25
|
-
@interpreter = ArgsFromQuotedText.new
|
26
|
-
|
27
|
-
assert_translation(['token'], "token")
|
28
|
-
assert_translation(['underscore_separated_tokens'],
|
29
|
-
'underscore separated tokens'
|
30
|
-
)
|
31
|
-
assert_translation(['whitespace_is_handled_intelligently'],
|
32
|
-
" whitespace\tis handled intelligently "
|
33
|
-
)
|
34
|
-
assert_translation(['here_is_an', 'argument'],
|
35
|
-
'here is an "argument"'
|
36
|
-
)
|
37
|
-
assert_translation(['single_spaces_are_args', 'too '],
|
38
|
-
" single spaces are args 'too ' "
|
39
|
-
)
|
40
|
-
assert_translation(['multiple', 'arguments', "work"],
|
41
|
-
%q{multiple 'arguments' "work"}
|
42
|
-
)
|
43
|
-
assert_translation(['only_the', 'prefix', "command"],
|
44
|
-
%q{only the 'prefix' is included in the 'command'}
|
45
|
-
)
|
46
|
-
|
47
|
-
assert_translation(['arguments_can', 'be', 'comma', "separated"],
|
48
|
-
%q{arguments can 'be', 'comma', and 'separated'}
|
49
|
-
)
|
50
|
-
|
51
|
-
assert_translation(['stuff_after_the', 'last', 'argument'],
|
52
|
-
%q{stuff after the 'last' 'argument' is ignored.}
|
53
|
-
)
|
54
|
-
|
55
|
-
assert_translation(['even_if_it_is_just', 'a period'],
|
56
|
-
%q{even if it is just 'a period'.}
|
57
|
-
)
|
58
|
-
|
59
|
-
assert_translation(['the_method_ignores_punctuation'],
|
60
|
-
%q{the method (ignores) punctuation.}
|
61
|
-
)
|
62
|
-
|
63
|
-
assert_translation(['except_that_dashes_become_underscore'],
|
64
|
-
%q{except that dashes become-underscore}
|
65
|
-
)
|
66
|
-
|
67
|
-
assert_translation(["its_possible_to_have_quotes_within_words"],
|
68
|
-
%q{it's possible to have quotes within words}
|
69
|
-
)
|
70
|
-
|
71
|
-
assert_translation(["while_a_messages_quotes_are_stripped", "an argument's are retained"],
|
72
|
-
%q{while a message's quotes are stripped, "an argument's are retained"}
|
73
|
-
)
|
74
|
-
|
75
|
-
assert_translation(["capitals_are_lowercased_throughout"],
|
76
|
-
%q{Capitals are lowercased THROUGHOUT})
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_messages_created_from_prefix_name_and_quoted_args
|
80
|
-
@interpreter = PrefixNameAndArgsFromQuotedText.new
|
81
|
-
|
82
|
-
assert_translation(["runs", "nathan"],
|
83
|
-
%q{Nathan runs})
|
84
|
-
|
85
|
-
assert_translation(["runs_to", "nathan", "Tacoma"],
|
86
|
-
%q{Nathan runs to "Tacoma"})
|
87
|
-
|
88
|
-
assert_raises_with_matching_message(StandardError, /'runs' cannot be split into a name and an action./) {
|
89
|
-
@interpreter.message_and_args_from('runs')
|
90
|
-
}
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_messages_created_from_page_names
|
94
|
-
@interpreter = TextAsNameOfPage.new('assert_on_page')
|
95
|
-
assert_translation(['assert_on_page', "markup"],
|
96
|
-
"MARKUP")
|
97
|
-
|
98
|
-
assert_translation(['assert_on_page', "outside-spaces"],
|
99
|
-
" outside-spaces ")
|
100
|
-
|
101
|
-
# TODO: don't know what makes sense for interior spaces or
|
102
|
-
# non-\w characters.
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
|
107
|
-
def test_ineffectual_interpreters_produce_messages_that_do_nothing
|
108
|
-
@interpreter = TextApplierThatDoesNothing.new
|
109
|
-
assert_translation([:object_id], "MARKUP")
|
110
|
-
end
|
111
|
-
end
|