Created
December 14, 2011 10:24
-
-
Save dsci/1476039 to your computer and use it in GitHub Desktop.
matchr_princess
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gem::Specification.new do |s| | |
s.name = 'matchr_princess' | |
s.version = '0.1' | |
s.platform = Gem::Platform::RUBY | |
s.author = 'Daniel Schmidt' | |
s.email = 'dsci@code79.net' | |
s.summary = 'Small matcher library for rspec' | |
s.description = 'This goes out to the marvelous novell "A princess of mars" by Edgar Rice Burroughs.' | |
s.files = ['matchr_princess.rb'] | |
s.require_path = '.' | |
# This will added later. | |
s.add_development_dependency('rspec', ["~> 2.0"]) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use this like: | |
# result = "foo" | |
# result.should be_equal_to "foo" | |
RSpec::Matchers.define :be_equal_to do |target| | |
match do |src| | |
src == target | |
end | |
end | |
RSpec::Matchers.define :be_status_for do |expected_status| | |
match do |response| | |
#puts response.status | |
response.status.to_s.include?(expected_status.to_s).should == true | |
end | |
end | |
RSpec::Matchers.define :be_json_for_key do |expected_json,key| | |
match do |response| | |
json = ActiveSupport::JSON::decode(response.body) | |
json[key.to_s].should == expected_json | |
end | |
end | |
RSpec::Matchers.define :have_eql_value_for_key do |key,expected_value| | |
match do |response| | |
json = ActiveSupport::JSON::decode(response.body) | |
json[key.to_s].should == expected_value | |
end | |
end | |
RSpec::Matchers.define :be_included_in do |list| | |
match do |src| | |
list.include?(src) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment