Permalink
Browse files

0.2.8 release, fixed cute bug where notes couldn't be amended in editor

  • Loading branch information...
1 parent b6b3033 commit d6eec12d78dc6495830f64cf97885656a6f9d6dc @banister committed Dec 12, 2012
Showing with 29 additions and 11 deletions.
  1. +1 −1 lib/pry-note/commands.rb
  2. +1 −1 lib/pry-note/version.rb
  3. +2 −2 pry-note.gemspec
  4. +25 −7 test/test_pry_note.rb
View
2 lib/pry-note/commands.rb
@@ -151,7 +151,7 @@ def reedit_note(name, message=nil)
if message
new_content = message
else
- old_content = notes[co_name][note_number.to_i - 1]
+ old_content = notes[co_name][note_number_s.to_i - 1]
new_content = edit_note(co_name, old_content.to_s)
end
View
2 lib/pry-note/version.rb
@@ -1,3 +1,3 @@
module PryNote
- VERSION = "0.2.7"
+ VERSION = "0.2.8"
end
View
4 pry-note.gemspec
@@ -2,11 +2,11 @@
Gem::Specification.new do |s|
s.name = "pry-note"
- s.version = "0.2.7"
+ s.version = "0.2.8"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["John Mair (banisterfiend)"]
- s.date = "2012-12-06"
+ s.date = "2012-12-12"
s.description = "Ease refactoring and exploration by attaching notes to methods and classes in Pry"
s.email = "jrmair@gmail.com"
s.files = ["README.md", "Rakefile", "lib/pry-note.rb", "lib/pry-note/commands.rb", "lib/pry-note/hooks.rb", "lib/pry-note/version.rb", "pry-note.gemspec", "test/helper.rb", "test/test_pry_note.rb"]
View
32 test/test_pry_note.rb
@@ -183,13 +183,31 @@ def ping
end
end
- describe "-m switch (used to amend note inline and bypass editor)" do
- it 'should amend the content of a note' do
- @t.process_command "note add PryNote::TestClass -m 'my note1'"
- @t.process_command "note edit PryNote::TestClass:1 -m 'bing'"
- PryNote.notes["PryNote::TestClass"].count.should == 1
- PryNote.notes["PryNote::TestClass"].first.should =~ /bing/
- end
+ it 'should amend the content of a note with -m' do
+ @t.process_command "note add PryNote::TestClass -m 'my note1'"
+ @t.process_command "note edit PryNote::TestClass:1 -m 'bing'"
+ PryNote.notes["PryNote::TestClass"].count.should == 1
+ PryNote.notes["PryNote::TestClass"].first.should =~ /bing/
+ end
+
+ # this is a regression against a bug which made it impossible to ever
+ # edit a note in an editor
+ it 'should not raise an exception when amending content without -m' do
+ Pry.config.editor = proc { nil }
+ @t.process_command "note add PryNote::TestClass -m 'my note1'"
+
+ capture_exception do
+ @t.process_command "note edit PryNote::TestClass:1"
+ end.is_a?(Exception).should == false
+ end
+
+ it 'should leave note unchanged when no changes are made in editor' do
+ Pry.config.editor = proc { nil }
+ @t.process_command "note add PryNote::TestClass -m 'my note1'"
+ @t.process_command "note edit PryNote::TestClass:1"
+
+ PryNote.notes["PryNote::TestClass"].count.should == 1
+ PryNote.notes["PryNote::TestClass"].first.should =~ /my note1/
end
end

0 comments on commit d6eec12

Please sign in to comment.