Skip to content

Commit

Permalink
teaspoon with coffeescript
Browse files Browse the repository at this point in the history
  • Loading branch information
tadyjp committed Mar 16, 2014
1 parent b5c44df commit 89ea2d0
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 10 deletions.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -90,6 +90,7 @@ group :development, :test do
gem 'database_rewinder'

gem 'teaspoon'
gem 'guard-teaspoon'
end

group :test do
Expand Down
4 changes: 4 additions & 0 deletions Gemfile.lock
Expand Up @@ -143,6 +143,9 @@ GEM
guard-rubocop (1.0.2)
guard (~> 2.0)
rubocop (~> 0.10)
guard-teaspoon (0.0.4)
guard (>= 1.6.1)
teaspoon (>= 0.5.3)
hashie (2.0.5)
hike (1.2.3)
htmlentities (4.3.1)
Expand Down Expand Up @@ -386,6 +389,7 @@ DEPENDENCIES
github-markdown
guard-rspec
guard-rubocop
guard-teaspoon
i18n_generators
jbuilder
jquery-rails
Expand Down
4 changes: 4 additions & 0 deletions Guardfile
Expand Up @@ -16,3 +16,7 @@ guard :rspec do
watch(%r{^spec/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end

guard :teaspoon do
watch(%r{^app/assets/javascripts/(.+).js}) { |m| "spec/javascripts/#{m[1]}_spec.js.coffee" }
watch(%r{^spec/javascripts/(.*)})
end
17 changes: 16 additions & 1 deletion app/assets/javascripts/modules/mod-md-editor.js.coffee
@@ -1,14 +1,29 @@
# TODO:
# mod-mdEditorがページ内に複数あった場合の処理

@_mod_md_editor = {}

class @_mod_md_editor.TextareaText
constructor: (@text, @sel_start, @sel_end) ->

total_line_num: ->
99
current_line_num: ->
80
current_line_head_pos: ->
70
current_pos_in_line: ->
4


$.fn.extend
mod_mdEditor: (options) ->
settings =
# preview api url
end_point: ''
settings = $.extend settings, options

return @each ()->
return @each () ->

$root = $(@)
$textarea = $root.find('.mod-mdEditor-textarea')
Expand Down
9 changes: 0 additions & 9 deletions spec/javascripts/mod-md-editor_spec.js

This file was deleted.

11 changes: 11 additions & 0 deletions spec/javascripts/modules/mod-md-editor_spec.js.coffee
@@ -0,0 +1,11 @@
#= require modules/mod-md-editor

describe "mod-md-editor", ->

text = new _mod_md_editor.TextareaText("aaaaaaaa\nbbbbbb\n\ncccccc", 10, 18)

it "_mod_md_editor.parse", ->
expect(text.total_line_num()).toBe(4)
expect(text.current_line_num()).toBe()
expect(text.current_line_head_pos()).toBe(4)
expect(text.current_pos_in_line()).toBe(4)

0 comments on commit 89ea2d0

Please sign in to comment.