Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mrproper and string spec #21

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bundler_args: --without guard
rvm:
- 1.9.2
- 1.9.3
Expand Down
9 changes: 4 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ source 'https://rubygems.org'

gemspec

group :development, :test do
group :darwin do
gem 'rb-fsevent'
gem 'growl'
end
group :guard do
gem 'guard'
gem 'guard-cane'
gem 'guard-rspec'
end
2 changes: 2 additions & 0 deletions lib/string.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
class String
def wrap(width)
width = 1 if width < 1

split("\n").collect { |line|
if line.length > width
line.gsub(/(.{1,#{width}})(\s+|$)/, "\\1\n").strip
Expand Down
19 changes: 19 additions & 0 deletions spec/lib/string_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,24 @@

it { string.wrap(1).should == "One\ntwo\nthree\nfour\nfive" }
it { string.wrap(10).should == "One two\nthree four\nfive" }

context "when wrapping at 0" do
it "wraps at 1" do
string.wrap(0).should == "One\ntwo\nthree\nfour\nfive"
end
end
end
end

require 'mrproper'

properties String do
data [String, Integer]

property '#wrap' do |string, wrap_at|
result = string.wrap(wrap_at)

assert_not_empty result
assert result.length == string.length
end
end
4 changes: 1 addition & 3 deletions tp.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ Gem::Specification.new do |gem|
gem.add_dependency "thor", "~> 0.17"

gem.add_development_dependency "cane"
gem.add_development_dependency "guard"
gem.add_development_dependency "guard-rspec"
gem.add_development_dependency "guard-cane"
gem.add_development_dependency "mrproper"
gem.add_development_dependency "rake"
gem.add_development_dependency "rspec"
gem.add_development_dependency "simplecov" if RUBY_DESCRIPTION.start_with? "ruby"
Expand Down