Skip to content

Commit

Permalink
Add some extra specs for mocking and stubbing
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Nov 10, 2013
1 parent 1b38065 commit 1e158d3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -26,7 +26,7 @@ def build_rspec
Opal.use_gem 'rspec'
Opal.use_gem 'rspec-expectations'

%w[fileutils test/unit/assertions coderay optparse shellwords socket uri
%w[time fileutils test/unit/assertions coderay optparse shellwords socket uri
drb/drb diff/lcs diff/lcs/hunk].each do |asset|
Opal::Processor.stub_file asset
end
Expand Down
17 changes: 16 additions & 1 deletion spec/mock_spec.rb
Expand Up @@ -13,6 +13,21 @@
obj.bar.should == 42
}.to raise_error(Exception)
end

it "allow" do
obj = Object.new
allow(obj).to receive(:name) { "Adam B" }
allow(obj).to receive(:job).and_return("Eating Fruit Gums")

expect(obj.name).to eq("Adam B")
expect(obj.job).to eq("Eating Fruit Gums")
end

it "expecting arguments" do
person = double("person")
expect(person).to receive(:foo).with(4, 5, 6)
person.foo(4, 5, 6)
end
end

describe "doubles" do
Expand All @@ -31,7 +46,7 @@
person = double("person")
expect(person).to receive(:name).twice
person.name
person.name
person.name.should
end
end
end

0 comments on commit 1e158d3

Please sign in to comment.