Skip to content

Commit 4aa659c

Browse files
committed
Merge pull request #71 from skalee/rspec-3-deprecated-syntax
Update for RSpec 3 beta 2
2 parents b48f7cb + f0c21fb commit 4aa659c

File tree

9 files changed

+40
-19
lines changed

9 files changed

+40
-19
lines changed

gemfiles/rspec3.gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ gemspec :path => '..'
44

55
group :test do
66
gem "cucumber", "~> 1.1", ">= 1.1.1"
7-
gem "rspec", ">= 3.0.0.beta1", "< 4.0"
7+
gem "rspec", "~> 3.0"
88
gem "rake", "~> 10.0"
99
end

lib/json_spec/matchers/be_json_eql.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@ def including(*keys)
4242
self
4343
end
4444

45-
def failure_message_for_should
45+
def failure_message
4646
message_with_path("Expected equivalent JSON")
4747
end
48+
alias :failure_message_for_should :failure_message
4849

49-
def failure_message_for_should_not
50+
def failure_message_when_negated
5051
message_with_path("Expected inequivalent JSON")
5152
end
53+
alias :failure_message_for_should_not :failure_message_when_negated
5254

5355
def description
5456
message_with_path("equal JSON")

lib/json_spec/matchers/have_json_path.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ def matches?(json)
1414
false
1515
end
1616

17-
def failure_message_for_should
17+
def failure_message
1818
%(Expected JSON path "#{@path}")
1919
end
20+
alias :failure_message_for_should :failure_message
2021

21-
def failure_message_for_should_not
22+
def failure_message_when_negated
2223
%(Expected no JSON path "#{@path}")
2324
end
25+
alias :failure_message_for_should_not :failure_message_when_negated
2426

2527
def description
2628
%(have JSON path "#{@path}")

lib/json_spec/matchers/have_json_size.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ def at_path(path)
1919
self
2020
end
2121

22-
def failure_message_for_should
22+
def failure_message
2323
message_with_path("Expected JSON value size to be #{@expected}, got #{@actual}")
2424
end
25+
alias :failure_message_for_should :failure_message
2526

26-
def failure_message_for_should_not
27+
def failure_message_when_negated
2728
message_with_path("Expected JSON value size to not be #{@expected}, got #{@actual}")
2829
end
30+
alias :failure_message_for_should_not :failure_message_when_negated
2931

3032
def description
3133
message_with_path(%(have JSON size "#{@expected}"))

lib/json_spec/matchers/have_json_type.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ def at_path(path)
1818
self
1919
end
2020

21-
def failure_message_for_should
21+
def failure_message
2222
message_with_path("Expected JSON value type to be #{@classes.join(", ")}, got #{@ruby.class}")
2323
end
24+
alias :failure_message_for_should :failure_message
2425

25-
def failure_message_for_should_not
26+
def failure_message_when_negated
2627
message_with_path("Expected JSON value type to not be #{@classes.join(", ")}, got #{@ruby.class}")
2728
end
29+
alias :failure_message_for_should_not :failure_message_when_negated
2830

2931
def description
3032
message_with_path(%(have JSON type "#{@classes.join(", ")}"))

lib/json_spec/matchers/include_json.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@ def including(*keys)
4242
self
4343
end
4444

45-
def failure_message_for_should
45+
def failure_message
4646
message_with_path("Expected included JSON")
4747
end
48+
alias :failure_message_for_should :failure_message
4849

49-
def failure_message_for_should_not
50+
def failure_message_when_negated
5051
message_with_path("Expected excluded JSON")
5152
end
53+
alias :failure_message_for_should_not :failure_message_when_negated
5254

5355
def description
5456
message_with_path("include JSON")

spec/json_spec/matchers/have_json_size_spec.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,18 @@
2121
%({"one":[1,2,3]}).should have_json_size(3).at_path("one")
2222
end
2323

24-
it "provides a failure message for should" do
24+
it "provides a failure message" do
2525
matcher = have_json_size(3)
2626
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
2829
end
2930

30-
it "provides a failure message for should not" do
31+
it "provides a failure message for negation" do
3132
matcher = have_json_size(3)
3233
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
3436
end
3537

3638
it "provides a description message" do

spec/json_spec/matchers/have_json_type_spec.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,18 @@
4646
%(10.0).should have_json_type(Numeric)
4747
end
4848

49-
it "provides a failure message for should" do
49+
it "provides a failure message" do
5050
matcher = have_json_type(Numeric)
5151
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
5354
end
5455

55-
it "provides a failure message for should not" do
56+
it "provides a failure message for negation" do
5657
matcher = have_json_type(Numeric)
5758
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
5961
end
6062

6163
it "provides a description message" do

spec/spec_helper.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
config.before do
55
JsonSpec.reset
66
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
714
end
815

916
def files_path

0 commit comments

Comments
 (0)