neo-rails 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 55b3133a849d0a61eec0778df76c617a0a2da5a8
4
+ data.tar.gz: 71c9ceff6849150b20c8d45c91a379970db26266
5
+ SHA512:
6
+ metadata.gz: 337f498564647661610f3bb5521aede869e96956a91966ca9d775cbc4d9cb0a2d376428958037238d9782490731e81ce7c8b1637bc2468dcd9e495ccaa4dad4b
7
+ data.tar.gz: 7407b070812b87df0b41d7f27e36456e6fa50a2b9b247342d7ea9f2bb752f4592733ed6292d57bbe6f4920c33c7db3b5158f76dda25d46e141d7731150df2cc2
@@ -0,0 +1,19 @@
1
+ require 'rails/generators'
2
+
3
+ class MockGenerator < Rails::Generators::NamedBase
4
+
5
+ source_root File.expand_path('../templates', __FILE__)
6
+
7
+ def create_mock_file
8
+ path = "app/mocks/#{file_name}_mock.rb"
9
+ if FileTest.exists?path
10
+ raise FileExistError, "This filename ist used by another mock:#{path}"
11
+ end
12
+
13
+ copy_file "mock_template.rb", path
14
+ gsub_file path, '-MockName-' , "#{class_name}"
15
+ end
16
+
17
+ end
18
+
19
+ class FileExistError < StandardError; end
@@ -0,0 +1,24 @@
1
+ class -MockName-Mock < Mock
2
+
3
+ # EXAMPLE:
4
+ # def age
5
+ # mock.tagged?(:old) ? 78 : 23
6
+ # end
7
+ #
8
+ # def name
9
+ # "Uncle bob"
10
+ # end
11
+ #
12
+ # def logged_in?
13
+ # true
14
+ # end
15
+ #
16
+ # def sexy?
17
+ # mock.tagged?(:sexy)
18
+ # end
19
+ #
20
+ # def car
21
+ # mock.option(:car)
22
+ # end
23
+
24
+ end
@@ -0,0 +1,39 @@
1
+ require 'rails/generators'
2
+
3
+ class PresenterGenerator < Rails::Generators::NamedBase
4
+
5
+ source_root File.expand_path('../templates', __FILE__)
6
+
7
+ def create_presenter_file
8
+ path = "app/presenters/#{file_name}_presenter.rb"
9
+ if FileTest.exists?path
10
+ raise FileExistError, "This filename ist used by another presenter:#{path}"
11
+ end
12
+
13
+ copy_file "presenter_template.rb", path
14
+ replace_class_name path
15
+ replace_singular_name path
16
+ end
17
+
18
+ def create_presenter_test_file
19
+ path = "test/presenters/#{file_name}_presenter_test.rb"
20
+ if FileTest.exists?path
21
+ raise FileExistError, "This filename ist used by another PresenterTest:#{path}"
22
+ end
23
+
24
+ copy_file "presenter_test_template.rb", path
25
+ replace_class_name path
26
+ end
27
+
28
+ private
29
+ def replace_class_name path
30
+ gsub_file path, '-classname-' , "#{class_name}"
31
+ end
32
+
33
+ def replace_singular_name path
34
+ gsub_file path, 'singular_name' , "#{plural_name.singularize}"
35
+ end
36
+
37
+ end
38
+
39
+ class FileExistError < StandardError; end
@@ -0,0 +1,7 @@
1
+ class -classname-Presenter < Presenter
2
+
3
+ def initialize(singular_name)
4
+ @singular_name = singular_name
5
+ end
6
+
7
+ end
@@ -0,0 +1,9 @@
1
+ #require 'test_helper'
2
+
3
+ class -classname-PresenterTest < ActiveSupport::TestCase
4
+
5
+ test "the truth" do
6
+ assert true
7
+ end
8
+
9
+ end
@@ -24,9 +24,9 @@ module Neo
24
24
  self.exposure_names.merge exposure_names
25
25
 
26
26
  # Define a helper method for each exposure
27
- exposure_names.each do |exposure_name|
28
- # see Rails: /actionpack/lib/abstract_controller/helpers.rb
29
- helper do
27
+ # see Rails: /actionpack/lib/abstract_controller/helpers.rb
28
+ helper do
29
+ exposure_names.each do |exposure_name|
30
30
  define_method exposure_name do
31
31
  controller.exposures[exposure_name]
32
32
  end
@@ -1,5 +1,5 @@
1
1
  module Neo
2
2
  module Rails
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
data/neo-rails.gemspec CHANGED
@@ -1,6 +1,8 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  require File.expand_path('../lib/neo/rails/version', __FILE__)
3
3
 
4
+ rails_version = ENV['RAILS_VERSION']
5
+
4
6
  Gem::Specification.new do |gem|
5
7
  gem.authors = ["Jonas Thiel", "Peter Suschlik"]
6
8
  gem.email = ["jt@neopoly.de", "ps@neopoly.de"]
@@ -15,8 +17,18 @@ Gem::Specification.new do |gem|
15
17
  gem.require_paths = ["lib"]
16
18
  gem.version = Neo::Rails::VERSION
17
19
 
20
+ case rails_version
21
+ when '4.0'
22
+ gem.add_development_dependency "minitest"
23
+ when '3.2'
24
+ gem.add_development_dependency "minitest", '~> 4.7'
25
+ when NilClass
26
+ abort "Missing env RAILS_VERSION"
27
+ else
28
+ abort "Rails version #{rails_version.inspect} not supported"
29
+ end
30
+
18
31
  gem.add_development_dependency "rake"
19
- gem.add_development_dependency "minitest"
20
32
  gem.add_development_dependency "rack-test"
21
33
  gem.add_development_dependency "simplecov"
22
34
  end
@@ -0,0 +1,19 @@
1
+ require 'helper'
2
+ require 'rails/generators'
3
+ require 'generators/mock/mock_generator'
4
+
5
+ class MockGeneratorTest < Rails::Generators::TestCase
6
+ tests MockGenerator
7
+ destination File.expand_path("../tmp", File.dirname(__FILE__))
8
+ setup :prepare_destination
9
+
10
+ test "create mock" do
11
+ run_generator %w(test)
12
+
13
+ assert_file "app/mocks/test_mock.rb" do |mock|
14
+ assert_match(/class TestMock < Mock/, mock)
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,30 @@
1
+ require 'helper'
2
+ require 'rails/generators'
3
+ require 'generators/presenter/presenter_generator'
4
+
5
+ class PresenterGeneratorTest < Rails::Generators::TestCase
6
+ tests PresenterGenerator
7
+ destination File.expand_path("../tmp", File.dirname(__FILE__))
8
+ setup :prepare_destination
9
+
10
+ test "create presenter" do
11
+ run_generator %w(test)
12
+
13
+ assert_file "app/presenters/test_presenter.rb" do |presenter|
14
+ assert_match(/class TestPresenter < Presenter/, presenter)
15
+ assert_match(/def initialize\(test\)/, presenter)
16
+ assert_match(/@test = test/, presenter)
17
+ end
18
+
19
+ end
20
+
21
+ test "create presenter test" do
22
+ run_generator %w(test)
23
+
24
+ assert_file "test/presenters/test_presenter_test.rb" do |presenter_test|
25
+ assert_match(/#require 'test_helper'/, presenter_test)
26
+ assert_match(/class TestPresenterTest < ActiveSupport::TestCase/, presenter_test)
27
+ end
28
+ end
29
+
30
+ end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neo-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
4
+ version: 0.2.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jonas Thiel
@@ -10,70 +9,62 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-07-02 00:00:00.000000000 Z
12
+ date: 2013-07-25 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
- name: rake
15
+ name: minitest
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - '>='
21
19
  - !ruby/object:Gem::Version
22
20
  version: '0'
23
21
  type: :development
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - '>='
29
26
  - !ruby/object:Gem::Version
30
27
  version: '0'
31
28
  - !ruby/object:Gem::Dependency
32
- name: minitest
29
+ name: rake
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ! '>='
32
+ - - '>='
37
33
  - !ruby/object:Gem::Version
38
34
  version: '0'
39
35
  type: :development
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ! '>='
39
+ - - '>='
45
40
  - !ruby/object:Gem::Version
46
41
  version: '0'
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: rack-test
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
- - - ! '>='
46
+ - - '>='
53
47
  - !ruby/object:Gem::Version
54
48
  version: '0'
55
49
  type: :development
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
- - - ! '>='
53
+ - - '>='
61
54
  - !ruby/object:Gem::Version
62
55
  version: '0'
63
56
  - !ruby/object:Gem::Dependency
64
57
  name: simplecov
65
58
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
59
  requirements:
68
- - - ! '>='
60
+ - - '>='
69
61
  - !ruby/object:Gem::Version
70
62
  version: '0'
71
63
  type: :development
72
64
  prerelease: false
73
65
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
66
  requirements:
76
- - - ! '>='
67
+ - - '>='
77
68
  - !ruby/object:Gem::Version
78
69
  version: '0'
79
70
  description: Some Rails helpers
@@ -95,6 +86,11 @@ files:
95
86
  - lib/assets/javascripts/neo/rails/scenarios/render_scenarios_list.js
96
87
  - lib/assets/stylesheets/neo-rails.css
97
88
  - lib/assets/stylesheets/neo/rails/scenarios/render_scenarios_list.css.sass
89
+ - lib/generators/mock/mock_generator.rb
90
+ - lib/generators/mock/templates/mock_template.rb
91
+ - lib/generators/presenter/presenter_generator.rb
92
+ - lib/generators/presenter/templates/presenter_template.rb
93
+ - lib/generators/presenter/templates/presenter_test_template.rb
98
94
  - lib/neo-rails.rb
99
95
  - lib/neo/rails.rb
100
96
  - lib/neo/rails/engine.rb
@@ -115,43 +111,40 @@ files:
115
111
  - test/exposure_test.rb
116
112
  - test/fixtures/exposure/exposures_test.rb
117
113
  - test/fixtures/views/exposes_via_value_with_template.html.erb
114
+ - test/generator/mock_generator_test.rb
115
+ - test/generator/presenter_generator_test.rb
118
116
  - test/helper.rb
119
117
  - test/mock_test.rb
120
118
  - test/presenter_test.rb
121
119
  homepage: ''
122
120
  licenses: []
121
+ metadata: {}
123
122
  post_install_message:
124
123
  rdoc_options: []
125
124
  require_paths:
126
125
  - lib
127
126
  required_ruby_version: !ruby/object:Gem::Requirement
128
- none: false
129
127
  requirements:
130
- - - ! '>='
128
+ - - '>='
131
129
  - !ruby/object:Gem::Version
132
130
  version: '0'
133
- segments:
134
- - 0
135
- hash: 4337019360723826631
136
131
  required_rubygems_version: !ruby/object:Gem::Requirement
137
- none: false
138
132
  requirements:
139
- - - ! '>='
133
+ - - '>='
140
134
  - !ruby/object:Gem::Version
141
135
  version: '0'
142
- segments:
143
- - 0
144
- hash: 4337019360723826631
145
136
  requirements: []
146
137
  rubyforge_project:
147
- rubygems_version: 1.8.25
138
+ rubygems_version: 2.0.3
148
139
  signing_key:
149
- specification_version: 3
140
+ specification_version: 4
150
141
  summary: Rails mocks, presenters, exposure and scenarios
151
142
  test_files:
152
143
  - test/exposure_test.rb
153
144
  - test/fixtures/exposure/exposures_test.rb
154
145
  - test/fixtures/views/exposes_via_value_with_template.html.erb
146
+ - test/generator/mock_generator_test.rb
147
+ - test/generator/presenter_generator_test.rb
155
148
  - test/helper.rb
156
149
  - test/mock_test.rb
157
150
  - test/presenter_test.rb