Skip to content

Commit ca52046

Browse files
committed
correct readme on running spec. add tests
1 parent 787cf92 commit ca52046

5 files changed

Lines changed: 158 additions & 2 deletions

File tree

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source 'http://rubygems.org'
2+
3+
gem 'rspec'
4+
gem 'vimrunner' # http://mudge.name/2012/04/18/testing-vim-plugins-on-travis-ci-with-rspec-and-vimrunner.html

Gemfile.lock

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
GEM
2+
remote: http://rubygems.org/
3+
specs:
4+
diff-lcs (1.2.5)
5+
rspec (2.14.1)
6+
rspec-core (~> 2.14.0)
7+
rspec-expectations (~> 2.14.0)
8+
rspec-mocks (~> 2.14.0)
9+
rspec-core (2.14.8)
10+
rspec-expectations (2.14.5)
11+
diff-lcs (>= 1.1.3, < 2.0)
12+
rspec-mocks (2.14.6)
13+
vimrunner (0.3.1)
14+
15+
PLATFORMS
16+
ruby
17+
18+
DEPENDENCIES
19+
rspec
20+
vimrunner

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ So, if you're anywhere inside a spec:
6464

6565
:AngularRunSpec
6666

67-
or the "go run spec" mapping:
67+
or the "run spec" mapping:
6868

69-
grs
69+
<leader>rs
7070

7171
will toggle the spec between "it" and "iit." This works especially well if
7272
you have a karma watch going. See the [screencast][screencast].

spec/angular_spec.rb

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
require "spec_helper"
2+
3+
describe "angular vim" do
4+
5+
specify "html tidy syntastic ignores" do
6+
value_of_variable = vim.echo('g:syntastic_html_tidy_ignore_errors')
7+
value_of_variable.should eq("[' proprietary attribute \"ng-', ' proprietary attribute \"ui-view', '<div> proprietary attribute \"src']")
8+
end
9+
10+
specify "run spec command with one spec" do
11+
write_file('test.js', <<-EOF)
12+
it('should work', function() {
13+
var actualThing = 'cow';
14+
expect(actualThing).toEqual('cow');
15+
});
16+
EOF
17+
18+
vim.edit 'test.js'
19+
vim.command 'AngularRunSpec'
20+
#vim.write # the AngularRunSpec writes the file
21+
22+
IO.read('test.js').strip.should eq normalize_string_indent(<<-EOF)
23+
iit('should work', function() {
24+
var actualThing = 'cow';
25+
expect(actualThing).toEqual('cow');
26+
});
27+
EOF
28+
end
29+
30+
specify "run spec command with two specs" do
31+
write_file('test.js', <<-EOF)
32+
it('should work', function() {
33+
var actualThing = 'cow';
34+
expect(actualThing).toEqual('cow');
35+
});
36+
37+
it('should also work', function() {
38+
var actualThing = 'cow';
39+
expect(actualThing).toEqual('cow');
40+
});
41+
EOF
42+
43+
vim.edit 'test.js'
44+
vim.normal '5j'
45+
vim.command 'AngularRunSpec'
46+
47+
IO.read('test.js').strip.should eq normalize_string_indent(<<-EOF)
48+
it('should work', function() {
49+
var actualThing = 'cow';
50+
expect(actualThing).toEqual('cow');
51+
});
52+
53+
iit('should also work', function() {
54+
var actualThing = 'cow';
55+
expect(actualThing).toEqual('cow');
56+
});
57+
EOF
58+
end
59+
60+
specify "run spec command untoggles" do
61+
write_file('test.js', <<-EOF)
62+
iit('should work', function() {
63+
var actualThing = 'cow';
64+
expect(actualThing).toEqual('cow');
65+
});
66+
67+
it('should also work', function() {
68+
var actualThing = 'cow';
69+
expect(actualThing).toEqual('cow');
70+
});
71+
EOF
72+
73+
vim.edit 'test.js'
74+
vim.command 'AngularRunSpec'
75+
76+
IO.read('test.js').strip.should eq normalize_string_indent(<<-EOF)
77+
it('should work', function() {
78+
var actualThing = 'cow';
79+
expect(actualThing).toEqual('cow');
80+
});
81+
82+
it('should also work', function() {
83+
var actualThing = 'cow';
84+
expect(actualThing).toEqual('cow');
85+
});
86+
EOF
87+
end
88+
89+
specify "run spec command grabs focus away from another spec" do
90+
write_file('test.js', <<-EOF)
91+
iit('should work', function() {
92+
var actualThing = 'cow';
93+
expect(actualThing).toEqual('cow');
94+
});
95+
96+
it('should also work', function() {
97+
var actualThing = 'cow';
98+
expect(actualThing).toEqual('cow');
99+
});
100+
EOF
101+
102+
vim.edit 'test.js'
103+
vim.normal '5j'
104+
vim.command 'AngularRunSpec'
105+
106+
IO.read('test.js').strip.should eq normalize_string_indent(<<-EOF)
107+
it('should work', function() {
108+
var actualThing = 'cow';
109+
expect(actualThing).toEqual('cow');
110+
});
111+
112+
iit('should also work', function() {
113+
var actualThing = 'cow';
114+
expect(actualThing).toEqual('cow');
115+
});
116+
EOF
117+
end
118+
end

spec/spec_helper.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
require 'vimrunner'
2+
require 'vimrunner/rspec'
3+
4+
Vimrunner::RSpec.configure do |config|
5+
config.reuse_server = true
6+
7+
config.start_vim do
8+
vim = Vimrunner.start#_gvim
9+
plugin_path = File.expand_path('../..', __FILE__)
10+
vim.prepend_runtimepath(plugin_path) # so the ftplugin behavior takes effect
11+
vim.add_plugin(plugin_path, 'plugin/vim-angular.vim')
12+
vim
13+
end
14+
end

0 commit comments

Comments
 (0)