Skip to content

Commit

Permalink
rr => mocha
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaclayton committed Aug 13, 2011
1 parent be14aa4 commit 554e6ab
Show file tree
Hide file tree
Showing 27 changed files with 258 additions and 271 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Expand Up @@ -5,7 +5,8 @@ gem "rspec", "~> 2.0"
gem "rcov"
gem "activerecord", :require => false
gem "activesupport", :require => false
gem "rr"
gem "mocha"
gem "bourne"
gem "sqlite3-ruby", :require => false
gem "appraisal", "~> 0.3.5"
gem "yard"
Expand Down
8 changes: 6 additions & 2 deletions Gemfile.lock
Expand Up @@ -22,6 +22,8 @@ GEM
cucumber (>= 0.10.5)
rspec (>= 2.6.0)
bluecloth (2.0.9)
bourne (1.0)
mocha (= 0.9.8)
builder (2.1.2)
childprocess (0.1.9)
ffi (~> 1.0.6)
Expand All @@ -37,9 +39,10 @@ GEM
json (>= 1.4.6)
i18n (0.4.2)
json (1.5.3)
mocha (0.9.8)
rake
rake (0.9.2)
rcov (0.9.9)
rr (1.0.2)
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
Expand All @@ -61,10 +64,11 @@ DEPENDENCIES
activesupport
appraisal (~> 0.3.5)
bluecloth
bourne
cucumber (~> 1.0.0)
mocha
rake
rcov
rr
rspec (~> 2.0)
sqlite3-ruby
yard
3 changes: 2 additions & 1 deletion factory_girl.gemspec
Expand Up @@ -22,7 +22,8 @@ Gem::Specification.new do |s|
s.add_development_dependency('cucumber')
s.add_development_dependency('activerecord', '~>2.3.5')
s.add_development_dependency('activerecord', '~>3.0.0.beta3')
s.add_development_dependency('rr')
s.add_development_dependency('mocha')
s.add_development_dependency('bourne')
s.add_development_dependency('sqlite3')
s.add_development_dependency('aruba')

Expand Down
16 changes: 9 additions & 7 deletions gemfiles/2.1.gemfile
Expand Up @@ -2,15 +2,17 @@

source "http://rubygems.org"

gem "test-unit", "~> 2.3.0", :platforms=>[:mri_19]
gem "rr"
gem "activerecord", "~> 2.1"
gem "cucumber", "~> 1.0.0"
gem "rake"
gem "sqlite3-ruby", :require=>false
gem "bluecloth"
gem "rspec", "~> 2.0"
gem "yard"
gem "rcov"
gem "cucumber", "~> 1.0.0"
gem "activerecord", "~> 2.1"
gem "activesupport", :require=>false
gem "mocha"
gem "bourne"
gem "sqlite3-ruby", :require=>false
gem "appraisal", "~> 0.3.5"
gem "yard"
gem "bluecloth"
gem "test-unit", "~> 2.3.0", :platforms=>[:mri_19]

9 changes: 7 additions & 2 deletions gemfiles/2.1.gemfile.lock
Expand Up @@ -13,6 +13,8 @@ GEM
cucumber (>= 0.10.5)
rspec (>= 2.6.0)
bluecloth (2.1.0)
bourne (1.0)
mocha (= 0.9.8)
builder (3.0.0)
childprocess (0.1.9)
ffi (~> 1.0.6)
Expand All @@ -27,9 +29,10 @@ GEM
gherkin (2.4.1)
json (>= 1.4.6)
json (1.5.3)
mocha (0.9.8)
rake
rake (0.9.2)
rcov (0.9.9)
rr (1.0.2)
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
Expand All @@ -50,12 +53,14 @@ PLATFORMS

DEPENDENCIES
activerecord (~> 2.1)
activesupport
appraisal (~> 0.3.5)
bluecloth
bourne
cucumber (~> 1.0.0)
mocha
rake
rcov
rr
rspec (~> 2.0)
sqlite3-ruby
test-unit (~> 2.3.0)
Expand Down
14 changes: 8 additions & 6 deletions gemfiles/2.3.gemfile
Expand Up @@ -2,14 +2,16 @@

source "http://rubygems.org"

gem "rr"
gem "activerecord", "~> 2.3"
gem "cucumber", "~> 1.0.0"
gem "rake"
gem "sqlite3-ruby", :require=>false
gem "bluecloth"
gem "rspec", "~> 2.0"
gem "yard"
gem "rcov"
gem "cucumber", "~> 1.0.0"
gem "activerecord", "~> 2.3"
gem "activesupport", :require=>false
gem "mocha"
gem "bourne"
gem "sqlite3-ruby", :require=>false
gem "appraisal", "~> 0.3.5"
gem "yard"
gem "bluecloth"

9 changes: 7 additions & 2 deletions gemfiles/2.3.gemfile.lock
Expand Up @@ -13,6 +13,8 @@ GEM
cucumber (>= 0.10.5)
rspec (>= 2.6.0)
bluecloth (2.1.0)
bourne (1.0)
mocha (= 0.9.8)
builder (3.0.0)
childprocess (0.1.9)
ffi (~> 1.0.6)
Expand All @@ -27,9 +29,10 @@ GEM
gherkin (2.4.1)
json (>= 1.4.6)
json (1.5.3)
mocha (0.9.8)
rake
rake (0.9.2)
rcov (0.9.9)
rr (1.0.2)
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
Expand All @@ -49,12 +52,14 @@ PLATFORMS

DEPENDENCIES
activerecord (~> 2.3)
activesupport
appraisal (~> 0.3.5)
bluecloth
bourne
cucumber (~> 1.0.0)
mocha
rake
rcov
rr
rspec (~> 2.0)
sqlite3-ruby
yard
14 changes: 8 additions & 6 deletions gemfiles/3.0.gemfile
Expand Up @@ -2,14 +2,16 @@

source "http://rubygems.org"

gem "rr"
gem "activerecord", "~> 3.0"
gem "cucumber", "~> 1.0.0"
gem "rake"
gem "sqlite3-ruby", :require=>false
gem "bluecloth"
gem "rspec", "~> 2.0"
gem "yard"
gem "rcov"
gem "cucumber", "~> 1.0.0"
gem "activerecord", "~> 3.0"
gem "activesupport", :require=>false
gem "mocha"
gem "bourne"
gem "sqlite3-ruby", :require=>false
gem "appraisal", "~> 0.3.5"
gem "yard"
gem "bluecloth"

9 changes: 7 additions & 2 deletions gemfiles/3.0.gemfile.lock
Expand Up @@ -21,6 +21,8 @@ GEM
cucumber (>= 0.10.5)
rspec (>= 2.6.0)
bluecloth (2.1.0)
bourne (1.0)
mocha (= 0.9.8)
builder (2.1.2)
childprocess (0.1.9)
ffi (~> 1.0.6)
Expand All @@ -36,9 +38,10 @@ GEM
json (>= 1.4.6)
i18n (0.5.0)
json (1.5.3)
mocha (0.9.8)
rake
rake (0.9.2)
rcov (0.9.9)
rr (1.0.2)
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
Expand All @@ -59,12 +62,14 @@ PLATFORMS

DEPENDENCIES
activerecord (~> 3.0)
activesupport
appraisal (~> 0.3.5)
bluecloth
bourne
cucumber (~> 1.0.0)
mocha
rake
rcov
rr
rspec (~> 2.0)
sqlite3-ruby
yard
53 changes: 26 additions & 27 deletions spec/acceptance/syntax/vintage_spec.rb
Expand Up @@ -64,17 +64,17 @@
describe "defining a factory" do
before do
@name = :user
@factory = "factory"
@factory = stub("factory", :names => [@name])
@proxy = "proxy"
stub(@factory).names { [@name] }
@options = { :class => 'magic' }
stub(FactoryGirl::Factory).new { @factory }
stub(FactoryGirl::DefinitionProxy).new { @proxy }
FactoryGirl::Factory.stubs(:new => @factory)
FactoryGirl::DefinitionProxy.stubs(:new => @proxy)
end

it "should create a new factory using the specified name and options" do
mock(FactoryGirl::Factory).new(@name, @options) { @factory }
FactoryGirl::Factory.stubs(:new => @factory)
Factory.define(@name, @options) {|f| }
FactoryGirl::Factory.should have_received(:new).with(@name, @options)
end

it "should pass the factory do the block" do
Expand All @@ -100,35 +100,39 @@
end

it "should use Proxy::AttributesFor for Factory.attributes_for" do
mock(@factory).run(FactoryGirl::Proxy::AttributesFor, :attr => 'value') { 'result' }
@factory.stubs(:run => "result")
Factory.attributes_for(@name, :attr => 'value').should == 'result'
@factory.should have_received(:run).with(FactoryGirl::Proxy::AttributesFor, :attr => 'value')
end

it "should use Proxy::Build for Factory.build" do
mock(@factory).run(FactoryGirl::Proxy::Build, :attr => 'value') { 'result' }
@factory.stubs(:run => "result")
Factory.build(@name, :attr => 'value').should == 'result'
@factory.should have_received(:run).with(FactoryGirl::Proxy::Build, :attr => 'value')
end

it "should use Proxy::Create for Factory.create" do
mock(@factory).run(FactoryGirl::Proxy::Create, :attr => 'value') { 'result' }
@factory.stubs(:run => "result")
Factory.create(@name, :attr => 'value').should == 'result'
@factory.should have_received(:run).with(FactoryGirl::Proxy::Create, :attr => 'value')
end

it "should use Proxy::Stub for Factory.stub" do
mock(@factory).run(FactoryGirl::Proxy::Stub, :attr => 'value') { 'result' }
@factory.stubs(:run => "result")
Factory.stub(@name, :attr => 'value').should == 'result'
@factory.should have_received(:run).with(FactoryGirl::Proxy::Stub, :attr => 'value')
end

it "should use default strategy option as Factory.default_strategy" do
stub(@factory).default_strategy { :create }
mock(@factory).run(FactoryGirl::Proxy::Create, :attr => 'value') { 'result' }
@factory.stubs(:default_strategy => :create, :run => "result")
Factory.default_strategy(@name, :attr => 'value').should == 'result'
@factory.should have_received(:run).with(FactoryGirl::Proxy::Create, :attr => 'value')
end

it "should use the default strategy for the global Factory method" do
stub(@factory).default_strategy { :create }
mock(@factory).run(FactoryGirl::Proxy::Create, :attr => 'value') { 'result' }
@factory.stubs(:default_strategy => :create, :run => "result")
Factory(@name, :attr => 'value').should == 'result'
@factory.should have_received(:run).with(FactoryGirl::Proxy::Create, :attr => 'value')
end

[:build, :create, :attributes_for, :stub].each do |method|
Expand All @@ -137,7 +141,7 @@
end

it "should recognize either 'name' or :name for Factory.#{method}" do
stub(@factory).run
@factory.stubs(:run)
lambda { Factory.send(method, @name.to_s) }.should_not raise_error
lambda { Factory.send(method, @name.to_sym) }.should_not raise_error
end
Expand All @@ -146,26 +150,22 @@

describe "defining a sequence" do
before do
@name = :count
@sequence = FactoryGirl::Sequence.new(@name) {}
stub(FactoryGirl::Sequence).new { @sequence }
@name = :count
end

it "should create a new sequence" do
mock(FactoryGirl::Sequence).new(@name, 1) { @sequence }
Factory.sequence(@name)
Factory.next(@name).should == 1
end

it "should use the supplied block as the sequence generator" do
stub(FactoryGirl::Sequence).new { @sequence }.yields(1)
yielded = false
Factory.sequence(@name) {|n| yielded = true }
(yielded).should be
Factory.sequence(@name) {|n| "user-#{n}" }
Factory.next(@name).should == "user-1"
end

it "should use the supplied start_value as the sequence start_value" do
mock(FactoryGirl::Sequence).new(@name, "A") { @sequence }
Factory.sequence(@name, "A")
Factory.next(@name).should == "A"
end
end

Expand All @@ -175,16 +175,15 @@
@sequence = FactoryGirl::Sequence.new(@name) {}
@value = '1 2 5'

stub(@sequence).next { @value }
stub(FactoryGirl::Sequence).new { @sequence }
@sequence.stubs(:next => @value)
FactoryGirl::Sequence.stubs(:new => @sequence)

Factory.sequence(@name) {}
end

it "should call next on the sequence when sent next" do
mock(@sequence).next

Factory.next(@name)
@sequence.should have_received(:next)
end

it "should return the value from the sequence" do
Expand Down
5 changes: 2 additions & 3 deletions spec/factory_girl/attribute/association_spec.rb
Expand Up @@ -21,10 +21,9 @@
end

it "should tell the proxy to associate when being added to a proxy" do
proxy = "proxy"
stub(proxy).associate
proxy = stub("proxy", :associate => nil)
@attr.add_to(proxy)
proxy.should have_received.associate(@name, @factory, @overrides)
proxy.should have_received(:associate).with(@name, @factory, @overrides)
end

it "should convert names to symbols" do
Expand Down
6 changes: 3 additions & 3 deletions spec/factory_girl/attribute/callback_spec.rb
Expand Up @@ -12,9 +12,9 @@
end

it "should set its callback on a proxy" do
@proxy = "proxy"
mock(@proxy).add_callback(@name, @block)
@attr.add_to(@proxy)
proxy = stub("proxy", :add_callback => true)
@attr.add_to(proxy)
proxy.should have_received(:add_callback).with(@name, @block)
end

it "should convert names to symbols" do
Expand Down

1 comment on commit 554e6ab

@justinko
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good move.

Please sign in to comment.