Sha256: ff1607e58af1376535d2838ee329548967c1d19a2d4535fad82e7ae493cc4ebf
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 KB
Contents
# encoding: utf-8 describe Hexx::API do let(:test) { Module.new.extend described_class } let(:foo) { double :foo, new: :foo, bar: :baz } before { described_class::Foo = foo } after { described_class.send :remove_const, :Foo } describe ".[]" do subject { test[:foo] } it "returns nil by default" do expect(subject).to be_nil end end # describe .[] describe ".api_method" do let(:args) { [:qux, :quxx, :quxxx] } context "without third argument" do subject { test.api_method :foo, foo } it "defines [:foo]" do expect { subject }.to change { test[:foo] }.from(nil).to(foo) end it "defines ['foo']" do expect { subject }.to change { test["foo"] }.from(nil).to(foo) end it "defines #foo as [:foo].new" do subject expect(foo).to receive(:new).with(*args) expect(test.foo(*args)).to eq :foo end end # context context "with third argument" do subject { test.api_method "foo", foo, :bar } it "defines [:foo]" do expect { subject }.to change { test[:foo] }.from(nil).to(foo) end it "defines #foo as custom method" do subject expect(foo).to receive(:bar).with(*args) expect(test.foo(*args)).to eq :baz end end # context end # describe .api_method end # describe Hexx::API
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hexx-api-0.0.1 | spec/tests/api_spec.rb |