fools 0.0.4

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 (66) hide show
  1. data/COPYING +674 -0
  2. data/History.txt +4 -0
  3. data/Manifest.txt +65 -0
  4. data/PostInstall.txt +31 -0
  5. data/README.rdoc +73 -0
  6. data/Rakefile +24 -0
  7. data/bin/carps_fools +27 -0
  8. data/bin/register_carps_fools +35 -0
  9. data/features/character_sheet.feature +35 -0
  10. data/features/dice.feature +28 -0
  11. data/features/dm_interface.feature +19 -0
  12. data/features/launch_dm.feature +10 -0
  13. data/features/launch_player.feature +9 -0
  14. data/features/player_interface.feature +19 -0
  15. data/features/rules.feature +66 -0
  16. data/features/step_definitions/common_steps.rb +168 -0
  17. data/features/steps/character_sheet.rb +152 -0
  18. data/features/steps/dice.rb +19 -0
  19. data/features/steps/dm_interface.rb +21 -0
  20. data/features/steps/dm_mod.rb +6 -0
  21. data/features/steps/dm_test_mailer.rb +23 -0
  22. data/features/steps/general.rb +7 -0
  23. data/features/steps/interface.rb +10 -0
  24. data/features/steps/launch_dm.rb +12 -0
  25. data/features/steps/launch_player.rb +6 -0
  26. data/features/steps/player_interface.rb +45 -0
  27. data/features/steps/player_mod.rb +6 -0
  28. data/features/steps/player_test_mailer.rb +27 -0
  29. data/features/steps/resource.rb +5 -0
  30. data/features/steps/rules.rb +144 -0
  31. data/features/support/common.rb +29 -0
  32. data/features/support/env.rb +4 -0
  33. data/features/support/matchers.rb +11 -0
  34. data/lib/fools/dm/interface.rb +97 -0
  35. data/lib/fools/dm/launch.rb +40 -0
  36. data/lib/fools/dm/mod.rb +120 -0
  37. data/lib/fools/dm.rb +20 -0
  38. data/lib/fools/interface.rb +32 -0
  39. data/lib/fools/mod.rb +74 -0
  40. data/lib/fools/player/interface.rb +66 -0
  41. data/lib/fools/player/launch.rb +37 -0
  42. data/lib/fools/player/mod.rb +105 -0
  43. data/lib/fools/player.rb +20 -0
  44. data/lib/fools/rules/combat/dice.rb +41 -0
  45. data/lib/fools/rules/combat/rule.rb +130 -0
  46. data/lib/fools/rules/drink/dice.rb +43 -0
  47. data/lib/fools/rules/drink/rule.rb +130 -0
  48. data/lib/fools/rules/romance/dice.rb +62 -0
  49. data/lib/fools/rules/romance/rule.rb +143 -0
  50. data/lib/fools/rules.rb +23 -0
  51. data/lib/fools/sheet/alter.rb +35 -0
  52. data/lib/fools/sheet/schema.rb +59 -0
  53. data/lib/fools/sheet/semantics.rb +129 -0
  54. data/lib/fools/sheet.rb +20 -0
  55. data/lib/fools/util/error.rb +28 -0
  56. data/lib/fools/util.rb +18 -0
  57. data/lib/fools.rb +33 -0
  58. data/permission +16 -0
  59. data/script/console +10 -0
  60. data/script/destroy +14 -0
  61. data/script/generate +14 -0
  62. data/tasks/readme_site.rake +28 -0
  63. data/test/test_fools.rb +11 -0
  64. data/test/test_helper.rb +3 -0
  65. data/website/index.html +103 -0
  66. metadata +213 -0
data/Manifest.txt ADDED
@@ -0,0 +1,65 @@
1
+ COPYING
2
+ History.txt
3
+ Manifest.txt
4
+ PostInstall.txt
5
+ README.rdoc
6
+ Rakefile
7
+ bin/carps_fools
8
+ bin/register_carps_fools
9
+ features/character_sheet.feature
10
+ features/dice.feature
11
+ features/dm_interface.feature
12
+ features/launch_dm.feature
13
+ features/launch_player.feature
14
+ features/player_interface.feature
15
+ features/rules.feature
16
+ features/step_definitions/common_steps.rb
17
+ features/steps/character_sheet.rb
18
+ features/steps/dice.rb
19
+ features/steps/dm_interface.rb
20
+ features/steps/dm_mod.rb
21
+ features/steps/dm_test_mailer.rb
22
+ features/steps/general.rb
23
+ features/steps/interface.rb
24
+ features/steps/launch_dm.rb
25
+ features/steps/launch_player.rb
26
+ features/steps/player_interface.rb
27
+ features/steps/player_mod.rb
28
+ features/steps/player_test_mailer.rb
29
+ features/steps/resource.rb
30
+ features/steps/rules.rb
31
+ features/support/common.rb
32
+ features/support/env.rb
33
+ features/support/matchers.rb
34
+ lib/fools.rb
35
+ lib/fools/dm.rb
36
+ lib/fools/dm/interface.rb
37
+ lib/fools/dm/launch.rb
38
+ lib/fools/dm/mod.rb
39
+ lib/fools/interface.rb
40
+ lib/fools/mod.rb
41
+ lib/fools/player.rb
42
+ lib/fools/player/interface.rb
43
+ lib/fools/player/launch.rb
44
+ lib/fools/player/mod.rb
45
+ lib/fools/rules.rb
46
+ lib/fools/rules/combat/dice.rb
47
+ lib/fools/rules/combat/rule.rb
48
+ lib/fools/rules/drink/dice.rb
49
+ lib/fools/rules/drink/rule.rb
50
+ lib/fools/rules/romance/dice.rb
51
+ lib/fools/rules/romance/rule.rb
52
+ lib/fools/sheet.rb
53
+ lib/fools/sheet/alter.rb
54
+ lib/fools/sheet/schema.rb
55
+ lib/fools/sheet/semantics.rb
56
+ lib/fools/util.rb
57
+ lib/fools/util/error.rb
58
+ permission
59
+ script/console
60
+ script/destroy
61
+ script/generate
62
+ tasks/readme_site.rake
63
+ test/test_fools.rb
64
+ test/test_helper.rb
65
+ website/index.html
data/PostInstall.txt ADDED
@@ -0,0 +1,31 @@
1
+ The Fools. Copyright John Morrice 2010.
2
+
3
+ The Fools is distributed for educational purposes: it is
4
+ intended to be used by programmers, as an aid in
5
+ learning how to write mods for CARPS.
6
+
7
+ The Fools is loosely based on the rules of the Drones RPG:
8
+ http://www.granta.demon.co.uk/drones/
9
+ Copyright Ian Crowther, Sheila Thomas, Victoria Uren 1995-1996
10
+
11
+ You should familiarise yourself with the rules before
12
+ play, though note the following differences and quriks
13
+ present in this CARPS mod:
14
+
15
+ * Your character points are present on the character
16
+ sheet. These are your total character points, rather
17
+ than the points you have not yet spent available.
18
+ Hence you should NOT reduce this value when you spend
19
+ a point.
20
+ As in the Fools rules, you should expect
21
+ the Game Master to tell you how many points you have
22
+ available before the game begins.
23
+
24
+ * Two additional character attributes are added:
25
+ Intoxication and Discomfiture.
26
+ These attributes are to keep track of the transitory
27
+ nature of drunkenness and being the subject of A Sound
28
+ Drubbing, respectively.
29
+ These values range from 0 to -10. 0 indicates
30
+ sobreity or perfect health, while -10 represents a
31
+ highly debilated state.
data/README.rdoc ADDED
@@ -0,0 +1,73 @@
1
+ = The Fools, an example CARPS mod
2
+
3
+ == The Fools is hosted on github:
4
+
5
+ * http://github.com/elginer/fools
6
+
7
+ == Description:
8
+
9
+ The Fools. Copyright John Morrice 2010.
10
+
11
+ The fools is an example mod for CARPS.
12
+
13
+ The Fools is distributed for educational purposes: it is
14
+ intended to be used by programmers, as an aid in
15
+ learning how to write mods for CARPS.
16
+
17
+ The Fools is loosely based on the rules of the Drones RPG:
18
+ http://www.granta.demon.co.uk/drones/
19
+
20
+ The Drones is Copyright Ian Crowther, Sheila Thomas, Victoria Uren 1995-1996
21
+
22
+ You should familiarise yourself with the rules before
23
+ play, though note the following differences
24
+ present in Fools:
25
+
26
+ * Your character points are present on the character
27
+ sheet. These are your total character points, rather
28
+ than the points you have not yet spent available.
29
+ Hence you should NOT reduce this value when you spend
30
+ a point.
31
+ As in the Fools rules, you should expect
32
+ the Game Master to tell you how many points you have
33
+ available before the game begins.
34
+
35
+ * Two additional character attributes are added:
36
+ Intoxication and Discomfiture.
37
+ These attributes are to keep track of the transitory
38
+ nature of drunkenness and being the subject of A Sound
39
+ Drubbing, respectively.
40
+ These values range from 0 to -10. 0 indicates
41
+ sobreity or perfect health, while -10 represents a
42
+ highly debilated state.
43
+
44
+ == Requirements:
45
+
46
+ CARPS
47
+
48
+ == To Install:
49
+
50
+ <tt># This installs the gem</tt>
51
+
52
+ <tt>sudo gem install fools</tt>
53
+
54
+ <tt># This registers the mod with CARPS</tt>
55
+
56
+ <tt>register_carps_fools</tt>
57
+
58
+ == License:
59
+
60
+ Copyright 2010 John Morrice
61
+
62
+ Fools is free software: you can redistribute it and/or modify
63
+ it under the terms of the GNU General Public License as published by
64
+ the Free Software Foundation, either version 3 of the License, or
65
+ (at your option) any later version.
66
+
67
+ Fools is distributed in the hope that it will be useful,
68
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
69
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
70
+ GNU General Public License for more details.
71
+
72
+ You should have received a copy of the GNU General Public License
73
+ along with Fools. If not, see <http://www.gnu.org/licenses/>.
data/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/fools'
6
+
7
+ Hoe.plugin :newgem
8
+ # Hoe.plugin :website
9
+ Hoe.plugin :cucumberfeatures
10
+
11
+ # Generate all the Rake tasks
12
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
+ $hoe = Hoe.spec 'fools' do
14
+ self.developer 'John Morrice', 'spoon@killersmurf.com'
15
+ self.post_install_message = File.read "PostInstall.txt"
16
+ self.summary = 'The Fools for CARPS'
17
+ self.description = "The Fools, copyright Ian Crowther, Sheila Thomas, Victoria Uren 1995-1996.\nsee http://www.granta.demon.co.uk/fools/\nThis is an implementation of The Fools for CARPS."
18
+ self.rubyforge_name = self.name
19
+ self.extra_deps = [['carps','>= 0.2.0']]
20
+
21
+ end
22
+
23
+ require 'newgem/tasks'
24
+ Dir['tasks/**/*.rake'].each { |t| load t }
data/bin/carps_fools ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/local/bin/ruby
2
+ # Copyright 2010 John Morrice
3
+
4
+ # This file is part of The Fools.
5
+
6
+ # The Fools is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+
11
+ # The Fools is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with The Fools. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ require "carps"
20
+
21
+ require "fools"
22
+
23
+ include CARPS
24
+ # A hack
25
+ include CARPS::Dice
26
+
27
+ CARPS::Launcher::launch Fools
@@ -0,0 +1,35 @@
1
+ #!/usr/local/bin/ruby
2
+ # Copyright 2010 John Morrice
3
+
4
+ # This file is part of The Fools.
5
+
6
+ # The Fools is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+
11
+ # The Fools is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with The Fools. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ require "carps"
20
+
21
+ require "yaml"
22
+
23
+ # Update the CARPS mod file
24
+ filename = CARPS::root_config + "mods.yaml"
25
+ contents = ""
26
+ contents = File.read filename
27
+ mods = {}
28
+ unless contents.empty?
29
+ mods = YAML::load contents
30
+ end
31
+ mods["fools"] = "carps_fools"
32
+ new_mods = mods.to_yaml
33
+ mod_file = File.open filename, "w"
34
+ mod_file.write new_mods
35
+ mod_file.close
@@ -0,0 +1,35 @@
1
+ Feature: Character sheet schema
2
+ As Fools users,
3
+ in order to exploit the features of CARPS,
4
+ The Fools needs to have a character sheet schema.
5
+
6
+ Scenario: valid sheet
7
+ Given the Fools' verifier
8
+ When a valid sheet is provided
9
+ Then accept the character sheet
10
+
11
+ Scenario: syntactically invalid sheet
12
+ Given the Fools' verifier
13
+ When a syntactically invalid sheet is provided
14
+ Then do not accept the character sheet
15
+
16
+ Scenario: out of bounds sheet
17
+ Given the Fools' verifier
18
+ When an out of bounds sheet is provided
19
+ Then do not accept the character sheet
20
+
21
+ Scenario: sheet on limit
22
+ Given the Fools' verifier
23
+ When a character sheet using exactly 8 character points is provided
24
+ Then accept the character sheet
25
+
26
+ Scenario: sheet out of limit
27
+ Given the Fools' verifier
28
+ When a character sheet using more than 8 character points is provided
29
+ Then do not accept the character sheet
30
+
31
+ Scenario: sheet under limit
32
+ Given the Fools' verifier
33
+ When a character sheet using less than 8 character points is provided
34
+ Then accept the character sheet
35
+
@@ -0,0 +1,28 @@
1
+ Feature: Non-determinism in the fools
2
+
3
+ As a Fools user,
4
+ I expect this mod to behave
5
+ as described by the game manual,
6
+ with respect to non-determinism.
7
+
8
+ # As yet I haven't done the maths to prove these work
9
+ # However, these tests will prevent the game from crashing.
10
+ Scenario: drink roll
11
+ Given a hash of the dice rolls
12
+ Given a roll is made for drunkenness
13
+ Then show the odds
14
+
15
+ Scenario: combat roll
16
+ Given a hash of the dice rolls
17
+ Given a roll is made for combat
18
+ Then show the odds
19
+
20
+ Scenario: romantic resistance roll
21
+ Given a hash of the dice rolls
22
+ Given a roll is made for romance
23
+ Then show the odds
24
+
25
+ Scenario: talking sense roll
26
+ Given a hash of the dice rolls
27
+ Given a roll is made for sense
28
+ Then show the odds
@@ -0,0 +1,19 @@
1
+ Feature: DM Interface
2
+ As a Fools DM,
3
+ I need control!
4
+
5
+ Scenario: present user interface
6
+ Given carps is initialized with test/server
7
+ Given a DM test mailer
8
+ Given a resource manager
9
+ Given the DM mod for campaign detective
10
+ Given the DM user interface
11
+ Then present the interface to the user
12
+
13
+ Scenario: test DM inputs
14
+ Given carps is initialized with test/server
15
+ Given a DM test mailer
16
+ Given a resource manager
17
+ Given the DM mod for campaign detective
18
+ Given the DM user interface
19
+ Then test all the DM user inputs
@@ -0,0 +1,10 @@
1
+ Feature: launch player
2
+ As a seriously minded Dungeon Master
3
+ I require launching
4
+ of this wonderful CARPS mod.
5
+
6
+ Scenario: launch DM
7
+ Given a DM test mailer
8
+ Given a campaign called snarkle
9
+ Given carps is initialized with test/client
10
+ Then launch the DM interface
@@ -0,0 +1,9 @@
1
+ Feature: launch player
2
+ As a Drone-to-be,
3
+ I require launching
4
+ of this wonderful CARPS mod.
5
+
6
+ Scenario: launch player
7
+ Given a test player mailer
8
+ Given carps is initialized with test/client
9
+ Then launch the player interface
@@ -0,0 +1,19 @@
1
+ Feature: Player Interface
2
+ As a Fools Player,
3
+ I need to speak to the DM,
4
+ And do other things too!
5
+
6
+ Scenario: present user interface
7
+ Given carps is initialized with test/client
8
+ Given a test player mailer
9
+ Given the Player mod
10
+ Given the Player user interface
11
+ Then present the interface to the user
12
+
13
+ Scenario: test player inputs
14
+ Given carps is initialized with test/server
15
+ Given a test player mailer
16
+ Given the Player mod
17
+ Given the Player user interface
18
+ When a character sheet is provided for the player
19
+ Then test all the Player user inputs
@@ -0,0 +1,66 @@
1
+ Feature: Fools rules
2
+
3
+ As a Fools user,
4
+ I expect the mod to faithfully
5
+ implement the rules as described
6
+ in the Fools manual.
7
+
8
+ Scenario: drinking odds
9
+ Given a hash of the rules
10
+ When the rule is drunkenness
11
+ Given a character sheet for an ordinary drone
12
+ Then show the odds for the drunk rule
13
+ Given a character sheet for a drone with a high tolerance for alcohol
14
+ Then show the odds for the drunk rule
15
+
16
+ Scenario: drinking application
17
+ Given a hash of the rules
18
+ When the rule is drunkenness
19
+ Given a character sheet for an ordinary drone
20
+ Then apply the drunk rule
21
+ Then display the character sheet
22
+
23
+ Scenario: combat odds
24
+ Given a hash of the rules
25
+ When the rule is combat
26
+ Given a character sheet for an ordinary drone
27
+ Given also a character sheet for a fit drone
28
+ Then show the odds for the combat rule
29
+
30
+ Scenario: combat application
31
+ Given a hash of the rules
32
+ When the rule is combat
33
+ Given a character sheet for an ordinary drone
34
+ Given also a character sheet for a fit drone
35
+ Then apply the combat rule
36
+ Then display the character sheet
37
+
38
+ Scenario: romantic resistance application
39
+ Given a hash of the rules
40
+ When the rule is romance
41
+ Given a character sheet for an ordinary drone
42
+ Given a character sheet for teh hawt wimenz
43
+ Then apply the romance rule
44
+
45
+ Scenario: romantic resistance odds
46
+ Given a hash of the rules
47
+ When the rule is romance
48
+ Given a character sheet for an ordinary drone
49
+ Given a character sheet for teh hawt wimenz
50
+ Then show the odds for the romance rule
51
+
52
+ Scenario: sense application
53
+ Given a hash of the rules
54
+ When the rule is sense
55
+ Given a character sheet for an ordinary drone
56
+ Given a character sheet for teh hawt wimenz
57
+ Given also a character sheet for a fit drone
58
+ Then apply the sense rule
59
+
60
+ Scenario: sense odds
61
+ Given a hash of the rules
62
+ When the rule is sense
63
+ Given a character sheet for an ordinary drone
64
+ Given a character sheet for teh hawt wimenz
65
+ Given also a character sheet for a fit drone
66
+ Then show the odds for the sense rule
@@ -0,0 +1,168 @@
1
+ Given /^this project is active project folder/ do
2
+ @active_project_folder = File.expand_path(File.dirname(__FILE__) + "/../..")
3
+ end
4
+
5
+ Given /^env variable \$([\w_]+) set to "(.*)"/ do |env_var, value|
6
+ ENV[env_var] = value
7
+ end
8
+
9
+ Given /"(.*)" folder is deleted/ do |folder|
10
+ in_project_folder { FileUtils.rm_rf folder }
11
+ end
12
+
13
+ When /^I invoke "(.*)" generator with arguments "(.*)"$/ do |generator, arguments|
14
+ @stdout = StringIO.new
15
+ in_project_folder do
16
+ if Object.const_defined?("APP_ROOT")
17
+ APP_ROOT.replace(FileUtils.pwd)
18
+ else
19
+ APP_ROOT = FileUtils.pwd
20
+ end
21
+ run_generator(generator, arguments.split(' '), SOURCES, :stdout => @stdout)
22
+ end
23
+ File.open(File.join(@tmp_root, "generator.out"), "w") do |f|
24
+ @stdout.rewind
25
+ f << @stdout.read
26
+ end
27
+ end
28
+
29
+ When /^I run executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
30
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
31
+ in_project_folder do
32
+ system "#{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
33
+ end
34
+ end
35
+
36
+ When /^I run project executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
37
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
38
+ in_project_folder do
39
+ system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
40
+ end
41
+ end
42
+
43
+ When /^I run local executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
44
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
45
+ executable = File.expand_path(File.join(File.dirname(__FILE__), "/../../bin", executable))
46
+ in_project_folder do
47
+ system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
48
+ end
49
+ end
50
+
51
+ When /^I invoke task "rake (.*)"/ do |task|
52
+ @stdout = File.expand_path(File.join(@tmp_root, "tests.out"))
53
+ in_project_folder do
54
+ system "rake #{task} --trace > #{@stdout} 2> #{@stdout}"
55
+ end
56
+ end
57
+
58
+ Then /^folder "(.*)" (is|is not) created/ do |folder, is|
59
+ in_project_folder do
60
+ File.exists?(folder).should(is == 'is' ? be_true : be_false)
61
+ end
62
+ end
63
+
64
+ Then /^file "(.*)" (is|is not) created/ do |file, is|
65
+ in_project_folder do
66
+ File.exists?(file).should(is == 'is' ? be_true : be_false)
67
+ end
68
+ end
69
+
70
+ Then /^file with name matching "(.*)" is created/ do |pattern|
71
+ in_project_folder do
72
+ Dir[pattern].should_not be_empty
73
+ end
74
+ end
75
+
76
+ Then /^file "(.*)" contents (does|does not) match \/(.*)\// do |file, does, regex|
77
+ in_project_folder do
78
+ actual_output = File.read(file)
79
+ (does == 'does') ?
80
+ actual_output.should(match(/#{regex}/)) :
81
+ actual_output.should_not(match(/#{regex}/))
82
+ end
83
+ end
84
+
85
+ Then /gem file "(.*)" and generated file "(.*)" should be the same/ do |gem_file, project_file|
86
+ File.exists?(gem_file).should be_true
87
+ File.exists?(project_file).should be_true
88
+ gem_file_contents = File.read(File.dirname(__FILE__) + "/../../#{gem_file}")
89
+ project_file_contents = File.read(File.join(@active_project_folder, project_file))
90
+ project_file_contents.should == gem_file_contents
91
+ end
92
+
93
+ Then /^(does|does not) invoke generator "(.*)"$/ do |does_invoke, generator|
94
+ actual_output = File.read(@stdout)
95
+ does_invoke == "does" ?
96
+ actual_output.should(match(/dependency\s+#{generator}/)) :
97
+ actual_output.should_not(match(/dependency\s+#{generator}/))
98
+ end
99
+
100
+ Then /help options "(.*)" and "(.*)" are displayed/ do |opt1, opt2|
101
+ actual_output = File.read(@stdout)
102
+ actual_output.should match(/#{opt1}/)
103
+ actual_output.should match(/#{opt2}/)
104
+ end
105
+
106
+ Then /^I should see "([^\"]*)"$/ do |text|
107
+ actual_output = File.read(@stdout)
108
+ actual_output.should contain(text)
109
+ end
110
+
111
+ Then /^I should see$/ do |text|
112
+ actual_output = File.read(@stdout)
113
+ actual_output.should contain(text)
114
+ end
115
+
116
+ Then /^I should not see$/ do |text|
117
+ actual_output = File.read(@stdout)
118
+ actual_output.should_not contain(text)
119
+ end
120
+
121
+ Then /^I should see exactly$/ do |text|
122
+ actual_output = File.read(@stdout)
123
+ actual_output.should == text
124
+ end
125
+
126
+ Then /^I should see all (\d+) tests pass/ do |expected_test_count|
127
+ expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
128
+ actual_output = File.read(@stdout)
129
+ actual_output.should match(expected)
130
+ end
131
+
132
+ Then /^I should see all (\d+) examples pass/ do |expected_test_count|
133
+ expected = %r{^#{expected_test_count} examples?, 0 failures}
134
+ actual_output = File.read(@stdout)
135
+ actual_output.should match(expected)
136
+ end
137
+
138
+ Then /^yaml file "(.*)" contains (\{.*\})/ do |file, yaml|
139
+ in_project_folder do
140
+ yaml = eval yaml
141
+ YAML.load(File.read(file)).should == yaml
142
+ end
143
+ end
144
+
145
+ Then /^Rakefile can display tasks successfully/ do
146
+ @stdout = File.expand_path(File.join(@tmp_root, "rakefile.out"))
147
+ in_project_folder do
148
+ system "rake -T > #{@stdout} 2> #{@stdout}"
149
+ end
150
+ actual_output = File.read(@stdout)
151
+ actual_output.should match(/^rake\s+\w+\s+#\s.*/)
152
+ end
153
+
154
+ Then /^task "rake (.*)" is executed successfully/ do |task|
155
+ @stdout.should_not be_nil
156
+ actual_output = File.read(@stdout)
157
+ actual_output.should_not match(/^Don't know how to build task '#{task}'/)
158
+ actual_output.should_not match(/Error/i)
159
+ end
160
+
161
+ Then /^gem spec key "(.*)" contains \/(.*)\// do |key, regex|
162
+ in_project_folder do
163
+ gem_file = Dir["pkg/*.gem"].first
164
+ gem_spec = Gem::Specification.from_yaml(`gem spec #{gem_file}`)
165
+ spec_value = gem_spec.send(key.to_sym)
166
+ spec_value.to_s.should match(/#{regex}/)
167
+ end
168
+ end