Skip to content

Commit

Permalink
merged spec changes
Browse files Browse the repository at this point in the history
  • Loading branch information
KCErb committed Jun 4, 2014
2 parents 49873d8 + 382bbd5 commit 4986d22
Show file tree
Hide file tree
Showing 75 changed files with 355 additions and 367 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

Shoes 4 : the next version of Shoes

## Still in development
## Pre-alpha

Hi there, thanks for checking by! Shoes4 is still in development. It doesn't support all of the shoes DSL just yet.
But if you want to check it out, that's awesome! If you're not too adventurous just yet you can still use the [old shoes](https://github.com/shoes/shoes)!
Hi there, thanks for checking by! Shoes 4 is still pre-alpha software. It currently supports almost all of the shoes DSL, but there are still some spots where you might get surprising results. If you're not too adventurous just yet you can still use the [old shoes](https://github.com/shoes/shoes)!

There is a first preview release now :)
There is a first [preview release](https://rubygems.org/gems/shoes/versions/4.0.0.pre1) now :)

## Installing Shoes4

Expand Down Expand Up @@ -83,6 +82,10 @@ Another alternative yet is to put `require 'shoes'` at the top of your applicati

$ jruby path/to/file.rb

On OS X you still need to supply the additional parameters to JRuby

$ jruby -J-XstartOnFirstThread path/to/file.rb

## Want to see what shoes can do?

You can run `rake samples` and random samples we believe are working will be run until you quit with Ctr + C. Some of them are really simple, while others are more complex or even games!
Expand Down Expand Up @@ -140,8 +143,6 @@ Also there is a list of samples that already work at samples/README, along with

With all you do, please make sure to write specs as Shoes 4 is developed TDD-style (see the [Running Specs](https://github.com/shoes/shoes4#running-specs) section below). So make sure that you don't break any tests :-)

We write our specs in rspec and are currently in the process of migrating from the old `should` syntax to the [new `expect` syntax](http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax). We basically say that whenever you touch a spec it'd be good if you converted it to the new syntax. Also new specs should be written in the new expect syntax.

If you feel unsure about testing or your implementation just open an issue or a pull request. Pull requests don't need to be done - they are great discussion starters! We're happy to help you get your contribution ready to be merged in order to help build Shoes 4!

In fact we greatly appreciate early pull requests to review code and help you find your way around Shoes4! =)
Expand Down
14 changes: 10 additions & 4 deletions lib/shoes/swt/common/painter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@ module Common
class Painter
include ::Swt::Events::PaintListener
include Resource
LINECAP = {curve: ::Swt::SWT::CAP_ROUND, rect: ::Swt::SWT::CAP_FLAT, project: ::Swt::SWT::CAP_SQUARE}

LINECAP = {
curve: ::Swt::SWT::CAP_ROUND,
rect: ::Swt::SWT::CAP_FLAT,
project: ::Swt::SWT::CAP_SQUARE
}

def initialize(obj)
@obj = obj
end

def paint_control(event)
graphics_context = event.gc
gcs_reset graphics_context
reset_graphics_context graphics_context
if @obj.dsl.visible? && @obj.dsl.positioned?
paint_object graphics_context
end
Expand All @@ -25,9 +30,10 @@ def paint_control(event)
end

def paint_object(graphics_context)
graphics_context.set_antialias ::Swt::SWT::ON
graphics_context.set_line_cap(LINECAP[@obj.dsl.style[:cap]] || LINECAP[:rect])
cap = LINECAP[@obj.dsl.style[:cap]]
graphics_context.set_line_cap(cap) if cap
graphics_context.set_transform(@obj.transform)

obj = @obj.dsl
case obj
when ::Shoes::Oval, ::Shoes::Rect
Expand Down
25 changes: 20 additions & 5 deletions lib/shoes/swt/common/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,26 @@ class Shoes
module Swt
module Common
module Resource
def gcs_reset gc
@gcs ||= []
@gcs.each{|g| g.dispose if g}
@gcs.clear
@gcs << gc
def reset_graphics_context(graphics_context)
dispose_previous_contexts
set_defaults_on_context(graphics_context)
track_graphics_context(graphics_context)
end

def dispose_previous_contexts
@graphic_contexts ||= []
@graphic_contexts.each{|g| g.dispose if g}
@graphic_contexts.clear
end

def set_defaults_on_context(graphics_context)
graphics_context.set_antialias(::Swt::SWT::ON)
graphics_context.set_line_cap(::Swt::SWT::CAP_FLAT)
graphics_context.set_transform(nil)
end

def track_graphics_context(graphics_context)
@graphic_contexts << graphics_context
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/shoes/swt/input_box.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def caret_to(index)
private
def nothing_changed?(event)
source = event.source
event.class == Java::OrgEclipseSwtEvents::ModifyEvent &&
source.class == Java::OrgEclipseSwtWidgets::Text &&
event.instance_of?(Java::OrgEclipseSwtEvents::ModifyEvent) &&
source.instance_of?(Java::OrgEclipseSwtWidgets::Text) &&
source.text == @last_text
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/shoes/swt/text_block/painter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def initialize(dsl)
end

def paintControl(paint_event)
gcs_reset(paint_event.gc)
reset_graphics_context(paint_event.gc)
return if @dsl.hidden?

draw_layouts(paint_event.gc)
Expand Down
1 change: 0 additions & 1 deletion samples/README
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ simple-timer.rb

good-arc.rb
good-clock.rb
good-clock-adjusted.rb
good-follow.rb
good-potato-chopping.rb
good-reminder.rb
Expand Down
49 changes: 0 additions & 49 deletions samples/good-clock-adjusted.rb

This file was deleted.

6 changes: 3 additions & 3 deletions shoes.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ Gem::Specification.new do |s|
s.add_dependency "after_do", "~>0.3"

s.add_development_dependency "guard"
s.add_development_dependency "guard-rspec"
s.add_development_dependency "guard-rspec", ">= 4.2"
s.add_development_dependency "pry"

s.add_development_dependency "rspec", "~>2.99.0.rc1"
s.add_development_dependency "rspec-its", "~>1.0.1"
s.add_development_dependency "rspec", "~>3.0"
s.add_development_dependency "rspec-its", "~>1.0"
s.add_development_dependency "rake"

s.add_development_dependency "yard"
Expand Down
2 changes: 1 addition & 1 deletion spec/async_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def eventually(options = {})
loop do
begin
yield
rescue => error
rescue Exception => error
end
return if error.nil?
raise error if Time.now >= time_limit
Expand Down
2 changes: 1 addition & 1 deletion spec/shoes/animation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
subject { Shoes::Animation.new( app, opts, block ) }

before :each do
app.should_receive(:gui) { app_gui }
expect(app).to receive(:gui) { app_gui }
end

it_behaves_like Shoes::Animation
Expand Down
8 changes: 4 additions & 4 deletions spec/shoes/app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
let(:input_blk) { Proc.new {} }

before do
Shoes::App.any_instance.stub(:flow)
allow_any_instance_of(Shoes::App).to receive(:flow)
end

it "initializes style hash", :qt do
Expand Down Expand Up @@ -228,7 +228,7 @@
end

it 'should receive a call to what is called in the append block' do
Shoes::App.any_instance.should_receive :para
expect_any_instance_of(Shoes::App).to receive :para
subject
end
end
Expand Down Expand Up @@ -298,13 +298,13 @@

it 'adds the child to the top_slot when there is one' do
top_slot_double = double 'top slot'
internal_app.stub(top_slot: top_slot_double)
allow(internal_app).to receive_messages(top_slot: top_slot_double)
expect(top_slot_double).to receive(:add_child).with(child)
internal_app.add_child child
end

it 'adds the child to the own contents when there is no top_slot' do
internal_app.stub top_slot: nil
allow(internal_app).to receive_messages top_slot: nil
internal_app.add_child child
expect(internal_app.contents).to include child
end
Expand Down
10 changes: 5 additions & 5 deletions spec/shoes/builtin_methods_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

before :each do
Shoes::LOG.clear
Shoes.stub(:logger) { logger }
allow(Shoes).to receive(:logger) { logger }
end

describe 'Shoes.p' do
Expand All @@ -24,7 +24,7 @@

describe "info" do
before :each do
logger.stub(:info)
allow(logger).to receive(:info)
app.info("test")
end

Expand All @@ -39,7 +39,7 @@

describe "debug" do
before :each do
logger.stub(:debug)
allow(logger).to receive(:debug)
app.debug("test")
end

Expand All @@ -54,7 +54,7 @@

describe "warn" do
before :each do
logger.stub(:warn)
allow(logger).to receive(:warn)
app.warn("test")
end

Expand All @@ -69,7 +69,7 @@

describe "error" do
before :each do
logger.stub(:error)
allow(logger).to receive(:error)
app.error("test")
end

Expand Down
2 changes: 1 addition & 1 deletion spec/shoes/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
subject {Shoes::CLI.new}

before :each do
subject.stub :package
allow(subject).to receive :package
end

it 'does not raise an error for a normal packaging command #624' do
Expand Down
2 changes: 1 addition & 1 deletion spec/shoes/color_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ class ColorDSLHelperTest

describe '#pattern' do
it 'creates an image pattern when fed a string for which a file exists' do
File.stub(exist?: true)
allow(File).to receive_messages(exist?: true)
my_path = '/some/path/to/image.png'
image_pattern = subject.pattern(my_path)
expect(image_pattern.path).to eq my_path
Expand Down
2 changes: 1 addition & 1 deletion spec/shoes/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

describe "#backend_with_app_for" do
it "passes app.gui to backend" do
Shoes.configuration.backend::Shape.should_receive(:new).with(dsl_object, app.gui, args)
expect(Shoes.configuration.backend::Shape).to receive(:new).with(anything, app.gui, anything)
dsl_object
end

Expand Down
16 changes: 8 additions & 8 deletions spec/shoes/dimensions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -777,27 +777,27 @@ def dimensions

subject do
dummy = DummyClass.new
dummy.stub dimensions: dimensions
allow(dummy).to receive_messages dimensions: dimensions
dummy
end

it 'forwards left calls to dimensions' do
dimensions.should_receive :left
expect(dimensions).to receive :left
subject.left
end

it 'forwards bottom calls to dimensions' do
dimensions.should_receive :bottom
expect(dimensions).to receive :bottom
subject.bottom
end

it 'forwards setter calls like left= do dimensions' do
dimensions.should_receive :left=
expect(dimensions).to receive :left=
subject.left = 66
end

it 'forwards absolutely_positioned? calls to the dimensions' do
dimensions.should_receive :absolutely_positioned?
expect(dimensions).to receive :absolutely_positioned?
subject.absolutely_positioned?
end
end
Expand All @@ -813,17 +813,17 @@ def dsl

subject do
dummy = AnotherDummyClass.new
dummy.stub dsl: dsl
allow(dummy).to receive_messages dsl: dsl
dummy
end

it 'forwards calls to dsl' do
dsl.should_receive :left
expect(dsl).to receive :left
subject.left
end

it 'does not forward calls to parent' do
dsl.should_not_receive :parent
expect(dsl).not_to receive :parent
expect {subject.parent}.to raise_error
end
end
Expand Down
4 changes: 3 additions & 1 deletion spec/shoes/download_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@
subject(:download) { Shoes::Download.new app, parent, name, opts}

it 'calls the progress proc from start, download and finish' do
skip 'Fails randomly.. maybe investigate with #681'
allow(download.gui).to receive :eval_block
eventually {
expect(download.gui).to receive(:eval_block).
expect(download.gui).to have_received(:eval_block).
with(progress_proc, download).
exactly(3).times
}
Expand Down
2 changes: 1 addition & 1 deletion spec/shoes/font_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
end

it 'calls the backend add_font method' do
Shoes.backend::Font.should_receive :add_font
expect(Shoes.backend::Font).to receive :add_font
main_object.font 'some/path'
end
end
Expand Down
Loading

0 comments on commit 4986d22

Please sign in to comment.