lookout-rack-test 2.3.1 → 3.0.0

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: 5966c38c1c55f5245f2973d343f23faf22994761
4
- data.tar.gz: 77e1c227f30e6ac8b5b27033cdae1c2dfa9c1618
3
+ metadata.gz: d772480091efff46c2b182b767967e47884f696e
4
+ data.tar.gz: 08e06bcd1d781492e44c9754e10f1fda21909eb8
5
5
  SHA512:
6
- metadata.gz: 36178e2b41cc81aa640ef85ee83975e6b091cd650ca0b2fd53f4110ab3844306cbeb1ec63c378b4cf95ebb2e628c17a68d7ebc8dd07a95c3a4395a82713f0cb7
7
- data.tar.gz: fadc37c301f92ee2b0ab8afe18df8660a771e1cfe4547be62c3ec99700d54b3f6f3e4fb076abee655c4d477ca224003d311dabcb1b8dfe6914d591d078416def
6
+ metadata.gz: a353035ed4598e473a23f3733a38143c2bc0a71252c7e091a5df08f2c1609defc743d78785ba67361b786d1289eff0e8d6758a61923d6589b70488845cf582eb
7
+ data.tar.gz: b497c3d94f55aee5dbbd3bedb64671a75f4c13fd2c60fb4103b7a1aad52c501b75dcaa6249087cb4fd1bad9d9b7ebf389d71ed437659d3923b01e2696e38cab3
@@ -4,4 +4,8 @@ rvm:
4
4
  - 1.9.3
5
5
  - jruby
6
6
  before_install:
7
- - gem install bundler
7
+ - gem install bundler
8
+ deploy:
9
+ provider: rubygems
10
+ api_key:
11
+ secure: NYRm2JAJY5zSehxYUDioKYidvU7QaGw0BtFqxo4wzdvQite7ZLOW4dtBiKv5kdFcpkUQhnrD2ilGkt3XhImqt4T20MA12JgZBZa17/vZHXN2bAkxkubx9Sqo7G4Rcip+x2vLZNlcJnaU76+91zBEyp9ts4jvljriANbUn4eFmuE=
data/Gemfile CHANGED
@@ -2,3 +2,11 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in lookout-rack-test.gemspec
4
4
  gemspec
5
+
6
+ # For local tests, pin dependencies for pre Ruby 2.X
7
+ if RUBY_VERSION.start_with?("1")
8
+ gem "activesupport", "< 5"
9
+ gem "liquid", "< 4"
10
+ elsif RUBY_VERSION =~ (/^2.[01]/)
11
+ gem "activesupport", "< 5"
12
+ end
@@ -16,12 +16,22 @@ When /^I (GET|PUT|POST|PATCH|DELETE)( to)? "([^"]*)" with:$/ do |verb, unused, u
16
16
  send(verb, render_string(url), options, headers)
17
17
  end
18
18
 
19
- When /^I (GET|PUT|POST|PATCH|DELETE) to "(.*?)" with the JSON:$/ do |verb, url, body|
19
+ When /^I (GET|PUT|POST|PATCH) to "(.*?)" with the JSON:$/ do |verb, url, body|
20
20
  verb = verb.downcase.to_sym
21
21
  headers = template_vars['headers'] || {}
22
22
  send(verb, render_string(url), render_string(body), headers)
23
23
  end
24
24
 
25
+ When /^I DELETE to "(.*?)" with the JSON:$/ do |url, body|
26
+ # Rack::Test lost the ability to provide a body for delete
27
+ # requests. Until https://github.com/rack-test/rack-test/issues/200
28
+ # is resolved, work around this
29
+ env = {:method => :delete,
30
+ :input => render_string(body),
31
+ }.merge(template_vars['headers'] || {})
32
+ request render_string(url), env
33
+ end
34
+
25
35
  Then /^the response (should be|is) (\d+)$/ do |verb, code|
26
36
  expect(last_response.status).to eq(code), "expected #{code} got #{last_response.status} \n\n #{last_response.body}
27
37
  "
@@ -51,4 +61,4 @@ end
51
61
  When /^I (PUT|POST) a file to "(.*?)"$/ do |verb, url|
52
62
  verb = verb.downcase.to_sym
53
63
  send(verb, render_string(url), "some file", template_vars['headers'] || {})
54
- end
64
+ end
@@ -1,5 +1,5 @@
1
1
  unless $factories_loaded
2
- require 'factory_girl'
3
- ::FactoryGirl.find_definitions
2
+ require 'factory_bot'
3
+ ::FactoryBot.find_definitions
4
4
  $factories_loaded = true
5
5
  end
@@ -1,11 +1,6 @@
1
1
  require 'cucumber/rake/task'
2
2
  require 'ci/reporter/rake/cucumber'
3
3
 
4
- # parallel_tests is somewhat pointless/nonfunctional on JRuby
5
- unless RUBY_PLATFORM == 'java'
6
- require 'parallel_tests/tasks'
7
- end
8
-
9
4
  namespace :cucumber do
10
5
  Cucumber::Rake::Task.new(:api) do |t|
11
6
  t.cucumber_opts = '--profile api'
@@ -1,6 +1,7 @@
1
1
  require 'rspec'
2
2
  require 'rack/test'
3
3
  require 'timecop'
4
+ require 'factory_bot'
4
5
 
5
6
  require 'lookout/rack/test'
6
7
  module Lookout::Rack::Test
@@ -19,29 +20,31 @@ module Lookout
19
20
  # .unsetup method
20
21
  def setup_models(models)
21
22
  ::RSpec.configure do |c|
23
+ c.include FactoryBot::Syntax::Methods
24
+
22
25
  c.around(:each, :speed => :slow) do |example|
23
26
  models.setup
24
27
  example.run
25
28
  models.unsetup
26
29
  end
27
-
30
+
28
31
  c.before(:all, :speed => :slow) do
29
32
  require 'lookout/rack/test/load_factories'
30
33
  end
31
34
  end
32
35
  end
33
-
36
+
34
37
  # Takes one argument, the application (e.g., SinatraApplication)
35
38
  def setup_routes(application)
36
39
  ::RSpec.configure do |c|
37
40
  c.include(::Rack::Test::Methods, :type => :route)
38
-
41
+
39
42
  require 'lookout/rack/test/rspec/route_helper'
40
43
  ::Lookout::Rack::Test.app = application
41
44
  c.include(::RouteHelper, :type => :route)
42
45
  end
43
46
  end
44
-
47
+
45
48
  def configure_rspec
46
49
  ::RSpec.configure do |c|
47
50
  c.around(:each, :timefreeze => true) do |example|
@@ -3,18 +3,18 @@ require 'rspec'
3
3
  module Lookout::Rack::Test::RSpec
4
4
  class FakeRequest
5
5
  attr_accessor :session, :env, :request
6
-
6
+
7
7
  def initialize
8
8
  @session = {}
9
9
  @env = {}
10
10
  @request = Object.new
11
11
  @request.stub(:path_info).and_return('')
12
12
  end
13
-
13
+
14
14
  def redirect(path, params={}); end # So we can catch calls to the redirect method
15
-
15
+
16
16
  def halt(status, error_string); end
17
-
17
+
18
18
  def to(url); url; end
19
19
  end
20
20
  end
@@ -1,7 +1,7 @@
1
1
  module Lookout
2
2
  module Rack
3
3
  module Test
4
- VERSION = "2.3.1"
4
+ VERSION = "3.0.0"
5
5
  end
6
6
  end
7
7
  end
@@ -32,7 +32,6 @@ Gem::Specification.new do |spec|
32
32
  # For freezing time inside of tests
33
33
  spec.add_dependency 'timecop'
34
34
  # Used to assist with scaffolded data and generating random data
35
- spec.add_dependency 'factory_girl'
35
+ spec.add_dependency 'factory_bot'
36
36
  spec.add_dependency 'cucumber'
37
- spec.add_dependency 'parallel_tests'
38
- end
37
+ end
@@ -0,0 +1,4 @@
1
+ FactoryBot.define do
2
+ factory :fake_request do
3
+ end
4
+ end
@@ -24,12 +24,26 @@ describe ':speed => :slow' do
24
24
  it 'should have called .setup on the Models module' do
25
25
  expect(TestModels.was_setup?).to be true
26
26
  end
27
+
28
+ it 'loads factories' do
29
+ expect(FactoryBot.build(:fake_request)).not_to be_nil
30
+ end
27
31
  end
28
32
 
29
33
  context 'a test not marked as :speed => :slow' do
34
+ before do
35
+ # Unload factories in case they were loaded in 'loads factories' spec above.
36
+ FactoryBot.reset_configuration
37
+ FactoryBot.register_default_strategies
38
+ end
39
+
30
40
  it 'should not have called .setup on the Models module' do
31
41
  expect(TestModels.was_setup?).to be false
32
42
  end
43
+
44
+ it 'does not load factories' do
45
+ expect { FactoryBot.build(:fake_request) }.to raise_error(/Factory not registered/)
46
+ end
33
47
  end
34
48
  end
35
49
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lookout-rack-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-03 00:00:00.000000000 Z
11
+ date: 2017-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -151,7 +151,7 @@ dependencies:
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: factory_girl
154
+ name: factory_bot
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
@@ -178,20 +178,6 @@ dependencies:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
- - !ruby/object:Gem::Dependency
182
- name: parallel_tests
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - ">="
186
- - !ruby/object:Gem::Version
187
- version: '0'
188
- type: :runtime
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - ">="
193
- - !ruby/object:Gem::Version
194
- version: '0'
195
181
  description: RSpec and Cucumber helpers
196
182
  email:
197
183
  - ian.smith@lookout.com
@@ -236,6 +222,7 @@ files:
236
222
  - lib/lookout/rack/test/rspec/route_helper.rb
237
223
  - lib/lookout/rack/test/version.rb
238
224
  - lookout-rack-test.gemspec
225
+ - spec/factories/fake_request.rb
239
226
  - spec/model_examples_spec.rb
240
227
  - spec/setup_spec.rb
241
228
  - spec/spec_helper.rb
@@ -259,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
259
246
  version: '0'
260
247
  requirements: []
261
248
  rubyforge_project:
262
- rubygems_version: 2.4.5.1
249
+ rubygems_version: 2.6.14
263
250
  signing_key:
264
251
  specification_version: 4
265
252
  summary: ''
@@ -276,6 +263,7 @@ test_files:
276
263
  - features/step_definitions/timefreeze_steps.rb
277
264
  - features/support/env.rb
278
265
  - features/timefreeze.feature
266
+ - spec/factories/fake_request.rb
279
267
  - spec/model_examples_spec.rb
280
268
  - spec/setup_spec.rb
281
269
  - spec/spec_helper.rb