toy-locomotive 0.1.0 → 0.1.1

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.
@@ -1,108 +1,108 @@
1
- require 'spec_helper'
2
-
3
- describe DogsController do
4
-
5
- subject { DogsController }
6
-
7
- its(:extract_model) {should == Dog}
8
- its(:extract_controller) {should == 'dogs'}
9
-
10
- [:get, :put, :post, :delete].each {|via| it { should respond_to(via) }}
11
-
12
- it "extracts vars" do
13
- dog_controller = DogsController.new
14
- dog_controller.extract_parent_vars[0].class.should == Alien
15
- dog_controller.extract_parent_vars[1].class.should == Human
16
- dog_controller.extract_member_var.class.should == Dog
17
- dog_controller.extract_collection_var.class.should == Array
18
- dog_controller.extract_collection_var.first.class.should == Dog
19
- end
20
-
21
- describe '.extract_action' do
22
- it "recognizes the root" do
23
- DogsController.extract_action('/').should == 'root'
24
- end
25
-
26
- it "returns the option :as if declared" do
27
- DogsController.extract_action('lorem-ipsum', as: 'dolor-sit').should == 'dolor_sit'
28
- end
29
-
30
- it "returns the path if no options" do
31
- DogsController.extract_action('lorem-ipsum').should == 'lorem_ipsum'
32
- end
33
- end
34
-
35
- describe '.extract_as' do
36
- it "returns the action if its absolute path" do
37
- DogsController.extract_as('/lorem-ipsum').should == 'lorem_ipsum'
38
- end
39
-
40
- it "returns the chain as method if its relative path" do
41
- DogsController.extract_as('lorem').should == 'lorem_alien_human_dog'
42
- end
43
- end
44
-
45
- describe '.extract_path' do
46
- it "returns itself if absolute path" do
47
- DogsController.extract_path('/lorem').should == '/lorem'
48
- end
49
-
50
- it "matches relative path on member" do
51
- DogsController.extract_path('lorem', on: 'member').should == '/aliens/:alien_id/humans/:human_id/dogs/:dog_id/lorem'
52
- end
53
-
54
- it "matches relative path on collection" do
55
- DogsController.extract_path('lorem', on: 'collection').should == '/aliens/:alien_id/humans/:human_id/dogs/lorem'
56
- end
57
- end
58
-
59
- describe '.get' do
60
- it "adds a empty method" do
61
- DogsController.get('/lorem'){}
62
- DogsController.new.should respond_to(:lorem)
63
- end
64
-
65
- it "adds a method from a block" do
66
- DogsController.get('/lorem') { 'lorem-ipsum' }
67
- DogsController.new.lorem.should == 'lorem-ipsum'
68
- end
69
- end
70
-
71
- describe 'resources' do
72
- it "gets an index" do
73
- DogsController.get('index') { 'index' }
74
- DogsController.new.index.should == 'index'
75
- end
76
-
77
- it "gets a show" do
78
- DogsController.get('show') { 'show' }
79
- DogsController.new.show.should == 'show'
80
- end
81
-
82
- it "gets a new" do
83
- DogsController.get('new') { 'new' }
84
- DogsController.new.new.should == 'new'
85
- end
86
-
87
- it "gets a edit" do
88
- DogsController.get('edit') { 'edit' }
89
- DogsController.new.edit.should == 'edit'
90
- end
91
-
92
- it "puts a update" do
93
- DogsController.put('update') { 'update' }
94
- DogsController.new.update.should == 'update'
95
- end
96
-
97
- it "posts a create" do
98
- DogsController.post('create') { 'create' }
99
- DogsController.new.create.should == 'create'
100
- end
101
-
102
- it "deletes a destroy" do
103
- DogsController.delete('destroy') { 'destroy' }
104
- DogsController.new.destroy.should == 'destroy'
105
- end
106
- end
107
-
108
- end
1
+ require 'spec_helper'
2
+
3
+ describe DogsController do
4
+
5
+ subject { DogsController }
6
+
7
+ its(:extract_model) {should == Dog}
8
+ its(:extract_controller) {should == 'dogs'}
9
+
10
+ [:get, :put, :post, :delete].each {|via| it { should respond_to(via) }}
11
+
12
+ it "extracts vars" do
13
+ dog_controller = DogsController.new
14
+ dog_controller.extract_parent_vars[0].class.should == Alien
15
+ dog_controller.extract_parent_vars[1].class.should == Human
16
+ dog_controller.extract_member_var.class.should == Dog
17
+ dog_controller.extract_collection_var.class.should == Array
18
+ dog_controller.extract_collection_var.first.class.should == Dog
19
+ end
20
+
21
+ describe '.extract_action' do
22
+ it "recognizes the root" do
23
+ DogsController.extract_action('/').should == 'root'
24
+ end
25
+
26
+ it "returns the option :as if declared" do
27
+ DogsController.extract_action('lorem-ipsum', as: 'dolor-sit').should == 'dolor_sit'
28
+ end
29
+
30
+ it "returns the path if no options" do
31
+ DogsController.extract_action('lorem-ipsum').should == 'lorem_ipsum'
32
+ end
33
+ end
34
+
35
+ describe '.extract_as' do
36
+ it "returns the action if its absolute path" do
37
+ DogsController.extract_as('/lorem-ipsum').should == 'lorem_ipsum'
38
+ end
39
+
40
+ it "returns the chain as method if its relative path" do
41
+ DogsController.extract_as('lorem').should == 'lorem_alien_human_dog'
42
+ end
43
+ end
44
+
45
+ describe '.extract_path' do
46
+ it "returns itself if absolute path" do
47
+ DogsController.extract_path('/lorem').should == '/lorem'
48
+ end
49
+
50
+ it "matches relative path on member" do
51
+ DogsController.extract_path('lorem', on: 'member').should == '/aliens/:alien_id/humans/:human_id/dogs/:dog_id/lorem'
52
+ end
53
+
54
+ it "matches relative path on collection" do
55
+ DogsController.extract_path('lorem', on: 'collection').should == '/aliens/:alien_id/humans/:human_id/dogs/lorem'
56
+ end
57
+ end
58
+
59
+ describe '.get' do
60
+ it "adds a empty method" do
61
+ DogsController.get('/lorem'){}
62
+ DogsController.new.should respond_to(:lorem)
63
+ end
64
+
65
+ it "adds a method from a block" do
66
+ DogsController.get('/lorem') { 'lorem-ipsum' }
67
+ DogsController.new.lorem.should == 'lorem-ipsum'
68
+ end
69
+ end
70
+
71
+ describe 'resources' do
72
+ it "gets an index" do
73
+ DogsController.get('index') { 'index' }
74
+ DogsController.new.index.should == 'index'
75
+ end
76
+
77
+ it "gets a show" do
78
+ DogsController.get('show') { 'show' }
79
+ DogsController.new.show.should == 'show'
80
+ end
81
+
82
+ it "gets a new" do
83
+ DogsController.get('new') { 'new' }
84
+ DogsController.new.new.should == 'new'
85
+ end
86
+
87
+ it "gets a edit" do
88
+ DogsController.get('edit') { 'edit' }
89
+ DogsController.new.edit.should == 'edit'
90
+ end
91
+
92
+ it "puts a update" do
93
+ DogsController.put('update') { 'update' }
94
+ DogsController.new.update.should == 'update'
95
+ end
96
+
97
+ it "posts a create" do
98
+ DogsController.post('create') { 'create' }
99
+ DogsController.new.create.should == 'create'
100
+ end
101
+
102
+ it "deletes a destroy" do
103
+ DogsController.delete('destroy') { 'destroy' }
104
+ DogsController.new.destroy.should == 'destroy'
105
+ end
106
+ end
107
+
108
+ end
@@ -1,49 +1,49 @@
1
- require 'spec_helper'
2
-
3
- describe Dog do
4
-
5
- subject { Dog }
6
-
7
- { to_params: :dog_id,
8
- to_collection_var: '@dogs',
9
- to_member_var: '@dog',
10
- to_route: '/dogs/:dog_id',
11
- route_chain: '/aliens/:alien_id/humans/:human_id',
12
- belongs_chain: [Human, Alien],
13
- belongs_to_route: Human,
14
- to_as: 'alien_human_dog'
15
- }.each{|method, expectation| its(method) {should == expectation}}
16
-
17
- end
18
-
19
- describe Human do
20
-
21
- subject { Human }
22
-
23
- { to_params: :human_id,
24
- to_collection_var: '@humans',
25
- to_member_var: '@human',
26
- to_route: '/humans/:human_id',
27
- route_chain: '/aliens/:alien_id',
28
- belongs_chain: [Alien],
29
- belongs_to_route: Alien,
30
- to_as: 'alien_human'
31
- }.each{|method, expectation| its(method) {should == expectation}}
32
-
33
- end
34
-
35
- describe Alien do
36
-
37
- subject { Alien }
38
-
39
- { to_params: :alien_id,
40
- to_collection_var: '@aliens',
41
- to_member_var: '@alien',
42
- to_route: '/aliens/:alien_id',
43
- route_chain: '',
44
- belongs_chain: [],
45
- belongs_to_route: nil,
46
- to_as: 'alien'
47
- }.each{|method, expectation| its(method) {should == expectation}}
48
-
49
- end
1
+ require 'spec_helper'
2
+
3
+ describe Dog do
4
+
5
+ subject { Dog }
6
+
7
+ { to_params: :dog_id,
8
+ to_collection_var: '@dogs',
9
+ to_member_var: '@dog',
10
+ to_route: '/dogs/:dog_id',
11
+ route_chain: '/aliens/:alien_id/humans/:human_id',
12
+ belongs_chain: [Human, Alien],
13
+ belongs_to_route: Human,
14
+ to_as: 'alien_human_dog'
15
+ }.each{|method, expectation| its(method) {should == expectation}}
16
+
17
+ end
18
+
19
+ describe Human do
20
+
21
+ subject { Human }
22
+
23
+ { to_params: :human_id,
24
+ to_collection_var: '@humans',
25
+ to_member_var: '@human',
26
+ to_route: '/humans/:human_id',
27
+ route_chain: '/aliens/:alien_id',
28
+ belongs_chain: [Alien],
29
+ belongs_to_route: Alien,
30
+ to_as: 'alien_human'
31
+ }.each{|method, expectation| its(method) {should == expectation}}
32
+
33
+ end
34
+
35
+ describe Alien do
36
+
37
+ subject { Alien }
38
+
39
+ { to_params: :alien_id,
40
+ to_collection_var: '@aliens',
41
+ to_member_var: '@alien',
42
+ to_route: '/aliens/:alien_id',
43
+ route_chain: '',
44
+ belongs_chain: [],
45
+ belongs_to_route: nil,
46
+ to_as: 'alien'
47
+ }.each{|method, expectation| its(method) {should == expectation}}
48
+
49
+ end
@@ -1,7 +1,7 @@
1
- require 'spec_helper'
2
-
3
- describe ToyLocomotive do
4
-
5
- it { should respond_to :routes }
6
-
7
- end
1
+ require 'spec_helper'
2
+
3
+ describe ToyLocomotive do
4
+
5
+ it { should respond_to :routes }
6
+
7
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
- require 'toy-locomotive'
2
- require 'rspec-rails'
3
-
4
- ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: './toy_locomotive.sqlite3')
5
-
6
- %w(schema models seeds controllers).each { |file| load "#{File.dirname(__FILE__)}/support/#{file}.rb" }
1
+ require 'toy-locomotive'
2
+ require 'rspec-rails'
3
+
4
+ ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: './toy_locomotive.sqlite3')
5
+
6
+ %w(schema models seeds controllers).each { |file| load "#{File.dirname(__FILE__)}/support/#{file}.rb" }
@@ -1,30 +1,30 @@
1
- class DogsController < ActionController::Base
2
-
3
- def params
4
- {alien_id: Alien.first.id, human_id: Human.first.id, dog_id: Dog.first.id}
5
- end
6
-
7
- get '/absolute' do
8
- 'absolute route'
9
- end
10
-
11
- get 'member', on: 'member' do
12
- 'member route'
13
- end
14
-
15
- get 'collection', on: 'collection' do
16
- 'collection route'
17
- end
18
-
19
- end
20
- DogsController.append_filters!
21
-
22
- class HumansController < ActionController::Base
23
-
24
- end
25
- HumansController.append_filters!
26
-
27
- class AliensController < ActionController::Base
28
-
29
- end
30
- AliensController.append_filters!
1
+ class DogsController < ActionController::Base
2
+
3
+ def params
4
+ {alien_id: Alien.first.id, human_id: Human.first.id, dog_id: Dog.first.id}
5
+ end
6
+
7
+ get '/absolute' do
8
+ 'absolute route'
9
+ end
10
+
11
+ get 'member', on: 'member' do
12
+ 'member route'
13
+ end
14
+
15
+ get 'collection', on: 'collection' do
16
+ 'collection route'
17
+ end
18
+
19
+ end
20
+ DogsController.append_filters!
21
+
22
+ class HumansController < ActionController::Base
23
+
24
+ end
25
+ HumansController.append_filters!
26
+
27
+ class AliensController < ActionController::Base
28
+
29
+ end
30
+ AliensController.append_filters!
@@ -1,16 +1,16 @@
1
- class Dog < ActiveRecord::Base
2
- belongs_to :human
3
- end
4
-
5
- class Human < ActiveRecord::Base
6
- belongs_to :alien
7
- has_many :dogs
8
- end
9
-
10
- class Alien < ActiveRecord::Base
11
- has_many :humans
12
- end
13
-
14
- ActiveSupport::Inflector.inflections do |inflect|
15
- inflect.irregular 'Human', 'Humans'
16
- end
1
+ class Dog < ActiveRecord::Base
2
+ belongs_to :human
3
+ end
4
+
5
+ class Human < ActiveRecord::Base
6
+ belongs_to :alien
7
+ has_many :dogs
8
+ end
9
+
10
+ class Alien < ActiveRecord::Base
11
+ has_many :humans
12
+ end
13
+
14
+ ActiveSupport::Inflector.inflections do |inflect|
15
+ inflect.irregular 'Human', 'Humans'
16
+ end
@@ -1,19 +1,19 @@
1
- ActiveRecord::Schema.define do
2
-
3
- self.verbose = false
4
-
5
- create_table :dogs, :force => true do |t|
6
- t.integer :human_id
7
- t.timestamps
8
- end
9
-
10
- create_table :humans, :force => true do |t|
11
- t.integer :alien_id
12
- t.timestamps
13
- end
14
-
15
- create_table :aliens, :force => true do |t|
16
- t.timestamps
17
- end
18
-
19
- end
1
+ ActiveRecord::Schema.define do
2
+
3
+ self.verbose = false
4
+
5
+ create_table :dogs, :force => true do |t|
6
+ t.integer :human_id
7
+ t.timestamps
8
+ end
9
+
10
+ create_table :humans, :force => true do |t|
11
+ t.integer :alien_id
12
+ t.timestamps
13
+ end
14
+
15
+ create_table :aliens, :force => true do |t|
16
+ t.timestamps
17
+ end
18
+
19
+ end
@@ -1 +1 @@
1
- Alien.create.humans.create.dogs.create
1
+ Alien.create.humans.create.dogs.create
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toy-locomotive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-29 00:00:00.000000000 Z
12
+ date: 2012-12-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &26806236 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,15 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
24
+ version_requirements: *26806236
30
25
  - !ruby/object:Gem::Dependency
31
26
  name: rspec-rails
32
- requirement: !ruby/object:Gem::Requirement
27
+ requirement: &26805972 !ruby/object:Gem::Requirement
33
28
  none: false
34
29
  requirements:
35
30
  - - ! '>='
@@ -37,15 +32,10 @@ dependencies:
37
32
  version: '0'
38
33
  type: :development
39
34
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
35
+ version_requirements: *26805972
46
36
  - !ruby/object:Gem::Dependency
47
37
  name: sqlite3
48
- requirement: !ruby/object:Gem::Requirement
38
+ requirement: &26805720 !ruby/object:Gem::Requirement
49
39
  none: false
50
40
  requirements:
51
41
  - - ! '>='
@@ -53,15 +43,10 @@ dependencies:
53
43
  version: '0'
54
44
  type: :development
55
45
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
46
+ version_requirements: *26805720
62
47
  - !ruby/object:Gem::Dependency
63
48
  name: shoulda
64
- requirement: !ruby/object:Gem::Requirement
49
+ requirement: &26805468 !ruby/object:Gem::Requirement
65
50
  none: false
66
51
  requirements:
67
52
  - - ! '>='
@@ -69,12 +54,7 @@ dependencies:
69
54
  version: '0'
70
55
  type: :development
71
56
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
57
+ version_requirements: *26805468
78
58
  description: a Different aproach to Rails applications
79
59
  email:
80
60
  - mortaro@towsta.com
@@ -131,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
111
  version: '0'
132
112
  requirements: []
133
113
  rubyforge_project: toy-locomotive
134
- rubygems_version: 1.8.24
114
+ rubygems_version: 1.8.16
135
115
  signing_key:
136
116
  specification_version: 3
137
117
  summary: a Toy Locomotive to run over Rails