Skip to content

Commit 2888648

Browse files
committed
Removed Widget example
1 parent 32bf4d2 commit 2888648

File tree

9 files changed

+12
-136
lines changed

9 files changed

+12
-136
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -416,10 +416,11 @@ Most of all it should be simple to use so if you have any problems please drop m
416416
* Removed monkey patch from FileUtils. It was more philosophical than necessary.
417417
* Changed terminal coloring gem back to official the term-ansicolor from my own fork now that my changes have been pulled into it.
418418
* Code clean up. While mostly not a real refactor I've separated out the code into functional groups (aka files).
419+
* Removed Widget example - it was making the examples too tightly coupled to HashModel.
420+
* Removed Cucumber features.
419421

420422
To do
421423

422-
* Removed Widget example - which was making the examples too tightly coupled to HashModel.
423424
* Added some more examples.
424425
* Updated docs to reflect changes.
425426

commandable.gemspec

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ EOF
2222
s.add_dependency("term-ansicolor", "~>1.0.7")
2323

2424
s.add_development_dependency("rspec", "~>2.5")
25-
s.add_development_dependency("cucumber", "~>0.10")
26-
s.add_development_dependency("aruba", "~>0.3")
25+
#buns.add_development_dependency("aruba", "~>0.3")
2726

2827
s.files = `git ls-files`.split("\n")
2928
s.test_files = `git ls-files -- {spec,autotest}/*`.split("\n")

features/ansicolor.feature

-11
This file was deleted.

features/copy_examples.feature

-13
This file was deleted.

features/download_widget.feature

-18
This file was deleted.

features/setup/env.rb

-5
This file was deleted.

features/step-definitions/step-definitions.rb

-15
This file was deleted.

lib/commandable/app_controller.rb

+9-40
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,17 @@
11
module Commandable
2-
2+
33
# A helper to display the read me file and generate an example app
44
class AppController
5-
WIDGET_GITHUB ||= "://github.com/mikbe/widget"
65

76
class << self
87
extend Commandable
9-
8+
109
# Displays the readme file
1110
command "displays the readme file", :default
1211
def readme
13-
`open #{File.expand_path((File.dirname(__FILE__) + '/../../readme.markdown'))}`
14-
end
15-
16-
command "Downloads a fully working app demonstrating how\nto use Commandable with RSpec and Cucumber"
17-
# Creates a simple example app demonstrating a fully working app
18-
def widget(path="./widget")
19-
# Test for Git
20-
unless git_installed?
21-
puts "Git must be installed to download Widget (You're a developer and you don't have Git installed?)"
22-
return
23-
end
24-
# Git already has all of its own error trapping so
25-
# it would be horrible coupling and duplication
26-
# of effort to do anything on my end for failures.
27-
puts "\nUnable to download Widget. You can find the souce code here:\nhttps#{WIDGET_GITHUB}" unless download_widget(path) == 0
12+
`open #{File.expand_path((File.dirname(__FILE__) + '/../../readme.md'))}`
2813
end
2914

30-
# Downloads Widget from the git repository
31-
# This is external to the widget command so it can be stubbed for testing
32-
def download_widget(path)
33-
`git clone git#{WIDGET_GITHUB}.git #{path}`
34-
$?.exitstatus
35-
end
36-
37-
# Checks to see if Git is installed
38-
# This is external to the widget command so it can be stubbed for testing
39-
def git_installed?
40-
!`git --version`.chomp.match(/^git version/i).nil?
41-
end
42-
4315
command "Copies the test classes to a folder so\nyou can see a bunch of small examples"
4416
# Copies the test classes to a folder so you can see a bunch of small examples
4517
def examples(path="./examples")
@@ -49,30 +21,27 @@ def examples(path="./examples")
4921
command "Will raise a programmer error, not a user error\nso you can see what happens when you have bad code"
5022
# Causes an error so you can see what it will look like if you have an error in your code.
5123
def error
52-
raise Exception, "An example of a non-user error caused by your bad code trapped in Commandable.execute()"
24+
raise Exception, "An example of what an error looks like if you make a mistake using Commandable."
5325
end
54-
26+
5527
command "Application Version", :xor
5628
# Version
5729
def v
5830
puts "Commandable: #{Commandable::VERSION}"
5931
end
6032
command "Application Version", :xor
6133
alias :version :v
62-
34+
6335
private
64-
36+
6537
def copy_dir(source, dest)
6638
files = Dir.glob("#{source}/**")
6739
mkdir_p dest
6840
cp_r files, dest
6941
end
7042

71-
7243
end
73-
74-
75-
44+
7645
end
77-
46+
7847
end

spec/commandable/app_controller_spec.rb

-31
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,6 @@
1818
# or it won't be able to use the settings
1919
load 'commandable/app_controller.rb'
2020
}
21-
22-
context "when running the widget command" do
23-
24-
context "when git isn't installed" do
25-
26-
it "should inform them they need Git" do
27-
Commandable::AppController.stub(:git_installed?){false}
28-
execute_output_s(["widget"]).should match(/Git must be installed/)
29-
end
30-
31-
end
32-
context "when git is installed" do
33-
34-
context "and it's able to install the files" do
35-
it "should download Widget from github" do
36-
Commandable::AppController.stub(:download_widget){0}
37-
execute_output_s(["widget"]).should_not include("Unable to download")
38-
end
39-
end
40-
41-
context "but it's not able to install the files" do
42-
it "should download Widget from github" do
43-
Commandable::AppController.stub(:download_widget){1}
44-
execute_output_s(["widget"]).should include("Unable to download")
45-
end
46-
end
4721

48-
49-
end
50-
51-
52-
end
5322

5423
end

0 commit comments

Comments
 (0)