Skip to content

Commit

Permalink
Merge pull request #93 from davetron5000/fix-test-unit-issue-for-2.2
Browse files Browse the repository at this point in the history
Fix test unit issue for 2.2
  • Loading branch information
davetron5000 committed Jun 7, 2015
2 parents 9ce6893 + 060234a commit 0605c09
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.0
2.2.2
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ notifications:
on_success: always
script: 'bundle exec rake'
rvm:
- 1.9.2
- 1.9.3
- 2.0.0
- 2.1.0
- 2.2.0
- jruby-18mode
- 2.2.2
- jruby-19mode
15 changes: 13 additions & 2 deletions bin/methadone
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ main do |app_name|

#Ensure the gemspec file mentions the correct license
gemspec_content = File.read(gemspec)
gemspec_content.gsub!(/(^\s*#{gem_variable}\.license\s*=\s*).*/,"\\1#{license.to_s.inspect}")
if gemspec_content =~ /(^\s*#{gem_variable}\.license\s*=\s*).*/
gemspec_content.gsub!(/(^\s*#{gem_variable}\.license\s*=\s*).*/,"\\1#{license.to_s.inspect}")
else
gemspec_content.gsub!(/(^\s*#{gem_variable}\.name\s*=\s*.*)/,"\\1\n #{gem_variable}.license=#{license.to_s.inspect}")
end
File.open(gemspec,'w') {|f| f.write gemspec_content }


Expand All @@ -82,10 +86,17 @@ main do |app_name|
" #{gem_variable}.add_development_dependency('rake')",
" #{gem_variable}.add_dependency('methadone', '~> #{Methadone::VERSION}')",
], :before => /^end\s*$/
ruby_major,ruby_minor,ruby_patch = RUBY_VERSION.split(/\./).map(&:to_i)

if ruby_major >= 2 && ruby_minor >= 2
add_to_file gemspec, [
" #{gem_variable}.add_development_dependency('test-unit')",
], :before => /^end\s*$/
end

if rspec
add_to_file gemspec, [
" #{gem_variable}.add_development_dependency('rspec', '~> 2.99')",
" #{gem_variable}.add_development_dependency('rspec', '~> 3')",
], :before => /^end\s*$/
end

Expand Down
30 changes: 13 additions & 17 deletions features/bootstrap.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Feature: Bootstrap a new command-line app
Given the directory "tmp/newgem" does not exist
And the directory "tmp/new-gem" does not exist

@wip
Scenario: Bootstrap a new app from scratch
When I successfully run `methadone tmp/newgem`
Then the following directories should exist:
Expand Down Expand Up @@ -38,6 +39,7 @@ Feature: Bootstrap a new command-line app
And the file "tmp/newgem/newgem.gemspec" should match /add_development_dependency\('rdoc'/
And the file "tmp/newgem/newgem.gemspec" should match /add_development_dependency\('rake'/
And the file "tmp/newgem/newgem.gemspec" should match /add_dependency\('methadone'/
And the file "tmp/newgem/newgem.gemspec" should include "test-unit" if needed
And the file "tmp/newgem/newgem.gemspec" should use the same block variable throughout
Given I cd to "tmp/newgem"
And my app's name is "newgem"
Expand All @@ -51,15 +53,15 @@ Feature: Bootstrap a new command-line app
And the banner should document that this app takes no arguments
When I successfully run `rake -T -I../../lib`
Then the output should match /rake clean/
Then the output should match /rake clobber/
Then the output should match /rake clobber_rdoc/
Then the output should match /rake features/
Then the output should match /rake rdoc/
Then the output should match /rake release/
Then the output should match /rake rerdoc/
Then the output should match /rake test/
And the output should match /rake install # Build and install newgem-0.0.1.gem into system gems/
And the output should match /rake build # Build newgem-0.0.1.gem into the pkg directory/
And the output should match /rake clobber/
And the output should match /rake clobber_rdoc/
And the output should match /rake features/
And the output should match /rake rdoc/
And the output should match /rake release/
And the output should match /rake rerdoc/
And the output should match /rake test/
And the output should match /rake install/
And the output should match /rake build/
When I run `rake -I../../../../lib`
Then the exit status should be 0
And the output should match /1 tests, 1 assertions, 0 failures, 0 errors/
Expand Down Expand Up @@ -100,21 +102,15 @@ Feature: Bootstrap a new command-line app
And I cd to "tmp/new-gem"
And my app's name is "new-gem"
When I successfully run `bin/new-gem --version` with "lib" in the library path
Then the output should contain:
"""
new-gem version 0.0.1
"""
Then the output should match /new-gem version 0/

Scenario: Version flag can be used to only show the app version with a custom format
Given I successfully run `methadone tmp/new-gem`
And "bin/new-gem" has configured version to show only the version with a custom format and not help
And I cd to "tmp/new-gem"
And my app's name is "new-gem"
When I successfully run `bin/new-gem --version` with "lib" in the library path
Then the output should contain:
"""
new-gem V0.0.1
"""
Then the output should match /new-gem V0/

Scenario: Won't squash an existing dir
When I successfully run `methadone tmp/newgem`
Expand Down
12 changes: 3 additions & 9 deletions features/rspec_support.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,11 @@ Feature: Bootstrap a new command-line app using RSpec instead of Test::Unit
|tmp/newgem/test |
And the following files should exist:
|tmp/newgem/spec/something_spec.rb |
And the file "tmp/newgem/newgem.gemspec" should match /add_development_dependency\('rspec', '~> 2.99'/
And the file "tmp/newgem/newgem.gemspec" should match /add_development_dependency\('rspec'/
When I cd to "tmp/newgem"
And I successfully run `rake -T -I../../lib`
Then the output should contain:
"""
rake spec # Run RSpec code examples
"""
And the output should not contain:
"""
rake test # Run tests
"""
Then the output should match /rake spec/
And the output should not match /rake test/
When I run `rake spec -I../../lib`
Then the exit status should be 0
And the output should contain:
Expand Down
6 changes: 6 additions & 0 deletions features/step_definitions/bootstrap_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,9 @@
end
end
end

Then /^the file "(.*?)" should include "(.*?)" if needed$/ do |file, gemname|
if RUBY_VERSION =~ /^2\./ && RUBY_VERSION !~ /^2.0/ && RUBY_VERSION !~ /^2.1/
step %{the file "#{file}" should match /add_development_dependency\\('#{gemname}/}
end
end
2 changes: 1 addition & 1 deletion methadone.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ Gem::Specification.new do |s|
s.add_development_dependency("clean_test")
s.add_development_dependency("mocha", "0.13.2")
s.add_development_dependency("sdoc")
s.add_development_dependency("rspec", "~> 3.0.0")
s.add_development_dependency("rspec", "~> 3")
s.add_development_dependency("i18n", "= 0.6.1")
end
2 changes: 1 addition & 1 deletion templates/rspec/spec/something_spec.rb.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe "TestSomething" do
it "should be true" do
true.should == true
expect(true).to eq(true)
end
end

0 comments on commit 0605c09

Please sign in to comment.