seatbelt 0.4.0 → 0.5.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: b432a1876ac0af308c81961c8a7bf8f917cd12ce
4
- data.tar.gz: ba90186340d96bd9af93aafa527d4e01b39ea587
3
+ metadata.gz: 75abded8d89e147f457755b7fe7be161a0cb195e
4
+ data.tar.gz: 899c5958c9befb0313f5aade6da73c82fd321bf1
5
5
  SHA512:
6
- metadata.gz: c1618255ffc44a0ea50d76a28c98e1fa8c5d177bbea5f4275b6bb1c28548e61f743d4abaf59d1609ddbaa6e734f989f8bee2d0abe7fc0ac822b2fe0f37fd01d5
7
- data.tar.gz: 5f511fa0bf35717cdd82dac728ff2dda955329bb79fe7e62afe0b848ecb13107b75f572d222e69506fa751f9f7341e3da78b32931a41cf91c7377cd315f8001b
6
+ metadata.gz: 30dfbd2f4392fc3e7372f12197120dbe905c090ca9019b67aab5cb868c02a0dd2145d3a8e8333dca3c3c1ceea90f83253c794da1432ff613766821036804fab9
7
+ data.tar.gz: 77ae5490f7ca72ba12edea4d508b3b8589687e1b32232649a7034c1d17aec69c11fe34b948e9322db9316971b71708eff84647c33d2f985208a4b0e801a0eaf8
data/.travis.yml CHANGED
@@ -1,11 +1,10 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 1.8.7
5
- - 1.9.2
6
4
  - 1.9.3
7
5
  - 2.0.0
8
6
  - 2.1.0
7
+ - 2.2.3
9
8
  # - jruby-18mode # JRuby in 1.8 mode
10
9
  - jruby-19mode # JRuby in 1.9 mode
11
10
  - rbx-2.2.1
@@ -14,33 +13,33 @@ gemfile:
14
13
  - gemfiles/rails_3.2.gemfile
15
14
  - gemfiles/rails_4.0.gemfile
16
15
  - gemfiles/rails_4.1.gemfile
16
+ - gemfiles/rails_4.2.gemfile
17
17
 
18
18
  matrix:
19
19
  allow_failures:
20
20
  - rvm: rbx-2.2.1
21
21
  - rvm: jruby-19mode
22
+ - gemfile: gemfiles/rails_3.2.gemfile
22
23
  exclude:
23
- - rvm: 1.8.7
24
- gemfile: gemfiles/rails_4.0.gemfile
25
- - rvm: 1.9.2
26
- gemfile: gemfiles/rails_4.0.gemfile
27
24
  - rvm: 1.9.3
28
25
  gemfile: gemfiles/rails_4.0.gemfile
29
- - rvm: 1.8.7
30
- gemfile: gemfiles/rails_4.1.gemfile
31
- - rvm: 1.9.2
32
- gemfile: gemfiles/rails_4.1.gemfile
33
26
  - rvm: 1.9.3
34
27
  gemfile: gemfiles/rails_4.1.gemfile
28
+ - rvm: 1.9.3
29
+ gemfile: gemfiles/rails_4.2.gemfile
35
30
  - rvm: jruby-19mode
36
31
  gemfile: gemfiles/rails_3.2.gemfile
37
32
  - rvm: jruby-19mode
38
33
  gemfile: gemfiles/rails_4.0.gemfile
39
34
  - rvm: jruby-19mode
40
35
  gemfile: gemfiles/rails_4.1.gemfile
36
+ - rvm: jruby-19mode
37
+ gemfile: gemfiles/rails_4.2.gemfile
41
38
  - rvm: rbx-2.2.1
42
39
  gemfile: gemfiles/rails_3.2.gemfile
43
40
  - rvm: rbx-2.2.1
44
41
  gemfile: gemfiles/rails_4.0.gemfile
45
42
  - rvm: rbx-2.2.1
46
43
  gemfile: gemfiles/rails_4.1.gemfile
44
+ - rvm: rbx-2.2.1
45
+ gemfile: gemfiles/rails_4.2.gemfile
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.5.0
4
+
5
+ * fix issue with encoding for latest _mail_ gem version (`2.6.4`)
6
+ * drop support for Ruby version 1.8.7 and 1.9.2
7
+ * re-use assert_json code from the assert_json gem
8
+
3
9
  ## 0.4.0
4
10
 
5
11
  * supporting `refute_mail` now as well (minitest style) (see [issue #4](https://github.com/alto/seatbelt/pull/4)), thanks to [@jch](https://github.com/jch)
data/Gemfile CHANGED
@@ -2,6 +2,6 @@ source "https://rubygems.org"
2
2
 
3
3
  gem 'rubysl', :platforms => :rbx
4
4
  gem "jruby-openssl", :platforms => :jruby
5
- gem "rails", "4.1.0"
5
+ gem "rails", '~> 4'
6
6
 
7
7
  gemspec
data/README.md CHANGED
@@ -1,18 +1,13 @@
1
1
  # Seatbelt
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/alto/seatbelt.png)](http://travis-ci.org/alto/seatbelt)
4
- [![Code Climate](https://codeclimate.com/github/alto/seatbelt.png)](https://codeclimate.com/github/alto/seatbelt)
5
- [![Coverage Status](https://coveralls.io/repos/aasm/aasm/badge.png?branch=master)](https://coveralls.io/r/aasm/aasm)
3
+ [![Build Status](https://travis-ci.org/alto/seatbelt.svg?branch=master)](https://travis-ci.org/alto/seatbelt)
4
+ [![Code Climate](https://codeclimate.com/github/alto/seatbelt/badges/gpa.svg)](https://codeclimate.com/github/alto/seatbelt)
6
5
 
7
6
  Seatbelt provides a number of custom, high-level assertions for Ruby and Ruby on Rails. The assertions work well with Ruby
8
- [1.8.7](http://ruby-doc.org/core-1.8.7/),
9
- [1.9.2](http://ruby-doc.org/core-1.9.2/),
10
7
  [1.9.3](http://ruby-doc.org/core-1.9.3/),
11
- [2.0.0](http://ruby-doc.org/core-2.0.0/) and
12
- [2.1.0](http://ruby-doc.org/core-2.1.0/).
13
- This includes compatibility with
14
- [test/unit](http://ruby-doc.org/stdlib-1.8.7/libdoc/test/unit/rdoc/index.html) and
15
- [minitest](http://ruby-doc.org/stdlib-1.9.3/libdoc/minitest/unit/rdoc/index.html).
8
+ [2.0.0](http://ruby-doc.org/core-2.0.0/),
9
+ [2.0.0](http://ruby-doc.org/core-2.1.0/) and
10
+ [2.1.0](http://ruby-doc.org/core-2.2.0/).
16
11
 
17
12
  ## Installation
18
13
 
@@ -36,7 +31,7 @@ Test your [JSON](http://www.json.org/) strings
36
31
 
37
32
  ```ruby
38
33
  class MyActionTest < ActionController::TestCase
39
- include Seatbelt::AssertJson
34
+ include AssertJson
40
35
 
41
36
  def test_my_action
42
37
  get :my_action, :format => 'json'
@@ -109,7 +104,7 @@ end
109
104
 
110
105
  ## Changelog ##
111
106
 
112
- Look at the [CHANGELOG](https://github.com/xing/assert_json/blob/master/CHANGELOG.md) for details.
107
+ Look at the [CHANGELOG](https://github.com/alto/seatbelt/blob/master/CHANGELOG.md) for details.
113
108
 
114
109
  ## Authors ##
115
110
 
@@ -2,6 +2,6 @@ source "https://rubygems.org"
2
2
 
3
3
  gem 'rubysl', :platforms => :rbx
4
4
  gem "jruby-openssl", :platforms => :jruby
5
- gem "rails", "3.2.16"
5
+ gem "rails", "~>3"
6
6
 
7
7
  gemspec :path => "../"
@@ -2,6 +2,6 @@ source "https://rubygems.org"
2
2
 
3
3
  gem 'rubysl', :platforms => :rbx
4
4
  gem "jruby-openssl", :platforms => :jruby
5
- gem "rails", "4.0.2"
5
+ gem "rails", "~>4.0"
6
6
 
7
7
  gemspec :path => "../"
@@ -2,6 +2,6 @@ source "https://rubygems.org"
2
2
 
3
3
  gem 'rubysl', :platforms => :rbx
4
4
  gem "jruby-openssl", :platforms => :jruby
5
- gem "rails", "4.1.0"
5
+ gem "rails", "~>4.1"
6
6
 
7
7
  gemspec :path => "../"
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'rubysl', :platforms => :rbx
4
+ gem "jruby-openssl", :platforms => :jruby
5
+ gem "rails", "~>4.2"
6
+
7
+ gemspec :path => "../"
data/lib/seatbelt.rb CHANGED
@@ -1,12 +1,12 @@
1
1
  require "seatbelt/version"
2
- require 'seatbelt/assert_json'
2
+ require 'assert_json'
3
3
  require 'seatbelt/assert_mail'
4
4
  require 'seatbelt/assert_content_type'
5
5
 
6
6
  if defined?(Test)
7
7
  class Test::Unit::TestCase
8
8
  include Seatbelt::AssertContentType if defined?(ActionController)
9
- include Seatbelt::AssertJson
9
+ include AssertJson
10
10
  include Seatbelt::AssertMail if defined?(ActionMailer)
11
11
  end
12
12
  end
@@ -15,13 +15,13 @@ if defined?(Minitest)
15
15
  if Minitest::Unit::VERSION[0].to_i < 5
16
16
  class Minitest::Unit::TestCase
17
17
  include Seatbelt::AssertContentType if defined?(ActionController)
18
- include Seatbelt::AssertJson
18
+ include AssertJson
19
19
  include Seatbelt::AssertMail if defined?(ActionMailer)
20
20
  end
21
21
  else
22
22
  class Minitest::Test
23
23
  include Seatbelt::AssertContentType if defined?(ActionController)
24
- include Seatbelt::AssertJson
24
+ include AssertJson
25
25
  include Seatbelt::AssertMail if defined?(ActionMailer)
26
26
  end
27
27
  end
@@ -62,8 +62,8 @@ module Seatbelt
62
62
  def unexpected_body?(mail, options)
63
63
  if options[:body]
64
64
  Array(options[:body]).each do |element|
65
- if !mail.body.encoded.match(element)
66
- # puts "#{element} not found in body: #{mail.body.encoded}"
65
+ if !mail.body.match(element)
66
+ # puts "#{element} not found in body: #{mail.body}"
67
67
  return true
68
68
  end
69
69
  end
@@ -1,3 +1,3 @@
1
1
  module Seatbelt
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
data/seatbelt.gemspec CHANGED
@@ -16,11 +16,10 @@ Gem::Specification.new do |gem|
16
16
  gem.require_paths = ["lib"]
17
17
  gem.version = Seatbelt::VERSION
18
18
 
19
- gem.add_dependency 'multi_json'
19
+ gem.add_dependency 'assert_json'
20
20
 
21
21
  gem.add_development_dependency 'rake'
22
- gem.add_development_dependency 'minitest'
23
- # gem.add_development_dependency 'turn'
22
+ gem.add_development_dependency 'maxitest'
24
23
  gem.add_development_dependency 'travis-lint'
25
24
  gem.add_development_dependency 'json'
26
25
  gem.add_development_dependency 'mocha'
@@ -1,7 +1,7 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/test_helper')
2
2
 
3
3
  class Seatbelt::AssertJsonTest < Minitest::Test
4
- include Seatbelt::AssertJson
4
+ include AssertJson
5
5
 
6
6
  # def test_string
7
7
  # assert_json '"key"' do |json|
@@ -1,7 +1,7 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class Seatbelt::AssertJsonNewDslTest < Minitest::Test
4
- include Seatbelt::AssertJson
4
+ include AssertJson
5
5
 
6
6
  # def test_string
7
7
  # assert_json '"key"' do
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  class Seatbelt::AssertMailTest < Minitest::Test
4
4
 
5
5
  def test_assert_mail
6
- Mailer.test.deliver
6
+ deliver
7
7
 
8
8
  assert_mail :to => 'test@seatbelt.co.nz'
9
9
  assert_mail :cc => 'cc@seatbelt.co.nz'
@@ -18,7 +18,7 @@ class Seatbelt::AssertMailTest < Minitest::Test
18
18
  assert_mail :to => 'test@seatbelt.co.nz', :subject => /subject/, :body => 'body'
19
19
  end
20
20
  def test_assert_mail_crosscheck
21
- Mailer.test.deliver
21
+ deliver
22
22
 
23
23
  assert_assertion_fails { assert_mail :to => 'unknown@seatbelt.co.nz' }
24
24
  assert_assertion_fails { assert_mail :cc => 'unknown@seatbelt.co.nz' }
@@ -30,8 +30,8 @@ class Seatbelt::AssertMailTest < Minitest::Test
30
30
  end
31
31
 
32
32
  def test_assert_mail_with_multiple_mails
33
- Mailer.test.deliver
34
- Mailer.test(:to => 'another@seatbelt.co.nz').deliver
33
+ deliver
34
+ deliver :to => 'another@seatbelt.co.nz'
35
35
 
36
36
  assert_mail :to => 'test@seatbelt.co.nz'
37
37
  assert_mail :to => 'another@seatbelt.co.nz'
@@ -39,13 +39,13 @@ class Seatbelt::AssertMailTest < Minitest::Test
39
39
 
40
40
  def test_assert_mail_with_block
41
41
  assert_mail :to => 'test@seatbelt.co.nz', :subject => /subject/, :body => 'body' do
42
- Mailer.test.deliver
42
+ deliver
43
43
  end
44
44
  end
45
45
  def test_assert_mail_with_block_crosscheck
46
46
  assert_assertion_fails do
47
47
  assert_mail :to => 'unknown@seatbelt.co.nz' do
48
- Mailer.test.deliver
48
+ deliver
49
49
  end
50
50
  end
51
51
  end
@@ -59,22 +59,28 @@ class Seatbelt::AssertMailTest < Minitest::Test
59
59
  refute_mail { 3 }
60
60
 
61
61
  assert_no_mail :to => 'another@seatbelt.co.nz' do
62
- Mailer.test.deliver
62
+ deliver
63
63
  end
64
64
  assert_no_mail :subject => 'my other subject' do
65
- Mailer.test.deliver
65
+ deliver
66
66
  end
67
67
  assert_no_mail :body => 'my other body text' do
68
- Mailer.test.deliver
68
+ deliver
69
69
  end
70
70
  end
71
71
 
72
72
  def test_assert_no_mail_crosscheck
73
73
  assert_assertion_fails do
74
74
  assert_no_mail :to => 'test@seatbelt.co.nz' do
75
- Mailer.test.deliver
75
+ deliver
76
76
  end
77
77
  end
78
78
  end
79
79
 
80
+ private
81
+
82
+ def deliver(*args)
83
+ ActionMailer::VERSION::MAJOR > 3 ? Mailer.test(*args).deliver_now : Mailer.test(*args).deliver
84
+ end
85
+
80
86
  end
data/test/test_helper.rb CHANGED
@@ -1,5 +1,4 @@
1
- require 'minitest/autorun'
2
- # require 'turn/autorun'
1
+ require 'maxitest/autorun'
3
2
  require 'active_support'
4
3
  require 'action_mailer'
5
4
  require 'json'
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seatbelt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thorsten Böttger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-01 00:00:00.000000000 Z
11
+ date: 2016-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: multi_json
14
+ name: assert_json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: minitest
42
+ name: maxitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -112,9 +112,9 @@ files:
112
112
  - gemfiles/rails_3.2.gemfile
113
113
  - gemfiles/rails_4.0.gemfile
114
114
  - gemfiles/rails_4.1.gemfile
115
+ - gemfiles/rails_4.2.gemfile
115
116
  - lib/seatbelt.rb
116
117
  - lib/seatbelt/assert_content_type.rb
117
- - lib/seatbelt/assert_json.rb
118
118
  - lib/seatbelt/assert_mail.rb
119
119
  - lib/seatbelt/version.rb
120
120
  - seatbelt.gemspec
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  version: '0'
145
145
  requirements: []
146
146
  rubyforge_project:
147
- rubygems_version: 2.2.2
147
+ rubygems_version: 2.4.5
148
148
  signing_key:
149
149
  specification_version: 4
150
150
  summary: Provide custom assertions for Ruby and Ruby on Rails
@@ -1,105 +0,0 @@
1
- require 'multi_json'
2
- module Seatbelt
3
- module AssertJson
4
-
5
- def assert_json(json_string, &block)
6
- if block_given?
7
- @json = AssertJson::Json.new(json_string)
8
- # json.instance_exec(json, &block)
9
- yield @json
10
- end
11
- end
12
-
13
- def has(*args, &block)
14
- @json.has(*args, &block)
15
- end
16
-
17
- def has_not(*args, &block)
18
- @json.has_not(*args, &block)
19
- end
20
-
21
- class Json
22
-
23
- def initialize(json_string)
24
- @decoded_json = MultiJson.decode(json_string)
25
- end
26
-
27
- def has(*args, &block)
28
- arg = args.shift
29
- token = @decoded_json.is_a?(Array) ? @decoded_json.shift : @decoded_json
30
-
31
- case token
32
- when Hash
33
- has_hash(token, arg, args)
34
- when Array
35
- has_array(token, arg)
36
- when String
37
- has_string(token, arg)
38
- when NilClass
39
- raise_error("no element left")
40
- else
41
- flunk
42
- end
43
-
44
- if block_given?
45
- begin
46
- in_scope, @decoded_json = @decoded_json, token.is_a?(Hash) ? token[arg] : token
47
- yield
48
- ensure
49
- @decoded_json = in_scope
50
- end
51
- end
52
-
53
- end
54
- alias element has
55
-
56
- def has_not(*args, &block)
57
- arg = args.shift
58
- token = @decoded_json
59
- case token
60
- when Array
61
- raise_error("element #{arg} found, but not expected") if token.include?(arg)
62
- else
63
- raise_error("element #{arg} found, but not expected") if token.keys.include?(arg)
64
- end
65
- end
66
- alias not_element has_not
67
-
68
- private
69
-
70
- def raise_error(message)
71
- if Object.const_defined?(:MiniTest)
72
- raise MiniTest::Assertion.new(message)
73
- else
74
- raise Test::Unit::AssertionFailedError.new(message)
75
- end
76
- end
77
-
78
- def has_hash(token, arg, args)
79
- raise_error("element #{arg} not found") unless token.keys.include?(arg)
80
- if second_arg = args.shift
81
- case second_arg
82
- when Regexp
83
- raise_error("element #{token[arg].inspect} does not match #{second_arg.inspect}") if second_arg !~ token[arg]
84
- else
85
- raise_error("element #{token[arg].inspect} does not match #{second_arg.inspect}") if second_arg != token[arg]
86
- end
87
- end
88
- end
89
-
90
- def has_array(token, arg)
91
- raise_error("element #{arg} not found") if token != arg
92
- end
93
-
94
- def has_string(token, arg)
95
- case arg
96
- when Regexp
97
- raise_error("element #{arg.inspect} not found") if token !~ arg
98
- else
99
- raise_error("element #{arg.inspect} not found") if token != arg
100
- end
101
- end
102
-
103
- end
104
- end
105
- end