Skip to content

Commit

Permalink
Added Dsl spec, and dsl
Browse files Browse the repository at this point in the history
  • Loading branch information
ianwhite committed Aug 24, 2010
1 parent 5e6c390 commit 390f766
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/pickle/dsl.rb
Expand Up @@ -3,13 +3,14 @@ module Pickle
#
# the pickle object is where all of the action is at, see Pickle::Session::Api
module Dsl
include MakeMatcher
include Pickle::MakeMatcher
include Pickle::Parser

# the pickle session, @see Pickle::Session::Api
def pickle
@pickle ||= Pickle::Session.new
end

delegate :model, :to => :pickle
delegate :model, :to => :pickle
end
end
23 changes: 23 additions & 0 deletions spec/pickle/dsl_spec.rb
@@ -0,0 +1,23 @@
require 'spec_helper'

describe Pickle::Dsl do
subject { Pickle::Dsl }

its(:included_modules) { should include(Pickle::MakeMatcher) }
its(:included_modules) { should include(Pickle::Parser) }

describe "when included" do
include Pickle::Dsl

it "#pickle should create a Pickle::Session::Object and keep referring to that" do
Pickle::Session::Object.should_receive(:new).and_return(session = mock('pickle'))
pickle
pickle.should == session
end

it "#model should call pickle.model" do
pickle.should_receive(:model).with('a user').and_return(user = mock)
model('a user').should == user
end
end
end

0 comments on commit 390f766

Please sign in to comment.