File: active_resource_builder.rb

package info (click to toggle)
ruby-shoulda-matchers 7.0.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,652 kB
  • sloc: ruby: 34,046; sh: 280; makefile: 9
file content (27 lines) | stat: -rw-r--r-- 617 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module UnitTests
  module ActiveResourceBuilder
    def self.configure_example_group(example_group)
      require 'active_resource'

      example_group.include ActiveResourceBuilder

      example_group.after do
        ActiveSupport::Dependencies.clear
      end
    end

    def define_active_resource_class(class_name, attributes = {}, &block)
      define_class(class_name, ActiveResource::Base) do
        schema do
          attributes.each do |attr, type|
            attribute attr, type
          end
        end

        if block_given?
          class_eval(&block)
        end
      end
    end
  end
end