scaffoldhub 0.0.14 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/lib/scaffoldhub.rb +1 -1
- data/lib/scaffoldhub/runner.rb +4 -0
- data/lib/scaffoldhub/specification.rb +2 -2
- data/spec/runnner_spec.rb +91 -0
- data/spec/scaffold_spec_spec.rb +7 -7
- metadata +6 -4
data/Gemfile.lock
CHANGED
data/lib/scaffoldhub.rb
CHANGED
data/lib/scaffoldhub/runner.rb
CHANGED
@@ -77,9 +77,9 @@ module Scaffoldhub
|
|
77
77
|
|
78
78
|
def adjusted_base_url
|
79
79
|
if base_url =~ /github.com\/([^\s]+\/[^\s]+)\/(tree|blob)\/(.*)$/
|
80
|
-
"https://github.com/#{$1}
|
80
|
+
"https://raw.github.com/#{$1}/#{$3}"
|
81
81
|
elsif base_url =~ /github.com\/([^\s^\/]+\/[^\s^\/]+)\/?$/
|
82
|
-
"https://github.com/#{$1}/
|
82
|
+
"https://raw.github.com/#{$1}/master"
|
83
83
|
else
|
84
84
|
base_url
|
85
85
|
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe Scaffoldhub::Runner do
|
4
|
+
|
5
|
+
describe 'push valid spec' do
|
6
|
+
before do
|
7
|
+
@test_scaffold = File.join(File.dirname(__FILE__), 'fixtures', 'test_scaffold.rb')
|
8
|
+
Scaffoldhub::Specification.stubs(:valid?).returns(true)
|
9
|
+
subject.expects(:post_spec).with(@test_scaffold)
|
10
|
+
end
|
11
|
+
it 'should post a valid spec' do
|
12
|
+
subject.push(@test_scaffold)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'push invalid spec' do
|
17
|
+
before do
|
18
|
+
@test_scaffold = File.join(File.dirname(__FILE__), 'fixtures', 'test_scaffold.rb')
|
19
|
+
Scaffoldhub::Specification.stubs(:valid?).returns(false)
|
20
|
+
Scaffoldhub::Specification.stubs(:errors).returns(['error one', 'error two'])
|
21
|
+
subject.expects(:post_spec).never
|
22
|
+
subject.expects(:say).with("Unable to post your new scaffold. Please resolve these errors:")
|
23
|
+
subject.expects(:say).with("error one")
|
24
|
+
subject.expects(:say).with("error two")
|
25
|
+
end
|
26
|
+
it 'should post a valid spec' do
|
27
|
+
subject.push(@test_scaffold)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'push missing spec' do
|
32
|
+
before do
|
33
|
+
@test_scaffold = '/invalid/path'
|
34
|
+
Scaffoldhub::Specification.expects(:valid?).never
|
35
|
+
subject.stubs(:say)
|
36
|
+
end
|
37
|
+
it 'should not post an invalid spec' do
|
38
|
+
subject.push(@test_scaffold)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe 'run scaffold via method missing' do
|
43
|
+
before do
|
44
|
+
subject.expects(:system).with("rails generate scaffoldhub person name:string --scaffold some_scaffold")
|
45
|
+
end
|
46
|
+
it 'should shell out to the specified scaffold' do
|
47
|
+
subject.some_scaffold 'person', 'name:string'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'run scaffold with a scaffold parameter via method missing' do
|
52
|
+
before do
|
53
|
+
subject.expects(:system).with("rails generate scaffoldhub person name:string --scaffold some_scaffold:some_field")
|
54
|
+
end
|
55
|
+
it 'should shell out to the specified scaffold' do
|
56
|
+
subject.send 'some_scaffold:some_field'.to_sym, 'person', 'name:string'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#post_spec' do
|
61
|
+
before do
|
62
|
+
Scaffoldhub::Runner.class_eval { public :post_spec }
|
63
|
+
subject.expects(:load_config).returns({:username => 'user', :password => 'pass'})
|
64
|
+
URI.expects(:parse).with("http://www.scaffoldhub.org/admin/scaffolds").returns(url = mock)
|
65
|
+
url.expects(:path).returns('/admin/scaffolds')
|
66
|
+
Net::HTTP::Post.expects(:new).with('/admin/scaffolds').returns(post = mock)
|
67
|
+
post.expects(:basic_auth).with('user', 'pass')
|
68
|
+
Scaffoldhub::Specification.expects(:to_yaml).returns('yaml')
|
69
|
+
post.expects(:set_form_data).with(
|
70
|
+
{
|
71
|
+
'scaffold' => 'yaml',
|
72
|
+
'spec_file_name' => 'some_scaffold.rb'
|
73
|
+
},
|
74
|
+
';'
|
75
|
+
)
|
76
|
+
url.expects(:host).returns('www.scaffoldhub.org')
|
77
|
+
url.expects(:port).returns(80)
|
78
|
+
Net::HTTP.expects(:new).with('www.scaffoldhub.org', 80).returns(http = mock)
|
79
|
+
http.expects(:start).returns(response = mock)
|
80
|
+
response.expects(:body).twice.returns('New scaffold created.')
|
81
|
+
subject.expects(:save_config).with('user', 'pass')
|
82
|
+
subject.expects(:say).with('New scaffold created.')
|
83
|
+
end
|
84
|
+
after do
|
85
|
+
Scaffoldhub::Runner.class_eval { private :post_spec }
|
86
|
+
end
|
87
|
+
it 'should post a scaffold to the server' do
|
88
|
+
subject.post_spec('/path/to/some_scaffold.rb')
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
data/spec/scaffold_spec_spec.rb
CHANGED
@@ -169,7 +169,7 @@ YAML
|
|
169
169
|
it 'should generate yaml from a scaffold spec' do
|
170
170
|
yaml = subject.to_yaml
|
171
171
|
parsed_yaml = YAML::load(yaml)
|
172
|
-
parsed_yaml[:base_url].should == 'https://github.com/your_name/your_repo/
|
172
|
+
parsed_yaml[:base_url].should == 'https://raw.github.com/your_name/your_repo/master'
|
173
173
|
parsed_yaml[:post_install_message].should == 'Please do this, this and that.'
|
174
174
|
parsed_yaml[:blog_post].should == 'http://patshaughnessy.net/2011/3/13/view-mapper-for-rails-3-scaffoldhub'
|
175
175
|
parsed_yaml[:name].should == 'test_scaffold'
|
@@ -191,23 +191,23 @@ YAML
|
|
191
191
|
describe '#adjusted_base_url' do
|
192
192
|
|
193
193
|
it 'should use the raw github url when a repo root is specified' do
|
194
|
-
Scaffoldhub::Specification.base_url = 'https://github.com/
|
195
|
-
Scaffoldhub::Specification.adjusted_base_url.should == 'https://github.com/
|
194
|
+
Scaffoldhub::Specification.base_url = 'https://github.com/patshaughnessy/scaffolds'
|
195
|
+
Scaffoldhub::Specification.adjusted_base_url.should == 'https://raw.github.com/patshaughnessy/scaffolds/master'
|
196
196
|
end
|
197
197
|
|
198
198
|
it 'should use the raw github url when a repo root is specified with a trailing slash' do
|
199
|
-
Scaffoldhub::Specification.base_url = 'https://github.com/
|
200
|
-
Scaffoldhub::Specification.adjusted_base_url.should == 'https://github.com/
|
199
|
+
Scaffoldhub::Specification.base_url = 'https://github.com/patshaughnessy/scaffolds/'
|
200
|
+
Scaffoldhub::Specification.adjusted_base_url.should == 'https://raw.github.com/patshaughnessy/scaffolds/master'
|
201
201
|
end
|
202
202
|
|
203
203
|
it 'should use the raw github url when a blob url is specified' do
|
204
204
|
Scaffoldhub::Specification.base_url = 'https://github.com/patshaughnessy/scaffolds/blob/master/autocomplete/scaffold_spec.rb'
|
205
|
-
Scaffoldhub::Specification.adjusted_base_url.should == 'https://github.com/patshaughnessy/scaffolds/
|
205
|
+
Scaffoldhub::Specification.adjusted_base_url.should == 'https://raw.github.com/patshaughnessy/scaffolds/master/autocomplete/scaffold_spec.rb'
|
206
206
|
end
|
207
207
|
|
208
208
|
it 'should use the raw github url when a tree url is specified' do
|
209
209
|
Scaffoldhub::Specification.base_url = 'https://github.com/patshaughnessy/scaffolds/tree/master/autocomplete/scaffold_spec.rb'
|
210
|
-
Scaffoldhub::Specification.adjusted_base_url.should == 'https://github.com/patshaughnessy/scaffolds/
|
210
|
+
Scaffoldhub::Specification.adjusted_base_url.should == 'https://raw.github.com/patshaughnessy/scaffolds/master/autocomplete/scaffold_spec.rb'
|
211
211
|
end
|
212
212
|
|
213
213
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scaffoldhub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.14
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Pat Shaughnessy
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-06-07 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -115,6 +115,7 @@ files:
|
|
115
115
|
- spec/fixtures/test_scaffold.rb
|
116
116
|
- spec/helper_spec.rb
|
117
117
|
- spec/remote_file_spec.rb
|
118
|
+
- spec/runnner_spec.rb
|
118
119
|
- spec/scaffold_spec_spec.rb
|
119
120
|
- spec/spec_helper.rb
|
120
121
|
- spec/template_file_spec.rb
|
@@ -157,6 +158,7 @@ test_files:
|
|
157
158
|
- spec/fixtures/test_scaffold.rb
|
158
159
|
- spec/helper_spec.rb
|
159
160
|
- spec/remote_file_spec.rb
|
161
|
+
- spec/runnner_spec.rb
|
160
162
|
- spec/scaffold_spec_spec.rb
|
161
163
|
- spec/spec_helper.rb
|
162
164
|
- spec/template_file_spec.rb
|