kitestrings 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 09a1d7d5265a7012cea917f77889c82ee15d3735
4
- data.tar.gz: 27aeeb8c04ef9a59318dee5f57962fbc812c99d9
3
+ metadata.gz: b5e7e7b1e26fec5ba18d84498ad21faf270e378f
4
+ data.tar.gz: 7e9c7e8e8c0879534bde9063c9842f4ddccd9e7e
5
5
  SHA512:
6
- metadata.gz: 2de52f0b07968416e93b1a1e20ca4206018d96f02f25690317cc6cd892fb81f9971cd6aefd5b186ff300e9b021f817406ab3dc8f82c0c693d65ad43ab82c182d
7
- data.tar.gz: 9136bbdc03df7fac3b93973dc555d24dcb340feee6b228b4218035fba4b14cccafaaf509969480f70ef830298b7a4bbf2d496502b6e76c44bf5638b0b147c21b
6
+ metadata.gz: 18fbd306f921ce2bbdb45acfae7a7e2e301d53ad1b3e23a638e53a96c697371b034c0e17ee22a9385ca95c0b6c8c45abb722c069b4e8ac04f17699205cfe6d1e
7
+ data.tar.gz: 9ca876d4e6842c11e225f8fb58c41903436d524de0cff886d44c7f847f6168451a2437592b62f5aa14cabeb597310b3cd2f388aba27ea6c4809b357a547777b2
@@ -1,5 +1,9 @@
1
1
  # Version history:
2
2
 
3
+ ## 1.2.1
4
+ * change to fixturen
5
+ * scaffold generators cleaned up (rspec 3)
6
+
3
7
  ## 1.2.0
4
8
  * reformatting for rubocop
5
9
 
@@ -6,9 +6,9 @@ require 'kitestrings/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "kitestrings"
8
8
  spec.version = Kitestrings::VERSION
9
- spec.authors = ["Tom Ridge", "Matt Connolly", "Geoffrey Donaldson"]
9
+ spec.authors = ["Tom Ridge", "Matt Connolly", "Geoffrey Donaldson", "Nigel Rausch"]
10
10
  spec.email = ["tom.ridge@tworedkites.com", "matt.connolly@tworedkites.com",
11
- "geoffrey.donaldson@tworedkites.com"]
11
+ "geoffrey.donaldson@tworedkites.com", "nigel.rausch@tworedkites.com"]
12
12
  spec.summary = %q{For all the 2rk goodness}
13
13
  spec.description = %q{}
14
14
  spec.homepage = ""
@@ -20,6 +20,7 @@ module Kitestrings
20
20
 
21
21
  def copy_rubocop_file
22
22
  copy_file "rubocop/.rubocop.yml", ".rubocop.yml"
23
+ directory "rubocop/routing", "spec/routing"
23
24
  end
24
25
 
25
26
  def copy_haml_files
@@ -50,8 +51,7 @@ module Kitestrings
50
51
 
51
52
  def setup_application_controller
52
53
  inject_into_file "app/controllers/application_controller.rb", :after => /protect_from_forgery.*$/ do
53
- <<-EOF
54
-
54
+ "
55
55
  respond_to :html
56
56
 
57
57
  unless Rails.application.config.consider_all_requests_local
@@ -60,8 +60,7 @@ module Kitestrings
60
60
  # Airbrake.notify(exception)
61
61
  render 'public/403', status: 403, layout: 'none'
62
62
  end
63
- end
64
- EOF
63
+ end"
65
64
  end
66
65
  end
67
66
 
@@ -70,6 +69,7 @@ EOF
70
69
  generators_configuration = <<-END
71
70
  config.generators do |g|
72
71
  g.view_specs false
72
+ g.test_framework :rspec, fixture: true
73
73
  end
74
74
 
75
75
  config.app_generators do |g|
@@ -0,0 +1,23 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+ <% unless attributes.empty? -%>
4
+ DEFAULTS: &DEFAULTS
5
+ <% attributes[1..-1].each do |attribute| -%>
6
+ <%= attribute.name %>: <%= attribute.default %>
7
+ <% end -%>
8
+
9
+ <%= table_name.singularize %>:
10
+ <%= attributes.first.name %>: <%= table_name.singularize %>
11
+ <<: *DEFAULTS
12
+
13
+ <%= table_name.singularize %>_other:
14
+ <%= attributes.first.name %>: <%= table_name.singularize %>_other
15
+ <<: *DEFAULTS
16
+ <% else -%>
17
+ # one:
18
+ # column: value
19
+ #
20
+ # two:
21
+ # column: value
22
+ <% end -%>
23
+
@@ -15,15 +15,13 @@ describe <%= controller_class_name %>Controller do
15
15
  before { allow(controller).to receive(:<%= file_name %>_params).and_return({}) }
16
16
 
17
17
  context 'not logged in' do
18
- before do
19
- sign_out :user
20
- end
18
+ before { sign_out :user }
21
19
 
22
20
  { index: :get, show: :get, new: :get, create: :post, edit: :get, update: :put,
23
21
  destroy: :delete }.each do |v, m|
24
22
  it "#{m} #{v} should logout" do
25
23
  send(m, v, id: <%= file_name %>)
26
- expect(response).to redirect_to new_user_session_path
24
+ is_expected.to redirect_to new_user_session_path
27
25
  end
28
26
  end
29
27
  end
@@ -38,85 +36,86 @@ describe <%= controller_class_name %>Controller do
38
36
  get :index
39
37
  end
40
38
 
41
- it { expect(response).to assign_to(:<%= table_name %>).with_items([<%= file_name %>]) }
42
- it { expect(response).to render_template :index }
43
- it { expect(response).to have_only_fractures(:new_<%= file_name %>_link) }
39
+ it { is_expected.to assign_to(:<%= table_name %>).with_items(<%= file_name %>) }
40
+ it { is_expected.to render_template :index }
41
+ it { is_expected.to have_only_fractures(:new_<%= file_name %>_link) }
44
42
  end
45
43
  <% end -%>
46
44
 
47
45
  describe 'GET show' do
48
46
  before { get :show, id: <%= file_name %> }
49
47
 
50
- it { expect(response).to assign_to(:<%= file_name %>).with(<%= file_name %>) }
51
- it { expect(response).to render_template :show }
52
- it { expect(response).to have_only_fractures(:edit_<%= file_name %>_link) }
48
+ it { is_expected.to assign_to(:<%= file_name %>).with(<%= file_name %>) }
49
+ it { is_expected.to render_template :show }
50
+ it { is_expected.to have_only_fractures(:edit_<%= file_name %>_link) }
53
51
  end
54
52
 
55
53
  describe 'GET new' do
56
54
  before { get :new }
57
55
 
58
- it { expect(response).to assign_to(:<%= file_name %>).with_kind_of(<%= class_name %>) }
59
- # it { expect(response).to assign_to('<%= file_name %>.parent').with(parent) }
60
- it { expect(response).to render_template :new }
61
- it { expect(response).to have_only_fractures :cancel_new_<%= file_name %>_link }
62
- it { expect(response).to have_a_form.that_is_new.with_path_of(<%= table_name %>_path) }
56
+ it { is_expected.to assign_to(:<%= file_name %>).with_kind_of(<%= class_name %>) }
57
+ # it { is_expected.to assign_to('<%= file_name %>.parent').with(parent) }
58
+ it { is_expected.to render_template :new }
59
+ it { is_expected.to have_only_fractures :cancel_new_<%= file_name %>_link }
60
+ it { is_expected.to have_a_form.that_is_new.with_path_of(<%= table_name %>_path) }
63
61
  end
64
62
 
65
63
  describe 'POST create' do
66
64
  context 'valid' do
67
65
  before do
68
- <%= class_name %>.any_instance.stub(:valid?).and_return(true)
66
+ allow_any_instance_of(<%= class_name %>).to receive(:valid?).and_return(true)
69
67
  post :create
70
68
  end
71
69
 
72
- it { expect(response).to redirect_to <%= file_name %>_path(<%= class_name %>.last) }
73
- it { expect(response).to assign_to(:<%= file_name %>).with(<%= class_name %>.last) }
74
- # it { expect(response).to assign_to('<%= file_name %>.parent').with(parent) }
70
+ it { is_expected.to redirect_to <%= file_name %>_path(<%= class_name %>.last) }
71
+ it { is_expected.to assign_to(:<%= file_name %>).with(<%= class_name %>.last) }
72
+ # it { is_expected.to assign_to('<%= file_name %>.parent').with(parent) }
75
73
  end
76
74
 
77
75
  context 'invalid' do
78
76
  before do
79
- <%= class_name %>.any_instance.stub(:valid?).and_return(false)
77
+ allow_any_instance_of(<%= class_name %>).to receive(:valid?).and_return(false)
80
78
  post :create
81
79
  end
82
- it { expect(response).to assign_to(:<%= file_name %>).with_kind_of(<%= class_name %>) }
83
- # it { expect(response).to assign_to('<%= file_name %>.parent').with(parent) }
84
- it { expect(response).to render_template :new }
85
- it { expect(response).to have_only_fractures :cancel_new_<%= file_name %>_link }
86
- it { expect(response).to have_a_form.that_is_new.with_path_of(<%= table_name %>_path) }
80
+
81
+ it { is_expected.to assign_to(:<%= file_name %>).with_kind_of(<%= class_name %>) }
82
+ # it { is_expected.to assign_to('<%= file_name %>.parent').with(parent) }
83
+ it { is_expected.to render_template :new }
84
+ it { is_expected.to have_only_fractures :cancel_new_<%= file_name %>_link }
85
+ it { is_expected.to have_a_form.that_is_new.with_path_of(<%= table_name %>_path) }
87
86
  end
88
87
  end
89
88
 
90
89
  describe 'GET edit' do
91
90
  before { get :edit, id: <%= file_name %> }
92
91
 
93
- it { expect(response).to assign_to(:<%= file_name %>).with(<%= file_name %>) }
94
- it { expect(response).to render_template :edit }
95
- it { expect(response).to have_only_fractures :cancel_edit_<%= file_name %>_link }
96
- it { expect(response).to have_a_form.that_is_edit.with_path_of(<%= file_name %>_path) }
92
+ it { is_expected.to assign_to(:<%= file_name %>).with(<%= file_name %>) }
93
+ it { is_expected.to render_template :edit }
94
+ it { is_expected.to have_only_fractures :cancel_edit_<%= file_name %>_link }
95
+ it { is_expected.to have_a_form.that_is_edit.with_path_of(<%= file_name %>_path) }
97
96
  end
98
97
 
99
98
  describe 'PUT update' do
100
99
  context 'valid' do
101
100
  before do
102
- <%= class_name %>.any_instance.stub(:valid?).and_return(true)
101
+ allow_any_instance_of(<%= class_name %>).to receive(:valid?).and_return(true)
103
102
  put :update, id: <%= file_name %>
104
103
  end
105
104
 
106
- it { expect(response).to assign_to(:<%= file_name %>).with(<%= file_name %>) }
107
- it { expect(response).to redirect_to <%= file_name %>_path(<%= file_name %>) }
105
+ it { is_expected.to assign_to(:<%= file_name %>).with(<%= file_name %>) }
106
+ it { is_expected.to redirect_to <%= file_name %>_path(<%= file_name %>) }
108
107
  end
109
108
  context 'invalid' do
110
109
  before do
111
110
  <%= file_name %>
112
- <%= class_name %>.any_instance.stub(:valid?).and_return(false)
111
+ allow_any_instance_of(<%= class_name %>).to receive(:valid?).and_return(false)
113
112
  put :update, id: <%= file_name %>
114
113
  end
115
114
 
116
- it { expect(response).to assign_to(:<%= file_name %>).with(<%= file_name %>) }
117
- it { expect(response).to render_template :edit }
118
- it { expect(response).to have_only_fractures :cancel_edit_<%= file_name %>_link }
119
- it { expect(response).to have_a_form.that_is_edit.with_path_of(<%= file_name %>_path) }
115
+ it { is_expected.to assign_to(:<%= file_name %>).with(<%= file_name %>) }
116
+ it { is_expected.to render_template :edit }
117
+ it { is_expected.to have_only_fractures :cancel_edit_<%= file_name %>_link }
118
+ it { is_expected.to have_a_form.that_is_edit.with_path_of(<%= file_name %>_path) }
120
119
  end
121
120
  end
122
121
 
@@ -124,7 +123,7 @@ describe <%= controller_class_name %>Controller do
124
123
  before { delete :destroy, id: <%= file_name %> }
125
124
 
126
125
  it { expect(<%= class_name %>.find_by_id(<%= file_name %>.id)).to be_nil }
127
- it { expect(response).to redirect_to <%= index_helper %>_path }
126
+ it { is_expected.to redirect_to <%= index_helper %>_path }
128
127
  end
129
128
  end
130
129
  end
@@ -0,0 +1,7 @@
1
+ inherit_from:
2
+ - ../../.rubocop.yml
3
+
4
+ # Allow routing specs to be longer
5
+ Metrics/LineLength:
6
+ Enabled: true
7
+ Max: 200
@@ -35,7 +35,7 @@ RSpec.configure do |config|
35
35
  # If you're not using ActiveRecord, or you'd prefer not to run each of your
36
36
  # examples within a transaction, remove the following line or assign false
37
37
  # instead of true.
38
- config.use_transactional_fixtures = false
38
+ config.use_transactional_fixtures = true
39
39
  config.global_fixtures = :selections
40
40
 
41
41
  # If true, the base class of anonymous controllers will be inferred
@@ -0,0 +1,44 @@
1
+ RSpec::Matchers.define :assign_to do |first|
2
+ match do |actual|
3
+ @actual = actual
4
+
5
+ firsts = first.to_s.split('.', 2)
6
+ if firsts.length == 2
7
+ @first = assigns(firsts.first).send(firsts.last)
8
+ else
9
+ @first = assigns(first)
10
+ end
11
+
12
+ case
13
+ when @second.is_a?(Class)
14
+ @first.is_a?(@second)
15
+ when @second.is_a?(Array)
16
+ expect(@first).to match_array(@second)
17
+ else
18
+ @first == @second
19
+ end
20
+ end
21
+
22
+ chain :with_items do |*second|
23
+ @second = Array(second)
24
+ end
25
+
26
+ chain :with do |second|
27
+ @second = second
28
+ end
29
+
30
+ chain :with_kind_of do |second|
31
+ @second = second
32
+ end
33
+
34
+ failure_message do
35
+ build = ''
36
+ if @second.is_a?(Array)
37
+ build = "Expected to get IDs of #{@first.map(&:id)} but got #{@second.map(&:id)}\n"\
38
+ end
39
+
40
+ build + "#{@first.inspect}\n"\
41
+ " === BUT GOT ===\n"\
42
+ "#{@second.inspect}\n"
43
+ end
44
+ end
@@ -1,3 +1,3 @@
1
1
  module Kitestrings
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitestrings
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Ridge
8
8
  - Matt Connolly
9
9
  - Geoffrey Donaldson
10
+ - Nigel Rausch
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2015-02-10 00:00:00.000000000 Z
14
+ date: 2015-02-11 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: rails
@@ -101,6 +102,7 @@ email:
101
102
  - tom.ridge@tworedkites.com
102
103
  - matt.connolly@tworedkites.com
103
104
  - geoffrey.donaldson@tworedkites.com
105
+ - nigel.rausch@tworedkites.com
104
106
  executables: []
105
107
  extensions: []
106
108
  extra_rdoc_files: []
@@ -144,11 +146,14 @@ files:
144
146
  - lib/generators/templates/rails/scaffold_controller/controller.rb
145
147
  - lib/generators/templates/rspec/helper/helper_spec.rb
146
148
  - lib/generators/templates/rspec/integration/request_spec.rb
149
+ - lib/generators/templates/rspec/model/fixtures.yml
147
150
  - lib/generators/templates/rspec/model/model_spec.rb
148
151
  - lib/generators/templates/rspec/scaffold/controller_spec.rb
149
152
  - lib/generators/templates/rspec/scaffold/routing_spec.rb
150
153
  - lib/generators/templates/rubocop/.rubocop.yml
154
+ - lib/generators/templates/rubocop/routing/.rubocop.yml
151
155
  - lib/generators/templates/spec/rails_helper.rb
156
+ - lib/generators/templates/support/assign_to_matcher.rb
152
157
  - lib/generators/templates/support/common_lets.rb
153
158
  - lib/generators/templates/support/database_cleaner.rb
154
159
  - lib/generators/templates/support/fracture.rb