json_spec 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MDEyZjVhZTBmM2M5MTE2ZmRkY2IzMWIwNzRiNzY5ODNiNjE2YjNlZg==
5
- data.tar.gz: !binary |-
6
- YzAyNTgzMmE3N2Y4ZjUyZGIwZjM3NGY5ZDlmYTk2MjBlZGIzNTNlZA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- YzA1MDUwZDlmM2Y4MjMzMDMyOGU4OTE2Yjk2Mzk1NjA2NGM5MzYwNmE1ZWE1
10
- N2U4ZTNkZmVjZGZlZGVmNDYxYTczMDQ1NjdmMTZmODI1NjllMTc5ZjY1YjEx
11
- MTZhNjA5YTU3MzdmN2NmNWNiMzA4ZTQxYjgwMmQwOGNlOTg3ZGM=
12
- data.tar.gz: !binary |-
13
- Y2U3OWY4OTYyNjNiMjU5MTZmNzBlMDNhZTU0ZGE0NGVmMGRhNWEwYWNiMzdj
14
- YTk2MTVlM2JkNjcxOTliMmVmY2VjNDU1NjcwYmRiNmVhYTQ4YjhmYjY2MDk0
15
- NTA1MzY1Yzk3ZTFmMGFkZTliOWFlN2RiMTcwMGI5NTk5ZTdmNjA=
2
+ SHA1:
3
+ metadata.gz: cb0b1f7ab27245791f7d65778506309a14a43645
4
+ data.tar.gz: 3aa7d4931332e3ffe04d7d44da3d8256b7fa613f
5
+ SHA512:
6
+ metadata.gz: ed9cb913d6d387841c2f7a725b4aaf192cf3a4aa72dad6e052f155574cdb563232ecb8f1d780d1a2636a324c6c8ea42cb7e9f4a15f0ffeb601ed294a6c19da7a
7
+ data.tar.gz: 3fba85ecb36f7d03cb4f04a661622f43b51764ec04ae9f3b6312c8f67bd54084cbbb9f6563c0121f1eb30a4ed85fedcf70d52140b64d6015498ee06b7c0bda84
data/.gitignore CHANGED
@@ -1,6 +1,4 @@
1
- *.gem
2
1
  .bundle
3
- .rvmrc
4
2
  Gemfile.lock
5
3
  gemfiles/*.lock
6
- pkg/*
4
+ pkg
@@ -1,6 +1,15 @@
1
+ branches:
2
+ only:
3
+ - master
4
+ gemfile:
5
+ - gemfiles/rspec2.gemfile
6
+ - gemfiles/rspec3.gemfile
1
7
  language: ruby
2
- branches: master
8
+ matrix:
9
+ allow_failures:
10
+ - rvm: ruby-head
3
11
  rvm:
4
- - 1.9.2
5
12
  - 1.9.3
6
- - 2.0.0
13
+ - "2.0"
14
+ - "2.1"
15
+ - ruby-head
data/Gemfile CHANGED
@@ -3,6 +3,5 @@ source "https://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  group :test do
6
- gem "cucumber", "~> 1.1", ">= 1.1.1"
7
- gem "rake", "~> 10.0"
6
+ gem "cucumber", "~> 1.3"
8
7
  end
File without changes
data/README.md CHANGED
@@ -1,10 +1,13 @@
1
- json_spec [![Build Status](https://secure.travis-ci.org/collectiveidea/json_spec.png)](http://travis-ci.org/collectiveidea/json_spec) [![Dependency Status](https://gemnasium.com/collectiveidea/json_spec.png)](https://gemnasium.com/collectiveidea/json_spec) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/collectiveidea/json_spec)
2
- =========
1
+ # json_spec
3
2
 
4
3
  Easily handle JSON in RSpec and Cucumber
5
4
 
6
- RSpec
7
- --------------
5
+ [![Gem Version](https://img.shields.io/gem/v/json_spec.svg?style=flat)](http://rubygems.org/gems/json_spec)
6
+ [![Build Status](https://img.shields.io/travis/collectiveidea/json_spec/master.svg?style=flat)](https://travis-ci.org/collectiveidea/json_spec)
7
+ [![Code Climate](https://img.shields.io/codeclimate/github/collectiveidea/json_spec.svg?style=flat)](https://codeclimate.com/github/collectiveidea/json_spec)
8
+ [![Dependency Status](https://img.shields.io/gemnasium/collectiveidea/json_spec.svg?style=flat)](https://gemnasium.com/collectiveidea/json_spec)
9
+
10
+ ## RSpec
8
11
 
9
12
  json_spec defines five new RSpec matchers:
10
13
 
@@ -101,8 +104,7 @@ hash keys and array indexes. For instance, with the following JSON:
101
104
 
102
105
  We could access the first friend's first name with the path `"friends/0/first_name"`.
103
106
 
104
- Cucumber
105
- --------
107
+ ## Cucumber
106
108
 
107
109
  json_spec provides Cucumber steps that utilize its RSpec matchers and that's where json_spec really
108
110
  shines. This is perfect for testing your app's JSON API.
@@ -316,8 +318,7 @@ Check out the [specs](https://github.com/collectiveidea/json_spec/blob/master/sp
316
318
  and [features](https://github.com/collectiveidea/json_spec/blob/master/features) to see all the
317
319
  various ways you can use json_spec.
318
320
 
319
- Contributing
320
- ------------
321
+ ## Contributing
321
322
 
322
323
  If you come across any issues, please [tell us](https://github.com/collectiveidea/json_spec/issues).
323
324
  Pull requests (with tests) are appreciated. No pull request is too small. Please help with:
@@ -333,8 +334,7 @@ Pull requests (with tests) are appreciated. No pull request is too small. Please
333
334
 
334
335
  If you report a bug and don't include a fix, please include a failing test.
335
336
 
336
- Copyright
337
- ---------
337
+ ## Copyright
338
338
 
339
339
  Copyright © 2011 Steve Richert
340
340
 
data/Rakefile CHANGED
@@ -3,13 +3,14 @@ require "rspec/core/rake_task"
3
3
  require "cucumber/rake/task"
4
4
 
5
5
  RSpec::Core::RakeTask.new(:spec)
6
- Cucumber::Rake::Task.new(:cucumber) do |t|
7
- t.cucumber_opts = "--tags ~@fail"
6
+
7
+ Cucumber::Rake::Task.new(:cucumber) do |task|
8
+ task.cucumber_opts = "--tags ~@fail"
8
9
  end
9
10
 
10
- Cucumber::Rake::Task.new(:negative_cucumber) do |t|
11
- t.cucumber_opts = "--tags @fail --wip"
11
+ Cucumber::Rake::Task.new(:negative_cucumber) do |task|
12
+ task.cucumber_opts = "--tags @fail --wip"
12
13
  end
13
14
 
14
- task :test => [:spec, :cucumber, :negative_cucumber]
15
- task :default => :test
15
+ task test: [:spec, :cucumber, :negative_cucumber]
16
+ task default: :test
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: ".."
4
+
5
+ gem "rspec", "~> 2.0"
6
+
7
+ group :test do
8
+ gem "cucumber", "~> 1.3"
9
+ end
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: ".."
4
+
5
+ gem "rspec", "~> 3.0"
6
+
7
+ group :test do
8
+ gem "cucumber", "~> 1.3"
9
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "json_spec"
5
- gem.version = "1.1.1"
5
+ gem.version = "1.1.2"
6
6
 
7
7
  gem.authors = ["Steve Richert"]
8
8
  gem.email = ["steve.richert@gmail.com"]
@@ -12,11 +12,11 @@ Gem::Specification.new do |gem|
12
12
  gem.license = "MIT"
13
13
 
14
14
  gem.add_dependency "multi_json", "~> 1.0"
15
- gem.add_dependency "rspec", "~> 2.0"
15
+ gem.add_dependency "rspec", ">= 2.0", "< 4.0"
16
16
 
17
17
  gem.add_development_dependency "bundler", "~> 1.0"
18
+ gem.add_development_dependency "rake", "~> 10.0"
18
19
 
19
- gem.files = `git ls-files`.split($\)
20
- gem.test_files = gem.files.grep(/^(features|spec)/)
21
- gem.require_paths = ["lib"]
20
+ gem.files = `git ls-files`.split($\)
21
+ gem.test_files = gem.files.grep(/^(features|spec)/)
22
22
  end
@@ -29,7 +29,7 @@ module JsonSpec
29
29
  end
30
30
 
31
31
  def reset
32
- instance_variables.each{|ivar| remove_instance_variable(ivar) }
32
+ instance_variables.each { |ivar| remove_instance_variable(ivar) }
33
33
  end
34
34
  end
35
35
  end
@@ -42,13 +42,15 @@ module JsonSpec
42
42
  self
43
43
  end
44
44
 
45
- def failure_message_for_should
45
+ def failure_message
46
46
  message_with_path("Expected equivalent JSON")
47
47
  end
48
+ alias :failure_message_for_should :failure_message
48
49
 
49
- def failure_message_for_should_not
50
+ def failure_message_when_negated
50
51
  message_with_path("Expected inequivalent JSON")
51
52
  end
53
+ alias :failure_message_for_should_not :failure_message_when_negated
52
54
 
53
55
  def description
54
56
  message_with_path("equal JSON")
@@ -14,13 +14,15 @@ module JsonSpec
14
14
  false
15
15
  end
16
16
 
17
- def failure_message_for_should
17
+ def failure_message
18
18
  %(Expected JSON path "#{@path}")
19
19
  end
20
+ alias :failure_message_for_should :failure_message
20
21
 
21
- def failure_message_for_should_not
22
+ def failure_message_when_negated
22
23
  %(Expected no JSON path "#{@path}")
23
24
  end
25
+ alias :failure_message_for_should_not :failure_message_when_negated
24
26
 
25
27
  def description
26
28
  %(have JSON path "#{@path}")
@@ -19,13 +19,15 @@ module JsonSpec
19
19
  self
20
20
  end
21
21
 
22
- def failure_message_for_should
22
+ def failure_message
23
23
  message_with_path("Expected JSON value size to be #{@expected}, got #{@actual}")
24
24
  end
25
+ alias :failure_message_for_should :failure_message
25
26
 
26
- def failure_message_for_should_not
27
+ def failure_message_when_negated
27
28
  message_with_path("Expected JSON value size to not be #{@expected}, got #{@actual}")
28
29
  end
30
+ alias :failure_message_for_should_not :failure_message_when_negated
29
31
 
30
32
  def description
31
33
  message_with_path(%(have JSON size "#{@expected}"))
@@ -10,7 +10,7 @@ module JsonSpec
10
10
 
11
11
  def matches?(json)
12
12
  @ruby = parse_json(json, @path)
13
- @classes.any?{|c| c === @ruby }
13
+ @classes.any? { |c| c === @ruby }
14
14
  end
15
15
 
16
16
  def at_path(path)
@@ -18,13 +18,15 @@ module JsonSpec
18
18
  self
19
19
  end
20
20
 
21
- def failure_message_for_should
21
+ def failure_message
22
22
  message_with_path("Expected JSON value type to be #{@classes.join(", ")}, got #{@ruby.class}")
23
23
  end
24
+ alias :failure_message_for_should :failure_message
24
25
 
25
- def failure_message_for_should_not
26
+ def failure_message_when_negated
26
27
  message_with_path("Expected JSON value type to not be #{@classes.join(", ")}, got #{@ruby.class}")
27
28
  end
29
+ alias :failure_message_for_should_not :failure_message_when_negated
28
30
 
29
31
  def description
30
32
  message_with_path(%(have JSON type "#{@classes.join(", ")}"))
@@ -34,7 +36,7 @@ module JsonSpec
34
36
  def type_to_classes(type)
35
37
  case type
36
38
  when Class then [type]
37
- when Array then type.map{|t| type_to_classes(t) }.flatten
39
+ when Array then type.map { |t| type_to_classes(t) }.flatten
38
40
  else
39
41
  case type.to_s.downcase
40
42
  when "boolean" then [TrueClass, FalseClass]
@@ -15,8 +15,8 @@ module JsonSpec
15
15
  actual = parse_json(actual_json, @path)
16
16
  expected = exclude_keys(parse_json(@expected_json))
17
17
  case actual
18
- when Hash then actual.values.map{|v| exclude_keys(v) }.include?(expected)
19
- when Array then actual.map{|e| exclude_keys(e) }.include?(expected)
18
+ when Hash then actual.values.map { |v| exclude_keys(v) }.include?(expected)
19
+ when Array then actual.map { |e| exclude_keys(e) }.include?(expected)
20
20
  when String then actual.include?(expected)
21
21
  else false
22
22
  end
@@ -42,13 +42,15 @@ module JsonSpec
42
42
  self
43
43
  end
44
44
 
45
- def failure_message_for_should
45
+ def failure_message
46
46
  message_with_path("Expected included JSON")
47
47
  end
48
+ alias :failure_message_for_should :failure_message
48
49
 
49
- def failure_message_for_should_not
50
+ def failure_message_when_negated
50
51
  message_with_path("Expected excluded JSON")
51
52
  end
53
+ alias :failure_message_for_should_not :failure_message_when_negated
52
54
 
53
55
  def description
54
56
  message_with_path("include JSON")
@@ -16,12 +16,12 @@ describe JsonSpec::Configuration do
16
16
  end
17
17
 
18
18
  it "excludes custom keys via block" do
19
- JsonSpec.configure{|c| c.exclude_keys("token") }
19
+ JsonSpec.configure { |c| c.exclude_keys("token") }
20
20
  JsonSpec.excluded_keys.should == ["token"]
21
21
  end
22
22
 
23
23
  it "excludes custom keys via block setter" do
24
- JsonSpec.configure{|c| c.excluded_keys = ["token"] }
24
+ JsonSpec.configure { |c| c.excluded_keys = ["token"] }
25
25
  JsonSpec.excluded_keys.should == ["token"]
26
26
  end
27
27
 
@@ -28,8 +28,8 @@ describe JsonSpec::Matchers::BeJsonEql do
28
28
  it "ignores excluded-by-default hash keys" do
29
29
  JsonSpec.excluded_keys.should_not be_empty
30
30
 
31
- actual = expected = {"json" => "spec"}
32
- JsonSpec.excluded_keys.each{|k| actual[k] = k }
31
+ actual = expected = { "json" => "spec" }
32
+ JsonSpec.excluded_keys.each { |k| actual[k] = k }
33
33
  actual.to_json.should be_json_eql(expected.to_json)
34
34
  end
35
35
 
@@ -21,16 +21,18 @@ describe JsonSpec::Matchers::HaveJsonSize do
21
21
  %({"one":[1,2,3]}).should have_json_size(3).at_path("one")
22
22
  end
23
23
 
24
- it "provides a failure message for should" do
24
+ it "provides a failure message" do
25
25
  matcher = have_json_size(3)
26
26
  matcher.matches?(%([1,2]))
27
- matcher.failure_message_for_should.should == "Expected JSON value size to be 3, got 2"
27
+ matcher.failure_message.should == "Expected JSON value size to be 3, got 2"
28
+ matcher.failure_message_for_should.should == "Expected JSON value size to be 3, got 2" # RSpec 2 interface
28
29
  end
29
30
 
30
- it "provides a failure message for should not" do
31
+ it "provides a failure message for negation" do
31
32
  matcher = have_json_size(3)
32
33
  matcher.matches?(%([1,2,3]))
33
- matcher.failure_message_for_should_not.should == "Expected JSON value size to not be 3, got 3"
34
+ matcher.failure_message_when_negated.should == "Expected JSON value size to not be 3, got 3"
35
+ matcher.failure_message_for_should_not.should == "Expected JSON value size to not be 3, got 3" # RSpec 2 interface
34
36
  end
35
37
 
36
38
  it "provides a description message" do
@@ -46,16 +46,18 @@ describe JsonSpec::Matchers::HaveJsonType do
46
46
  %(10.0).should have_json_type(Numeric)
47
47
  end
48
48
 
49
- it "provides a failure message for should" do
49
+ it "provides a failure message" do
50
50
  matcher = have_json_type(Numeric)
51
51
  matcher.matches?(%("foo"))
52
- matcher.failure_message_for_should.should == "Expected JSON value type to be Numeric, got String"
52
+ matcher.failure_message.should == "Expected JSON value type to be Numeric, got String"
53
+ matcher.failure_message_for_should.should == "Expected JSON value type to be Numeric, got String" # RSpec 2 interface
53
54
  end
54
55
 
55
- it "provides a failure message for should not" do
56
+ it "provides a failure message for negation" do
56
57
  matcher = have_json_type(Numeric)
57
58
  matcher.matches?(%(10))
58
- matcher.failure_message_for_should_not.should == "Expected JSON value type to not be Numeric, got Fixnum"
59
+ matcher.failure_message_when_negated.should == "Expected JSON value type to not be Numeric, got Fixnum"
60
+ matcher.failure_message_for_should_not.should == "Expected JSON value type to not be Numeric, got Fixnum" # RSpec 2 interface
59
61
  end
60
62
 
61
63
  it "provides a description message" do
@@ -7,12 +7,12 @@ describe JsonSpec::Memory do
7
7
 
8
8
  it "memorizes strings" do
9
9
  JsonSpec.memorize(:key, "value")
10
- JsonSpec.memory.should == {:key => "value"}
10
+ JsonSpec.memory.should == { key: "value" }
11
11
  end
12
12
 
13
13
  it "symbolizes keys" do
14
14
  JsonSpec.memorize("key", "value")
15
- JsonSpec.memory.should == {:key => "value"}
15
+ JsonSpec.memory.should == { key: "value" }
16
16
  end
17
17
 
18
18
  it "regurgitates unremembered strings" do
@@ -4,6 +4,13 @@ RSpec.configure do |config|
4
4
  config.before do
5
5
  JsonSpec.reset
6
6
  end
7
+
8
+ config.expect_with :rspec do |c|
9
+ c.syntax = [:should, :expect]
10
+ end
11
+ config.mock_with :rspec do |c|
12
+ c.syntax = [:should, :expect]
13
+ end
7
14
  end
8
15
 
9
16
  def files_path
metadata CHANGED
@@ -1,57 +1,77 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Richert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-19 00:00:00.000000000 Z
11
+ date: 2014-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '2.0'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '4.0'
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - ~>
41
+ - - ">="
39
42
  - !ruby/object:Gem::Version
40
43
  version: '2.0'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '4.0'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: bundler
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - ~>
51
+ - - "~>"
46
52
  - !ruby/object:Gem::Version
47
53
  version: '1.0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - ~>
58
+ - - "~>"
53
59
  - !ruby/object:Gem::Version
54
60
  version: '1.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '10.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '10.0'
55
75
  description: RSpec matchers and Cucumber steps for testing JSON content
56
76
  email:
57
77
  - steve.richert@gmail.com
@@ -59,10 +79,10 @@ executables: []
59
79
  extensions: []
60
80
  extra_rdoc_files: []
61
81
  files:
62
- - .gitignore
63
- - .travis.yml
82
+ - ".gitignore"
83
+ - ".travis.yml"
64
84
  - Gemfile
65
- - LICENSE
85
+ - LICENSE.txt
66
86
  - README.md
67
87
  - Rakefile
68
88
  - features/equivalence.feature
@@ -74,6 +94,8 @@ files:
74
94
  - features/step_definitions/steps.rb
75
95
  - features/support/env.rb
76
96
  - features/types.feature
97
+ - gemfiles/rspec2.gemfile
98
+ - gemfiles/rspec3.gemfile
77
99
  - json_spec.gemspec
78
100
  - lib/json_spec.rb
79
101
  - lib/json_spec/configuration.rb
@@ -115,17 +137,17 @@ require_paths:
115
137
  - lib
116
138
  required_ruby_version: !ruby/object:Gem::Requirement
117
139
  requirements:
118
- - - ! '>='
140
+ - - ">="
119
141
  - !ruby/object:Gem::Version
120
142
  version: '0'
121
143
  required_rubygems_version: !ruby/object:Gem::Requirement
122
144
  requirements:
123
- - - ! '>='
145
+ - - ">="
124
146
  - !ruby/object:Gem::Version
125
147
  version: '0'
126
148
  requirements: []
127
149
  rubyforge_project:
128
- rubygems_version: 2.0.3
150
+ rubygems_version: 2.2.2
129
151
  signing_key:
130
152
  specification_version: 4
131
153
  summary: Easily handle JSON in RSpec and Cucumber