Sha256: e8559c81a1e932337f9382267416208e637936665bedfdf25b0db6c54a4a8149
Contents?: true
Size: 1.99 KB
Versions: 3
Compression:
Stored size: 1.99 KB
Contents
require "support" module Omise class Teapot include Attributes end end class TestAttributes < Omise::Test setup do @attributes = JSON.load(JSON.dump({ object: "teapot", name: "Potts", location: "/teapots/teap_1", deleted: false, child: { object: "teapot", name: "Chip Potts", location: "/teapots/teap_2", deleted: false, } })) @teapot = Omise::Teapot.new(@attributes) end def test_that_we_can_create_a_teapot assert_instance_of Omise::Teapot, @teapot assert_equal "teapot", @teapot.object end def test_that_the_child_of_a_teapot_is_still_a_teapot assert_instance_of Omise::Teapot, @teapot.child assert_equal "teapot", @teapot.child.object end def test_that_we_can_get_the_attributes_of_the_teapot assert_equal @attributes, @teapot.attributes assert_equal @attributes, @teapot.as_json end def test_that_we_can_update_the_teapot_attributes @teapot.attributes.taint @teapot.assign_attributes({}) refute @teapot.attributes.tainted? end def test_that_we_can_tell_if_a_teapot_has_not_been_destroyed refute @teapot.destroyed? end def test_that_we_can_tell_if_a_teapot_has_been_destroyed @teapot.assign_attributes(@attributes.merge("deleted" => true)) assert @teapot.destroyed? end def test_that_we_get_the_location_of_the_teapot assert_equal "/teapots/teap_1", @teapot.location assert_equal "/teapots/teap_1/child", @teapot.location("child") end def test_that_we_can_access_an_attributes_value_with_the_square_bracket_accessor assert_equal "Potts", @teapot["name"] assert_nil @teapot["color"] assert_instance_of Omise::Teapot, @teapot["child"] end def test_that_we_can_tell_if_a_key_is_present_in_the_attributes assert @teapot.key?("name") refute @teapot.key?("color") end def test_that_a_teapot_respond_correctly_to_dynamic_method_names assert @teapot.respond_to?("name") refute @teapot.respond_to?("color") end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
omise-0.6.0 | test/omise/test_attributes.rb |
omise-0.5.1 | test/omise/test_attributes.rb |
omise-0.5.0 | test/omise/test_attributes.rb |