Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gemfiles/rspec3.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ gemspec :path => '..'

group :test do
gem "cucumber", "~> 1.1", ">= 1.1.1"
gem "rspec", ">= 3.0.0.beta1", "< 4.0"
gem "rspec", "~> 3.0"
gem "rake", "~> 10.0"
end
6 changes: 4 additions & 2 deletions lib/json_spec/matchers/be_json_eql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ def including(*keys)
self
end

def failure_message_for_should
def failure_message
message_with_path("Expected equivalent JSON")
end
alias :failure_message_for_should :failure_message

def failure_message_for_should_not
def failure_message_when_negated
message_with_path("Expected inequivalent JSON")
end
alias :failure_message_for_should_not :failure_message_when_negated

def description
message_with_path("equal JSON")
Expand Down
6 changes: 4 additions & 2 deletions lib/json_spec/matchers/have_json_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ def matches?(json)
false
end

def failure_message_for_should
def failure_message
%(Expected JSON path "#{@path}")
end
alias :failure_message_for_should :failure_message

def failure_message_for_should_not
def failure_message_when_negated
%(Expected no JSON path "#{@path}")
end
alias :failure_message_for_should_not :failure_message_when_negated

def description
%(have JSON path "#{@path}")
Expand Down
6 changes: 4 additions & 2 deletions lib/json_spec/matchers/have_json_size.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ def at_path(path)
self
end

def failure_message_for_should
def failure_message
message_with_path("Expected JSON value size to be #{@expected}, got #{@actual}")
end
alias :failure_message_for_should :failure_message

def failure_message_for_should_not
def failure_message_when_negated
message_with_path("Expected JSON value size to not be #{@expected}, got #{@actual}")
end
alias :failure_message_for_should_not :failure_message_when_negated

def description
message_with_path(%(have JSON size "#{@expected}"))
Expand Down
6 changes: 4 additions & 2 deletions lib/json_spec/matchers/have_json_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ def at_path(path)
self
end

def failure_message_for_should
def failure_message
message_with_path("Expected JSON value type to be #{@classes.join(", ")}, got #{@ruby.class}")
end
alias :failure_message_for_should :failure_message

def failure_message_for_should_not
def failure_message_when_negated
message_with_path("Expected JSON value type to not be #{@classes.join(", ")}, got #{@ruby.class}")
end
alias :failure_message_for_should_not :failure_message_when_negated

def description
message_with_path(%(have JSON type "#{@classes.join(", ")}"))
Expand Down
6 changes: 4 additions & 2 deletions lib/json_spec/matchers/include_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ def including(*keys)
self
end

def failure_message_for_should
def failure_message
message_with_path("Expected included JSON")
end
alias :failure_message_for_should :failure_message

def failure_message_for_should_not
def failure_message_when_negated
message_with_path("Expected excluded JSON")
end
alias :failure_message_for_should_not :failure_message_when_negated

def description
message_with_path("include JSON")
Expand Down
10 changes: 6 additions & 4 deletions spec/json_spec/matchers/have_json_size_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@
%({"one":[1,2,3]}).should have_json_size(3).at_path("one")
end

it "provides a failure message for should" do
it "provides a failure message" do
matcher = have_json_size(3)
matcher.matches?(%([1,2]))
matcher.failure_message_for_should.should == "Expected JSON value size to be 3, got 2"
matcher.failure_message.should == "Expected JSON value size to be 3, got 2"
matcher.failure_message_for_should.should == "Expected JSON value size to be 3, got 2" # RSpec 2 interface
end

it "provides a failure message for should not" do
it "provides a failure message for negation" do
matcher = have_json_size(3)
matcher.matches?(%([1,2,3]))
matcher.failure_message_for_should_not.should == "Expected JSON value size to not be 3, got 3"
matcher.failure_message_when_negated.should == "Expected JSON value size to not be 3, got 3"
matcher.failure_message_for_should_not.should == "Expected JSON value size to not be 3, got 3" # RSpec 2 interface
end

it "provides a description message" do
Expand Down
10 changes: 6 additions & 4 deletions spec/json_spec/matchers/have_json_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,18 @@
%(10.0).should have_json_type(Numeric)
end

it "provides a failure message for should" do
it "provides a failure message" do
matcher = have_json_type(Numeric)
matcher.matches?(%("foo"))
matcher.failure_message_for_should.should == "Expected JSON value type to be Numeric, got String"
matcher.failure_message.should == "Expected JSON value type to be Numeric, got String"
matcher.failure_message_for_should.should == "Expected JSON value type to be Numeric, got String" # RSpec 2 interface
end

it "provides a failure message for should not" do
it "provides a failure message for negation" do
matcher = have_json_type(Numeric)
matcher.matches?(%(10))
matcher.failure_message_for_should_not.should == "Expected JSON value type to not be Numeric, got Fixnum"
matcher.failure_message_when_negated.should == "Expected JSON value type to not be Numeric, got Fixnum"
matcher.failure_message_for_should_not.should == "Expected JSON value type to not be Numeric, got Fixnum" # RSpec 2 interface
end

it "provides a description message" do
Expand Down
7 changes: 7 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
config.before do
JsonSpec.reset
end

config.expect_with :rspec do |c|
c.syntax = [:should, :expect]
end
config.mock_with :rspec do |c|
c.syntax = [:should, :expect]
end
end

def files_path
Expand Down